Hot!Bootloader Application re flash issue

Author
SuperDannyHatch
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2016/08/11 05:36:36
  • Location: 0
  • Status: offline
2017/09/13 04:02:59 (permalink)
0

Bootloader Application re flash issue

Hi,
 
Processor - PIC32mx270f256B
 
Compiler - XC32
 
I have modified the SD card boot loader example in the AN1388 application. I used the pic32mx250128b linker scripts as my starting point. Then changed the linker scripts to allow for the extra memory. 
 
My linker scripts are as follows 
 
Bootloader
/*************************************************************************
 * For interrupt vector handling
 *************************************************************************/
PROVIDE(_vector_spacing = 0x00000001);
_ebase_address = 0x9D000000;

/*************************************************************************
 * 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 = 0x9FC00490;
_DBG_CODE_SIZE = 0x760 ;
_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 = 0x9D001000, LENGTH = 0x6000 /* All C Files will be located here */
  exception_mem : ORIGIN = 0x9D000000, LENGTH = 0x1000 /* Interrupt vector table */
  debug_exec_mem : ORIGIN = 0x9FC00490, LENGTH = 0x760
  kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x0 /* This memory region is dummy */
  kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x490 /* C Startup code */
  config3 : ORIGIN = 0xBFC00BF0, LENGTH = 0x4
  config2 : ORIGIN = 0xBFC00BF4, LENGTH = 0x4
  config1 : ORIGIN = 0xBFC00BF8, LENGTH = 0x4
  config0 : ORIGIN = 0xBFC00BFC, LENGTH = 0x4
  kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x10000
  sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
  configsfrs : ORIGIN = 0xBFC00BF0, LENGTH = 0x10
}

 
Application 

/*************************************************************************
 * For interrupt vector handling
 *************************************************************************/
PROVIDE(_vector_spacing = 0x00000001);
_ebase_address = 0x9D006000;

/*************************************************************************
 * 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 = (0x9D006000 + 0x1000);
_BEV_EXCPT_ADDR = ((0x9D006000 + 0x1000) + 0x380);
_DBG_EXCPT_ADDR = ((0x9D006000 + 0x1000) + 0x480);
_DBG_CODE_ADDR = 0x9FC00490;
_DBG_CODE_SIZE = 0x760 ;
_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 = (0x9D006000 + 0x1000 + 0x490), LENGTH = 0x40000 - (0x6000 + 0x1000 + 0x490) /* All C Files will be located here */
  exception_mem : ORIGIN = 0x9D006000, LENGTH = 0x1000 /* Interrupt vector table */
  debug_exec_mem : ORIGIN = 0x9FC00490, LENGTH = 0x760
  kseg0_boot_mem : ORIGIN = 0x9D006000, LENGTH = 0x0 /* This memory region is dummy */
  kseg1_boot_mem : ORIGIN = (0x9D006000 + 0x1000), LENGTH = 0x490 /* C Startup code */
  config3 : ORIGIN = 0xBFC00BF0, LENGTH = 0x4
  config2 : ORIGIN = 0xBFC00BF4, LENGTH = 0x4
  config1 : ORIGIN = 0xBFC00BF8, LENGTH = 0x4
  config0 : ORIGIN = 0xBFC00BFC, LENGTH = 0x4
  kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x10000
  sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
  configsfrs : ORIGIN = 0xBFC00BF0, LENGTH = 0x10
}

 
 
The bootloader.h file 
 
#define APP_FLASH_BASE_ADDRESS 0x9D006000 
#define APP_FLASH_END_ADDRESS PROGRAM_FLASH_END_ADRESS

/* Address of the Flash from where the application starts executing */
/* Rule: Set APP_FLASH_BASE_ADDRESS to _RESET_ADDR value of application linker script*/

// For PIC32MX1xx and PIC32MX2xx Controllers only
#define USER_APP_RESET_ADDRESS (0x9D006000 + 0x1000)

 
My problem:
 
