picoboot icon indicating copy to clipboard operation
picoboot copied to clipboard

PicoBootSerial and Avrdude

Open MCUdude opened this issue 3 years ago • 4 comments

Hi!

I have a few questions regarding the PicoBootSerial bootloader, and possibly integrating it with Avrdude, which by the way has migrated over to Github and seems to be reasonably active again.

First, I'll assume that PicoBootSerial is intended to be used on microcontrollers that have no bootloader section like ATtiny13, ATtiny25/45/85, and ATtiny24/44/84, and not on "ATmegas"?

Are other clock frequencies and baud rates supported than 230400 baud @ 8 MHz? The ATtiny13 is the weird one here, with an internal oscillator that runs at 9.6 MHz.

I'd love to give this bootloader a try on some ATtinys. If this turns out to be a reliable bootloader, that "just works", I see no reason why PicoBootSerial couldn't be "officially" added to Avrdude as a supported programmer option.

MCUdude avatar Jan 05 '22 07:01 MCUdude

I actually submitted avrdude patches to Jeorg back in 2014 but he rejected them. For a couple years I maintained my own version of avrdude. After that my focus was writing larger (but still small) bootloaders that are compatible with the standard Arduino bootloader (the way Optiboot is).

I wouldn't recommend it for general use in its current form. The 230.4kbps baud rate was done as a test to see what was the maximum speed I could get out of a hand-tuned bit-bang UART implementation. I may still have copies of the slower versions (57.6 & 115.2kbps) that are much more reliable. If not, it wouldn't take me long to do the mods.

I don't have much time to work on MCU projects these days, but I've put an entry in my calendar to take an hour or two this weekend to look at this suggestion.

nerdralph avatar Jan 05 '22 14:01 nerdralph

I actually submitted avrdude patches to Jeorg back in 2014 but he rejected them

Any particular reason why he rejected them? I wasn't able to find the conversation between you two.

MCUdude avatar Jan 05 '22 14:01 MCUdude

I actually submitted avrdude patches to Jeorg back in 2014 but he rejected them

Any particular reason why he rejected them? I wasn't able to find the conversation between you two.

I looked back and it was actually a smaller patch for zero-wire auto-reset I had sent him and he rejected. His reason was that I emailed the patches directly to him and documented them on my blog. Apparently that didn't comply with his undocumented rules for patches. http://nerdralph.blogspot.com/2014/02/zero-wire-serial-auto-reset-for-arduino.html

When I finished my picoboot patches for avrdude I figured there was no point in submitting them as long as he was still in control.

nerdralph avatar Jan 05 '22 14:01 nerdralph

I finished reviewing the old bootloader code and avrdude code: https://github.com/nerdralph/picoboot-avrdude/blob/master/picoboot.c

If I'm going to refresh it, I'd like some advice on improving usability & reliability. Dropping the baud rate to 57.6kbps will get the rx timing error range to about 1% for 8 & 9.6Mhz.

In 64 bytes, I wasn't able to implement a bootloader entry timeout. It looks for the Rx pin to be high to enter the bootloader. This makes it a bit cumbersome for development as it requires disconnecting Rx after flashing, followed by a manual reset.

My first thought is to use DTR and/or RTS to control reset. Avrdude would pulse reset low while leaving the host Tx idle (high) to enter the bootloader. To exit the bootloader after flashing, the host would toggle reset while transmitting a break (Tx low) to skip the bootloader. If the bootloader is left in the flash when the project is deployed, the pin used by the bootloader would need a weak pull-down.

What do you think?

nerdralph avatar Jan 09 '22 15:01 nerdralph