Skip to content

board/arduino-nano-33-ble: add initial support#13194

Merged
fjmolinas merged 4 commits intoRIOT-OS:masterfrom
aabadie:pr/board/arduino-nano-33-ble
Apr 8, 2020
Merged

board/arduino-nano-33-ble: add initial support#13194
fjmolinas merged 4 commits intoRIOT-OS:masterfrom
aabadie:pr/board/arduino-nano-33-ble

Conversation

@aabadie
Copy link
Contributor

@aabadie aabadie commented Jan 24, 2020

Contribution description

This PR adds support for the Arduino Nano 33 BLE board which runs on an nRF52840 CPUs and thus provides 802.15.4 and BLE radio.

To flash this board, Arduino uses the same approach as with other samd21 based boards (MKR, etc): there's a bootloader at beginning of the flash. This bootloader can communicate with the Bossa tool but not the one from the upstream project because it doesn't support the nrf52 cpu. Arduino added support on his fork and as a consequence, this PR changes the Bossa repository to use the Arduino one.

Note that this PR is based on #12304 because I could adapt the same strategy for the nrf CPUs.

Timers, I2C were tested with success.

UART was also tested with success, using the following patch:

Details
diff --git a/tests/periph_uart/main.c b/tests/periph_uart/main.c
index 81c08362947..c5aed5eb97a 100644
--- a/tests/periph_uart/main.c
+++ b/tests/periph_uart/main.c
@@ -69,10 +69,10 @@ static int parse_dev(char *arg)
         printf("Error: Invalid UART_DEV device specified (%u).\n", dev);
         return -1;
     }
-    else if (UART_DEV(dev) == STDIO_UART_DEV) {
-        printf("Error: The selected UART_DEV(%u) is used for the shell!\n", dev);
-        return -2;
-    }
+    // else if (UART_DEV(dev) == STDIO_UART_DEV) {
+    //     printf("Error: The selected UART_DEV(%u) is used for the shell!\n", dev);
+    //     return -2;
+    // }
     return dev;
 }

SPI is untested.

Testing procedure

  • Check that you can flash the board, interact with the on-board LEDs using the examples/saul application:
make BOARD=arduino-nano-33-ble -C examples/saul flash term

Issues/PRs references

Based on #12304

@aabadie aabadie added Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first Area: boards Area: Board ports labels Jan 24, 2020
@aabadie aabadie requested a review from fjmolinas January 24, 2020 08:55
@miri64
Copy link
Member

miri64 commented Jan 24, 2020

This PR adds support for the Arduino Nano 33 BLE board which runs on an nRF52840 CPUs and thus provides 802.15.4 and BLE radio.

The link just leads here...

@aabadie
Copy link
Contributor Author

aabadie commented Jan 24, 2020

The link just leads here...

Sorry, I forgot to put the link... Fixed :)

@aabadie aabadie force-pushed the pr/board/arduino-nano-33-ble branch from 298f792 to fca7cfe Compare March 18, 2020 13:13
@aabadie aabadie added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: waiting for other PR State: The PR requires another PR to be merged first labels Mar 18, 2020
@aabadie aabadie force-pushed the pr/board/arduino-nano-33-ble branch from fca7cfe to e6641d1 Compare April 6, 2020 19:24
@aabadie
Copy link
Contributor Author

aabadie commented Apr 7, 2020

@fjmolinas maybe you could be interested by this one ?

@aabadie
Copy link
Contributor Author

aabadie commented Apr 7, 2020

I can provide some output

@fjmolinas
Copy link
Contributor

I can provide some output

Please do.

@aabadie
Copy link
Contributor Author

aabadie commented Apr 7, 2020

`examples/hello_world` (with bossa-nrf52 bootstrap)
$ make BOARD=arduino-nano-33-ble -C examples/hello-world/ flash term --no-print-directory 
Building application "hello-world" for "arduino-nano-33-ble" with MCU "nrf52".

