ATMega328p doesn't go in bootloader after reset.

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

Hi all.

 

I want my 328p go into bootloader after a hardware reset but no success so far.

 

My board is an Arduino UNO but I only use the hardware part of Arduino project.

 

- I've configured the fuses as follow:

Low fuse      : 0xff
High fuse     : 0xd0
extended fuse : 0x7

 

So If I've read spec correctly (chapter 26) high fuse is configured for:

BOOTSZ = '00' so I have a 2048 words space for my boot oader starting at 0x3800.

BOOTRST = '0' so Reset Vector = Boot Loader Reset

 

- Also I have 2 HEX file (app + BL)

 

- I have built my boot loader with the avr-gcc option -Wl,--section-start=.text=0x3800 to place the boot loader at the correct address (It's clear in hex file).

 

- I've combined both hex files following instructions from this website.

 

- I can jump in boot loader from application with asm( "jmp 0x3800" )

 

But after reset uC goes directly in application !!!

 

What do I miss ?

 

Thanks in advance.

This topic has a solution.
Last Edited: Mon. Nov 10, 2014 - 09:25 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avr-gcc uses byte addressing.   So you would say:

 

-Wl,--section-start=.text=0x7000

 

Just look at the HEX file that you produce.    Hex files work in bytes.   So you should see your bootloader at 0x7000.

If you see it at 0x3800,   you have got it in regular app space.

 

David.

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

Ok avr-gcc use byte addressing so like you wrote I've use -Wl,--section-start=.text=0x7000.

 

It worked perfectly, Many thanks.

 

But why my jump from application to 0x3800 still works ? is it word addressing inside application ?

 

 

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

is it word addressing inside application ?

More to the point it's word addressing "inside" the assembler. BTW if you want the app to get back to the bootloader why hard code the entry address? Why not just force a watchdog reset or is the bootloader already using WDT for its own purposes?

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

clawson wrote:

is it word addressing inside application ?

More to the point it's word addressing "inside" the assembler. BTW if you want the app to get back to the bootloader why hard code the entry address? Why not just force a watchdog reset or is the bootloader already using WDT for its own purposes?

 

You're perfectly right, the hard-coded address was for debug purposes (when I started to go crazy trying to understand).

WDT reset is a much better solution for that.

 

Thanks

 

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

found on wikipedia

 

Opcodes of AVR are 16bits wide.

 

http://en.wikipedia.org/wiki/Atmel_AVR_instruction_set#Instruction_encoding

 

Here 'word' really means 16 bits.

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

Why not get the opcode manual? The explanation of "JMP" is very precise.
 

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

clawson wrote:

Why not get the opcode manual? The explanation of "JMP" is very precise.
 

 

I will thanks