Debugging with Atmel-ICE on Custom Arduino micro board

Information:

I got a custom board (without much information). It has a USB-C Port and a 6pin-ISP-Interface.

It seems to imitate a Ardunio Micro since Arduino IDE 2 automatically detects it as that.
The uC is an Atmega32u4.

I managed to flash it via MPLAP-IPE (Got a .hex-File from another developer).
It’s also possible to flash it via USB (COM port in Arduino IDE 2).

The source-code is written in “Arduino C++” => .ino files.

I wanna use PlatformIO on VSCode.

Question:
My goal is to flash and debug it via Atmel-ICE (on the ISP-Interface).
Basic question: Is that possible with PlatformIO? Since it isn’t possible with the Arduino IDE 2.

I’ve tried different things, but didn’t get it to work.

My platformio.ini:

[env:micro]
platform = atmelavr
framework = arduino
debug_build_flags = -Os
debug_tool = atmel-ice
debug_init_break = tbreak setup
board = micro
upload_protocol = atmel-ice

DebugInvalidOptionsError: Unknown debug tool atmel-ice.
Please use one of simavr or custom

I think the problem is, that the micro board doesn’t support atmel-ice by default.

I also tried adding a custom board, but I couldn’t figure out how to manipulate the JSON.
I copied the original from GitHub and modified these parts:

"debug": {
    "tools": {
      "atmel-ice": {
        "onboard": false
      }
    },
    "simavr_target": "atmega32u4"
  },
"name": "microice",

(also changed the board to microice)

.pioinit:13: Error in sourced command file:
:3333: The system tried to join a drive to a directory on a joined drive.

I guess either it is not possible at all or my custom board JSON is wrong.

I made progress!

I’m now able to flash the uC (upload firmware) via Atmel-ICE and ISP-Interface.

platformio.ini:

[env:micro]
platform = atmelavr
framework = arduino
debug_build_flags = -Os
debug_tool = atmelice_isp
debug_init_break = tbreak setup
board = microice
upload_protocol = atmelice_isp
upload_flags = -e
upload_port = usb

custom board modifications (atmelice_isp):

"name": "microice",
"upload": {
  "disable_flushing": true,
  "maximum_ram_size": 2560,
  "maximum_size": 28672,
  "protocol": "atmelice_isp",
  "require_upload_port": true
},
"debug": {
  "tools": {
    "atmelice_isp": {
      "onboard": false
    }
  },
  "simavr_target": "atmega32u4"
},

Debugging still doesn’t work, but I’m on it.

I would be happy if someone could help me!