Skip to content

Commit f5be5ed

Browse files
committed
Merge branch 'master' into nrf52840_usbboot
2 parents 6143710 + c1924f3 commit f5be5ed

80 files changed

Lines changed: 246 additions & 5514 deletions

Some content is hidden

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

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@
7070
[submodule "ports/atmel-samd/peripherals"]
7171
path = ports/atmel-samd/peripherals
7272
url = https://github.com/adafruit/samd-peripherals.git
73+
[submodule "ports/nrf/nrfx"]
74+
path = ports/nrf/nrfx
75+
url = https://github.com/NordicSemiconductor/nrfx.git

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
"ports/nrf/drivers",
117117
"ports/nrf/hal",
118118
"ports/nrf/modules",
119+
"ports/nrf/nrfx",
119120
"ports/pic16bit",
120121
"ports/qemu-arm",
121122
"ports/stm32",

ports/atmel-samd/boards/itsybitsy_m4_express/pins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
1818
{ MP_OBJ_NEW_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA17) },
1919
{ MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA17) },
2020
{ MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA07) },
21+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB22) },
22+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA14) },
2123
{ MP_OBJ_NEW_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) },
2224
{ MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA18) },
2325
{ MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA19) },

ports/nrf/Makefile

Lines changed: 19 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Select the board to build for: if not given on the command line,
2-
# then default to feather52.
3-
BOARD ?= feather52
2+
# then default to feather52832.
3+
BOARD ?= feather52832
44
ifeq ($(wildcard boards/$(BOARD)/.),)
55
$(error Invalid BOARD specified)
66
endif
@@ -12,24 +12,17 @@ SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
1212

1313
# TODO: Verify that it is a valid target.
1414

15-
ifeq ($(SD), )
16-
# If the build directory is not given, make it reflect the board name.
17-
BUILD ?= build-$(BOARD)
18-
include ../../py/mkenv.mk
19-
include boards/$(BOARD)/mpconfigboard.mk
20-
-include mpconfigport.mk
15+
# If the build directory is not given, make it reflect the board name
16+
BUILD ?= $(if $(SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
2117

22-
else
23-
# If the build directory is not given, make it reflect the board name.
24-
BUILD ?= build-$(BOARD)-$(SD_LOWER)
25-
include ../../py/mkenv.mk
26-
include boards/$(BOARD)/mpconfigboard_$(SD_LOWER).mk
27-
-include mpconfigport.mk
18+
include ../../py/mkenv.mk
19+
include boards/$(BOARD)/mpconfigboard.mk
20+
-include mpconfigport.mk
2821

22+
ifneq ($(SD), )
2923
include drivers/bluetooth/bluetooth_common.mk
3024
endif
3125

32-
3326
# qstr definitions (must come before including py.mk)
3427
QSTR_DEFS = qstrdefsport.h $(BUILD)/pins_qstr.h
3528

@@ -44,43 +37,33 @@ FATFS_DIR = lib/oofatfs
4437

4538
CROSS_COMPILE = arm-none-eabi-
4639

47-
MCU_VARIANT_UPPER = $(shell echo $(MCU_VARIANT) | tr '[:lower:]' '[:upper:]')
48-
4940
INC += -I.
5041
INC += -I../..
5142
INC += -I$(BUILD)
5243
INC += -I$(BUILD)/genhdr
5344
INC += -I./../../lib/cmsis/inc
45+
INC += -I./boards/$(BOARD)
5446
INC += -I./device
5547
INC += -I./device/$(MCU_VARIANT)
5648
INC += -I./hal
5749
INC += -I./hal/$(MCU_VARIANT)
58-
INC += -I./modules/machine
5950
INC += -I./modules/ubluepy
60-
INC += -I./modules/music
6151
INC += -I./modules/random
6252
INC += -I./modules/ble
6353
INC += -I../../lib/mp-readline
6454
INC += -I./drivers/bluetooth
6555
INC += -I./drivers
6656

67-
NRF_DEFINES += -D$(MCU_VARIANT_UPPER)
6857
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
6958

70-
CFLAGS_CORTEX_M = -mthumb -mabi=aapcs -fsingle-precision-constant -Wdouble-promotion
71-
72-
CFLAGS_MCU_m4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
73-
74-
CFLAGS_MCU_m0 = $(CFLAGS_CORTEX_M) --short-enums -mtune=cortex-m0 -mcpu=cortex-m0 -mfloat-abi=soft -fno-builtin
75-
76-
77-
CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
59+
CFLAGS += -mthumb -mabi=aapcs -fsingle-precision-constant -Wdouble-promotion
60+
CFLAGS += -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
7861
CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES) $(CFLAGS_MOD)
7962
CFLAGS += -fno-strict-aliasing
8063
CFLAGS += -fstack-usage
8164
CFLAGS += -fdata-sections -ffunction-sections
82-
CFLAGS += -Iboards/$(BOARD)
8365
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
66+
CFLAGS += -D__START=main
8467

8568
LDFLAGS = $(CFLAGS)
8669
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
@@ -97,17 +80,13 @@ CFLAGS += -Os -DNDEBUG
9780
LDFLAGS += -Os
9881
endif
9982

100-
LIBS = \
101-
102-
ifeq ($(MCU_VARIANT), nrf52)
10383
LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
10484
LIBC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a)
10585
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
10686

