• AVR Freaks

Hot!PIC32MK Application Linker Script

Author
Mael
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2009/09/08 08:12:02
  • Location: 0
  • Status: offline
2017/12/11 04:42:02 (permalink)
0

PIC32MK Application Linker Script

Hi.
 
I'm making a bootloader for a PIC32MK1024GPE1024.
 
For the bootloader application, I went to MPLAB Harmony configuration, and choose Harmony Framework Configuration->Bootloader Library and the checked Use Bootloader Library? Then, selected Bootloader Type: USB_DEVICE and checked Build a Bootloader?
Linker script for Bootloader was generated automatically, and Bootloader application works correctly
 
The problem is when I try to develop an application to load on the bootloader, for this I started a new project and also went to 
MPLAB Harmony configuration, and choose Harmony Framework Configuration->Bootloader Library and the checked Use Bootloader Library? Then, selected Bootloader Type: USB_DEVICE and checked Build a Application Linker Script?
In this case, also linker script is automatically generated, but when I try to debug application, PC goes to address 0x1FC00380 and holds there, only way to debug project is remove the linker script and then it works. it seems that this linker script is done for PIC32MX and not for PIC32MK.
 
Do anybody know if there is an Application Linker Script specific for PIC32MK?
 
Thanks in advance and best regards.
#1

