Skip to content

Commit 8e557d9

Browse files
committed
nano33ble: add support
1 parent 46317c2 commit 8e557d9

File tree

5 files changed

+379
-1
lines changed

5 files changed

+379
-1
lines changed

boards.txt

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,74 @@ giga.debug.server.openocd.scripts.0=interface/{programmer.protocol}.cfg
6969
giga.debug.server.openocd.scripts.1={programmer.transport_script}
7070
giga.debug.server.openocd.scripts.2=target/stm32h7x_dual_bank.cfg
7171
giga.debug.cortex-debug.custom.request=attach
72-
giga.debug.svd_file={runtime.platform.path}/svd/STM32H747_CM7.svd
72+
giga.debug.svd_file={runtime.platform.path}/svd/STM32H747_CM7.svd
73+
74+
##########################################################################################
75+
76+
nano33ble.name=Arduino Nano 33 BLE
77+
nano33ble.build.core=arduino
78+
nano33ble.build.crossprefix=arm-zephyr-eabi-
79+
nano33ble.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
80+
81+
nano33ble.menu.debug.false=Standard
82+
nano33ble.menu.debug.true=Debug
83+
84+
nano33ble.menu.debug.false.post_build_arg=
85+
nano33ble.menu.debug.true.post_build_arg=debug
86+
87+
nano33ble.build.variant=arduino_nano_33_ble_sense
88+
nano33ble.build.mcu=cortex-m4
89+
nano33ble.build.fpu=-mfpu=fpv4-sp-d16
90+
nano33ble.build.architecture=cortex-m4
91+
nano33ble.compiler.zephyr.arch.define=
92+
93+
nano33ble.build.board={build.variant}
94+
95+
nano33ble.build.float-abi=-mfloat-abi=hard
96+
nano33ble.build.extra_flags=
97+
nano33ble.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
98+
nano33ble.build.architecture=cortex-m4
99+
nano33ble.build.board=ARDUINO_NANO33BLE
100+
nano33ble.build.extra_ldflags=
101+
nano33ble.compiler.zephyr.defines=-DLL_EXTENSION_BUILD -DCONFIG_ARDUINO_API_SERIAL_BUFFER_SIZE=256 -DNRF52840_XXAA -DKERNEL -DK_HEAP_MEM_POOL_SIZE=32768 -DPICOLIBC_LONG_LONG_PRINTF_SCANF -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -imacros{build.variant.path}/llext-edk/include/zephyr/include/generated/zephyr/autoconf.h -imacros{build.variant.path}/llext-edk/include/zephyr/include/zephyr/toolchain/zephyr_stdint.h
102+
nano33ble.compiler.zephyr.ldflags=-fno-exceptions -fno-rtti -fno-threadsafe-statics -fno-unwind-tables -fno-use-cxa-atexit
103+
nano33ble.compiler.zephyr.cflags=-fno-strict-aliasing -fno-printf-return-value -fno-common -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop --specs=picolibc.specs -D_POSIX_THREADS -mlong-calls -nodefaultlibs
104+
nano33ble.compiler.zephyr.cxxflags={compiler.zephyr.ldflags} -fdata-sections -ffunction-sections -fno-unwind-tables -fno-strict-aliasing -fno-printf-return-value -fno-common -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop --specs=picolibc.specs -D_POSIX_THREADS -mlong-calls -nodefaultlibs
105+
nano33ble.compiler.zephyr.includes={build.variant.path}/includes.txt
106+
nano33ble.compiler.zephyr.extra_ldflags=-lstdc++ -lsupc++ -lnosys -nostdlib
107+
nano33ble.compiler.zephyr=
108+
nano33ble.vid.0=0x2341
109+
nano33ble.pid.0=0x035a
110+
nano33ble.upload_port.0.vid=0x2341
111+
nano33ble.upload_port.0.pid=0x005a
112+
113+
nano33ble.upload.tool=bossac
114+
nano33ble.upload.tool.default=bossac
115+
nano33ble.upload.protocol=
116+
nano33ble.upload.transport=
117+
nano33ble.upload.vid=0x2341
118+
nano33ble.upload.pid=0x005a
119+
nano33ble.upload.interface=0
120+
nano33ble.upload.use_1200bps_touch=true
121+
nano33ble.upload.wait_for_upload_port=true
122+
nano33ble.upload.native_usb=true
123+
nano33ble.upload.maximum_size=1966080
124+
nano33ble.upload.maximum_data_size=523624
125+
nano33ble.upload.address=0xD0000
126+
127+
nano33ble.upload.maximum_size=786432
128+
nano33ble.upload.maximum_data_size=523624
129+
130+
nano33ble.bootloader.tool=bossac
131+
nano33ble.bootloader.tool.default=bossac
132+
nano33ble.bootloader.vid=0x2341
133+
nano33ble.bootloader.pid=0x035b
134+
nano33ble.bootloader.interface=0
135+
nano33ble.bootloader.file=zephyr-arduino_nano_33_ble_sense.bin
136+
nano33ble.bootloader.address=0x0000
137+
138+
nano33ble.debug.tool=gdb
139+
nano33ble.debug.server.openocd.scripts.0=interface/{programmer.protocol}.cfg
140+
nano33ble.debug.server.openocd.scripts.1={programmer.transport_script}
141+
nano33ble.debug.server.openocd.scripts.2=target/nrf52.cfg
142+
nano33ble.debug.cortex-debug.custom.request=attach
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CONFIG_BT=y
2+
CONFIG_BT_SMP=y
3+
CONFIG_BT_PERIPHERAL=y
4+
CONFIG_BT_CENTRAL=y
5+
CONFIG_BT_DIS=y
6+
CONFIG_BT_DIS_PNP=n
7+
CONFIG_BT_BAS=y
8+
CONFIG_BT_HRS=y
9+
10+
CONFIG_USB_DEVICE_STACK=y
11+
CONFIG_USB_DEVICE_PRODUCT="Arduino Nano 33 BLE"
12+
CONFIG_USB_DEVICE_MANUFACTURER="Arduino"
13+
CONFIG_USB_DEVICE_VID=0x2341
14+
CONFIG_USB_DEVICE_PID=0x035A
15+
16+
CONFIG_USB_CDC_ACM=y
17+
CONFIG_USB_CDC_ACM_RINGBUF_SIZE=512
18+
CONFIG_UART_LINE_CTRL=y
19+
CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT=y
20+
21+
CONFIG_ADC=y
22+
CONFIG_PWM=y
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
&zephyr_udc0 {
2+
cdc_acm_uart0: cdc_acm_uart0 {
3+
compatible = "zephyr,cdc-acm-uart";
4+
status = "okay";
5+
};
6+
};
7+
8+
&flash0 {
9+
partitions {
10+
compatible = "fixed-partitions";
11+
#address-cells = <1>;
12+
#size-cells = <1>;
13+
14+
boot_partition: partition@0 {
15+
label = "sam-ba";
16+
reg = <0x00000000 0x00010000>;
17+
read-only;
18+
};
19+
20+
code_partition: partition@10000 {
21+
label = "code";
22+
reg = <0x00010000 0x000d0000>;
23+
read-only;
24+
};
25+
26+
user_sketch: partition@e0000 {
27+
label = "user";
28+
reg = <0x0e0000 0x18000>;
29+
};
30+
31+
/*
32+
* The flash starting at 0x000f8000 and ending at
33+
* 0x000fffff is reserved for use by the application.
34+
*
35+
* Storage partition will be used by FCB/LittleFS/NVS
36+
* if enabled.
37+
*/
38+
storage_partition: partition@f8000 {
39+
label = "storage";
40+
reg = <0x000f8000 0x00008000>;
41+
};
42+
};
43+
};
44+
45+
46+
/ {
47+
zephyr,user {
48+
digital-pin-gpios = <&arduino_nano_header 0 0>,
49+
<&arduino_nano_header 1 0>,
50+
<&arduino_nano_header 2 0>,
51+
<&arduino_nano_header 3 0>,
52+
<&arduino_nano_header 4 0>,
53+
<&arduino_nano_header 5 0>,
54+
<&arduino_nano_header 6 0>,
55+
<&arduino_nano_header 7 0>,
56+
<&arduino_nano_header 8 0>,
57+
<&arduino_nano_header 9 0>,
58+
<&arduino_nano_header 10 0>,
59+
<&arduino_nano_header 11 0>,
60+
<&arduino_nano_header 12 0>,
61+
<&arduino_nano_header 13 0>,
62+
<&arduino_nano_header 14 0>, /* D14 / A0 */
63+
<&arduino_nano_header 15 0>,
64+
<&arduino_nano_header 16 0>,
65+
<&arduino_nano_header 17 0>,
66+
<&arduino_nano_header 18 0>, /* D18 / A4 / I2C-SDA */
67+
<&arduino_nano_header 19 0>, /* D19 / A5 / I2C-SCL */
68+
<&arduino_nano_header 20 0>,
69+
<&arduino_nano_header 21 0>;
70+
71+
pwm-pin-gpios = <&arduino_nano_header 3 0>,
72+
<&arduino_nano_header 5 0>,
73+
<&arduino_nano_header 6 0>,
74+
<&arduino_nano_header 13 0>,
75+
<&arduino_nano_header 9 0>,
76+
<&arduino_nano_header 10 0>,
77+
<&arduino_nano_header 11 0>;
78+
79+
adc-pin-gpios = <&arduino_nano_header 14 0>,
80+
<&arduino_nano_header 15 0>,
81+
<&arduino_nano_header 16 0>,
82+
<&arduino_nano_header 17 0>,
83+
<&arduino_nano_header 18 0>,
84+
<&arduino_nano_header 19 0>,
85+
<&arduino_nano_header 20 0>,
86+
<&arduino_nano_header 21 0>;
87+
88+
builtin-led-gpios = <&arduino_nano_header 13 0>;
89+
90+
pwms = <&pwm1 1 255 PWM_POLARITY_NORMAL>,
91+
<&pwm1 2 255 PWM_POLARITY_NORMAL>,
92+
<&pwm1 3 255 PWM_POLARITY_NORMAL>,
93+
<&pwm2 0 255 PWM_POLARITY_NORMAL>,
94+
<&pwm2 1 255 PWM_POLARITY_NORMAL>,
95+
<&pwm2 2 255 PWM_POLARITY_NORMAL>,
96+
<&pwm2 3 255 PWM_POLARITY_NORMAL>;
97+
98+
io-channels = <&adc 2>,
99+
<&adc 3>,
100+
<&adc 6>,
101+
<&adc 5>,
102+
<&adc 7>,
103+
<&adc 0>,
104+
<&adc 4>,
105+
<&adc 1>;
106+
107+
serials = <&cdc_acm_uart0>, <&uart0>;
108+
cdc-acm = <&cdc_acm_uart0>;
109+
i2cs = <&arduino_nano_i2c>;
110+
};
111+
};
112+
113+
&adc {
114+
#address-cells = <1>;
115+
#size-cells = <0>;
116+
117+
channel@0 {
118+
reg = <0>;
119+
zephyr,gain = "ADC_GAIN_1_6";
120+
zephyr,reference = "ADC_REF_INTERNAL";
121+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
122+
zephyr,input-positive = <NRF_SAADC_AIN0>; /* P0.02 */
123+
zephyr,resolution = <10>;
124+
};
125+
126+
channel@1 {
127+
reg = <1>;
128+
zephyr,gain = "ADC_GAIN_1_6";
129+
zephyr,reference = "ADC_REF_INTERNAL";
130+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
131+
zephyr,input-positive = <NRF_SAADC_AIN1>; /* P0.03 */
132+
zephyr,resolution = <10>;
133+
};
134+
135+
channel@2 {
136+
reg = <2>;
137+
zephyr,gain = "ADC_GAIN_1_6";
138+
zephyr,reference = "ADC_REF_INTERNAL";
139+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
140+
zephyr,input-positive = <NRF_SAADC_AIN2>; /* P0.04 */
141+
zephyr,resolution = <10>;
142+
};
143+
144+
channel@3 {
145+
reg = <3>;
146+
zephyr,gain = "ADC_GAIN_1_6";
147+
zephyr,reference = "ADC_REF_INTERNAL";
148+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
149+
zephyr,input-positive = <NRF_SAADC_AIN3>; /* P0.05 */
150+
zephyr,resolution = <10>;
151+
};
152+
153+
channel@4 {
154+
reg = <4>;
155+
zephyr,gain = "ADC_GAIN_1_6";
156+
zephyr,reference = "ADC_REF_INTERNAL";
157+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
158+
zephyr,input-positive = <NRF_SAADC_AIN4>; /* P0.28 */
159+
zephyr,resolution = <10>;
160+
};
161+
162+
channel@5 {
163+
reg = <5>;
164+
zephyr,gain = "ADC_GAIN_1_6";
165+
zephyr,reference = "ADC_REF_INTERNAL";
166+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
167+
zephyr,input-positive = <NRF_SAADC_AIN5>; /* P0.29 */
168+
zephyr,resolution = <10>;
169+
};
170+
171+
channel@6 {
172+
reg = <6>;
173+
zephyr,gain = "ADC_GAIN_1_6";
174+
zephyr,reference = "ADC_REF_INTERNAL";
175+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
176+
zephyr,input-positive = <NRF_SAADC_AIN6>; /* P0.30 */
177+
zephyr,resolution = <10>;
178+
};
179+
180+
channel@7 {
181+
reg = <7>;
182+
zephyr,gain = "ADC_GAIN_1_6";
183+
zephyr,reference = "ADC_REF_INTERNAL";
184+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
185+
zephyr,input-positive = <NRF_SAADC_AIN7>; /* P0.31 */
186+
zephyr,resolution = <10>;
187+
};
188+
};
189+
190+
&pinctrl {
191+
pwm1_default: pwm1_default {
192+
group1 {
193+
psels = <NRF_PSEL(PWM_OUT0, 1, 9)>, /* keep original config */
194+
<NRF_PSEL(PWM_OUT1, 1, 12)>,
195+
<NRF_PSEL(PWM_OUT2, 1, 13)>,
196+
<NRF_PSEL(PWM_OUT3, 1, 14)>;
197+
nordic,invert;
198+
};
199+
};
200+
201+
pwm1_sleep: pwm1_sleep {
202+
group1 {
203+
psels = <NRF_PSEL(PWM_OUT0, 1, 9)>, /* keep original config */
204+
<NRF_PSEL(PWM_OUT1, 1, 12)>,
205+
<NRF_PSEL(PWM_OUT2, 1, 13)>,
206+
<NRF_PSEL(PWM_OUT3, 1, 14)>;
207+
low-power-enable;
208+
};
209+
};
210+
211+
pwm2_default: pwm2_default {
212+
group1 {
213+
psels = <NRF_PSEL(PWM_OUT0, 0, 13)>, /* keep original config */
214+
<NRF_PSEL(PWM_OUT1, 0, 27)>,
215+
<NRF_PSEL(PWM_OUT2, 1, 2)>,
216+
<NRF_PSEL(PWM_OUT3, 1, 1)>;
217+
nordic,invert;
218+
};
219+
};
220+
221+
pwm2_sleep: pwm2_sleep {
222+
group1 {
223+
psels = <NRF_PSEL(PWM_OUT0, 0, 13)>, /* keep original config */
224+
<NRF_PSEL(PWM_OUT1, 0, 27)>,
225+
<NRF_PSEL(PWM_OUT2, 1, 2)>,
226+
<NRF_PSEL(PWM_OUT3, 1, 1)>;
227+
low-power-enable;
228+
};
229+
};
230+
};
231+
232+
&pwm1 {
233+
status = "okay";
234+
pinctrl-0 = <&pwm1_default>;
235+
pinctrl-1 = <&pwm1_sleep>;
236+
pinctrl-names = "default", "sleep";
237+
};
238+
239+
&pwm2 {
240+
status = "okay";
241+
pinctrl-0 = <&pwm2_default>;
242+
pinctrl-1 = <&pwm2_sleep>;
243+
pinctrl-names = "default", "sleep";
244+
};