107-
LIBS += -L $(dir $(LIBM_FILE_NAME)) -lm
87+
LIBS := -L $(dir $(LIBM_FILE_NAME)) -lm
10888
LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc
10989
LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc
110-
endif
11190

11291
SRC_HAL = $(addprefix hal/,\
11392
hal_uart.c \
@@ -122,19 +101,12 @@ SRC_HAL = $(addprefix hal/,\
122101
hal_temp.c \
123102
hal_gpio.c \
124103
hal_rng.c \
125-
)
126-
127-
ifeq ($(MCU_VARIANT), nrf52)
128-
SRC_HAL += $(addprefix hal/,\
129104
hal_pwm.c \
130105
)
131-
endif
132-
133106

134107
SRC_C += \
135108
mphalport.c \
136109
help.c \
137-
pin_named_pins.c \
138110
fatfs_port.c \
139111
fifo.c \
140112
tick.c \
@@ -143,7 +115,7 @@ SRC_C += \
143115
drivers/bluetooth/ble_drv.c \
144116
drivers/bluetooth/ble_uart.c \
145117
boards/$(BOARD)/board.c \
146-
device/$(MCU_VARIANT)/system_$(MCU_SUB_VARIANT).c \
118+
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \
147119
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
148120
lib/oofatfs/ff.c \
149121
lib/oofatfs/option/ccsbcs.c \
@@ -158,18 +130,6 @@ SRC_C += \
158130

159131

160132
DRIVERS_SRC_C += $(addprefix modules/,\
161-
machine/modmachine.c \
162-
machine/uart.c \
163-
machine/spi.c \
164-
machine/i2c.c \
165-
machine/adc.c \
166-
machine/pin.c \
167-
machine/timer.c \
168-
machine/pwm.c \
169-
machine/led.c \
170-
machine/temp.c \
171-
utime/modutime.c \
172-
pyb/modpyb.c \
173133
ubluepy/modubluepy.c \
174134
ubluepy/ubluepy_peripheral.c \
175135
ubluepy/ubluepy_service.c \
@@ -180,13 +140,10 @@ DRIVERS_SRC_C += $(addprefix modules/,\
180140
ubluepy/ubluepy_descriptor.c \
181141
ubluepy/ubluepy_scanner.c \
182142
ubluepy/ubluepy_scan_entry.c \
183-
music/modmusic.c \
184-
music/musictunes.c \
185143
ble/modble.c \
186144
random/modrandom.c \
187145
)
188146

189-
190147
SRC_COMMON_HAL += \
191148
board/__init__.c \
192149
digitalio/__init__.c \
@@ -208,8 +165,8 @@ SRC_COMMON_HAL += \
208165
pulseio/PulseOut.c \
209166
pulseio/PWMOut.c \
210167
storage/__init__.c \
211-
supervisor/__init__.c \
212-
supervisor/Runtime.c \
168+
supervisor/__init__.c \
169+
supervisor/Runtime.c \
213170

214171
# These don't have corresponding files in each port but are still located in
215172
# shared-bindings to make it clear what the contents of the modules are.
@@ -346,10 +303,10 @@ SRC_QSTR_AUTO_DEPS +=
346303
$(OBJ): | $(HEADER_BUILD)/pins.h
347304

348305
# Use a pattern rule here so that make will only call make-pins.py once to make
349-
# both pins_$(BOARD).c and pins.h
350-
$(BUILD)/%_gen.c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(BUILD)/%_qstr.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
306+
# both pins_g.c and pins.h
307+
$(BUILD)/%_gen.c $(HEADER_BUILD)/%.h $(BUILD)/%_qstr.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
351308
$(ECHO) "Create $@"
352-
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --qstr $(GEN_PINS_QSTR) --af-const $(GEN_PINS_AF_CONST) --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
309+
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --qstr $(GEN_PINS_QSTR) > $(GEN_PINS_SRC)
353310

354311
$(BUILD)/pins_gen.o: $(BUILD)/pins_gen.c
355312
$(call compile_c)
@@ -361,8 +318,6 @@ PREFIX_FILE = boards/$(MCU_VARIANT)_prefix.c
361318
GEN_PINS_SRC = $(BUILD)/pins_gen.c
362319
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
363320
GEN_PINS_QSTR = $(BUILD)/pins_qstr.h
364-
GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h
365-
GEN_PINS_AF_PY = $(BUILD)/pins_af.py
366321

367322
ifneq ($(FROZEN_DIR),)
368323
# To use frozen source modules, put your .py files in a subdirectory (eg scripts/)

ports/nrf/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Prerequisite steps for building the nrf port:
5151
git submodule update --init
5252
make -C mpy-cross
5353

54-
By default, the feather52 (nRF52832) is used as compile target. To build and flash issue the following command inside the ports/nrf/ folder:
54+
By default, the feather52832 is used as compile target. To build and flash issue the following command inside the ports/nrf/ folder:
5555

5656
make
5757
make flash
@@ -82,7 +82,7 @@ Note: further tuning of features to include in bluetooth or even setting up the
8282
Target Board (BOARD) | Bluetooth Stack (SD) | Bluetooth Support | Flash Util
8383
---------------------|-------------------------|------------------------|-------------------------------
8484
pca10040 | s132 | Peripheral and Scanner | [Segger](#segger-targets)
85-
feather52 | s132 | Peripheral and Scanner | [UART DFU](#dfu-targets)
85+
feather52832 | s132 | Peripheral and Scanner | [UART DFU](#dfu-targets)
8686
pca10056 | s140 | Peripheral and Scanner | [Segger](#segger-targets)
8787

8888
## Segger Targets
@@ -113,11 +113,11 @@ note: On Linux it might be required to link SEGGER's `libjlinkarm.so` inside nrf
113113
* dfu-gen: Generates a Firmware zip to be used by the DFU flash application.
114114
* dfu-flash: Triggers the DFU flash application to upload the firmware from the generated Firmware zip file.
115115

116-
Example on how to generate and flash feather52 target:
116+
Example on how to generate and flash feather52832 target:
117117

118-
make BOARD=feather52 SD=s132
119-
make BOARD=feather52 SD=s132 dfu-gen
120-
make BOARD=feather52 SD=s132 dfu-flash
118+
make BOARD=feather52832 SD=s132
119+
make BOARD=feather52832 SD=s132 dfu-gen
120+
make BOARD=feather52832 SD=s132 dfu-flash
121121

122122
## Bluetooth LE REPL
123123

ports/nrf/boards/feather52832/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ $ sudo python setup.py install
4747
#### REPL over UART (default settings)
4848

4949
To build a CircuitPython binary with default settings for the
50-
`feather52` target enter:
50+
`feather52832` target enter:
5151

52-
> **NOTE:** `BOARD=feather52` is the default option and isn't stricly required.
52+
> **NOTE:** `BOARD=feather52832` is the default option and isn't stricly required.
5353
5454
```
55-
$ make BOARD=feather52 V=1
55+
$ make BOARD=feather52832 V=1
5656
```
5757

5858
#### REPL over BLE UART (AKA 'NUS')
@@ -68,7 +68,7 @@ set to `1` in the `#elif (BLUETOOTH_SD == 132)` section:
6868
... then build as normal, via:
6969

7070
```
71-
$ make BOARD=feather52 V=1
71+
$ make BOARD=feather52832 V=1
7272
```
7373

7474
You can then connect over BLE UART using an application like Bluefruit LE
@@ -95,15 +95,15 @@ Feather52 boards to a single-bank CircuitPython compatible version:
9595
By default s132 v2.0.1 is used when no `SOFTDEV_VERSION` field is passed in:
9696

9797
```
98-
$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART boot-flash
98+
$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART boot-flash
9999
```
100100

101101
#### S132 v5.0.0 (BLE5, experimental):
102102

103103
To enable BLE5 support and the latest S132 release, flash the v5.0.0 bootloader via:
104104

105105
```
106-
$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART SOFTDEV_VERSION=5.0.0 boot-flash
106+
$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART SOFTDEV_VERSION=5.0.0 boot-flash
107107
```
108108

109109
### 2. Generate and flash a CircuitPython DFU .zip package over serial
@@ -117,15 +117,15 @@ image, as described earlier in this readme.
117117
> The name of the serial port target will vary, depending on your OS.
118118
119119
```
120-
$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART dfu-gen dfu-flash
120+
$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART dfu-gen dfu-flash
121121
```
122122

123123
By default, CircuitPython will build with **BLE** support enabled using
124124
`SD=s132` and the `SOFTDEV_VERSION=2.0.1`. If you wish to specify a different
125125
SD family or version you can enter the optional fields as shown below:
126126

127127
```
128-
$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART SD=s132 SOFTDEV_VERSION=5.0.0 dfu-gen dfu-flash
128+
$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART SD=s132 SOFTDEV_VERSION=5.0.0 dfu-gen dfu-flash
129129
```
130130

131131
## Working with CircuitPython

ports/nrf/boards/feather52832/mpconfigboard.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@
2828
#define MICROPY_HW_MCU_NAME "NRF52832"
2929
#define MICROPY_PY_SYS_PLATFORM "nrf52"
3030

31-
#define MICROPY_PY_MACHINE_HW_PWM (1)
32-
#define MICROPY_PY_MACHINE_HW_SPI (1)
33-
#define MICROPY_PY_MACHINE_TIMER (1)
34-
#define MICROPY_PY_MACHINE_RTC (0)
35-
#define MICROPY_PY_MACHINE_I2C (1)
36-
#define MICROPY_PY_MACHINE_ADC (1)
37-
#define MICROPY_PY_MACHINE_TEMP (1)
38-
3931
#define MICROPY_HW_HAS_LED (1)
4032
#define MICROPY_HW_HAS_SWITCH (0)
4133
#define MICROPY_HW_HAS_FLASH (0)

ports/nrf/boards/feather52832/mpconfigboard.mk

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MCU_SERIES = m4
22
MCU_VARIANT = nrf52
3-
MCU_SUB_VARIANT = nrf52832
3+
MCU_SUB_VARIANT = nrf52
44
SOFTDEV_VERSION ?= 2.0.1
55

66
LD_FILE = boards/feather52832/custom_nrf52832_dfu_app_$(SOFTDEV_VERSION).ld
@@ -15,11 +15,6 @@ else
1515
NRFUTIL = nrfutil
1616
endif
1717

18-
ifeq ($(SD), )
19-
INC += -Idrivers/bluetooth/s132_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/s132_$(MCU_VARIANT)_$(SOFTDEV_VERSION)_API/include
20-
INC += -Idrivers/bluetooth/s132_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/s132_$(MCU_VARIANT)_$(SOFTDEV_VERSION)_API/include/$(MCU_VARIANT)
21-
endif
22-
2318
CFLAGS += -DADAFRUIT_FEATHER52
2419

2520
check_defined = \

ports/nrf/boards/feather52832/mpconfigboard_s132.mk

Lines changed: 0 additions & 4 deletions
This file was deleted.

ports/nrf/boards/feather52832/pins.csv

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
A0,P0_02,ADC0_IN0
2-
A1,P0_03,ADC0_IN1
3-
A2,P0_04,ADC0_IN2
4-
A3,P0_05,ADC0_IN3
1+
A0,P0_02
2+
A1,P0_03
3+
A2,P0_04
4+
A3,P0_05
55
TX,P0_06
66
RX,P0_08
77
NFC1,P0_09
@@ -18,7 +18,7 @@ DFU,P0_20
1818
SDA,P0_25
1919
SCL,P0_26
2020
D27,P0_27
21-
A4,P0_28,ADC0_IN4
22-
A5,P0_29,ADC0_IN5
23-
A6,P0_30,ADC0_IN6
24-
A7,P0_31,ADC0_IN7
21+
A4,P0_28
22+
A5,P0_29
23+
A6,P0_30
24+
A7,P0_31

0 commit comments

Comments
 (0)