"make" -C /work/riot/RIOT/boards/arduino-nano-33-ble
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/nrf52
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/nrf52/periph
"make" -C /work/riot/RIOT/cpu/nrf5x_common
"make" -C /work/riot/RIOT/cpu/nrf5x_common/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/auto_init/usb
"make" -C /work/riot/RIOT/sys/event
"make" -C /work/riot/RIOT/sys/isrpipe
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/tsrb
"make" -C /work/riot/RIOT/sys/usb/usbus
"make" -C /work/riot/RIOT/sys/usb/usbus/cdc/acm
"make" -C /work/riot/RIOT/sys/usb_board_reset
   text	   data	    bss	    dec	    hex	filename
  15080	    128	   5612	  20820	   5154	/work/riot/RIOT/examples/hello-world/bin/arduino-nano-33-ble/hello-world.elf
stty -F /dev/ttyACM0 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
sleep 1
[INFO] bossac nrf52 binary not found - building it from source
[INFO] cloning bossa
Cloning into '/work/riot/RIOT/dist/tools/bossa-nrf52/bin'...
remote: Enumerating objects: 1760, done.
remote: Total 1760 (delta 0), reused 0 (delta 0), pack-reused 1760
Receiving objects: 100% (1760/1760), 1.15 MiB | 895.00 KiB/s, done.
Resolving deltas: 100% (1348/1348), done.
HEAD is now at 52e0a4a Fix Windows build
[INFO] updating bossa /work/riot/RIOT/dist/tools/bossa-nrf52/bin/.pkg-state.git-downloaded
echo 52e0a4a28721296e64083de7780b30580e0fad16 > /work/riot/RIOT/dist/tools/bossa-nrf52/bin/.pkg-state.git-downloaded
[INFO] patch bossa
[INFO] compiling bossac from source now
make[2]: wx-config: Command not found
make[2]: wx-config: Command not found
CPP APPLET src/WordCopyArm.cpp
CPP COMMON src/Samba.cpp
CPP COMMON src/Flash.cpp
CPP COMMON src/D5xNvmFlash.cpp
CPP COMMON src/D2xNvmFlash.cpp
CPP COMMON src/NullFlash.cpp
CPP COMMON src/EfcFlash.cpp
CPP COMMON src/EefcFlash.cpp
CPP COMMON src/Applet.cpp
CPP COMMON src/WordCopyApplet.cpp
CPP COMMON src/Flasher.cpp
CPP COMMON src/Device.cpp
CPP COMMON src/PosixSerialPort.cpp
CPP COMMON src/LinuxPortFactory.cpp
CPP BOSSAC src/bossac.cpp
CPP BOSSAC src/CmdOpts.cpp
LD /work/riot/RIOT/dist/tools/bossa-nrf52/bin/bossac
STRIP /work/riot/RIOT/dist/tools/bossa-nrf52/bin/bossac
[INFO] bossac nrf52 binary successfully built!
/work/riot/RIOT/dist/tools/bossa-nrf52/bossac -p /dev/ttyACM0  -e -i -w -v -b -R /work/riot/RIOT/examples/hello-world/bin/arduino-nano-33-ble/hello-world.bin
Device       : nRF52840-QIAA
Version      : Arduino Bootloader (SAM-BA extended) 2.0 [Arduino:IKXYZ]
Address      : 0x0
Pages        : 256
Page Size    : 4096 bytes
Total Size   : 1024KB
Planes       : 1
Lock Regions : 0
Locked       : none
Security     : false
Erase flash

Done in 0.001 seconds
Write 15208 bytes to flash (4 pages)
[==============================] 100% (4/4 pages)
Done in 0.613 seconds
Verify 15208 bytes of flash
[==============================] 100% (4/4 pages)
Verify successful
Done in 0.023 seconds
Set boot flash true
sleep 2
/work/riot/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200" 
2020-04-07 10:18:23,430 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
2020-04-07 10:18:24,433 # d/arduino-nano-33-ble)
2020-04-07 10:18:24,433 # Hello World!
2020-04-07 10:18:24,433 # You are running RIOT on a(n) arduino-nano-33-ble board.
2020-04-07 10:18:24,434 # This board features a(n) nrf52 MCU.
2020-04-07 10:41:25,766 # Exiting Pyterm
`examples/default`
$ make BOARD=arduino-nano-33-ble -C examples/default/ flash term --no-print-directory 
Building application "default" for "arduino-nano-33-ble" with MCU "nrf52".