4 Replies Related Threads

    aschen0866
    Super Member
    • Total Posts : 4482
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: PIC32MK Application Linker Script 2017/12/11 08:19:47 (permalink)
    0
    I am not a Harmony user. However, from your description, it sounds like you were trying to run a debug session using a release build linker script. There are different ways handling debug vs. release for the application, but they all come down to changing the reset address. For debug, the reset address needs to be at BFC0_0000, for release, it is where your application starts.
    #2
    anna.virabyan
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2019/01/30 03:18:54
    • Location: 0
    • Status: offline
    Re: PIC32MK Application Linker Script 2019/02/04 01:21:40 (permalink)
    0
    Please help me, I use harmony bootloader with uart (without interrupt) and I use harmony app with timer interrupt. The project successfully loaded by bootloader to pic32mk0512gpd064. But when app meets interrupt event, app hangs up. I don't understand why.
     
     
    This is a bootloader linker script
     
    /*************************************************************************
    * Processor-specific peripheral libraries are optional
    *************************************************************************/
    OPTIONAL("libmchp_peripheral.a")
    /*************************************************************************
    * For interrupt vector handling
    *************************************************************************/
    PROVIDE(_vector_spacing = 0x00000001);
    _ebase_address = 0x9FC01000;
    /*************************************************************************
    * Memory Address Equates
    * _RESET_ADDR -- Reset Vector
    * _BEV_EXCPT_ADDR -- Boot exception Vector
    * _DBG_EXCPT_ADDR -- In-circuit Debugging Exception Vector
    * _DBG_CODE_ADDR -- In-circuit Debug Executive address
    * _DBG_CODE_SIZE -- In-circuit Debug Executive size
    * _GEN_EXCPT_ADDR -- General Exception Vector
    *************************************************************************/
    _RESET_ADDR = 0xBFC00000;
    _BEV_EXCPT_ADDR = (0xBFC00000 + 0x380);
    _DBG_EXCPT_ADDR = (0xBFC00000 + 0x480);
    _DBG_CODE_ADDR = 0xBFC02000;
    _DBG_CODE_SIZE = 0xFF0;
    _GEN_EXCPT_ADDR = _ebase_address + 0x180;
    /*************************************************************************
    * Memory Regions
    *
    * Memory regions without attributes cannot be used for orphaned sections.
    * Only sections specifically assigned to these regions can be allocated
    * into these regions.
    *************************************************************************/
    MEMORY
    {
    kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x7000 /* All C Files will be located here */ 
    kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x0 /* This memory region is dummy */ 
    exception_mem : ORIGIN = 0x9FC01000, LENGTH = 0x1000 /* Interrupt vector table */
    config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
    config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
    config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4
    config0 : ORIGIN = 0xBFC02FFC, LENGTH = 0x4
    kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x300 /* C Startup code */
    kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000
    sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
    debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0xFF0
    configsfrs : ORIGIN = 0xBFC02FF0, LENGTH = 0x10
    }
     
     
    This is a app linker script 
     
    /*************************************************************************
    * Processor-specific object file. Contains SFR definitions.
    *************************************************************************/
    INPUT("processor.o")

    /*************************************************************************
    * Processor-specific peripheral libraries are optional
    *************************************************************************/
    OPTIONAL("libmchp_peripheral.a")
    /*************************************************************************
    * For interrupt vector handling
    *************************************************************************/
    PROVIDE(_vector_spacing = 0x00000001);
    _ebase_address = 0x9D008000;
    /*************************************************************************
    * Memory Address Equates
    * _RESET_ADDR -- Reset Vector
    * _BEV_EXCPT_ADDR -- Boot exception Vector
    * _DBG_EXCPT_ADDR -- In-circuit Debugging Exception Vector
    * _DBG_CODE_ADDR -- In-circuit Debug Executive address
    * _DBG_CODE_SIZE -- In-circuit Debug Executive size
    * _GEN_EXCPT_ADDR -- General Exception Vector
    *************************************************************************/
    _RESET_ADDR = (0x9D007000);
    _GEN_EXCPT_ADDR = _ebase_address + 0x180;
    /*************************************************************************
    * Memory Regions
    *
    * Memory regions without attributes cannot be used for orphaned sections.
    * Only sections specifically assigned to these regions can be allocated
    * into these regions.
    *************************************************************************/
    MEMORY
    {
    kseg0_program_mem (rx) : ORIGIN = (0x9D000000 + 0x7000), LENGTH = (0x80000 - 0x7000) /* All C Files will be located here */
    kseg0_boot_mem : ORIGIN = 0x9D000000 + 0x7000, LENGTH = 0x0 /* This memory region is dummy */
    config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
    config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
    config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4
    config0 : ORIGIN = 0xBFC02FFC, LENGTH = 0x4
    kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000
    sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
    debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0xFF0
    configsfrs : ORIGIN = 0xBFC02FF0, LENGTH = 0x10
    }
     
     
    I found the solution in this link https://www.microchip.com/forums/m1036793.aspx.
    post edited by anna.virabyan - 2019/02/08 04:26:05
    #3
    ymams
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2019/01/31 18:46:05
    • Location: 0
    • Status: offline
    Re: PIC32MK Application Linker Script 2019/02/14 20:57:16 (permalink)
    0
    PIC32MK USB Device HID Bootloader
     
    I'm making a USB bootloader for a PIC32MK1024GPE064.
     
    For the bootloader application, I went to MPLAB Harmony configuration v2.06, and choose Harmony Framework Configuration->Bootloader Library and the checked Use Bootloader Library. Then, selected Bootloader Type: USB_DEVICE and checked Build a Bootloader.
    Linker script(btl_mx.ld) for Bootloader was generated automatically, and uploaded but Bootloader application works not correctly. When I try to debug Bootloader, I noticed to reset Bootloader, and doesn't detected USB HID device on Device Manager on my windows pc. 
    So I reinstalled MPLAB Harmony configuration v1.11 for USB HID bootloader from internet search, but new harmony project for PIC32MK family can't create. 
     
    Please help me!

    PS: When unchecked Application Configuration->Exception Handling-> Use MPLAB Harmony Exception Handler Template?  on Harmony configuration, bootloader compiled successfully.
    But when checked Application Configuration->Exception Handling-> Use MPLAB Harmony Exception Handler Template? (default) , bootloader has link errors as follow.
     
    -------------------------------------------------
    ...
    "C:\Program Files (x86)\Microchip\xc32\v2.10\bin\xc32-gcc.exe" -mprocessor=32MK1024GPE064 -o dist/default/production/SATRbootloader.X.production.elf build/default/production/_ext/1360937237/app.o build/default/production/_ext/1360937237/main.o build/default/production/_ext/1606335029/bootloader.o build/default/production/_ext/1606335029/nvm.o build/default/production/_ext/826599022/datastream.o build/default/production/_ext/826599022/datastream_usb_hid.o build/default/production/_ext/185269848/drv_tmr.o build/default/production/_ext/972827896/sys_clk.o build/default/production/_ext/972827896/sys_clk_pic32mk.o build/default/production/_ext/122796885/sys_int_pic32.o build/default/production/_ext/1264926591/sys_tmr.o build/default/production/_ext/764219029/drv_usbfs.o build/default/production/_ext/610166344/usb_device.o build/default/production/_ext/764219029/drv_usbfs_device.o build/default/production/_ext/610166344/usb_device_hid.o build/default/production/_ext/340578644/sys_devcon.o build/default/production/_ext/340578644/sys_devcon_pic32mk.o build/default/production/_ext/822048611/sys_ports_static.o build/default/production/_ext/68765530/sys_reset.o build/default/production/_ext/74298950/bsp.o build/default/production/_ext/1688732426/system_init.o build/default/production/_ext/1688732426/system_interrupt.o build/default/production/_ext/1688732426/system_exceptions.o build/default/production/_ext/1688732426/system_tasks.o ..\..\..\..\bin\framework\peripheral\PIC32MK1024GPE064_peripherals.a -DXPRJ_default=default -no-legacy-libc -Wl,--defsym=__MPLAB_BUILD=1,--script="..\src\system_config\default\btl_mx.ld",--defsym=_min_heap_size=512,--gc-sections,--no-code-in-dinit,--no-dinit-in-serial-mem,-Map="dist/default/production/SATRbootloader.X.production.map",--memorysummary,dist/default/production/memoryfile.xml

    nbproject/Makefile-default.mk:415: recipe for target 'dist/default/production/SATRbootloader.X.production.hex' failed
    make[2]: Leaving directory 'C:/microchip/harmony/v2_06/apps/SATRbootloader/firmware/SATRbootloader.X'
    nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
    make[1]: Leaving directory 'C:/microchip/harmony/v2_06/apps/SATRbootloader/firmware/SATRbootloader.X'
    nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

    default-nmi-handler.o: Link Error: Could not allocate section .text, size = 24 bytes, attributes = code
    build/default/production/_ext/972827896/sys_clk_pic32mk.o: Link Error: Could not allocate section .rodata, size = 20 bytes, attributes = code
    build/default/production/_ext/122796885/sys_int_pic32.o: Link Error: Could not allocate section .text.SYS_INT_Initialize, size = 20 bytes, attributes = code
    build/default/production/_ext/764219029/drv_usbfs_device.o: Link Error: Could not allocate section .text.DRV_USBFS_DEVICE_CurrentSpeedGet, size = 20 bytes, attributes = code
    build/default/production/_ext/610166344/usb_device_hid.o: Link Error: Could not allocate section .rodata, size = 20 bytes, attributes = code
    build/default/production/_ext/340578644/sys_devcon.o: Link Error: Could not allocate section .text.SYS_DEVCON_Initialize, size = 20 bytes, attributes = code
    build/default/production/_ext/68765530/sys_reset.o: Link Error: Could not allocate section .text.SYS_RESET_ReasonClear, size = 16 bytes, attributes = code
    build/default/production/_ext/1606335029/bootloader.o: Link Error: Could not allocate section .text.BOOTLOADER_ForceBootloadRegister, size = 12 bytes, attributes = code
    build/default/production/_ext/826599022/datastream.o: Link Error: Could not allocate section .text.DATASTREAM_BufferEventHandlerSet, size = 12 bytes, attributes = code
    build/default/production/_ext/972827896/sys_clk.o: Link Error: Could not allocate section .text.SYS_CLK_SystemFrequencyGet, size = 12 bytes, attributes = code
    build/default/production/_ext/1360937237/app.o: Link Error: Could not allocate section .text.APP_Bootloader_ForceEvent, size = 8 bytes, attributes = code
    build/default/production/_ext/764219029/drv_usbfs.o: Link Error: Could not allocate section .text.DRV_USBFS_Tasks, size = 8 bytes, attributes = code
    default-on-reset.o: Link Error: Could not allocate section .text._on_reset, size = 8 bytes, attributes = code
    default-on-bootstrap.o: Link Error: Could not allocate section .text._on_bootstrap, size = 8 bytes, attributes = code
    Link Error: Could not allocate program memory
    collect2.exe: error: ld returned 255 exit status
    make[2]: *** [dist/default/production/SATRbootloader.X.production.hex] Error 255
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2
    BUILD FAILED (exit value 2, total time: 7s)
    -------------------------------------------------


    #4
    AndreasPaulin
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/02/26 08:36:53
    • Location: 0
    • Status: offline
    Re: PIC32MK Application Linker Script 2019/03/27 01:54:12 (permalink)
    0
    Linker files for MX and MK atztached. Feel free to ask..
     
    hth
     
    Andi
    post edited by AndreasPaulin - 2019/03/27 01:56:30
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5