Hi,
I have run into a peculiar problem on my custom boards and I was hoping someone had some insight to what is going on.
My setup is this:
I have a custom board using an ATmega328p with standard bootloader (the one that Arduino IDE gives). I'm using a USB FTDI cable to upload my application to the board through the bootloader. The board controls a device that needs to be very power efficient, so at sometimes the application turns off the MCU (the hardware is designed for this). The MCU is then again awoken by pressing a button, that will re-power the MCU.
Naturally, I want my application to be as responsive as possible and thus running very soon after the MCU has been powered up. At the same time I need the bootloader to be present as I will need trained operators to upload updates without having to use a programmer.
With the ATmega328p, and the FTDI cable disconnected, the boot time (time before my application runs) is ~50ms (well within target time). All is good
If I connect the FTDI cable to my PC and the board, all is still good. However if I connect the FTDI cable to the board but NOT to my PC (leaving the USB end out). The boot time is ~2 seconds!!
In production this is not a problem as no FTDI cable are connected so I have shrugged my shoulders so far and ignored this.
But alas, due to the scarcity of ATmega328p, I have been forced to change to the new ATmega328pb. But with this MCU, the ~2 seconds boot time seems to happen even with the cable completely out, which renders the device useless.
I have done a lot of tests and it seems to be a bootloader communication issue, where it "thinks" it needs to talk to something in the other end, and has to wait for a timeout to happen (~2 seconds).
If I connect the FTDI cable to both board and PC (and thus power the board from the FTDI cable), it boots in the expected 50ms, but this is the only way I can obtain the fast boot time.
I have tried stock bootloader and Minicore bootloader, but they both do this on the 328pb. On the 328p it is no problem...
Does anyone have any insight into what the bootloader is trying to communicate with and how I can get around it when no cable is connected and the UART?
I know this was a long one, but I'm practically bald from pulling my hair from this. Any suggestions are appreciated