XMEGA: Initial Values in User Signature Row at compile time

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

Dear all,

One of the new features of the XMEGA is a "User Signature Row" that is a dedicated page of flash for storing non-volatile and rarely changed information, such as serial numbers, keys, MAC addresses etc.

What I want to do is set some of these values at compile time using avr-gcc.

The catch is, it is not part of the normal flash address space. Therefore, I'm not sure if the usual approach of PROGMEM and linking to a section to a specifc address will work.

It does, however, occupy a particular address in the PDI memory map - 0x008E0400 according to Figure 30-4 of the XMEGA Manual.

Has anyone had a look at this problem? What sort of solution did you come up with?

-- Damien.

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

Why don't you just use a named memory section and a --section-start= to the linker?

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

clawson wrote:
Why don't you just use a named memory section and a --section-start= to the linker?

USR_SIG is closer to operation in EEPROM than Flash.

I tried this:

  uint32_t *usr_sig_u32_ptr = (uint32_t *) 0x008E0400;
  byte_u8 = *usr_sig_u32_ptr;

which returns a value of 0x01 when USR_SIG[0] has 0x66
in it.

You can view and edit the USR_SIG values at the bottom of the "Advance" tab in Studio for the XMega parts. It will also let you load a file there.

So you might be able to use the special section then use rec_scat to split out and create the file that could be loaded there.

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

bpaddock wrote:

I tried this:

  uint32_t *usr_sig_u32_ptr = (uint32_t *) 0x008E0400;
  byte_u8 = *usr_sig_u32_ptr;

which returns a value of 0x01 when USR_SIG[0] has 0x66
in it.

Which doesn't surprise me. I thought the only way to **read** them at run-time was using the NVM command (which is fine by me).

My problem is getting them there in the first place. I've just discovered the advanced editor (thank you!), but it'd be great if could do this in code. What I sort of mean is:

// Pseudocode only !!!
//---------------------

// Resort to a default string if not defined elsewhere
#ifndef USER_SIGNATURE_KEY
    #define USER_SIGNATURE_KEY "Hello"
#endif

// USR_SIG is a placeholder for defining something to be in the user signature (and whatever ".section" preamble may be needed).  
USR_SIG const char key[] = USER_SIGNATURE_KEY;

There is potentially an alternative strategy. The AVR Studio help hinted at being able to use a hex file to define the user signature, presumably like supplying a hex file for the EEPROM contents. Any thoughts?

-- Damien

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

Yeah, I didn't think that would work but thought it was worth a try to see what would happen.

I set my USR_SIG stuff with my bootlaoder via IrDA.

What I'd try is use the special section as suggested. Then use srec_cat to look for those addresses in the resultant .hex file and create a new next file offset back to 0x00000000 that the advanced editor wants to see. Also rewrite the original .hex file with that section removed to put in the Flash.

scat_rec can do this stuff but it is a bit taxing to figure out.

An example from my makefile (looks worse here because of the forum wrappeing the text)

ifeq ($(USE_CRC_FLASH_CHECK),1)
	mv $(OBJDIR)/../$@ $(OBJDIR)/../$(TARGET).org.hex
	srec_cat $(OBJDIR)/../$(TARGET).org.hex -Intel -Little_Endian_CRC16 -max $(OBJDIR)/../$(TARGET).org.hex -Intel -Cyclic_Redundancy_Check_16_XMODEM -Fill 0xFF -OVER $(OBJDIR)/../$(TARGET).org.hex -Intel -Output $(OBJDIR)/../$(TARGET).hex -Intel
endif
#       Make the bootloader AFTER CRCing the file:
	srec_cat $(OBJDIR)/../$(TARGET).hex -Intel BootLoader/!SC500mBootLoader/SC500MBootLoader.hex -Intel -o $(OBJDIR)/$(TARGET)AndBootLoader.hex -Intel
# Security by obscurity:
	srec_cat $(OBJDIR)/../$(TARGET).hex -Intel -Fill 0xFF -over $(OBJDIR)/../$(TARGET).hex -Intel -o $(OBJDIR)/../$(TARGET).flash.bin.1 -binary
	srec_cat $(OBJDIR)/../$(TARGET).flash.bin.1 -binary --xor 0x00 -o $(OBJDIR)/../$(TARGET).flash.bin -binary
	rm $(OBJDIR)/../$(TARGET).flash.bin.1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can check out how they did . I'm not sure of all of what they did for but if it required patches to the binutils (like the linker) I think the "User Signature Row" would also.

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

This topic looks right, but I am afraid that I do not understand the answers.

If I am using AVRStudio 5, and would like to add a unique serial number to the User Signature Row of each device that I load software onto, without recompiling the software, how would I do it?

I have not been able to find this info on searching the web nor the Atmel docs.

Thanks

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

dtlinker wrote:
...would like to add a unique serial number to the User Signature Row of each device that I load software onto, without recompiling the software, how would I do it?

Each XMega has a built in unique serial number, could you make use of that?

https://www.avrfreaks.net/index.p... explains how to read it.