"make" -C /work/riot/RIOT/boards/arduino-nano-33-ble
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/nrf52
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/nrf52/periph
"make" -C /work/riot/RIOT/cpu/nrf52/radio/nrf802154
"make" -C /work/riot/RIOT/cpu/nrf5x_common
"make" -C /work/riot/RIOT/cpu/nrf5x_common/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/netdev_ieee802154
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/drivers/saul
"make" -C /work/riot/RIOT/drivers/saul/init_devs
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/auto_init/usb
"make" -C /work/riot/RIOT/sys/event
"make" -C /work/riot/RIOT/sys/fmt
"make" -C /work/riot/RIOT/sys/isrpipe
"make" -C /work/riot/RIOT/sys/luid
"make" -C /work/riot/RIOT/sys/net/gnrc
"make" -C /work/riot/RIOT/sys/net/gnrc/netapi
"make" -C /work/riot/RIOT/sys/net/gnrc/netif
"make" -C /work/riot/RIOT/sys/net/gnrc/netif/hdr
"make" -C /work/riot/RIOT/sys/net/gnrc/netif/ieee802154
"make" -C /work/riot/RIOT/sys/net/gnrc/netif/init_devs
"make" -C /work/riot/RIOT/sys/net/gnrc/netreg
"make" -C /work/riot/RIOT/sys/net/gnrc/pkt
"make" -C /work/riot/RIOT/sys/net/gnrc/pktbuf
"make" -C /work/riot/RIOT/sys/net/gnrc/pktbuf_static
"make" -C /work/riot/RIOT/sys/net/gnrc/pktdump
"make" -C /work/riot/RIOT/sys/net/link_layer/ieee802154
"make" -C /work/riot/RIOT/sys/net/link_layer/l2util
"make" -C /work/riot/RIOT/sys/net/netif
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/od
"make" -C /work/riot/RIOT/sys/phydat
"make" -C /work/riot/RIOT/sys/ps
"make" -C /work/riot/RIOT/sys/random
"make" -C /work/riot/RIOT/sys/random/tinymt32
"make" -C /work/riot/RIOT/sys/saul_reg
"make" -C /work/riot/RIOT/sys/shell
"make" -C /work/riot/RIOT/sys/shell/commands
"make" -C /work/riot/RIOT/sys/tsrb
"make" -C /work/riot/RIOT/sys/usb/usbus
"make" -C /work/riot/RIOT/sys/usb/usbus/cdc/acm
"make" -C /work/riot/RIOT/sys/usb_board_reset
   text	   data	    bss	    dec	    hex	filename
  40380	    164	   9168	  49712	   c230	/work/riot/RIOT/examples/default/bin/arduino-nano-33-ble/default.elf
stty -F /dev/ttyACM0 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
sleep 1
/work/riot/RIOT/dist/tools/bossa-nrf52/bossac -p /dev/ttyACM0  -e -i -w -v -b -R /work/riot/RIOT/examples/default/bin/arduino-nano-33-ble/default.bin
Device       : nRF52840-QIAA
Version      : Arduino Bootloader (SAM-BA extended) 2.0 [Arduino:IKXYZ]
Address      : 0x0
Pages        : 256
Page Size    : 4096 bytes
Total Size   : 1024KB
Planes       : 1
Lock Regions : 0
Locked       : none
Security     : false
Erase flash

