How to compile a hex-file for User Page data (ATUC256L4U)

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

Hi,

 

I'm storing some data in the user page section of the memory that is programmed at production. This data never changes once the unit leaves production, however, sometimes in the production environment a value might change from say 30.0 to 31.1 or such. Right now I have to manually edit the .hex file, send it to the production facility, and then have them program it into the memory with an Atmel ICE. This is less than ideal.

I would like to simply have some sort of header file with a bunch of #define VARIABLE with values that they could edit at the production site, re-compile, and get a programmable hex file spat out without needing to manually fiddle with the .hex file.

 

I'm not really sure how to go about this since I'm not actually writing a program to do anything. I just need a bunch of floats stored at a specific location.

 

example hex file:

 

:020000048080FA

:10000000FFFFFFFFFFFFFFFF4396000042000000DD

:1000100000000078000000000000000043C800005D

:1000200042C800004448000000000000000000003A

:1000300041D8000041F000003DCCCCCD4000000094

:1000400055555555DC770000000000190000001AD6

:100050000000001BFFFFFFFFFFFFFFFFFFFFFFFF91

:10006000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA0

:10007000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF90

:10008000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80

:10009000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70

:1000A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF60

:1000B000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF50

:1000C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF40

:1000D000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF30

:1000E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF20

:1000F000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF10

:10010000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

:10011000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF

:10012000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDF

:10013000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFCF

:10014000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBF

:10015000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAF

:10016000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9F

:10017000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8F

:10018000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7F

:10019000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6F

:1001A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5F

:1001B000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4F

:1001C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3F

:1001D000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2F

:1001E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1F

:1001F000FFFFFFFFFFFFFFFF929E0E62E11EFDD992

:00000001FF

 

This topic has a solution.

1010001010111101110111

Last Edited: Thu. Sep 30, 2021 - 07:19 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just do something like:

__attribute__((section(".mysect"))) uint8_t data[] = { 0xF3, 0xB7, 0x17, 0x29 ... };

add that as part of your build (even just an empty main). Then just objcopy with a -j to extract .mysect from the ELF and write as "ihex"

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

Hi clawson,

 

Thank you. Isn't there something about the user page where you have to make sure that the write to it is 512 bytes? In the ASF it is mentioned that writing to that section of the memory is not as straight-forward as other sections.

1010001010111101110111

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

I don't know UC3 or ASF I am simply saying how you can easily get some data from easily editable C source into a .hex file.

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

clawson wrote:
I don't know UC3

As this model is UC3 then is this the right forum?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

A good question. There is a UC3 forum but the question (as my answer shows) is a bit more generic than that. For anything that has a GCC compiler you can put some data into a named section so it goes to the ELF then you can extract that from the ELF with objcopy. That works for AVR, AVR32, ARM, Intel or anything that has GCC support. In which case it is "general programming" I guess?

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

The UserPage is a 'special' area of the flash-memory.
Adding to post #2, the Linker puts the UserPage into a section labelled userpage so try ;
__attribute__((__section__(".userpage"))) static uint8_t flash_userpage[AVR32_FLASHC_USER_PAGE_SIZE] = { , , , , ..... };

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

That will, of course, require programming software that handles ELF sections and knows what to do with ".userpage".

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

Thank you all kindly for your help with this issue. I will mark Clawson's original post as the solution as it worked. 

 

mikech wrote:
The UserPage is a 'special' area of the flash-memory.
Adding to post #2, the Linker puts the UserPage into a section labelled userpage so try ;
__attribute__((__section__(".userpage"))) static uint8_t flash_userpage[AVR32_FLASHC_USER_PAGE_SIZE] = { , , , , ..... };

 

This pretty much exactly what I ended up doing.

1010001010111101110111