Which boot loader?

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

I've used bootloaders for other uC families, but not for AVR. Is there a protocol standard? If not, how does one get Atmel Studio to live with a given standard as executed by a particular boot loader?

Is there tweakable bootloader code I should be starting with?

The target here will be an educational device built around the ATmega640/1280, which has serial ports out the ear, so I thought I'd use one for a bootloader interface, along with standard ISP.

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

Atmel has several bootloader standard formats. They have changed over the years. Among the oldest is app note AVR109 as I recall.

AVR chips do not come with a pre-programmed bootloader. If you purchase certain end items, say, an Arduino board, they will have written to flash, in the AVR's special space for bootloaders, that world's standard bootloader. If you buy a Teensy2 from PJRC, they have their own (terrific) USB based bootloader. And so on.

To put a bootloader of your own choice into an AVR, perhaps replacing what's there now, you need an In System Programmer (ISP). That uses the MOSI, MISO and so on interface, and an ISP programmer such as the Atmel MK-II.

As a beginner, I'd recommend the Teensy2 since you can use that for arduino and non-arduino code work, with the Arduino development IDE or Atmel Studio 6 or any of the commercial compilers for AVR.
http://www.pjrc.com/teensy/index...

Here's an oldie bootloader, serial port, as an example. This freeware has both the AVR code (small, asm, source provided) and the PC side with graphical user interface.
https://www.avrfreaks.net/index.p...

So lots of alternatives.

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

AS4 used to come with "Avrprog" which was used for things like talking to the Butterfly and the STK500 bootloader. It talked AV109 protocol so that seemed like a good choice to base a bootloader on (it was fairly simple so an Asm bootloader could just about fit into 512 bytes).

AS6 seems to have lost avrprog (I don't think atprogram handles 109) - there's certainly nothing available from the GUI interface to invoke 109 protocol anyway.

So I guess AS6 announces the death of AVR109?

The next protocol that may be worth looking at is the one that would make the AVR bootloader look like an STK500 in CTRL mode. There was originally an "stk500" protocol but this was updated and these days an STK500 talks "stk500v2" protocol. A lot of non-Atmel programmers talk this same protocol which is why you get all those programmer interfaces on ebay that call themselves "STK500" when they have nothing to do with an STK500 but simply use its communication protocol (thankfully those devices are now replaced by USBAsp's in fact).

stk500v2 is described in AVR068

Luckily for the world there is already an STK500 v2 template bootloader:

http://homepage.hispeed.ch/peter...

(towards the bottom of Peter Fleury's page).

I *think* you can therefore tell AS6 through the GUI you are programming via STK500 and it will channel via that bootloader.

Another option would be DFU which (for USB devices) is now Atmel's chosen bootloader format but curiously they don't ship the PC side of this (Flip! - a Java program) with AS6. This may be because they are too embarrassed as it is a POS.

Of course, if you are willing to forgo Studio compatibility then the world is your oyster (and avrdude can talk to most bootloaders).

Shameless plug: If you were willing to put an SD card slot in the design you could use this: http://spaces.atmel.com/gf/proje... ;-)

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

When I was teaching at a University, we used Steve's BLIPS 4. Hundreds of ATMEGA12's were used by students with no problems since then.

Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
Riddle me this...How did the serpent move around before the fall?

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

Thanks for all the info so far. So is it the case that Atmel Studio cannot program an Arduino via the latter's bootloader? If true that is an appalling oversight.

As I mentioned, this is an educational application, so whatever is easiest to do from AS6 is probably what I will go with.

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

Quote:

So is it the case that Atmel Studio cannot program an Arduino via the latter's bootloader?

Correct. Of course AS6 has the facility for the user to define menu entries or toolbar buttons that go on to trigger any command (even providing VS2010 like "meta variables" such as the project directory and output file name). So it's trivial to set up a button or whatever that issues the appropriate avrdude.exe command but so far the Arduino bootloader is only (as far as I know) driven by avrdude.exe.
Quote:

If true that is an appalling oversight.

Possibly true - I imagine, given the recent success of Arduino it must be in the mind of someone at Atmel to build in something even if it does just mean shipping avrdude.exe and triggering it at the right moment.
Quote:

As I mentioned, this is an educational application, so whatever is easiest to do from AS6 is probably what I will go with.

If you setup such a menu entry or toolbar button the user would likely have no idea it wasn't all just happening within AS6. Lots of prior threads in AS6 forum about how to do this.

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

The arduino Uno uses a subset of stk500v1 (which is old, and is actually a "device programmer" communications protocol rather than a bootloader protocol.) Avrdude has gradually been updated to consider it a special type, in order to get around other changes in avrdude, and to support the auto-reset capability.

Arduino MEGA uses a stk500v2-based bootloader (it's only 16x bigger! (It does include significant extra functionality.))

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

This is great, I have no room for a 4K BL so without this I'd be updating manually (take chip out- move to computer etc etc).

 

It works and updates the flash, but does not find the correct sector for the file data.  The SD is a 2GB Fat16 formatted.

 

 lba = firstclust - fat_offset; //lba=1
 lba *= SecPerClus;// lba=64  
 lba += RootDir;//lba=672 RootDir=608

The lba=672 is incorrect, it should be 640, so adding lba=640; after the above code is the only way it works at present.

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

I don't see what a "file system" has got to do with a bootloader.

 

The Arduino UNO bootloader is only 512 bytes.    It uploads programs to the flash memory via the UART / USB cable.

 

Yes,   you can have a bootloader that can upload from an SD disk.    But obviously you need a SD disk.

I think that Cliff (clawson) has a suitable bootloader.    I suspect that it will need all of 4kB.

 

But let's face it.   If you have a SD card in your product,   you can offload data / text from flash memory and read it from the SD card.

 

David.

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

I edit up a bat file that has the avrdude comport and baudrate params and the filename being burned. After compiling, I just click on the bat file and the program slides down the wire and jumps into the avr.

 

Imagecraft compiler user

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

 

 

Atmel Studio 6.x with the free Visual Micro plugin can program AVRs via AVRdude.

The AVR should have optiboot or any other STK500 compatible bootloader firmware.

Last Edited: Fri. Nov 28, 2014 - 05:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think that Cliff (clawson) has a suitable bootloader.   

David, it's my code he's talking about - he's cross posted this - I have answered in the more appropriate thread.

 

(to be honest I *thought* I was implementing fatgen103.doc correctly but OP has discovered a case that seems to have exposed a flaw in my logic).