Secondary bootloader jump with USB enable

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Secondary bootloader jump with USB enable

435 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fchiarion on Fri Nov 27 12:09:14 MST 2015
Hello guys,

I need a little help.
I am using FreeRTOS, and i have a task running USB on a application program. I have a small bootloader in the start area of my microcontroller.
The application with FreeRTOS and USB run normally if i remap my memory map in the icf configuration of IAR, and bootloader always run normally to.
When i disable USB task on FreeRTOS my bootloader can jump to application normally and run everything, just in case USB enabled i have problem to jump to application.
I already changed my application stack, USB stack and memory, but always get the same failure to jump. I know is something related to jump because i could attach binary of bootloader together application and compile both to have just one generated file and run in debug with JLink (my setup is IAR plugin under eclipse and JLink). When i run with this setup described (with both - bootloader+app together and USB enabled) i can get application running (this is strange ... in debug with JLink, Application starts without run bootloader), so i disconnect JLink cable and switch the power - the result is bootloader run and the last thing i see bootloader running is before call application  (i know this because i put a message in the UART before jump, and then application don´t even start - apparently).
If i comment the task of USB, bootloader run, and application run (just blink things and UART traces). If i do the same procedure - disconnect JLink and switch the power, i can see bootloader running and than application run normally.

This is my Jump Code:
typedef void (*USER_ENTRY_PFN)();
void vExecuteUserCode(void)
{

  USER_ENTRY_PFN user_entry;
  /* NEW CODE */


  /* Change the Vector Table to the USER_FLASH_START
  in case the user application uses interrupts */

  unsigned int stack_adr = (FLASH_APP_START_ADDRESS);
  stack_adr = *(unsigned int*)stack_adr;
  __set_CONTROL(0);
  __set_MSP(stack_adr);


  SCB->VTOR = (FLASH_APP_START_ADDRESS & 0x1FFFFF80);
  /* END NEW CODE */

  user_entry = (USER_ENTRY_PFN)*((uint32_t*)(FLASH_APP_START_ADDRESS +4));
  (user_entry)();

}


This is my icf memory map:

/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_BOOT_start__ = 0x1A000000;
/*-FHC redefined for bootloader ROM_end -*/
define symbol __ICFEDIT_region_ROM_BOOT_end__   = 0x1A003FFF;

/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x1A006000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x1A006140;
define symbol __ICFEDIT_region_ROM_end__   = 0x1A080000;
define symbol __ICFEDIT_region_RAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_RAM_end__   = 0x10007FFF;
define symbol __ICFEDIT_region_AHB_RAM_start__  = 0x20003000;
define symbol __ICFEDIT_region_AHB_RAM_end__    = 0x2000FFFF;

/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x400;
define symbol __ICFEDIT_size_heap__   = 0x200;
/**** End of ICF editor section. ###ICF###*/

define symbol __ICFEDIT_region_RAM_Exclude_start__ = 0x10008000;
define symbol __ICFEDIT_region_RAM_Exclude_end__   = 0x1007FFFF;


define memory mem with size = 4G;
define region ROM_BOOT_region   = mem:[from __ICFEDIT_region_ROM_BOOT_start__   to __ICFEDIT_region_ROM_BOOT_end__];
define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__  to __ICFEDIT_region_AHB_RAM_end__] - mem:[from __ICFEDIT_region_RAM_Exclude_start__  to __ICFEDIT_region_AHB_RAM_start__];

define symbol _AHB_RAM_USB_start__  = 0x20000000;
define symbol _AHB_RAM_USB_end__    = 0x20002FFF;
define region AHB_RAM_USB_region = mem:[from _AHB_RAM_USB_start__ to _AHB_RAM_USB_end__];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };
initialize by copy { readwrite };
do not initialize  { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { section .intvec };
place in ROM_region     { readonly };
place in RAM_region     { readwrite,
                          block CSTACK, block HEAP };
place in AHB_RAM_USB_region { section USB_RAM  };                        
place in ROM_BOOT_region { section CSTARTUPCODE };

Can you please give a light.

Regards.
Labels (1)
0 Kudos
0 Replies