Skip to content

Commit 538971e

Browse files
committed
variants: add arduino_nano_rp2040
Signed-off-by: Gilberto Conti <g.conti@arduino.cc>
1 parent b22c6bf commit 538971e

13 files changed

Lines changed: 738 additions & 3 deletions

File tree

boards.txt

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,4 +757,71 @@ unoq.bootloader.tool.default=remoteocd
757757
unoq.bootloader.file=zephyr-{build.variant}.elf
758758
unoq.bootloader.target=stm32u585zitxq
759759

760-
##########################################################################################
760+
##############################################################################################################
761+
762+
nano_connect.name=Arduino Nano RP2040 Connect
763+
nano_connect.build.core=arduino
764+
nano_connect.build.crossprefix=arm-zephyr-eabi-
765+
nano_connect.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/
766+
767+
nano_connect.menu.debug.false=Standard
768+
nano_connect.menu.debug.true=Debug
769+
nano_connect.menu.debug.true.build.zsk_args.debug=-debug
770+
771+
nano_connect.menu.link_mode.dynamic=Dynamic
772+
nano_connect.menu.link_mode.static=Static
773+
nano_connect.menu.link_mode.static.build.link_mode=static
774+
nano_connect.menu.link_mode.static.upload.extension=bin-zsk.bin
775+
776+
nano_connect.build.zephyr_target=arduino_nano_connect
777+
nano_connect.build.zephyr_args=
778+
nano_connect.build.zephyr_hals=hal_rpi_pico
779+
nano_connect.build.artifact=zephyr_main
780+
nano_connect.build.variant=arduino_nano_connect_rp2040
781+
nano_connect.build.mcu=cortex-m0plus
782+
nano_connect.build.fpu=
783+
nano_connect.build.architecture=cortex-m0plus
784+
nano_connect.compiler.zephyr.arch.define=
785+
786+
nano_connect.build.float-abi=-mfloat-abi=soft
787+
nano_connect.build.extra_flags=
788+
nano_connect.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
789+
nano_connect.recipe.hooks.objcopy.postobjcopy.3.pattern="{runtime.tools.bin2uf2.path}/bin2uf2" {upload.address} {upload.familyid} "{build.path}/{build.project_name}.{upload.extension}" "{build.path}/{build.project_name}.uf2"
790+
nano_connect.build.board=NANO_RP2040_CONNECT
791+
nano_connect.compiler.zephyr=
792+
nano_connect.vid.0=0x2341
793+
nano_connect.pid.0=0x005E
794+
nano_connect.upload_port.0.vid=0x2341
795+
nano_connect.upload_port.0.pid=0x005E
796+
797+
nano_connect.upload.tool=picotool
798+
nano_connect.upload.tool.default=picotool
799+
nano_connect.upload.protocol=
800+
nano_connect.upload.transport=
801+
nano_connect.upload.vid=0x2341
802+
nano_connect.upload.pid=0x005E
803+
nano_connect.upload.interface=0
804+
nano_connect.upload.use_1200bps_touch=true
805+
nano_connect.upload.wait_for_upload_port=false
806+
nano_connect.upload.native_usb=true
807+
nano_connect.upload.maximum_size=16777216
808+
nano_connect.upload.maximum_data_size=270336
809+
810+
nano_connect.upload.address=0x100E0000
811+
nano_connect.upload.familyid=0xe48bff56
812+
813+
nano_connect.bootloader.tool=picotool
814+
nano_connect.bootloader.tool.default=picotool
815+
nano_connect.bootloader.vid=0x2341
816+
nano_connect.bootloader.pid=0x005E
817+
nano_connect.bootloader.interface=0
818+
nano_connect.bootloader.file=zephyr-{build.variant}
819+
820+
nano_connect.debug.tool=gdb
821+
nano_connect.debug.server.openocd.scripts.0=interface/{programmer.protocol}.cfg
822+
nano_connect.debug.server.openocd.scripts.1={programmer.transport_script}
823+
nano_connect.debug.server.openocd.scripts.2=target/rp2040-core0.cfg
824+
nano_connect.debug.cortex-debug.custom.request=attach
825+
nano_connect.debug.svd_file={runtime.platform.path}/svd/rp2040.svd
826+
827+
##############################################################################################################

