• AVR Freaks

Hot!Format Hex File for Download not working

Author
jswanson
Super Member
  • Total Posts : 381
  • Reward points : 0
  • Joined: 2003/11/07 12:44:05
  • Status: offline
2021/01/04 10:14:57 (permalink)
0

Format Hex File for Download not working

Hi,
I am building for a PIC18F26K83 with 2.31.  I have a Code Offset of 800 for the bootoloader.  Using the' Format Hex File for Download' option in the linker seems to have no effect, with a few bytes of initialisation data being placed at the top of memory.  This is a problem for the bootoloder.  The only way I can force this not to happen is to restrict the ROM range in the linker, but it is a bit messy.  I thought the option should create (almost) contigous code?
 
Jeremy.
#1

8 Replies Related Threads

    crosland
    Super Member
    • Total Posts : 2176
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: Format Hex File for Download not working 2021/01/04 11:17:54 (permalink)
    +1 (1)
    I know it is supposed to ensure 16 (?) byte records in the .hex file but I am not sure it guarantees to generate records for unused addresses. Why is it a problem for the bootloader? Your bootloader should be reading the addresses and programming locations accordingly. It should be able to skip any block that is all FFs. Otherwise, fix it.
     
    If you are really asking about generating contiguous code then that has nothing to do with formatting the hex file. It's the linker that decides where to place the code. For various reasons it may generate code top-down as well as bottom-up, leaving a hole in the middle. This should not be an issue.
     
    #2
    1and0
    Access is Denied
    • Total Posts : 12108
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Format Hex File for Download not working 2021/01/04 11:25:39 (permalink)
    +2 (2)
    jswanson
    I am building for a PIC18F26K83 with 2.31.  I have a Code Offset of 800 for the bootoloader.  Using the' Format Hex File for Download' option in the linker seems to have no effect, with a few bytes of initialisation data being placed at the top of memory.  This is a problem for the bootoloder.  The only way I can force this not to happen is to restrict the ROM range in the linker, but it is a bit messy.  I thought the option should create (almost) contigous code?

    The XC8 compiler is known to allocate code at the top and bottom of the program memory. The "Download" option just pads the data records in the hex file to 16-byte lengths and aligns them on 16-byte boundaries. That should be easily processed by the bootloader. If not, then fix your bootloader. ;) My bootloader can handle data records of varying lengths and non-contiguous code.
     
    #3
    jswanson
    Super Member
    • Total Posts : 381
    • Reward points : 0
    • Joined: 2003/11/07 12:44:05
    • Status: offline
    Re: Format Hex File for Download not working 2021/01/20 03:37:10 (permalink)
    0
    Thanks for the reply. I had not realised the option was just a hexmate thing.  I would have thought it was pretty easy for the linker to produce contiguous code.  I have a project that updates via NFC memory where this is a problem.
    #4
    mlp
    boots too small
    • Total Posts : 1005
    • Reward points : 0
    • Joined: 2012/09/10 15:12:07
    • Location: previously Microchip XC8 team
    • Status: offline
    Re: Format Hex File for Download not working 2021/01/21 18:45:54 (permalink)
    +2 (2)
    jswanson
    I would have thought it was pretty easy for the linker to produce contiguous code.

    Write a linker that meets all the constraints the XC8 linker has to, then say that again with a straight face.

    Mark (this opinion available for hire)
    #5
    jswanson
    Super Member
    • Total Posts : 381
    • Reward points : 0
    • Joined: 2003/11/07 12:44:05
    • Status: offline
    Re: Format Hex File for Download not working 2021/01/22 02:37:20 (permalink)
    0
    I can force the code to be contiguous by compiling, adding the 2 blocks of code together and restricting the ROM range to that.  If I can do it, I'm sure the linker could also.  
    In the end I changed the code to eliminate the small CONST array.  There is a small overhead to load the array in RAM, but the access is quicker than from ROM.  
    #6
    1and0
    Access is Denied
    • Total Posts : 12108
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Format Hex File for Download not working 2021/01/22 17:19:11 (permalink)
    +1 (1)
    mark.pappin
    jswanson
    I would have thought it was pretty easy for the linker to produce contiguous code.

    Write a linker that meets all the constraints the XC8 linker has to, then say that again with a straight face.

    After the compiler and linker do their jobs, the number of program memory bytes used should be known. Then automatically restrict the ROM range and recompile with another pass. Shouldn't that work?
    #7
    mlp
    boots too small
    • Total Posts : 1005
    • Reward points : 0
    • Joined: 2012/09/10 15:12:07
    • Location: previously Microchip XC8 team
    • Status: offline
    Re: Format Hex File for Download not working 2021/01/24 18:55:15 (permalink)
    0
    jswanson
    I can force the code to be contiguous by compiling, adding the 2 blocks of code together and restricting the ROM range to that.  If I can do it, I'm sure the linker could also. 

    Just because it can doesn't mean it should.

    The linker targeting an embedded MCU is reasonably entitled to believe it has the entire memory space (less any explicit exclusions) at its disposal. At one point we seriously considered implementing an extra compiler pass to use any otherwise-unused space for more speed optimizations like loop unrolling and lookup tables.
     
    The firmware developer is reasonably entitled to believe the linker will do its job as quickly as possible without performing unnecessary work. They shouldn't be forced to wait for an extra link pass every build to get no-functional-benefit contiguous memory use if they don't need it.

    Mark (this opinion available for hire)
    #8
    jswanson
    Super Member
    • Total Posts : 381
    • Reward points : 0
    • Joined: 2003/11/07 12:44:05
    • Status: offline
    Re: Format Hex File for Download not working 2021/01/25 09:48:43 (permalink)
    +2 (2)
    Don't tick the option then.
    #9
    Jump to:
    © 2021 APG vNext Commercial Version 4.5