Hot!Harmony V2.05 Bootloader Linker script does not work.

Author
NKurzman
A Guy on the Net
  • Total Posts : 15734
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
2018/02/02 17:57:08 (permalink)
0

Harmony V2.05 Bootloader Linker script does not work.

Harmony V2.05.01
MHC  V2.05.02
MplabX V4.05
PIC32MX530F128H
 
The Linker script for the Bootloader generated by MHC has issues..
The script cause the Program to crash when any interrupts are enabled.
 
I thought the MX would be easier, But I guess not.
#1

16 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/05 11:00:58 (permalink)
    0
    Anyone have an suggestions, or am I looking at the AN1388 appnote for guidance?
    2 years and still issues.
    #2
    friesen
    Super Member
    • Total Posts : 1867
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/06 06:14:19 (permalink)
    0
    What types of issues, crash on interrupt enables, or what?

    Erik Friesen
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/06 07:51:29 (permalink)
    0
    I get exceptions when the interrupts happen. But the debugger list then in normal code. If I disable the Harmony script, it then uses the default linker script and builds fine. I am using that for now to continue to code. I guess I will copy the default and change the ram size.
    I assume that will be easy.
    I am more concerned about the application linker script.
    #4
    friesen
    Super Member
    • Total Posts : 1867
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/06 08:18:28 (permalink)
    0
    Which processor? 
     
    I am using the MZ bootloader and application scripts without issues on a DA, excepting that the application does what you describe when using FREERtos.  The fix for that is PROVIDE(_ebase_address = 0x9D004000); instead of 1000.  I found that on a forum somewhere and it works, but I'd really like to know why.

    Erik Friesen
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/06 09:38:59 (permalink)
    0
    That is my issue with both MZ and MX Micro chip does not appear to provide information on how to edit the Linker scripts.  The MZ in more complicated since the IVT is variable length.  The MX is supposed to be fixed like the PIC24.  The MZ you need to leave enough room for it (no details).  As I sais I am still on the Bootloader, I have not tried the application script yet.
    #6
    Larry.Standage
    Moderator
    • Total Posts : 803
    • Reward points : 0
    • Joined: 2011/12/30 09:50:47
    • Location: 0
    • Status: offline
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/06 12:44:06 (permalink)
    0
    The chief difference between the bootloader linker script and default linker script for these devices is that it moves the IVT from the end of Flash memory (default) to the beginning (bootloader). Since these devices have only 3K of boot flash, there isn't enough room to put the IVT there, as there is in the MX devices with 12K of boot flash.
     
    I don't have hardware in front of me, but after generating a USB device bootloader through MHC, the simulator seems to be okay with it. Does the simulator work for you?
    #7
    muellernick
    Super Member
    • Total Posts : 378
    • Reward points : 0
    • Joined: 2015/01/06 23:58:23
    • Location: Germany
    • Status: offline
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/07 06:38:07 (permalink)
    0
    Do the interrupts happen while in the boot loader or while in the application?
    Where are your interrupt vectors? In boot loader memory or in application memory? (look at the map file)
     
    I just remember that it was a pain to edit the linker script to work properly. The canned linker scripts only do work, when you use exactly Harmonies model. As soon as you are nuts enough to implement you own boot loader, you lost.
    Main cause is, that the linker script is a pure hack!
    I'm still on 1.09 and I know why.
     
    Nick
    #8
    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/07 06:57:08 (permalink)
    0
    I have it working with a modified script from XC32. I used the notes from the appnotes and a comparison to the harmony 2.05 script.
    They appear to be mostly the same. I had to add more space since my boot loader did not fit it to the 8k provided. So I added a page. ( seems a little big to me, certainly bigger than the chip designer thought a bootloader would be)
    I did notice the moving of the ivt to the beginning. I do not know the trade offs for beginning or end.
    The harmony script appears similar in the parameters I changed. But many of the later items in the script are different. I do not know if they matter. But I would have to assume they do, at least for my pic. I rarely use the simulator. I go right to silicon.

    I assume I will have the same issue with application script.
    #9
    EseDeveloper
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2018/01/26 01:23:42
    • Location: 0
    • Status: offline
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/08 00:48:13 (permalink)
    0
    I also got exceptions and crashes using the bootloader with the provided linker files and Harmony v2.03b, but with a PIC32MK1024GPE100. The linker files which Harmony v2.03b adds for this device are made for another device and the correct placement of the configuration bits is missing and not correct. There were also some other issues in the linker files so I combined the working standard linker files and the provided bootloader linker files. I have attached the files, they are certainly not perfect, but work for me, maybe someone finds them useful. Note that they are for a PIC32MK1024GPE100 and not a MX device and I renamed them to *.txt.
    #10
    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/09 12:39:04 (permalink)
    5 (1)
    I have the Bootload Linker script in some working shape. The 3K boot block are a little different that the 12K ones.
    I am having some issue with the application script.  the . Reset section does not appear to be added.
    Attached is both script and what I think is the memory map.
     
    harmony moves ebase to the Botton, XC32 has it at the top of memory.  is there a benefit to either method?
     
    excel = map
    p32MX530F128H.ld = XC32 V1.44 script
    app_mx.ld = Harmony app  script
    btl_mx.ld = Harmony  bootloaderscript
    p32MX530F128H-app.ld = my app script based on the XC32 one.
    p32MX530F128H-btl.ld  = my bootloader script based on the XC32 one.
     
     
    post edited by NKurzman - 2018/02/09 12:47:57
    #11
    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/09 12:41:20 (permalink)
    0
    This is from the Harmony script.
    SECTIONS
    {
       .config_BFC02FF0 : {
       KEEP(*(.config_BFC00BF0))
       } > config3
       .config_BFC02FF4 : {
       KEEP(*(.config_BFC00BF4))
       } > config2
       .config_BFC02FF8 : {
       KEEP(*(.config_BFC00BF8))
       } > config1
       .config_BFC02FFC : {
       KEEP(*(.config_BFC00BFC))
       } > config0
    }
     
    are these suppose to match like in the XC32 one?
    post edited by NKurzman - 2018/02/09 12:46:40
    #12
    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/09 21:48:33 (permalink)
    0
    This appears to be closer to working:
    _RESET_ADDR                    = (0x9D000000 + 0x3000);  as opposed to  (0xBD000000 + 0x3000); 
    I guess different segment different address.
    #13
    aschen0866
    Super Member
    • Total Posts : 4258
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/10 09:48:12 (permalink)
    0
    Start with the linker scripts you posted in Post#11.
    p32MX530F128H-btl.ld.txt:
    1. Since you have ebase at 9D00_0000, change exception_mem to 9D00_0000 as well. This is where the vector table goes.
    2. Adjust kseg0_program_mem to 9D00_1000 to accommodate this change.

    PROVIDE(_vector_spacing = 0x0001);
    PROVIDE(_ebase_address = 0x9D000000); /* Move IVT (was 0x9D01F000) - NSK */
    ...
    kseg0_program_mem (rx) : ORIGIN = 0x9D001000, LENGTH = 0x3000 /* Change length to 12K - NSK, All C Files will be located here */
    exception_mem : ORIGIN = 0x9D000000, LENGTH = 0x1000

     
    Now your entire application effectively starts at 9D00_4000. Make these changes in p32MX795F512L_app.ld

    PROVIDE(_vector_spacing = 0x0001);
    PROVIDE(_ebase_address = 0x9D005000); /* ebase */
     
    _RESET_ADDR  = _RESET_LOC; /* application entry point */
     
    kseg0_program_mem (rx) : ORIGIN = 0x9D006000, LENGTH = (0x80000 - 0x6000) /* Main app code */
    exception_mem : ORIGIN = 0x9D005000, LENGTH = 0x1000 /* vector table */
    kseg1_boot_mem : ORIGIN = _RESET_LOC, LENGTH = 0x1000 /* reset + startup code */

     
    Create two build configurations in MPLABX, one for debug and one for release. Go to Project Properties -> xc32-ld, in the "Additional options" field, add "-D_RESET_LOC=0xBFC00000" for debug and "-D_RESET_LOC=0xBD004000" for release. Now you can use the same linker script for both builds, and the only difference between the debug and release is where you put the reset and startup code.
     
    #14
    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/02/10 11:40:04 (permalink)
    0
    Thank you I will go through this on Monday.
    The mips cpu seems wasteful for small programs. I am not sure why they thought a 3K boot block was useful.
    My last linker script did work. I see the address must match the space or bad things happen.
    Thanks for the input. 😃
    #15
    maxruben
    Super Member
    • Total Posts : 3217
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/04/13 04:04:55 (permalink)
    0
    The 3K boot block is not named as it is because it is to be used for a bootloader (but it can if small enough) but because it is there the chip boots up. It also contains the debug executive and normally one exception vector block and the startup code for the application (with no bootloader).
     
    /Ruben
    #16
    NKurzman
    A Guy on the Net
    • Total Posts : 15734
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Harmony V2.05 Bootloader Linker script does not work. 2018/04/13 06:46:23 (permalink)
    0
    Thanks. Microchip has a long term habit of making the lockable area for the boot loader to be too small. But “bootblock” is not just for bootloaders on a pic32mx.

    FYI to future readers. My bootloader worked so these scripts are functional.
    Update: No they are not, I will re-post the correct ones.
    post edited by NKurzman - 2018/04/20 19:53:51
    #17
    Jump to:
    © 2018 APG vNext Commercial Version 4.5