FILEA - quick flash LED sequence
FILEB - slow flash LED sequence 
 
The bootloader with work with FileA.hex, renamed to image.hex, straight after programming. I can then power up my board and jump straight to the application, and I can also power up and re flash the image.hex successfully. 
 
However, when I change my image.hex to FILEB.hex which is renamed to image.hex. The board will flash the LED to indicate erasing, and then flash the LED to indicate writing, but the image flashed is not correct. 
 
I can program the board with the bootloader code but with FILEB as the starting point and it works correctly, then re flashing FILEA does not. 
 
So I think it must either not be erasing correctly or writing correctly.
 
Any help is much appreciated
#1

7 Replies Related Threads

    optimus_jack
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2017/02/16 03:02:47
    • Location: 0
    • Status: offline
    Re: Bootloader Application re flash issue 2017/09/13 20:23:37 (permalink)
    0
    Hi,
    I could see that the APP_FLASH_BASE_ADDRESS and USER_APP_RESET_ADDRESS are not matching and could be leading to the issue
     
    #2
    SuperDannyHatch
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2016/08/11 05:36:36
    • Location: 0
    • Status: offline
    Re: Bootloader Application re flash issue 2017/09/14 00:35:35 (permalink)
    0
    Thanks for your reply. 
     
    I will try this today. 
    #3
    aschen0866
    Super Member
    • Total Posts : 4159
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: Bootloader Application re flash issue 2017/09/14 07:38:11 (permalink)
    0
    Check all your memory region partitions. They don't look right to me. For example, if your bootloader has:
     
    kseg0_program_mem (rx) : ORIGIN = 0x9D001000, LENGTH = 0x6000
     
    then your application shouldn't have:
     
    exception_mem : ORIGIN = 0x9D006000, LENGTH = 0x1000
     
    #4
    SuperDannyHatch
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2016/08/11 05:36:36
    • Location: 0
    • Status: offline
    Re: Bootloader Application re flash issue 2017/09/15 00:25:05 (permalink)
    0
     
    If it the app shouldn't have that address, what address should it have? The address would in theory be
     
    kseg0_program_mem (rx) : ORIGIN = 0x9D001000, LENGTH = 0x5000

    exception_mem : ORIGIN = 0x9D006000, LENGTH = 0x1000 
     
    because the exception_mem needs to start at 0x9D006000, which is from 0x9D001000 + 0x5000, if that is correct. However, this now does not write the image.hex. It will just keep trying to erase and flash, but flash unsuccessfully. 
    post edited by SuperDannyHatch - 2017/09/15 01:47:31
    #5
    mario.basanta
    Junior Member
    • Total Posts : 95
    • Reward points : 0
    • Joined: 2011/09/12 07:57:29
    • Location: 0
    • Status: offline
    Re: Bootloader Application re flash issue 2017/09/16 00:47:44 (permalink)
    0
    Ive been having a similar problem, but in my case the App starts but the USB module doesnt starts, if i dowload the APP Firmware without the linker  the USB works fine. But when i use the linker, the USB interruption doesnt starts. Could be a mapping problem too? This are my linkers:
    Bootloader:
    /*************************************************************************
     * For interrupt vector handling
     *************************************************************************/
    PROVIDE(_vector_spacing = 0x00000001);
    _ebase_address = 0x9D000000;

    /*************************************************************************
     * 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 = 0x9FC00490;
    _DBG_CODE_SIZE = 0x760 ;
    _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 = 0x9D001000, LENGTH = 0x5F00 /* All C Files will be located here */
      exception_mem : ORIGIN = 0x9D000000, LENGTH = 0x1000 /* Interrupt vector table */
      debug_exec_mem : ORIGIN = 0x9FC00490, LENGTH = 0x760
      kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x0 /* This memory region is dummy */
      kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x490 /* C Startup code */
      config3 : ORIGIN = 0xBFC00BF0, LENGTH = 0x4
      config2 : ORIGIN = 0xBFC00BF4, LENGTH = 0x4
      config1 : ORIGIN = 0xBFC00BF8, LENGTH = 0x4
      config0 : ORIGIN = 0xBFC00BFC, LENGTH = 0x4
      kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x4000
      sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
      configsfrs : ORIGIN = 0xBFC00BF0, LENGTH = 0x10
    }

    Application:
    /* Default linker script, for normal executables */
    OUTPUT_FORMAT("elf32-tradlittlemips")
    OUTPUT_ARCH(pic32mx)
    ENTRY(_reset)
    /*
     * Provide for a minimum stack and heap size
     * - _min_stack_size - represents the minimum space that must be made
     * available for the stack. Can be overridden from
     * the command line using the linker's --defsym option.
     * - _min_heap_size - represents the minimum space that must be made
     * available for the heap. Can be overridden from
     * the command line using the linker's --defsym option.
     */
    EXTERN (_min_stack_size _min_heap_size)
    PROVIDE(_min_stack_size = 0x400) ;
    /* PROVIDE(_min_heap_size = 0) ; Defined on the command line */
    /*************************************************************************
     * Processor-specific object file. Contains SFR definitions.
     *************************************************************************/
    INPUT("processor.o")

    /*************************************************************************
     * Processor-specific peripheral libraries are optional
     *************************************************************************/


    /*************************************************************************
     * For interrupt vector handling
     *************************************************************************/
    PROVIDE(_vector_spacing = 0x00000001);
    _ebase_address = 0x9D007000;

    /*************************************************************************
     * 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 + 0x1000);
    _BEV_EXCPT_ADDR = ((0x9D007000 + 0x1000) + 0x380);
    _DBG_EXCPT_ADDR = ((0x9D007000 + 0x1000) + 0x480);
    _DBG_CODE_ADDR = 0x9FC00490;
    _DBG_CODE_SIZE = 0x760 ;
    _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 = (0x9D007000 + 0x1000 + 0x490), LENGTH = 0x17B00 /* All C Files will be located here */
      user_mark_mem (w!x) : ORIGIN = 0x9D01FFF0, LENGTH = 0x10
      exception_mem : ORIGIN = 0x9D007000, LENGTH = 0x1000 /* Interrupt vector table */
      debug_exec_mem : ORIGIN = 0x9FC00490, LENGTH = 0x760
      kseg0_boot_mem : ORIGIN = 0x9D007000, LENGTH = 0x0 /* This memory region is dummy */
      kseg1_boot_mem : ORIGIN = (0x9D007000 + 0x1000), LENGTH = 0x490 /* C Startup code */
      config3 : ORIGIN = 0xBFC00BF0, LENGTH = 0x4
      config2 : ORIGIN = 0xBFC00BF4, LENGTH = 0x4
      config1 : ORIGIN = 0xBFC00BF8, LENGTH = 0x4
      config0 : ORIGIN = 0xBFC00BFC, LENGTH = 0x4
      kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x4000
      sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000
      configsfrs : ORIGIN = 0xBFC00BF0, LENGTH = 0x10
    }

     
     
    #6
    SuperDannyHatch
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2016/08/11 05:36:36
    • Location: 0
    • Status: offline
    Re: Bootloader Application re flash issue 2017/09/18 00:03:16 (permalink)
    0
    What compiler are you using? and does the boot loader have the same configuration bits as the application?
    #7
    SuperDannyHatch
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2016/08/11 05:36:36
    • Location: 0
    • Status: offline
    Re: Bootloader Application re flash issue 2017/09/20 02:42:30 (permalink)
    0
    I have re downloaded the 1388 source files. I am using a PIC32mx250f128 this time as there is linker files already created for this PIC, and get the exact same results. I am now wondering if it is something to do with the compiler as I am using the example projects and I still get the same results. 
    #8
    Jump to:
    © 2017 APG vNext Commercial Version 4.5