2017-10-24 08:21 PM
I want to put the boot_loader_version of 'const unsigned char boot_loader_version[3]={1,0,0};' at 0x600 of code flash, so the application can read it. How could I do it?
2017-10-26 01:47 AM
Hello Zhang ,
you shouldadd your sections in your linker files
SECTIONS
{
. = ORIGIN(flash);
.boot0 : ALIGN(16) SUBALIGN(16)
{
. += 0x00000000;
KEEP(*(.boot))
KEEP(*(.handlers))
KEEP(*(.crt0))
} > flash
.boot1 : ALIGN(16) SUBALIGN(16)
{
/* The vectors table requires a 2kB alignment.*/
. = ALIGN(0x800);
KEEP(*(.vectors))
/* The IVPR register requires a 4kB alignment.*/
. = ALIGN(0x1000);
__ivpr_base__ = .;
KEEP(*(.ivors))
} > flash
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
and
__attribute__ ((section ('.bootloadersection'))) const unsigned char boot_loader_version[3]={1,0,0};�?
you can try this ;)
Best Regards
Erwan
2018-06-11 08:15 PM
Hello Erwan:
I have the similar question,but the difference is I want to put the function at the permanent address,so that I can jump to it from the application program? what should I do ?Thanks.
2018-06-12 01:56 AM
Hello Wang ,
you should create a section located in 0x600 in user.ld.
and use __attribute__ in the function prototype.
There is a nice article about that
Best Regards
Erwan
2018-06-12 02:40 AM
Hello Erwan:
Appreciate for your reply,I have tired the way that you suggested above, and I have seen the FUNC is already at the address where I put in the UDE. But I have problem with the jump, after the jump code is implement, the FUNC at the loadaddress(0x8000) does't run. Here is the my code ,could you help me to find the problem?
//**********************************************************************************
__attribute__ (( __section__ ('loadaddress'))) void Bootloader(void)
{componentsInit();/* Enable Interrupts */irqIsrEnable();Flash_Init();mCanDrv_Init();while(1){// Process CAN drivermCan_Drv_Process();// Manage programming operationsmPrgm_Process();pal_lld_togglepad(PORT_A,PIN_TEST);}}
MEMORY
{flash : org = 0x00000000, len = 384k
dataflash : org = 0x00800000, len = 64kram : org = 0x40000000, len = 36kbootload : org = 0x00008000, len = 1k}ENTRY(_reset_address)
/*
* Derived constants.*/__bootload_size__ = LENGTH(bootload);
__bootload_start__ = ORIGIN(bootload);__bootload_end__ = ORIGIN(bootload) + LENGTH(bootload);loadaddress : ALIGN(4) SUBALIGN(4)
{PROVIDE(__loadaddress_start = .);KEEP(*(.loadaddress))KEEP(*(SORT(.loadaddress.*)))PROVIDE(__loadaddress_end = .);} > bootloadSPCSetPeripheralClockMode(SPC5_PIT_PCTL, SPC5_PIT_STOP_PCTL);
irqIsrDisable();ME.DRUN.R = (0UL | SPC5_ME_MC_MVRON | SPC5_ME_MC_DFLAON_NORMAL | SPC5_ME_MC_CFLAON_NORMAL | SPC5_ME_MC_IRCON | SPC5_ME_MC_SYSCLK_IRC);if (SPCSetRunMode(SPC5_RUNMODE_DRUN) == CLOCK_FAILED) {SPC5_CLOCK_FAILURE_HOOK();}(*(APPFn)(CVECT_BOOT_ISPOS))();//&sharpdefine CVECT_BOOT_ISPOS 0x8000
__attribute__ (( __section__ ('loadaddress'))) void Bootloader(void)// @ CVECT_BOOT_ISPOS
{0x00008000: 18 21 06 F8 E_STWU R1,-0x8(R1)0x00008004: 00 80 SE_MFLR R00x00008006: D3 01 SE_STW R0,0xC(R1)2018-06-12 03:53 AM
Hello Wang,
Your linker is strange
there is a conflict between
flash : org = 0x00000000, len = 384k <==> bootload : org = 0x00008000, len = 1k
You have to be sure that flash and bootloader sections are not in conflict.
To analyze a crash , you have to checked R14 and PC
Best regards
Erwan
2018-06-12 04:23 AM
Hello Erwan:
I have changed it like below, but it does not work, and I am confused about the flash and the bootload section, the flash size should be the whole program size , and the FUNC is located in the program, so I supposed the booload section should not be loacted beyond the flash size boundary, it seems not right. and how to check R14?? Thanks!
MEMORY
{ flash : org = 0x00000000, len = 48k dataflash : org = 0x00800000, len = 64k ram : org = 0x40000000, len = 36k bootload(rwx) : org = 0x00008000, len = 0x40}2018-06-12 11:02 PM
Hello Erwan?
I checked the PC pointer?and found that when I jumped from application program to bootloader FUNC which been located at 0x8000?the PC pointer was missing at the init FUNC? and I press the ?break? button ?the PC was always at the 0x00000C14?which is the vector address?but the R14 is always 0x00000000?the init FUNC is library function. Why could this happen?