cores/arduino/llext_wrappers.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@
6565
#ifdef CONFIG_ARM
6666
/* ARM EABI thread pointer access */
6767
W0(size_t, __aeabi_read_tp)
68+
69+
/*
70+
* Thumb1 switch-dispatch helpers.
71+
*
72+
* These use a non-standard calling convention: BL sets LR to the jump table
73+
* base (not a return address). With -mlong-calls the compiler lowers each
74+
* void-void wrapper to a tail call (ldr r3, =addr; bx r3), leaving LR
75+
* unchanged so the real function sees the original table pointer.
76+
*/
77+
V0(__gnu_thumb1_case_uqi)
78+
V0(__gnu_thumb1_case_sqi)
79+
V0(__gnu_thumb1_case_uhi)
80+
V0(__gnu_thumb1_case_shi)
81+
V0(__gnu_thumb1_case_si)
6882
#endif
6983

7084
/* string.h */

extra/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ line_continuation='\\$' # match lines ending with '\'
9191
c_comment='\s*\/\*.*?\*\/' # match C-style comments and any preceding space
9292
perl -i -pe "s/${c_comment}//gs unless /${line_preproc_ok}/ || (/${line_comment_only}/ && !/${line_continuation}/)" $(find ${VARIANT_DIR}/llext-edk/include/ -type f)
9393

94-
for ext in elf bin hex; do
94+
for ext in elf bin hex uf2; do
9595
rm -f firmwares/zephyr-$variant.$ext
9696
if [ -f ${BUILD_DIR}/zephyr/zephyr.$ext ]; then
9797
cp ${BUILD_DIR}/zephyr/zephyr.$ext firmwares/zephyr-$variant.$ext

