Skip to content

Commit d4492aa

Browse files
committed
Merge remote-tracking branch 'adafruit/master' into packet_buffer
2 parents 11a8fc7 + 22644d3 commit d4492aa

File tree

104 files changed

+8242
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+8242
-11
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,16 @@ jobs:
102102
- "feather_m0_rfm9x"
103103
- "feather_m0_supersized"
104104
- "feather_m4_express"
105+
- "feather_mimxrt1011"
106+
- "feather_mimxrt1062"
105107
- "feather_nrf52840_express"
106108
- "feather_radiofruit_zigbee"
107109
- "feather_stm32f405_express"
108110
- "gemma_m0"
109111
- "grandcentral_m4_express"
110112
- "hallowing_m0_express"
111113
- "hallowing_m4_express"
114+
- "imxrt1010_evk"
112115
- "itsybitsy_m0_express"
113116
- "itsybitsy_m4_express"
114117
- "itsybitsy_nrf52840_express"

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,6 @@
108108
[submodule "lib/mp3"]
109109
path = lib/mp3
110110
url = https://github.com/adafruit/Adafruit_MP3
111+
[submodule "ports/mimxrt10xx/sdk"]
112+
path = ports/mimxrt10xx/sdk
113+
url = https://github.com/arturo182/MIMXRT10xx_SDK

conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@
131131
"ports/esp8266/common-hal",
132132
"ports/esp8266/modules",
133133
"ports/minimal",
134+
"ports/mimxrt10xx/peripherals",
135+
"ports/mimxrt10xx/sdk",
134136
"ports/nrf/device",
135137
"ports/nrf/bluetooth",
136138
"ports/nrf/modules",

docs/shared_bindings_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import re
2727

2828

29-
SUPPORTED_PORTS = ["atmel-samd", "nrf"]
29+
SUPPORTED_PORTS = ["atmel-samd", "nrf", "mimxrt10xx"]
3030

3131

3232
def parse_port_config(contents, chip_keyword=None):

docs/supported_ports.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and ESP8266.
88
:maxdepth: 2
99

1010
../ports/atmel-samd/README
11+
../ports/mimxrt10xx/README
1112
../ports/nrf/README
1213
../ports/stm32f4/README
1314
../ports/cxd56/README

ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@
1919
// USB is always used internally so skip the pin objects for it.
2020
#define IGNORE_PIN_PA24 1
2121
#define IGNORE_PIN_PA25 1
22+
23+
// Enable the use of 2 displays
24+
25+
#define CIRCUITPY_DISPLAY_LIMIT (2)
26+
27+
28+

ports/atmel-samd/boards/pewpew_m4/board.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,36 @@
3535

3636
displayio_fourwire_obj_t board_display_obj;
3737

38+
typedef struct {
39+
const uint32_t *config_data;
40+
void *handoverHID;
41+
void *handoverMSC;
42+
const char *info_uf2;
43+
} UF2_BInfo;
44+
45+
#define APP_START_ADDRESS 0x00004000
46+
#define UF2_BINFO ((UF2_BInfo *)(APP_START_ADDRESS - sizeof(UF2_BInfo)))
47+
48+
#define CFG_DISPLAY_CFG0 39
49+
#define CFG_MAGIC0 0x1e9e10f1
50+
3851
#define DELAY 0x80
3952

