Hot!.hex contains code that is located at addresses that do not exist on the PIC32MZ

Page: 12 > Showing page 1 of 2
Author
ffb.boy.30
Junior Member
  • Total Posts : 98
  • Reward points : 0
  • Joined: 2016/08/31 00:59:51
  • Location: 0
  • Status: offline
2017/12/06 01:54:00 (permalink)
0

.hex contains code that is located at addresses that do not exist on the PIC32MZ

I open this thread again because it is impossible to add an question to the existing thread.
 
In the Larry's post I've a question about kseg0_program_mem region size.
I'm using the MHC bootloader and I don't understand
Change the length of the kseg0_program_mem region so it ends before 0x9DF0FF00, so it doesn't overwrite the config bits.

What is the value to put for my 32MZ2048ECH144 here
kseg0_program_mem (rx) : ORIGIN = 0x9fc01000, LENGTH = 0x2FF00 - 0x1000

beacuse the region start at 0x9fc01000 and after 0x9DF0FF00
 
Thanks you
 
#1

25 Replies Related Threads

    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 04:07:16 (permalink)
    0
    Looks like your linker script already stops the program data before the config bits - 0x2FF00 is the end of the non-config boot flash, and since you're starting it at 0x1000 offset (presumably for vector table location compatibility) the "- 0x1000" at the end keeps that limit correct.
    #2
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 04:20:40 (permalink)
    0
    Actually, sorry - I hadn't looked to see how much boot flash you have.
     
    Each boot flash partition is only 0xFF00 long on your chip, so you want:

     
    kseg0_program_mem (rx) : ORIGIN = 0x9fc01000, LENGTH = 0xFF00 - 0x1000
     

     
    the 0x20000 offset would map it into the upper boot alias, which presumably you don't want?
    #3
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 04:50:58 (permalink)
    0
    When I program with MPLABX the compilation and programmation works perfectly.
    But if I try to program the same hex with the IPE I've the problem.
    I don't understand why the generated hex is not good for the IPE
    #4
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 04:53:28 (permalink)
    0
    Well, there is no contiguous memory from 0x9fc01000 to 0x9fc2ff00. Maybe MPLAB is fixing it for you, but IPE is somewhat dumber. Fix the length in your linker script and maybe it'll work in both.
    #5
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 05:30:28 (permalink)
    0
    I understand what you mean but I don't know how to do this.
    I never take time to read linker script documentation, and actually I'm in panic so no time sad: sad.
     
    Thanks you
     
    #6
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 05:33:29 (permalink)
    0
    I gave you the solution just a moment ago. Put that in your linker script.
     
    If you currently do not have a linker script, then get the one for your chip from the compiler's install dir. It's under include iirc and has a folder for each part. Also look at the one from harmony's bootloader example.
    #7
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 06:12:23 (permalink)
    0
    Hi,
    I put
    your solution in the linker
        kseg0_program_mem (rx) : ORIGIN = 0x9fc01000, LENGTH = 0xFF00 - 0x1000
     
    Now I've thousand of errors
    ...
    write.o: Link Error: Could not allocate section .text.write, size = 156 bytes, attributes = code
    ..
    memcmp.o: Link Error: Could not allocate section .text, size = 152 bytes, attributes = code
    ...
    rand.o: Link Error: Could not allocate section .text.rand, size = 140 bytes, attributes = code
    ...
    tcpip_helpers.o: Link Error: Could not allocate section .rodata, size = 124 bytes, attributes = code
    ...
    strncpy.o: Link Error: Could not allocate section .text.strncpy, size = 116 bytes, attributes = code
    .....

     
    My code is a bootloader
    #8
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 06:14:16 (permalink)
    0
    Is it based on some kind of bootloader example from Microchip? What is your current entry for kseg0_program_mem?
    #9
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 06:17:20 (permalink)
    0
    Yes it is the microchip sample
    the original line is
     
    kseg0_program_mem (rx) : ORIGIN = 0x9fc01000, LENGTH = 0x2FF00 - 0x1000

    Here is the build result
     
    post edited by ffb.boy.30 - 2017/12/06 06:21:57
    #10
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 06:25:47 (permalink)
    0
    And what chip was the example targeted at?
     
    If we consider the bootloader example for the pic32MZ in harmony, it contains this:
     

     
    MEMORY
    {
        kseg1_boot_mem          : ORIGIN = 0xBFC00000, LENGTH = 0x480
        kseg0_program_mem  (rx) : ORIGIN = 0x9fc01000, LENGTH = 0xFF00 - 0x1000
        kseg0_boot_mem          : ORIGIN = 0x9fc004b0, LENGTH = 0x00000000
      kseg1_boot_mem_4B0          : ORIGIN = 0xBFC004B0, LENGTH = 0x1000 - 0x4B0
     

     
    This file can be found at <harmony install dir>/v2.04/apps/bootloader/LiveUpdate/LiveUpdate_Switcher/firmware/src/system_config/usart_pic32mz_ef_sk/btl_mz.ld
     
    Perhaps your bootloader is too big to fit in the 64KiB boot flash?
    post edited by Noble_Techno - 2017/12/06 06:31:32
    #11
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 07:35:49 (permalink)
    0
    In my bootloader I only add a function to read a structure stored in the last page of the PIC.
    But I don't write anything.
    When I look at the dashboard in MPLABX it says:
    Program Used 0x22A0C
    The bootloader works perfectly when I program it from MPLABX
     
     
    #12
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 07:39:26 (permalink)
    0
    ffb.boy.30
    Program Used 0x22A0C

     
    In which case it is waaay too big to fit in boot flash. You may have only added one function, but what other functionality existed in the bootloader before you started modifying it? And what chip was it targeted for?
     
    I have no idea why or how it works when you program with MPLAB.
    #13
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 07:47:17 (permalink)
    0
    I'm a hasshole the size is not for the bootloader project , that why it is so big.
    The bootloader size is 0x13EB4
    There is something strnage in the built result

    Warning: C:/microchip/harmony/v2_03b/apps/bootloader/Bootloder_32MZ_V1.1/firmware/basic.X/dist/udp_pic32mz_ef_sk/production/basic.X.production.hex code overlaps current code and will overwrite it.
    Warning: C:/microchip/harmony/v2_03b/apps/bootloader/Bootloder_32MZ_V1.1/firmware/basic.X/dist/udp_pic32mz_ef_sk/production/basic.X.production.hex contains code that is located at addresses that do not exist on the PIC32MZ2048ECH144.
    Code incompletely loaded.
    Configuration Bits: address 0x1FC0FFC8: FNOSC = 0 does not match any valid value in the device database.
    Setting to the default value.
    Warning: The hex file has the debug bit set.  The debug bit has been cleared during load to memory.  The original hex file has not been modified.
    Configuration Bits: address 0x1FC0FFCC: ICESEL = 0 does not match any valid value in the device database.
    Setting to the default value.
    Loading completed

    #14
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 07:52:35 (permalink)
    0
    Yeah it seems like your executable data is overlapping the config bits - which the linker is allowing because your boot flash segment size is wrong.
     
    The bootloader size is 0x13EB4

     
    Still too big! Needs to be 0xEF00 or less. Theoretically I guess you could move some of the bootloader code to the upper boot partition, but that would require even more linker trickery - and assumes that you don't want to update the bootloader itself by using the other partition.
    #15
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 08:07:42 (permalink)
    0
    The original source code size is 0x2800 . I will look why my code is such bigger now
    Thanks you
    #16
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/06 13:45:29 (permalink)
    0
    From the original sample I just change USART to UDP in the bootloader parameters and the size of the code grow to 0x29A4.
    Is it impossible to go under 0xEF00.
     
    #17
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/07 01:37:19 (permalink)
    0
    Adding something that loads code over UDP implies that you'll then be linking in a TCP/IP stack and any other stuff that goes with it. Not a great surprise that the code grows a lot.
     
    You may have to look into putting your bootloader in program flash and then partitioning some of it off manually. You'll have to be very careful with page alignment and write protection to avoid the bootloader erasing / overwriting itself. Also be aware of issues when erasing & writing to the same block of memory that you're currently running from.
     
    Alternatively it seems like you might fit your bootloader into boot flash if you use both partitions. You'll have to do some linker section magic to make that happen.
    #18
    ffb.boy.30
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2016/08/31 00:59:51
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/07 03:22:48 (permalink)
    0
    I suppose I'm not alone with this kind of problem.
    Why I can't find information about a bootloader UDP ?
    I don't understand why my bootlader works perfectly and the main program too.
    To be honest, I'm afraid about what you explain me to do.
    I don't understand, it is the first time I look inside a bootloader code.
     
    Thanks you
    #19
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: .hex contains code that is located at addresses that do not exist on the PIC32MZ 2017/12/07 03:32:48 (permalink)
    0
    There are plenty of bootloaders in the world that use UDP - after all, that's how TFTP works. It should be entirely possible to fit everything needed in a lot less than 64KiB of program memory... but not if you're using a library that includes loads of unnecessary stuff.
     
    To help in figuring out how on earth it works now, try:
    1) Program in MPLAB so it "works"
    2) Read back entire memory with IPE, save to .hex
    3) Convert both production .hex output and .hex read from device to .bin (xc32-objcopy -I ihex --output-target=binary in.hex out.bin)
    4) Compare the two binaries and try to figure out what's going where. Okay, this is the hard bit. Use the linker map output to look for locations of key blocks of code, look at that address in the production.bin, copy a small snippet of data and then look for that data in the readback.bin. Repeat until you've understood what's going where. HxD would be your friend, along with a verry large pot of caffeinated beverage.
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2017 APG vNext Commercial Version 4.5