Definition of my_board.json for Atmega32U4 custom board

Hello all,
I would like to flash a sample code that I have successfully tested on a small Arduino board (Pro Micro, Atmega32U4) to a self-developed board in my own application, with the Atemga32U4 in factory settings, i.e. without Arduino bootloader.
During flashing, I pull the reset button to “low”. However, this error message always appears:
Error: Please specify upload_port for environment or use global --upload-port option.
What settings do I have to make in platformio.ini to adapt the settings to a custom board?
I use Vistual Studio Code as my development environment.
Many greetings
Michael

If your board doesn’t require a COM port that represents the uploader device / flashing device, you should set at least require_upload_port to false.

(Note: the last two settings are for interacting with a device, that react to resetting to bootloader mode when they detect a usb serial port open at 1200 baud. If you have no bootloader that does this reset method, you should also set those two to false.)

I am not sure if the board needs a COM port which is the uploader device.
When I plug the device in, I hear a login sound, as well as when I press the reset button, however, the device does not show up in the Device Manager, i.e. I do not have a COM port occupied by the device here. Is it possible that I still have to install a WIN10 driver so that the device is recognised as a USB device?

Hm… okay. So if you haven’t burned any different bootloader on your factory-new Atmega32u4 chip, it should still have its USB DFU bootloader per

https://ww1.microchip.com/downloads/en/DeviceDoc/doc7618.pdf

Go to the device manager but change the view to “Device by container”. Collapse everything but the uppermost level. Plug the device is. Do you see any new USB device?

It isn’t a COM port that should show up, but a USB DFU-class device.

Yes, that’s right, I didn’t install a bootloader, I don’t even have access to the ISP port. But I have connected an external 16MHz. After installing the Arduino IDE, the device now logs into the Device Manager as ATm32U4DFU->ATmega32U4.

But I still have the error message regarding the upload port:
Error: Please specify upload_port for environment or use global --upload-port option.

So it does have drivers installed in the Device Manager?

What’s your full platformio.ini and board JSON now after the modifications?

That’s my .json:

{
  "my_board": {
  "build": {
    "core": "arduino",
    "extra_flags": "-DARDUINO_AVR_MICRODUINO_CORE_USB",
    "f_cpu": "16000000L",
    "hwids": [
      [
        "0x2341",
        "0x8036"
      ]
    ],
    "mcu": "atmega32u4",
    "variant": "microduino_32u4"
  },
  "debug": {
    "simavr_target": "atmega32u4"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "Microduino Core USB (ATmega32U4@16M,5V)",
  "upload": {
    "disable_flushing": true,
    "maximum_ram_size": 2560,
    "maximum_size": 28672,
    "protocol": "avr109",
    "require_upload_port": false,
    "speed": 57600,
    "use_1200bps_touch": false,
    "wait_for_upload_port": true
    "require_upload_port": true,
    "use_1200bps_touch": true,
    "wait_for_upload_port": true

    
    
  },
  "url": "http://wiki.microduinoinc.com/Microduino-Module_CoreUSB",
  "vendor": "Microduino"
}
}

And that’s the platformio.ini:

[env:my_board]
platform = atmelavr
board = leonardo
framework = arduino
lib_deps = SPI
adafruit/Adafruit BusIO@^1.14.1
Wire adafruit/Adafruit GFX Library@^1.10.1
nkawu/TFT 22 ILI9225@^1.4.5
bblanchon/ArduinoJson@^6.20.0

Theres a lot of options twice in there?

Oh sorry, there war a mistake by copying the code.

What upload port do I have to define in my_board.json?
due to the fact, that it is a USB-board on a port: Port_#0004.Hub_#0001

You shouldn’t define the upload_port in the board JSON file. PlatformIO will autodetect it if it needs to (and you instruct it to), or you can set it via upload_port in the platformio.ini.

What’s the current version of your board JSON and the upload log?

Thank you for your answer, that’s my .json:

{
  "build": {
    "core": "arduino",
    "extra_flags": "-DARDUINO_AVR_PROMICRO16",
    "f_cpu": "16000000L",
    "hwids": [
      [
        "0x1B4F",
        "0x9206"
      ],
      [
        "0x1B4F",
        "0x9205"
      ],
      [
        "0x2341",
        "0x8037"
      ],
      [
        "0x2341",
        "0x0037"
      ]
    ],
    "mcu": "atmega32u4",
    "usb_product": "SparkFun Pro Micro",
    "variant": "sparkfun_promicro"
  },
  "debug": {
    "simavr_target": "atmega32u4"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "SparkFun Pro Micro 5V/16MHz",
  "upload": {
    "disable_flushing": true,
    "maximum_ram_size": 2560,
    "maximum_size": 28672,
    "protocol": "flip1",
    "require_upload_port": false,
    "speed": 57600,
    "use_1200bps_touch": true,
    "wait_for_upload_port": false,
    
  },
  "url": "https://www.sparkfun.com/products/12640",
  "vendor": "SparkFun"
}

and that’s the error message:
Looking for upload port…
Error: Please specify upload_port for environment or use global --upload-port option.
For some development platforms it can be a USB flash drive (i.e. /media//)
*** [upload] Explicit exit, status 1

Again that should be false otherwise you’re triggering this logic

This also seems strange to me. Are you sure that’s the avrdude protocol specifier needed for when an ATMega32u4 is in its native USB DFU bootloader mode?

Your are right, I changed it out using “protocol”: “avr109”.
But unfortunately the same error.

Please post the current state of your board JSON again.

I also set this to false, but still the same error. I do have to press the reset-button while programming my custom board, right?

{
  "build": {
    "core": "arduino",
    "extra_flags": "-DARDUINO_AVR_PROMICRO16",
    "f_cpu": "16000000L",
    "hwids": [
      [
        "0x1B4F",
        "0x9206"
      ],
      [
        "0x1B4F",
        "0x9205"
      ],
      [
        "0x2341",
        "0x8037"
      ],
      [
        "0x2341",
        "0x0037"
      ]
    ],
    "mcu": "atmega32u4",
    "usb_product": "SparkFun Pro Micro",
    "variant": "sparkfun_promicro"
  },
  "debug": {
    "simavr_target": "atmega32u4"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "SparkFun Pro Micro 5V/16MHz",
  "upload": {
    "disable_flushing": true,
    "maximum_ram_size": 2560,
    "maximum_size": 28672,
    "protocol": "avr109",
    "require_upload_port": false,
    "speed": 57600,
    "use_1200bps_touch": false,
    "wait_for_upload_port": false,
    
  },
  "url": "https://www.sparkfun.com/products/12640",
  "vendor": "SparkFun"
}