53+
uint32_t lookupCfg(uint32_t key, uint32_t defl) {
54+
const uint32_t *ptr = UF2_BINFO->config_data;
55+
if (!ptr || (((uint32_t)ptr) & 3) || *ptr != CFG_MAGIC0) {
56+
// no config data!
57+
} else {
58+
ptr += 4;
59+
while (*ptr) {
60+
if (*ptr == key)
61+
return ptr[1];
62+
ptr += 2;
63+
}
64+
}
65+
return defl;
66+
}
67+
4068
uint8_t display_init_sequence[] = {
4169
0x01, 0 | DELAY, 150, // SWRESET
4270
0x11, 0 | DELAY, 255, // SLPOUT
@@ -63,8 +91,6 @@ uint8_t display_init_sequence[] = {
6391
0x2E, 0x2C, 0x29, 0x2D,
6492
0x2E, 0x2E, 0x37, 0x3F,
6593
0x00, 0x00, 0x02, 0x10,
66-
0x2a, 3, 0x02, 0x00, 0x81, // _CASET XSTART = 2, XEND = 129
67-
0x2b, 3, 0x02, 0x00, 0x81, // _RASET XSTART = 2, XEND = 129
6894
0x13, 0 | DELAY, 10, // _NORON
6995
0x29, 0 | DELAY, 100, // _DISPON
7096
};
@@ -83,14 +109,17 @@ void board_init(void) {
83109
&pin_PA17, // TFT_RST Reset
84110
60000000);
85111

112+
uint32_t cfg0 = lookupCfg(CFG_DISPLAY_CFG0, 0x000000);
113+
uint32_t offX = (cfg0 >> 8) & 0xff;
114+
uint32_t offY = (cfg0 >> 16) & 0xff;
86115
displayio_display_obj_t* display = &displays[0].display;
87116
display->base.type = &displayio_display_type;
88117
common_hal_displayio_display_construct(display,
89118
bus,
90119
160, // Width (after rotation)
91120
128, // Height (after rotation)
92-
0, // column start
93-
0, // row start
121+
offX, // column start
122+
offY, // row start
94123
0, // rotation
95124
16, // Color depth
96125
false, // grayscale

ports/mimxrt10xx/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build-*/

ports/mimxrt10xx/Makefile

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
# This file is part of the MicroPython project, http://micropython.org/
2+
#
3+
# The MIT License (MIT)
4+
#
5+
# Copyright (c) 2019 Dan Halbert for Adafruit Industries
6+
# Copyright (c) 2019 Artur Pacholec
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the "Software"), to deal
10+
# in the Software without restriction, including without limitation the rights
11+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in
16+
# all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
# THE SOFTWARE.
25+
26+
# Select the board to build for.
27+
ifeq ($(BOARD),)
28+
$(error You must provide a BOARD parameter)
29+
else
30+
ifeq ($(wildcard boards/$(BOARD)/.),)
31+
$(error Invalid BOARD specified)
32+
endif
33+
endif
34+
35+
# If the build directory is not given, make it reflect the board name.
36+
BUILD ?= build-$(BOARD)
37+
38+
include ../../py/mkenv.mk
39+
# Board-specific
40+
include boards/$(BOARD)/mpconfigboard.mk
41+
# Port-specific
42+
include mpconfigport.mk
43+
# CircuitPython-specific
44+
include $(TOP)/py/circuitpy_mpconfig.mk
45+
46+
# qstr definitions (must come before including py.mk)
47+
QSTR_DEFS = qstrdefsport.h
48+
49+
# include py core make definitions
50+
include $(TOP)/py/py.mk
51+
52+
include $(TOP)/supervisor/supervisor.mk
53+
54+
# Include make rules and variables common across CircuitPython builds.
55+
include $(TOP)/py/circuitpy_defns.mk
56+
57+
CROSS_COMPILE = arm-none-eabi-
58+
59+
INC += \
60+
-I. \
61+
-I../.. \
62+
-I../lib/mp-readline \
63+
-I../lib/timeutils \
64+
-I../../lib/tinyusb/src \
65+
-I../../supervisor/shared/usb \
66+
-I$(BUILD) \
67+
-Iboards/ \
68+
-Iboards/$(BOARD) \
69+
-Iperipherals/ \
70+
-Iperipherals/mimxrt10xx/ \
71+
-Isdk/CMSIS/Include \
72+
-Isdk/devices/$(CHIP_FAMILY) \
73+
-Isdk/devices/$(CHIP_FAMILY)/drivers \
74+
75+
# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt.
76+
77+
CFLAGS += -Os -DNDEBUG
78+
79+
# TinyUSB defines
80+
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
81+
82+
#Debugging/Optimization
83+
ifeq ($(DEBUG), 1)
84+
CFLAGS += -ggdb
85+
# You may want to disable -flto if it interferes with debugging.
86+
#CFLAGS += -flto -flto-partition=none
87+
# You may want to enable these flags to make setting breakpoints easier.
88+
CFLAGS += -fno-inline -fno-ipa-sra
89+
else
90+
# -finline-limit can shrink the image size.
91+
# -finline-limit=80 or so is similar to not having it on.
92+
# There is no simple default value, though.
93+
94+
# Do a default shrink for small builds.
95+
ifndef CFLAGS_INLINE_LIMIT
96+
ifeq ($(CIRCUITPY_SMALL_BUILD),1)
97+
CFLAGS_INLINE_LIMIT = 50
98+
endif
99+
endif
100+
101+
ifdef CFLAGS_INLINE_LIMIT
102+
CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT)
103+
endif
104+
#CFLAGS += -flto -flto-partition=none
105+
endif
106+
107+
CFLAGS += $(INC) -Wall -Wno-cast-align -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)
108+
109+
CFLAGS += \
110+
-mthumb \
111+
-mapcs \
112+
-mcpu=cortex-m7 \
113+
-mfloat-abi=hard \
114+
-mfpu=fpv5-sp-d16 \
115+
-DCPU_$(CHIP_VARIANT) \
116+
-DDEBUG \
117+
-DXIP_EXTERNAL_FLASH=1 \
118+
-DXIP_BOOT_HEADER_ENABLE=1 \
119+
-D__START=main \
120+
-Os -g3 -Wno-unused-parameter \
121+
-ffunction-sections -fdata-sections -fstack-usage \
122+
-D__STARTUP_CLEAR_BSS
123+
124+
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
125+
LIBS := -lgcc -lc -lnosys -lm
126+
127+
# Use toolchain libm if we're not using our own.
128+
ifndef INTERNAL_LIBM
129+
LIBS += -lm
130+
endif
131+
132+
LDFLAGS += -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mthumb -mapcs
133+
BOOTLOADER_SIZE := 0x6000C000
134+
135+
SRC_SDK := \
136+
drivers/fsl_adc.c \
137+
drivers/fsl_cache.c \
138+
drivers/fsl_clock.c \
139+
drivers/fsl_common.c \
140+
drivers/fsl_flexspi.c \
141+
drivers/fsl_gpio.c \
142+
drivers/fsl_lpi2c.c \
143+
drivers/fsl_lpspi.c \
144+
drivers/fsl_lpuart.c \
145+
drivers/fsl_ocotp.c \
146+
drivers/fsl_pwm.c \
147+
drivers/fsl_snvs_hp.c \
148+
drivers/fsl_tempmon.c \
149+
drivers/fsl_trng.c \
150+
system_$(CHIP_FAMILY).c \
151+
152+
SRC_SDK := $(addprefix sdk/devices/$(CHIP_FAMILY)/, $(SRC_SDK))
153+
154+
SRC_C = \
155+
background.c \
156+
boards/$(BOARD)/board.c \
157+
boards/$(BOARD)/pins.c \
158+
fatfs_port.c \
159+
lib/mp-readline/readline.c \
160+
lib/oofatfs/ff.c \
161+
lib/oofatfs/option/ccsbcs.c \
162+
lib/timeutils/timeutils.c \
163+
lib/utils/buffer_helper.c \
164+
lib/utils/context_manager_helpers.c \
165+
lib/utils/interrupt_char.c \
166+
lib/utils/pyexec.c \
167+
lib/utils/stdout_helpers.c \
168+
lib/utils/sys_stdio_mphal.c \
169+
lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c \
170+
mphalport.c \
171+
peripherals/mimxrt10xx/$(CHIP_FAMILY)/clocks.c \
172+
peripherals/mimxrt10xx/$(CHIP_FAMILY)/periph.c \
173+
peripherals/mimxrt10xx/$(CHIP_FAMILY)/pins.c \
174+
reset.c \
175+
supervisor/flexspi_nor_flash_ops.c \
176+
supervisor/shared/memory.c \
177+
tick.c
178+
179+
ifeq ($(CIRCUITPY_NETWORK),1)
180+
CFLAGS += -DMICROPY_PY_NETWORK=1
181+
182+
SRC_MOD += lib/netutils/netutils.c
183+
184+
ifneq ($(MICROPY_PY_WIZNET5K),0)
185+
WIZNET5K_DIR=drivers/wiznet5k
186+
INC += -I$(TOP)/$(WIZNET5K_DIR)
187+
CFLAGS_MOD += -DMICROPY_PY_WIZNET5K=$(MICROPY_PY_WIZNET5K) -D_WIZCHIP_=$(MICROPY_PY_WIZNET5K)
188+
SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
189+
ethernet/w$(MICROPY_PY_WIZNET5K)/w$(MICROPY_PY_WIZNET5K).c \
190+
ethernet/wizchip_conf.c \
191+
ethernet/socket.c \
192+
internet/dns/dns.c \
193+
internet/dhcp/dhcp.c \
194+
)
195+
196+
endif # MICROPY_PY_WIZNET5K
197+
endif # CIRCUITPY_NETWORK
198+
199+
ifeq ($(CIRCUITPY_NETWORK),1)
200+
ifneq ($(MICROPY_PY_WIZNET5K),0)
201+
SRC_SHARED_MODULE += wiznet/__init__.c wiznet/wiznet5k.c
202+
endif
203+
endif
204+
205+
# TODO
206+
#ifeq ($(CIRCUITPY_AUDIOBUSIO),1)
207+
#SRC_C += peripherals/samd/i2s.c peripherals/samd/$(CHIP_FAMILY)/i2s.c
208+
#endif
209+
#
210+
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
211+
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
212+
$(addprefix common-hal/, $(SRC_COMMON_HAL))
213+
214+
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
215+
$(addprefix shared-module/, $(SRC_SHARED_MODULE)) \
216+
$(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL))
217+
218+
SRC_S = \
219+
sdk/devices/$(CHIP_FAMILY)/gcc/startup_$(CHIP_FAMILY).S \
220+
supervisor/cpu.S
221+
222+
OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
223+
OBJ += $(addprefix $(BUILD)/, $(SRC_SDK:.c=.o))
224+
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
225+
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
226+
ifeq ($(INTERNAL_LIBM),1)
227+
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
228+
endif
229+
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.S=.o))
230+
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
231+
232+
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
233+
234+
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
235+
236+
$(BUILD)/firmware.elf: $(LD_FILE) $(OBJ)
237+
$(STEPECHO) "LINK $@"
238+
$(Q)$(CC) -o $@ $(LDFLAGS) $(filter-out $<,$^) -Wl,--start-group $(LIBS) -Wl,--end-group
239+
240+
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
241+
$(STEPECHO) "Create $@"
242+
$(Q)$(OBJCOPY) -O binary -j .interrupts -j .text -j .ARM.exidx -j .data $^ $@
243+
244+
$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin
245+
$(STEPECHO) "Create $@"
246+
$(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $^
247+
248+
include $(TOP)/py/mkrules.mk
249+
250+
# Print out the value of a make variable.
251+
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
252+
print-%:
253+
@echo $* = $($*)

ports/mimxrt10xx/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CircuitPython Port To The NXP i.MX RT10xx Series
2+
3+
This is a port of CircuitPython to the i.MX RT10xx series of chips.

0 commit comments

Comments
 (0)