Hi, I am using VSCode and PlatformIO for Arduino. I use USBAsp programmer and I want to disable bootloader for my board. I use MH_Tiny board and Arduino Nano. How to configure build to disable bootloader to avoid troubles wit watchdog timer?
platform = atmelavr
board = nanoatmega328new
framework = arduino
board_build.mcu = atmega328p
board_build.f_cpu = 16000000L
upload_protocol = usbasp
upload_flags = -Pusb
board_bootloader.file = …avr\1u.5.2\bootloaders\empty\empty_all.hex
But anyway I have troubles with bootloader. As for me line “board_bootloader.file =” doesn’t work. How to make empty bootloader. Help me, please. Thank you!!!
I’ve never used a usbASP, I use usbTiny myself, however…
As you don’t want a bootloader, remove that line from the ini file.
When you upload with an ICSP device, the existing bootloader is overwritten.
The UNO bootloader can be programmed to a Nano, or Duemilanove, to prevent the watchdog reset loop.
In case you don’t know, when the watchdog resets a board, it comes back up with the watchdog enabled, but with the minimum timeout. The older bootloaders didn’t check and/or disable the watchdog fast enough, so the watchdog rebooted while the bootloader was still running.
I suspect that you simply need to upload anything with the usbASP to solve your problem. Try the blink sketch, which is what I did when i had this problem on my Duemilanove.
I wonder if that’s specific to the UusbASP device? My USBtiny is fine. Whenever I screw up and get the watchdog reset loop, I simply power down and connect up to the programmer and upload the blink sketch. There’s no point uploading the same sketch again as it’s going to cause the watchdog to timeout and we’ll be back to square one! The fact that the programmer is being used rather than the boot loader should allow you to reprogram the Nano without suffering from the reset loop.
Looking around the Arduino forums, and the Internet in general, I see issues raised back prior to 2017 where this problem is listed. Apparently, Arduino don’t make the Nano (news to me!) so they apparently don’t care, if that’s the correct word, about fixing the bootloader. They are seemingly Chinese devices, who just slap in the standard Nano bootloader which cannot handle a watchdog reset.
The solution appears to be, install the Optiboot bootloader.
When you say “doesn’t work” do you mean it resets the board constantly, or is there some other problem?
Well, yes, that’s what you do when you use your usbASP device.
I notice from your platformio.ini file, that your board is set to nanoatmega328new. This should get you the Optiboot bootloader, and as such, you should not be getting the reset loop. Have you, by any chance, inadvertently configured your Nano with a different board name, such as nanoatmega328and burned a bootloader? If so, this could be the source of your problem.
To (re-) burn the correct bootloader:
Plug in your Nano and the usbASP device.
Open the blink sketch PlatformIo project, if you have one, in VSCode, as normal. As long as you have a sketch for your board.
Make sure the board is set to nanoatmega328new in platformio.ini.
Click the Ant’s head icon on the left toolbar.
Under “nanoatmega328new”, find “Platform” and click it to open.
Under “Platform” find “Burn bootloader” and click it.
You shouldn’t need to specify a bootloader as the default one for the board “nanoatmega328new” is Optiboot.
Once the bootloader is burned, you should find that the device is no longer actually programmed as writing the bootloader normally wipes everything.