Done in 0.001 seconds
Write 40544 bytes to flash (10 pages)
[==============================] 100% (10/10 pages)
Done in 1.551 seconds
Verify 40544 bytes of flash
[==============================] 100% (10/10 pages)
Verify successful
Done in 0.061 seconds
Set boot flash true
sleep 2
/work/riot/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200" 
2020-04-07 11:03:25,422 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
2020-04-07 11:03:26,427 # main(): This is RIOT! (Version: 2020.04-devel-1937-gf1b9b-pr/board/arduino-nano-33-ble)
2020-04-07 11:03:26,428 # Welcome to RIOT!
> help
2020-04-07 11:03:27,921 #  help
2020-04-07 11:03:27,922 # Command              Description
2020-04-07 11:03:27,923 # ---------------------------------------
2020-04-07 11:03:27,924 # reboot               Reboot the node
2020-04-07 11:03:27,926 # version              Prints current RIOT_VERSION
2020-04-07 11:03:27,928 # ps                   Prints information about running threads.
2020-04-07 11:03:27,929 # random_init          initializes the PRNG
2020-04-07 11:03:27,931 # random_get           returns 32 bit of pseudo randomness
2020-04-07 11:03:27,932 # ifconfig             Configure network interfaces
2020-04-07 11:03:27,934 # txtsnd               Sends a custom string as is over the link layer
2020-04-07 11:03:27,937 # saul                 interact with sensors and actuators using SAUL
> ifconfig
2020-04-07 11:03:30,399 #  ifconfig
2020-04-07 11:03:30,400 # Iface  5  HWaddr: 56:85  Channel: 26  NID: 0x23
2020-04-07 11:03:30,402 # Long HWaddr: 73:B7:28:AB:92:47:56:85 
2020-04-07 11:03:30,403 #  TX-Power: 0dBm L2-PDU:102 Source address length: 2
2020-04-07 11:03:30,403 # 
> saul
2020-04-07 11:03:34,020 #  saul
2020-04-07 11:03:34,021 # ID	Class		Name
2020-04-07 11:03:34,023 # #0	ACT_SWITCH	LED0 (Orange)
2020-04-07 11:03:34,024 # #1	ACT_SWITCH	LED1 (RED)
2020-04-07 11:03:34,025 # #2	ACT_SWITCH	LED2 (GREEN)
2020-04-07 11:03:34,026 # #3	ACT_SWITCH	LED3 (BLUE)
2020-04-07 11:03:34,027 # #4	ACT_SWITCH	LED4 (PWR)
2020-04-07 11:03:34,028 # #5	SENSE_TEMP	NRF_TEMP
> saul read 5
2020-04-07 11:03:40,673 #  saul read 5
2020-04-07 11:03:40,675 # Reading from #5 (NRF_TEMP|SENSE_TEMP)
2020-04-07 11:03:40,676 # Data:	             26 °C
> saul write 0 1
2020-04-07 11:03:45,321 #  saul write 0 1
2020-04-07 11:03:45,323 # Writing to device #0 - LED0 (Orange)
2020-04-07 11:03:45,323 # Data:	              1 
2020-04-07 11:03:45,325 # data successfully written to device #0
> saul write 1 1 
2020-04-07 11:03:52,595 #  saul write 1 1
2020-04-07 11:03:52,596 # Writing to device #1 - LED1 (RED)
2020-04-07 11:03:52,597 # Data:	              1 
2020-04-07 11:03:52,598 # data successfully written to device #1
> saul write 2 1 
2020-04-07 11:03:57,520 #  saul write 2 1
2020-04-07 11:03:57,522 # Writing to device #2 - LED2 (GREEN)
2020-04-07 11:03:57,523 # Data:	              1 
2020-04-07 11:03:57,524 # data successfully written to device #2
> saul write 3 1 
2020-04-07 11:04:01,278 #  saul write 3 1
2020-04-07 11:04:01,279 # Writing to device #3 - LED3 (BLUE)
2020-04-07 11:04:01,280 # Data:	              1 
2020-04-07 11:04:01,281 # data successfully written to device #3
> saul write 4 1 
2020-04-07 11:04:08,337 #  saul write 4 1
2020-04-07 11:04:08,338 # Writing to device #4 - LED4 (PWR)
2020-04-07 11:04:08,339 # Data:	              1 
2020-04-07 11:04:08,340 # data successfully written to device #4
> saul write 0 0 
2020-04-07 11:04:14,577 #  saul write 0 0
2020-04-07 11:04:14,579 # Writing to device #0 - LED0 (Orange)
2020-04-07 11:04:14,580 # Data:	              0 
2020-04-07 11:04:14,581 # data successfully written to device #0
> 2020-04-07 11:04:17,919 # Exiting Pyterm
`examples/hello_world`, with stdio_null
$ USEMODULE=stdio_null make BOARD=arduino-nano-33-ble -C examples/hello-world/ --no-print-directory 
Building application "hello-world" for "arduino-nano-33-ble" with MCU "nrf52".

