• AVR Freaks

Hot!PIC32MK Bootloader + Application Issue [Solved]

Author
darren
Starting Member
  • Total Posts : 67
  • Reward points : 0
  • Joined: 2010/10/02 04:31:04
  • Location: 0
  • Status: offline
2020/05/12 07:37:52 (permalink)
0

PIC32MK Bootloader + Application Issue [Solved]

Hi All,
 
I'm developing an application using the PIC32MK1024GDP100 for which I need a bootloader. I'm using Harmoney ver 2.06. So far, I have the application ready and working (when programmed without bootloader). As for the bootloader, I generated one using MHC and confirmed that I have correct communication form the host PC to the device. For both the bootloader and application, I generated the linker script from MHC following the Harmoney Help Volume V part i (page 1219). 
 
I am now trying to debug the application with the bootloader. I added the bootloader in the "Loadables" local folder of the application project and managed to compile. First issue I note is that while the application should have approx. 160k of RAM usage (its a graphic application), when compiling the the bootlader in the Loadables folder it only marks a RAM usage of approx 23k. The flash usage is marked correctly (application approx 331k, bootloader approx. 11k, app + bootloader approx. 341k). 
 
When I run the application, the bootloader recognise there is an application and correctly jumps to the application reset vector and runs the application but soon after I enable the interrupts, I get an exception (code 6, "Instruction bus error"). Disabling the interrupts, the app does work as I need the interrupts enabled but there is not exception generated so I ake it as the interrupts are the issue. I check the application linker and seen that IVT ebase address is 0x9D001000 which, as far as I know is correct. 
 
Does anyone have an idea what is the issue?
 
I attached the linker scripts assuming they'll help (changed the extension so I could attach them). 
 
Thanks
post edited by darren - 2020/05/14 02:06:19
#1

9 Replies Related Threads

    optimus_jack
    Senior Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2017/02/16 03:02:47
    • Location: 0
    • Status: online
    Re: PIC32MK Bootloader + Application Issue 2020/05/12 20:46:02 (permalink)
    0
    @darren you can give a try with Harmonn3 based bootloader. below is the example
    https://github.com/Microc...er/bootloader/firmware
    #2
    darren
    Starting Member
    • Total Posts : 67
    • Reward points : 0
    • Joined: 2010/10/02 04:31:04
    • Location: 0
    • Status: offline
    Re: PIC32MK Bootloader + Application Issue 2020/05/13 01:49:46 (permalink)
    0
    Hi optimus_jack,
     
    Thanks for the link but still have the same issue. I now realised that when I compile the application using the custom linker script without the bootloader project in the loadables folder, the RAM usage is still wrong. So the issue is coming from the custom linker script.  
     
    Any idea why my 150kB frame buffer is being ignored by the custom linker but not by the default linker script?
    As a side note, does anyone know which linker script is used by XC32 by default on the PIC32MK? Comparing the default with the custom linker may help...
    #3
    Stefiff
    Starting Member
    • Total Posts : 84
    • Reward points : 0
    • Joined: 2012/07/15 15:26:29
    • Location: 0
    • Status: offline
    Re: PIC32MK Bootloader + Application Issue 2020/05/13 04:18:50 (permalink)
    0
    About RAM/Memory.
    What you see as allocated memory, is allocated by the compiler. If you have something / variables set to fixed addresses, they are not visible because the compiler does not allocate them.
     
    Problem with Interrupts.
    It depends on many things, not just the linker script. In the bootloader, depends on which modules are used by the processor. In what mode does the processor itself work. Usually here working in single mode. Interruptions are minimal or not allowed at all. MVEC=0.
    The moment you jump in to the application, the compiler will try to re-initialize the CPU with all vectors and stack (first MVEC=0 will be). Therefore, it is desirable, at the time of exit from the bootloader, to set them to default. Stop ALL modules. Later here MVEC=1.
    For MK, I don't know exactly, but for MX and MZ, the address with the table with the vectors must be at an address multiple of 4K. This is related to the registry that is responsible for this.
     
    _ebase_address =  0x9FC00300; - is bad idea
     
    Unfortunately, when you use harmony, you have no control over exactly what happens and what is used.
     
    #4
    darren
    Starting Member
    • Total Posts : 67
    • Reward points : 0
    • Joined: 2010/10/02 04:31:04
    • Location: 0
    • Status: offline
    Re: PIC32MK Bootloader + Application Issue 2020/05/14 02:05:14 (permalink)
    0
    Hi Stefiff,
     
    Thanks for your reply. I have tried change the _ebase_address to a multiple of 4k (0x9FC01000) but still didn't work. Finally, I managed to find the default linker used for the PIC32MK1024GPD100 and updated the starting address of the application and removed the boot section. It worked. I attached both the bootloader and application linkers should anyone finds himself in the same situation. 
     
    #5
    MPaulHolmes
    Junior Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2009/10/31 10:52:40
    • Location: 0
    • Status: offline
    Re: PIC32MK Bootloader + Application Issue 2020/05/25 08:08:14 (permalink)
    0
    I've never tried a bootloader before, and a lot of the conversation on this thread was confusing to me.  I don't even know what to ask.  Basically, my microcontroller is the p32mk1024MCF100 (and maybe sometimes the p32mk512mcf100).  If I started with the above 2 attachments, what would I need to do to get a functional bootloader for those microcontrollers?  
     
    I started to wade into this:
    https://github.com/Microchip-MPLAB-Harmony/bootloader
     
    But it didn't specifically mention my microcontrollers.  I had no idea what random stuff to change for my microcontrollers to work, since it all just seems like a black box to me.
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 18773
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: PIC32MK Bootloader + Application Issue 2020/05/25 09:11:14 (permalink)
    0
    Are you using Harmony to create a bootloader?
    Which version of Harmony, and what kind of bootloader?
    #7
    MPaulHolmes
    Junior Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2009/10/31 10:52:40
    • Location: 0
    • Status: offline
    Re: PIC32MK Bootloader + Application Issue 2020/05/25 09:24:41 (permalink)
    5 (1)
    I am willing to use harmony if that will work well.  I have the latest version of harmony (I just updated it today).  I'm not sure what it updated to (since I never use it), but I did update it.  I was going to use this:
    https://github.com/Microchip-MPLAB-Harmony/bootloader
     
    And was going to use the UART bootloader.  But then I was reading this thread, and it sounded like I am going to have to make a bunch of random changes that make no sense to me to get it working.
    #8
    MPaulHolmes
    Junior Member
    • Total Posts : 89
    • Reward points : 0
    • Joined: 2009/10/31 10:52:40
    • Location: 0
    • Status: offline
    Re: PIC32MK Bootloader + Application Issue 2020/05/25 10:05:50 (permalink)
    0
    trying to delete the post.  oh well.
    post edited by MPaulHolmes - 2020/05/25 16:32:26
    #9
    hud789
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2020/06/09 09:08:28
    • Location: 0
    • Status: offline
    Re: PIC32MK Bootloader + Application Issue 2020/06/30 16:18:55 (permalink)
    0
    So basically it is the linker scripts causes the issue? Any theory behind it? I have the similar issue with my PIC32MK1024GPE64 bootloader with CAN communication. I have a working application, but if called from bootloader, it had exception. But If I simplify the application to just a led blinking function, it works fine.
    #10
    Jump to:
    © 2020 APG vNext Commercial Version 4.5