loader/fixups.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#if CONFIG_BOARD_ARDUINO_NANO_33_BLE
2+
3+
#include <cmsis_core.h>
4+
void disable_mpu_rasr_xn(void)
5+
{
6+
uint32_t index;
7+
/* Kept the max index as 8(irrespective of soc) because the sram
8+
* would most likely be set at index 2.
9+
*/
10+
for (index = 0U; index < 8; index++) {
11+
MPU->RNR = index;
12+
#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE)
13+
if (MPU->RBAR & MPU_RBAR_XN_Msk) {
14+
MPU->RBAR ^= MPU_RBAR_XN_Msk;
15+
}
16+
#else
17+
if (MPU->RASR & MPU_RASR_XN_Msk) {
18+
MPU->RASR ^= MPU_RASR_XN_Msk;
19+
}
20+
#endif /* CONFIG_ARMV8_M_BASELINE || CONFIG_ARMV8_M_MAINLINE */
21+
}
22+
}
23+
24+
int disable_bootloader_mpu() {
25+
// MPU was previously enabled in the bootloader
26+
// https://github.com/bcmi-labs/zephyr/blob/31cb7dd00fd5bce4c69896b3b2ddf6259d0c0f2b/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_defconfig#L10C1-L10C15
27+
__disable_irq();
28+
disable_mpu_rasr_xn();
29+
__DMB();
30+
MPU->CTRL = 0;
31+
__enable_irq();
32+
return 0;
33+
}
34+
SYS_INIT(disable_bootloader_mpu, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
35+
36+
#endif
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <hal/nrf_power.h>
2+
3+
void _on_1200_bps() {
4+
nrf_power_gpregret_set(NRF_POWER, 0, 0xb0);
5+
NVIC_SystemReset();
6+
}

0 commit comments

Comments
 (0)