"make" -C /work/riot/RIOT/boards/arduino-nano-33-ble
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/nrf52
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/nrf52/periph
"make" -C /work/riot/RIOT/cpu/nrf5x_common
"make" -C /work/riot/RIOT/cpu/nrf5x_common/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/stdio_null
   text	   data	    bss	    dec	    hex	filename
   7716	    108	   2544	  10368	   2880	/work/riot/RIOT/examples/hello-world/bin/arduino-nano-33-ble/hello-world.elf

Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, pinout seems right. Only some comments. Will trust @aabadie testing on this one.

@fjmolinas fjmolinas self-assigned this Apr 7, 2020
@aabadie aabadie force-pushed the pr/board/arduino-nano-33-ble branch from e6641d1 to 3ff6614 Compare April 7, 2020 15:28
@aabadie
Copy link
Contributor Author

aabadie commented Apr 7, 2020

There are some unrelated errors on Murdock:

-- running on worker mobi8.inet.haw-hamburg.de thread 2, build number 2940.
make: Entering directory '/tmp/dwq.0.40077763006094835/48e0e572d2d338057a8cc9c698719a4f/tests/driver_si114x'
Building application "tests_driver_si114x" for "atmega328p" with MCU "atmega328p".

Traceback (most recent call last):
  File "/tmp/dwq.0.40077763006094835/48e0e572d2d338057a8cc9c698719a4f/dist/tools/lazysponge/lazysponge.py", line 102, in <module>
    main()
  File "/tmp/dwq.0.40077763006094835/48e0e572d2d338057a8cc9c698719a4f/dist/tools/lazysponge/lazysponge.py", line 98, in main
    outfd.write(stdinbytes)
OSError: [Errno 28] No space left on device
/tmp/dwq.0.40077763006094835/48e0e572d2d338057a8cc9c698719a4f/tests/driver_si114x/../../Makefile.include:878: recipe for target '/tmp/dwq.0.40077763006094835/48e0e572d2d338057a8cc9c698719a4f/build/riotbuild/riotbuild.h.in' failed
make: *** [/tmp/dwq.0.40077763006094835/48e0e572d2d338057a8cc9c698719a4f/build/riotbuild/riotbuild.h.in] Error 1
make: Leaving directory '/tmp/dwq.0.40077763006094835/48e0e572d2d338057a8cc9c698719a4f/tests/driver_si114x'
-- build directory size: 0

@aabadie
Copy link
Contributor Author

aabadie commented Apr 7, 2020

They are all happening on mobi8.inet.haw-hamburg.de so I guess there's a disk space issue on this worker.

@aabadie aabadie added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 7, 2020
@fjmolinas
Copy link
Contributor

@aabadie please squash.

@aabadie aabadie force-pushed the pr/board/arduino-nano-33-ble branch from 3ff6614 to 8f99b71 Compare April 8, 2020 07:46
@fjmolinas
Copy link
Contributor

@aabadie this one diverged!

@aabadie aabadie force-pushed the pr/board/arduino-nano-33-ble branch from 8f99b71 to 239e080 Compare April 8, 2020 07:59
@aabadie
Copy link
Contributor Author

aabadie commented Apr 8, 2020

this one diverged!

ok, sorry. Should be ok now :)

Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@fjmolinas fjmolinas merged commit 3b423a9 into RIOT-OS:master Apr 8, 2020
@leandrolanzieri leandrolanzieri added this to the Release 2020.04 milestone Apr 8, 2020
@aabadie aabadie deleted the pr/board/arduino-nano-33-ble branch June 24, 2020 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: boards Area: Board ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants