• AVR Freaks

Hot!XC8 fills program memory from high to low. How can I get the opposite?

Author
alexconway
Starting Member
  • Total Posts : 37
  • Reward points : 0
  • Joined: 2009/07/14 08:40:24
  • Location: 0
  • Status: offline
2019/10/28 08:08:55 (permalink)
0

XC8 fills program memory from high to low. How can I get the opposite?

Hi Chaps,
I am using a PIC18F27K42 which has a very large program memory. With XC8 2.10 and MplabX 5.25.
When I compile my small program it stuffs all the code up at the highest locations.
I would like to be able to tell the compiler to fill from 0x000 up. Is this possible?
Using the -mreserve option would do something similar but I'd have to adjust it all the time.
Cheers
Alex
#1

16 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6361
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 08:19:06 (permalink)
    +1 (1)
    sorry, I must ask why ?
    #2
    alexconway
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2009/07/14 08:40:24
    • Location: 0
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 08:34:58 (permalink)
    0
    Because I want to minimise the amount of blank space I have to upload via my bootloader.
     
    #3
    1and0
    Access is Denied
    • Total Posts : 9982
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: online
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 09:00:41 (permalink)
    +2 (2)
    "Blank space" does not get generated in the hex file by the compiler, unless you export the hex data.
    #4
    alexconway
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2009/07/14 08:40:24
    • Location: 0
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 09:12:08 (permalink)
    0
    1and0
    "Blank space" does not get generated in the hex file by the compiler, unless you export the hex data.


    Yes, that is what I want to do.
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 18033
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 09:34:09 (permalink)
    +1 (1)
    1. You can’t.
    2. You can tell the compiler that you have a smaller memory to minimize the issue.
    3. Your real issue is your bootloader and hex file.
    4.the compiler puts the code at the bottom and constants at the top. Leaving the empty space in the middle.
    #6
    alexconway
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2009/07/14 08:40:24
    • Location: 0
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 09:43:05 (permalink)
    0
    NKurzman
    1. You can’t.
    2. You can tell the compiler that you have a smaller memory to minimize the issue.
    3. Your real issue is your bootloader and hex file.
    4.the compiler puts the code at the bottom and constants at the top. Leaving the empty space in the middle.

    1. What can't I?
    2. I already have that as a possibility
    3. You may be right, but that is not the question I'm asking
    4. It doesn't
     
     
    #7
    du00000001
    Just Some Member
    • Total Posts : 3230
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 10:23:24 (permalink)
    +2 (2)
    If it's only about reducing the transfer time:
    there's no need to transfer FF lines from the hex file at all. Just leave them out.
    Either by stripping the hex file (by some post-processing tool) or by making your boot loader somewhat smarter.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #8
    alexconway
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2009/07/14 08:40:24
    • Location: 0
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 12:50:52 (permalink)
    0
    It's about the question in the first post:
    Can I make the compiler fill from the bottom up instead of the top down?
    Cheers
    Alex
    #9
    ric
    Super Member
    • Total Posts : 24581
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 13:09:15 (permalink)
    +1 (1)
    No.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #10
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11423
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 13:16:11 (permalink)
    +1 (1)
    I haven't tested it, but I would expect Hexmate to remove unused locations from your exported hex file.
    #11
    mad_c
    Super Member
    • Total Posts : 1206
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 13:20:23 (permalink)
    +1 (1)
    Hi,
     
    As you already have a solution, you might have already seen the section in the User's Guide, 
    How Can I Speed Up Programming Times? but if you haven't, then it indicates that reserving memory is an easy way to stop the code being spread out.
     
    Jeff.
     
    #12
    alexconway
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2009/07/14 08:40:24
    • Location: 0
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 13:29:32 (permalink)
    0
    mad_c
    As you already have a solution..

    yes, but not an answer to the question.
    ric
    No.

    Aw shucks sad I'll have to use my 'solution'
    I hesitate to ask, why is it filling from the top down?
    post edited by alexconway - 2019/10/28 13:34:54
    #13
    NKurzman
    A Guy on the Net
    • Total Posts : 18033
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 16:21:44 (permalink)
    +1 (1)
    alexconway
    NKurzman
    1. You can’t.
    2. You can tell the compiler that you have a smaller memory to minimize the issue.
    3. Your real issue is your bootloader and hex file.
    4.the compiler puts the code at the bottom and constants at the top. Leaving the empty space in the middle.

    1. What can't I?
    2. I already have that as a possibility
    3. You may be right, but that is not the question I'm asking
    4. It doesn't



    1. You can't make it fill the way you want to.
    #14
    1and0
    Access is Denied
    • Total Posts : 9982
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: online
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 19:04:47 (permalink)
    +1 (1)
    The answer is no and the reason is because that is the way the compiler is designed.  If you want to have control of where code is allocated use assembly in absolute mode. ;)
    #15
    mad_c
    Super Member
    • Total Posts : 1206
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/10/28 20:16:05 (permalink)
    +2 (2)
    alexconway
    I hesitate to ask, why is it filling from the top down?

    When there are several psects all sharing the same memory space, it is easier to have those in some groups allocated top-down, and those in other groups allocated bottom-up. Certain conditions (and I'd have to do some serious studying of the code to say what) cause some psects to be the luck ones linked top-down.
     
    Jeff.
    #16
    trossin
    New Member
    • Total Posts : 26
    • Reward points : 0
    • Joined: 2006/06/02 11:31:50
    • Location: 0
    • Status: offline
    Re: XC8 fills program memory from high to low. How can I get the opposite? 2019/11/15 12:35:59 (permalink)
    0
    I found that if I have an interrupt handler, it fills from location 0 on up. If I do not, it packs the program at max address minus program size ( at the end of memory). Either way, it must write a few locations starting at zero as this is the reset vector. I also wrote my own boot loader and just force the compiler to not use the last 384 locations and put my boot loader code there. Either type of application then works without trouble.
    #17
    Jump to:
    © 2019 APG vNext Commercial Version 4.5