Writing boot page from boot section

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

Hi, I'm trying to write a boot page but it doesn't working at this point.

I've load page of data using:

 

nvm_flash_load_word_to_buffer()

Then tried to write page using:

nvm_flash_atomic_write_boot_page()

 

but it doesn't write nothing :(

 

What am I doing wrong?

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

When trying to use the impenetrable ASF I find the "Quick Start Guides" section of the manual to be the best approach to trying to understand how they have constructed the layers of the onion. For NVM writing this seems to be the best guide they have:

 

http://asf.atmel.com/docs/latest...

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

Thanks clawson,

The problem is that there are no examples about flash there...

 

Do you have a sample code or reference to how to do it without ASF?

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

I wouldn't touch ASF with yours!

 

I find ASF to be an abortion and actively avoid it. No doubt there are working examples out there on the internet showing examples of using many of its facilities but I wouldn't know where to look.

 

To find the page in the manual about "nvm_flash_atomic_write_boot_page" I simply lifted that text from your post above and Googled it. I would guess that if I'd stuck at it some of those Google results might have been examples of other people using the same API.

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

Of course I tried to look in Google, but I didn't find any extra info about it.

 

How can I write to boot without ASF?

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

arkadi wrote:
How can I write to boot without ASF?

You do know that ASF is only software don't you? It's not performing any particular magic. At the end of the day it's just writing to SFR registers of peripherals in the chip.

 

On tiny/mega the self programming this was fairly easy - you just fiddle about with Z a bit then execute an SPM opcode (in the right place!) and it performed some action (write/erase/whatever) possibly using data accessed via Z.

 

For Xmega it's made slightly more complicated now because there is now a specific peripheral (Non Volatile Memory controller) involved. But to use it you just read the book and do what it says there - like any peripheral.

 

A very quick skim through the book seems to suggest the sequence might be something like a command 0x26 (erase flash buffer - just to be sure!), 0x23 (load flash buffer), 0x2D (erase/write a boot page).

 

I'll bet your nvm_flash_atomic_write_boot_page() above is really doing very little more than issuing a 0x2D to the NVM controller and then executing an SPM.

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

I assume your code resides in boot flash.

 

You could download bootloader source and look at the code.

 

Bandtank used to have an avr911 bootloader on github.  Maybe it's still there. 

 

It uses assembler functions contained in sp_driver.c.   My copy does have an assembler function SP_WriteBootPage but it is not called.  Finding a bootloader that writes to boot flash might be hard to do.