• AVR Freaks

Hot!"const" initialization in program memory at absolute address doesn't work as expected

Author
adown
New Users
  • Total Posts : 57
  • Reward points : 0
  • Joined: 2017/10/19 16:09:17
  • Location: Calgary
  • Status: offline
2020/04/07 12:32:25 (permalink)
0

"const" initialization in program memory at absolute address doesn't work as expected

Good afternoon, im working with a PIC32MZ and i am trying to place a checksum word at a specific location in program memory.  As far as i can tell from the XC32 documentation, and the past threads i've found this should be simple with the following attribute directives:
 
unsigned int checksum __attribute__((space(prog),address(0x9D000000)))=0xABCDABCD;
 
however when i program this, then inspect the program memory through the execution memory window 0xABCDABCD isn't anywhere in flash, and its certainly not at the PHY address 0x9D000000&0x1FFFFFFF=0x1D000000.
 
If i remove the absolute address from the attribute and instead compile and download this:
 
unsigned int low_flash_id __attribute__((space(prog)))=0xABCDABCD;
I can see the word 0xABCDABCD correctly located in program flash, at an address assigned by the linker.
 
I'm using the default linker script, so there shouldnt be any surprises there.  Can anyone suggest what i've done incorrectly in the first absolute addressed definition?
 
Alexander
#1

2 Replies Related Threads

    davekw7x
    Entropy++
    • Total Posts : 1870
    • Reward points : 0
    • Joined: 2012/01/16 12:01:07
    • Location: Second star on the right, straight on till morning
    • Status: offline
    Re: "const" initialization in program memory at absolute address doesn't work as expected 2020/04/07 16:34:26 (permalink)
    +1 (1)
    adown
    ...suggest...



     
    This works for me.
    const unsigned int checksum __attribute__((space(prog),address(0xBD000000)))=0xABCDABCD;

    XC32 version 2.40, MPLABX version 5.35, PIC32MZ2048EFM100
     
    Regards,
     
    Dave
    post edited by davekw7x - 2020/04/08 08:17:38

    Attachment(s)

    Attachments are not available: Download requirements not met

    Sometimes I just can't help myself...
    #2
    JasonK
    Moderator
    • Total Posts : 3406
    • Reward points : 0
    • Joined: 2003/11/14 09:49:40
    • Location: Microchip Technology in Arizona, USA
    • Status: offline
    Re: "const" initialization in program memory at absolute address doesn't work as expected 2020/04/13 14:33:14 (permalink)
    +6 (6)
    We recently identified a critical issue where the address() attribute may behave incorrectly when compiling for a PIC32M (MIPS) target on a Linux or macOS host. The Windows release is not affected. In this case, the address attribute won't work properly and another function or variable may overlap with the specified address. We are currently in the process of preparing a fix for this issue and will release a new version with this issue fixed.
     

    Jason Kajita
     Follow me on Twitter
    http://support.microchip.com for urgent questions
    #3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5