Debugging NuttX on Atmel SAM L21 microcontroller with J-Link programmer

Run JLink GDB server this way:

$ JLinkGDBServer -device ATSAML21J18 -if SWD

Execute GDB passing the ELF file:

$ arm-none-eabi-gdb nuttx

Connect to GDB server:

(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0xfffffffe in ?? ()

Reset, load, add breakpoint and continue:

(gdb) monitor reset
Resetting target

(gdb) load nuttx
Loading section .text, size 0xc758 lma 0x0
Loading section .ARM.exidx, size 0x8 lma 0xc758
Loading section .data, size 0x70 lma 0xc760
Start address 0xa4, load size 51152
Transfer rate: 12488 KB/sec, 3410 bytes/write.

(gdb) b os_start
Breakpoint 1 at 0x3130: file init/os_start.c, line 260.

(gdb) c

(gdb) step