Bootloader Pre-Tutorial Source Code - ATmega644

Go To Last Post
64 posts / 0 new

Pages

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

Have you actually tested any of the above?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Quote:
Have you actually tested any of the above?
Now you want me to test it too? I'm not by my 'stuff', so I just compiled it. The compiled code looked ok to me, but who knows. I would also need an avr that can read the signatures via spm (and I also would have to be motivated to actually try it, as I don't really care that much). You can tell me which versions above don't work, or if they all don't work, or you can just ignore them. Your choice.

I'm assuming in the first two that you are using winavr20071221. You would also need the 'if defined(SIGRD)' wherever you are checking for that 's' command (if avr doesn't have SIGRD, can't get signatures).

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

Quote:
Now you want me to test it too?
Will I get my money back if they don't work? :mrgreen:

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Quote:
Will I get my money back if they don't work?
DOUBLE your money back.

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

I should add that if you happen to use PROGMEM in your bootloaders (I don't think you are), and are removing the vector table, then a little different approach would be needed as .progmem is right after the .vectors section. You don't want that progmem section to start executing at the boot reset address, so this would be one way to handle it

//.vectors (reset address)
void skip_progmem(void) __attribute__ ((naked,section (".vectors")));
void skip_progmem(void){
    //skip over .progmem section
    asm volatile("rjmp my_crt");
}
//.progmem data is located here
//.init0
void my_crt (void) __attribute__ ((naked,section (".init0")));
void my_crt (void){
    asm volatile ( "clr __zero_reg__" );
    SREG=0; //newer crt1.S does this
    SP=RAMEND;
}
//.init1-.init8 - will run (if exists)
//.init9 - make sure main is the first to run
int main (void) __attribute__ ((naked,section (".init9")));
//.text - everything else will follow

This would handle the occasions that progmem would be used (probably only needed with 'smart' bootloaders, as those relying on a pc app aren't going to be sending 'human readable' strings anyway). You end up with 1 unneeded rjmp if progmem is not used. This would be a good 'one-size-fits-almost-all' setup, but skip_progmem could be removed if not needed (and we are then back to my original code).

You can also edit the linker script to move progmem around, but linker scripts are best left untouched (mostly).

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

curtvm,

Thanks for all the good information. I think I'll also spend some time learning the .initx and other location parameters since it is beginning to look like they may be useful after all.

Smiley

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

My goodness curtvm, all that typing to achieve:

.org FIRSTBOOTSTART

and a couple of lines to init the stack and maybe clear the ram.

No wonder some people only use C on April 1.... :lol:

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
My goodness curtvm, all that typing to achieve:

.org FIRSTBOOTSTART

Well, none of that typing had anything to do with where the bootloader code starts. You changed that in the avr studio memory settings earlier.

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

I have been doing a bit more reading and I see how the boot.h does the signature byte reading with boot_signature_byte_get, very nice.

So you'll be happy that no refund is necessary as the "simple, inefficient version" works well and I can get the code down to 1020 bytes, just inside the first bootloader space.
Haven't tried the other versions.

Still confused about the various .initx thingy, maybe use one of the "Unused. User definable" and put a simple stack init and ram clearing code? It would be nice to get rid of the dead vectors. At least it would be a good exercise in getting to know things a bit deeper.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

OK Vectors gone!! :) size of code now 870 bytes and whats more it STILL works, downloaded my world famous flashing led program with AVROSPii and it's flashing.

I guess had I read the bit

Quote:
// From Peter Fluery AVRFreaks Aug 10 2005 - to remove interrupt Vector table
// put -nostartfiles in LDFlags, add the following function
// saves wasted space
I could have had this working a lot earlier. :(

By just adding -nostartfiles into the Custom Option, it goes into the compiler directives instead of the LINKER directives.

By clicking on the [Linker Options] and THEN adding -nostartfiles, the vectors go away.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

you could have simply read this post (was not so long ago)-
https://www.avrfreaks.net/index.p...

which was an answer to your question-

Quote:
Any hints on how to do this with the Studio config options?

Maybe I need to learn how to use RED highlighting

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

Do you mean something like:

Quote:
select [Linker options],
:)
yep, that would have helped, I skipped over that bit altogether. Didn't know that I had to click on the Linker options on the L/H windows, I thought that was just some display window.

I guess this proves that one cannot be too specific or too clear when explaining things to dummies. :(

does Red come in flashing too???

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Quote:
does Red come in flashing too???
everyone may be sorry you showed me red was possible. We hope flashing text is not possible.

Pages