loader/fixups.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,53 @@ SYS_INIT(disable_bootloader_mpu, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAU
5353
SYS_INIT(disable_mpu_rasr_xn, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
5454
#endif
5555

56+
#if defined(CONFIG_BOARD_ARDUINO_NANO_RP2040_CONNECT)
57+
#include <zephyr/kernel.h>
58+
#include <zephyr/drivers/gpio.h>
59+
#include <pico/bootrom.h>
60+
61+
/*
62+
* Double-tap reset detection: if the board is reset twice within 500ms,
63+
* enter USB bootloader (BOOTSEL) mode. This mirrors the original
64+
* ArduinoCore-mbed NANO_RP2040_CONNECT behavior.
65+
*
66+
* A magic token is stored in uninitialized RAM (.noinit), which survives
67+
* a warm reset but is lost on power cycle. On boot:
68+
* - If the token is present: a second reset happened quickly, so we
69+
* clear the token and enter USB boot mode (never returns).
70+
* - If not: write the token, wait 500ms, then clear it and boot normally.
71+
*/
72+
static const uint32_t magic_token[] = {
73+
0xf01681de,
74+
0xbd729b29,
75+
0xd359be7a,
76+
};
77+
78+
static uint32_t magic_location[3] __attribute__((section(".noinit.double_tap")));
79+
80+
#define NANO_RP2040_LED_PIN 6
81+
82+
int double_tap_check(void) {
83+
if (magic_location[0] == magic_token[0] && magic_location[1] == magic_token[1] &&
84+
magic_location[2] == magic_token[2]) {
85+
magic_location[0] = 0;
86+
reset_usb_boot(1 << NANO_RP2040_LED_PIN, 0);
87+
/* never returns */
88+
}
89+
90+
for (int i = 0; i < 3; i++) {
91+
magic_location[i] = magic_token[i];
92+
}
93+
94+
k_busy_wait(500000);
95+
96+
magic_location[0] = 0;
97+
return 0;
98+
}
99+
100+
SYS_INIT(double_tap_check, POST_KERNEL, 0);
101+
#endif
102+
56103
#if defined(CONFIG_INPUT)
57104
#include <zephyr/kernel.h>
58105
#include <zephyr/device.h>

loader/llext_exports.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,16 @@ EXPORT_SYMBOL(sys_clock_cycle_get_32);
301301
#if defined(CONFIG_ARM)
302302
extern uint32_t __aeabi_read_tp(void);
303303
EXPORT_LIBC_SYM(__aeabi_read_tp);
304+
extern void __gnu_thumb1_case_uqi(void);
305+
EXPORT_LIBC_SYM(__gnu_thumb1_case_uqi);
306+
extern void __gnu_thumb1_case_sqi(void);
307+
EXPORT_LIBC_SYM(__gnu_thumb1_case_sqi);
308+
extern void __gnu_thumb1_case_uhi(void);
309+
EXPORT_LIBC_SYM(__gnu_thumb1_case_uhi);
310+
extern void __gnu_thumb1_case_shi(void);
311+
EXPORT_LIBC_SYM(__gnu_thumb1_case_shi);
312+
extern void __gnu_thumb1_case_si(void);
313+
EXPORT_LIBC_SYM(__gnu_thumb1_case_si);
304314
FORCE_EXPORT_SYM(__aeabi_dcmpun);
305315
FORCE_EXPORT_SYM(__aeabi_dcmple);
306316
FORCE_EXPORT_SYM(__aeabi_d2lz);
@@ -330,6 +340,8 @@ FORCE_EXPORT_SYM(__aeabi_idivmod);
330340
FORCE_EXPORT_SYM(__aeabi_ldivmod);
331341
FORCE_EXPORT_SYM(__aeabi_ul2f);
332342
FORCE_EXPORT_SYM(__aeabi_dcmpge);
343+
FORCE_EXPORT_SYM(__aeabi_lmul);
344+
#endif
333345

334346
#if defined (CONFIG_CPP)
335347
FORCE_EXPORT_SYM(__cxa_pure_virtual);

platform.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,15 @@ tools.picotool.path={runtime.tools.rp2040tools.path}
249249
tools.picotool.cmd=rp2040load
250250
tools.picotool.upload.params.verbose=-v
251251
tools.picotool.upload.params.quiet=
252-
tools.picotool.upload.pattern="{path}/{cmd}" {upload.verbose} -D "{build.path}/{build.project_name}.elf"
252+
tools.picotool.upload.pattern="{path}/{cmd}" {upload.verbose} -D "{build.path}/{build.project_name}"
253+
254+
tools.picotool.erase.params.verbose=
255+
tools.picotool.erase.params.quiet=
256+
tools.picotool.erase.pattern=
257+
258+
tools.picotool.bootloader.params.verbose=-v
259+
tools.picotool.bootloader.params.quiet=
260+
tools.picotool.bootloader.pattern="{path}/{cmd}" {upload.verbose} -D "{runtime.platform.path}/firmwares/{bootloader.file}"
253261

254262
#
255263
# IMGTOOL
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) Arduino s.r.l. and/or its affiliated companies
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_USB_DEVICE_STACK=y
5+
CONFIG_USB_DEVICE_PRODUCT="Arduino Nano RP2040 Connect"
6+
CONFIG_USB_DEVICE_MANUFACTURER="Arduino"
7+
CONFIG_USB_DEVICE_VID=0x2341
8+
CONFIG_USB_DEVICE_PID=0x005E
9+
10+
CONFIG_SERIAL=y
11+
CONFIG_CONSOLE=y
12+
CONFIG_UART_CONSOLE=y
13+
CONFIG_UART_LINE_CTRL=y
14+
15+
CONFIG_USB_CDC_ACM=y
16+
CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024
17+
CONFIG_UART_LINE_CTRL=y
18+
CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT=y
19+
20+
CONFIG_LLEXT_STORAGE_WRITABLE=n
21+
22+
CONFIG_HEAP_MEM_POOL_SIZE=16384
23+
CONFIG_MAIN_STACK_SIZE=32768
24+
CONFIG_LLEXT_HEAP_SIZE=64
25+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1
26+
27+
CONFIG_LOG_BACKEND_UART=y
28+
CONFIG_LOG_BACKEND_UART_AUTOSTART=n
29+
CONFIG_LOG_DEFAULT_LEVEL=2
30+
31+
CONFIG_ADC=y
32+
CONFIG_DAC=n
33+
CONFIG_PWM=y
34+

0 commit comments

Comments
 (0)