I little of context here: debugging AVR and Atmega on Linux is was not easy until recently (even for chips like Atmega128 that has JTAG). Unfortunately OpenOCD doesn’t support debugging Atmega128, although it has support to flash the Atmega128.

When you try avarice with Atmel-ICE tool (yes the beautiful White and Blue box https://www.mouser.com/ProductDetail/Microchip-Technology/ATATMEL-ICE-BASIC?qs=KLFHFgXTQiAG498QgmqIdw%3D%3D ) you discover that is also doesn’t work: https://www.avrfreaks.net/s/topic/a5C3l000000BpqjEAC/t391261

Fortunately that last link bring me some enlightenment: use the bloom tool! (https://bloom.oscillate.io/)

So, I just entered inside nuttx/ directory and ran:

$ bloom init

It created a bloom.yaml that I modified to use Atmel-ICE with JTAG:

environments:
default:
shutdownPostDebugSession: true

tool:
name: "atmel-ice"

target:
name: "atmega128"
physicalInterface: "jtag"
hardwareBreakpoints: true

server:
name: "avr-gdb-rsp"
ipAddress: "127.0.0.1"
port: 1442
rangeStepping: true

insight:
activateOnStartup: false

After saving I just executed the bloom command and voilá:

$ bloom
2023-12-25 17:48:50.249 -03 [MT]: [INFO] Selected environment: "default"
2023-12-25 17:48:50.249 -03 [TC]: [INFO] Starting TargetController
2023-12-25 17:48:50.253 -03 [TC]: [INFO] Connecting to debug tool
2023-12-25 17:48:50.298 -03 [TC]: [INFO] Debug tool connected
2023-12-25 17:48:50.298 -03 [TC]: [INFO] Debug tool name: Atmel-ICE
2023-12-25 17:48:50.335 -03 [TC]: [INFO] Debug tool serial: J41800094192
2023-12-25 17:48:50.342 -03 [TC]: [INFO] Activating target
2023-12-25 17:48:52.247 -03 [TC]: [WARNING] Execution on AVR8 target could not be halted post attach - Failed to receive break event for AVR8 target
2023-12-25 17:48:52.628 -03 [TC]: [INFO] Target activated
2023-12-25 17:48:52.628 -03 [TC]: [INFO] Target ID: 0x1e9702
2023-12-25 17:48:52.628 -03 [TC]: [INFO] Target name: ATmega128
2023-12-25 17:48:52.628 -03 [TC]: [INFO] Available hardware breakpoints: 3
2023-12-25 17:48:52.628 -03 [TC]: [INFO] Reserved hardware breakpoints: 1
2023-12-25 17:48:52.681 -03 [DS]: [INFO] Starting DebugServer
2023-12-25 17:48:52.702 -03 [DS]: [INFO] Selected DebugServer: AVR GDB Remote Serial Protocol Debug Server
2023-12-25 17:48:52.702 -03 [DS]: [INFO] GDB RSP address: 127.0.0.1
2023-12-25 17:48:52.702 -03 [DS]: [INFO] GDB RSP port: 1442
2023-12-25 17:48:52.702 -03 [DS]: [INFO] DebugServer ready
2023-12-25 17:48:52.702 -03 [DS]: [INFO] Waiting for GDB RSP connection

So I just opened a new terminal and:

$ avr-gdb nuttx
GNU gdb (GDB) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=avr".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from nuttx...
(gdb) tar rem :1442
Remote debugging using :1442
0x00000000 in vectortab ()
(gdb) b os_start
Breakpoint 1 at 0x25c: file init/os_start.c, line 379.
Note: automatically using hardware breakpoints for read-only addresses.
(gdb) c
Continuing.
Breakpoint 1, os_start () at init/os_start.c:379
379 g_os_initstate = OSINIT_BOOT;
(gdb)

Very easy!

BTW, the title is also a reference to the Everclear song I Will Buy You a New Life.