Running NuttX on Arduino M0

NuttX has support to SAMD21 MCU and this is the MCU used on Arduino M0. Then I decided to add board support to Arduino M0 on NuttX mainline.

I used the Wemos SAMD21 M0 (a compatible Arduino M0 board), but you can use the original Arduino M0 or even the RobotDyn SAMD21 M0 board.

Enter inside NuttX directory, clear it and configure to use the arduino-m0:

$ cd nuttx
$ make distclean 
$ ./tools/ arduino-m0:nsh
Detected arm Architecture
Detected samd2l2 Chip
Copy files

Compile it:

$ make

After compilation, confirm the binary was generated:

$ ls -l nuttx.bin 
-rwxr-xr-x 1 alan alan 43436 set 22 13:13 nuttx.bin

Connect J-Link to SWD (EDBG) pin header and run and flash the firmware:

$ sudo JLinkExe -device ATSAML21G18 -if SWD

SEGGER J-Link Commander V6.46h (Compiled Jun 28 2019 17:19:57)
DLL version V6.46h, compiled Jun 28 2019 17:19:50
Connecting to J-Link via USB…O.K.
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware version: V8.00
S/N: 26800XXXX
License(s): FlashBP, GDB

Type "connect" to establish a target connection, '?' for help
Specify target interface speed [kHz]. : 4000 kHz

Device "ATSAML21G18" selected.
Connecting to target via SWD
Found SW-DP with ID 0x0BC11477

Scanning AP map to find all available APs
AP[1]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x04770031)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0x41003000
CPUID register: 0x410CC601. Implementer code: 0x41 (ARM)
Found Cortex-M0 r0p1, Little endian.
FPUnit: 4 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ 41003000
ROMTbl[0][0]: E00FF000, CID: B105100D, PID: 000BB4C0 ROM Table
ROMTbl[1] @ E00FF000
ROMTbl[1][0]: E000E000, CID: B105E00D, PID: 000BB008 SCS
ROMTbl[1][1]: E0001000, CID: B105E00D, PID: 000BB00A DWT
ROMTbl[1][2]: E0002000, CID: B105E00D, PID: 000BB00B FPB
ROMTbl[0][1]: 41006000, CID: B105900D, PID: 001BB932 MTB-M0+
Cortex-M0 identified.
J-Link>loadbin nuttx.bin 0

Now use a USB/Serial and connect the RXD to RXD pad of the board and TXD to TXD pad. Configure the minicom to use 115200 8n1 and after reseting the board you should get:

NuttShell (NSH)

2 thoughts on “Running NuttX on Arduino M0

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s