picoboot-lib arduino protocol bootloader in 258 (now 320) bytes

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I've written a bootloader for tiny AVRs that needs only 258 bytes of flash.  It's written to be used as a library, so adding a single include to your main enables the bootloader.  This adds a call to the bootloader in .init1 before main.  If the bootloader times out, it returns and execution continues from .init2.  When the bootloader main loop is run, the arduino/stk500 quit command will jump to the reset vector.

https://github.com/nerdralph/pic...

 

picoboot-lib will be integrated into the next release of picoCore.

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

Last Edited: Tue. Aug 4, 2020 - 02:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've released v0.4, which includes automatic OSCCAL tuning and exposes picoboot-lib's UART transmit and receive functions.

I believe this is the first AVR bootloader to support fully-automatic OSCCAL tuning.

 

I plan to add the automatic OSCCAL tuning to the megaAVR version of picoboot as well.

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ralphd, I'm familiar with writing bootloaders to interact with the AVRospII (PC side Software), or chip to chip programming but no exp. in AVRDude to bootloader interaction. 

So basically you install the bootloader, hook up serial and then selfprogram?   

Nice work! Sorry for my confusion, I don't do arduino much. I use AVRDude for my USBtiny programmer but not to bootload.  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Plexd wrote:

Ralphd, I'm familiar with writing bootloaders to interact with the AVRospII (PC side Software), or chip to chip programming but no exp. in AVRDude to bootloader interaction. 

So basically you install the bootloader, hook up serial and then selfprogram?   

Nice work! Sorry for my confusion, I don't do arduino much. I use AVRDude for my USBtiny programmer but not to bootload.  

 

It's intended for use with an Arduino core like my picoCore.  If you are not familiar with tweaking Arduino boards.txt and platform.txt files, I'd suggest waiting until it's integrated into an Arduino core.  I should have picoCore v0.4.0 released in about a week.  ATTinyCore will support picoboot-lib, though I'm not sure of the timeframe.

https://github.com/SpenceKonde/A...

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've got ( I think) the Spence/Konde ATTinyCore installed in the IDE which I would use for my t84A, t85 and t2313A  (and it does work)... if I used it much. I think for me, it's more about being able to move the serial port to different pins on the m328 or any chip... that's the appeal. The  Enable Read While Write code and some other things would need to be added if it was attempted. Are you going to include a version for the m328p or is it geared mainly for tinys? After reading a little on AVRDude, I believe it supports AVR109 and /or AVR911 app notes/protocols which is what I based my bootloaders on. So I could've been using AVRDude this whole time... LOL, live and learn. Getting info on AVRDude has been a challenge for me. I will look for the Spence/Konde update... Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Plexd wrote:

I've got ( I think) the Spence/Konde ATTinyCore installed in the IDE which I would use for my t84A, t85 and t2313A  (and it does work)... if I used it much. I think for me, it's more about being able to move the serial port to different pins on the m328 or any chip... that's the appeal. The  Enable Read While Write code and some other things would need to be added if it was attempted. Are you going to include a version for the m328p or is it geared mainly for tinys? After reading a little on AVRDude, I believe it supports AVR109 and /or AVR911 app notes/protocols which is what I based my bootloaders on. So I could've been using AVRDude this whole time... LOL, live and learn. Getting info on AVRDude has been a challenge for me. I will look for the Spence/Konde update... Thanks!

 

The version of picoboot for the megas does autobaud and uses the hardware UART.

http://nerdralph.blogspot.com/20...

 

I have been thinking of doing a version similar to picoboot-lib with my soft UART code.  I'm currently working on some mcs51 stuff, but give me a week or two and I should be able to put something together.  On the megas it's easier not to use the RWW and just block for all writes.

 

As for avrdude, the docs suck, so I just look at the source.

 

 

 

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I actually have a working m328 loader that uses half duplex bitbang code on PORTB any pins (AVR_OSP)... I forgot about that.   Anyway you're right, its the AVRDude code is what I need to be looking at.  Thanks Ralph... I'll look at the AVRDude source. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've just released v0.7, which is a major update.

 

Based on feedback from v0.5, I've implemented virtual reset vector support.  This has increased code size to 320 bytes + 2 bytes reserved for the virtual reset vector.  A noise filter has been added to the OSCCAL auto-tuning, and for robustness pb-tiny implements the chip erase command wherein the user flash space is erased top-down.

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ralphd wrote:

I've released v0.4, which includes automatic OSCCAL tuning and exposes picoboot-lib's UART transmit and receive functions.

I believe this is the first AVR bootloader to support fully-automatic OSCCAL tuning.

 

I plan to add the automatic OSCCAL tuning to the megaAVR version of picoboot as well.

 

 

How do you auto-tune OSCCAL? What is the timing reference?

 

I hand tune OSCCAL by listening to the clock on an HF radio, then zero beat it to a calibration source (I use a tiny piece of code to grab input from the serial port so I can type in different OSCCAL values and hear which one is closest).

 

I would love to have a simpler way to do it...

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Krupski wrote:

ralphd wrote:

I've released v0.4, which includes automatic OSCCAL tuning and exposes picoboot-lib's UART transmit and receive functions.

I believe this is the first AVR bootloader to support fully-automatic OSCCAL tuning.

 

I plan to add the automatic OSCCAL tuning to the megaAVR version of picoboot as well.

 

 

How do you auto-tune OSCCAL? What is the timing reference?

 

I hand tune OSCCAL by listening to the clock on an HF radio, then zero beat it to a calibration source (I use a tiny piece of code to grab input from the serial port so I can type in different OSCCAL values and hear which one is closest).

 

I would love to have a simpler way to do it...

 

 

" To ensure reliable, high-speed serial communication, automatic OSCCAL tuning is included. The first time the host communicates to the bootloader, OSCCAL is adjusted based on the timing of the incoming serial data. The tuned OSCCAL value is saved in the bootloader flash space, and is used every subsequent time the bootloader runs."

 

I've also some dedicated OSCCAL tuning programs.  Here's one of them:

https://gist.github.com/nerdralp...

 

 

I have no special talents.  I am only passionately curious. - Albert Einstein