Initialisation of Variable in seperated segment

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Initialisation of Variable in seperated segment

1,293 次查看
Seppel
Contributor I

Hi,

 

i'm writing a bootloader, and therefor i need to put few variable initialisations into the seperated bootloader segment (not in standard COPYDOWN section!). How can i do this?

 

The bootloader segment is defined in *.prm file like this

SEGMENTS...BOOTLOADER        =  READ_ONLY    0xD600 TO 0xF9FF;...ENDPLACEMENT...BOOT INTO BOOTLOADER;...END

The bootloader code is located in a Boot.c file, and this file starts with

//beginning of Boot.c
#pragma CODE_SEG BOOT

unsigned long my_var = 0x11;

void MyFunc(void)
{
...
}

 In the *.map file i can see that the functions in this Boot.c are located in BOOT segment, but my_var is still in the standard COPYDOWN segment. How can i put my_var initial value in BOOT?

标签 (1)
0 项奖励
回复
4 回复数

1,116 次查看
kef
Specialist I

I think you are on the wrong track. Doing separate booloader application is easier, no need to care about library or compiler version mismatch between bootloader and loadable application, no problems migrating to different compiler vendor.

 

It is not possible to have two separate COPYDOWN sections for bootloader and app within the same project. Additionally you will have "a fun" of providing that bootloader isn't calling any library function and that there are no functions shared between bootloader and application. Doing separate bootloader you will avoid a lot of problems and save your time. 

0 项奖励
回复

1,116 次查看
Seppel
Contributor I

So you suggest me to build two different projects, aren't you? Project1 with Bootloader-Code and Project2 with Application-Code... sounds good, but how could i combine these two projects in one microcontroller?

 

F.e. Both projects will have the same startup point, startup code, copydown section, etc. where the adresses/datas from project 1 will overlay that ones from project 2.

0 项奖励
回复

1,116 次查看
kef
Specialist I

Bootloader and app don't overlap. Bootloader and main vectors table sit at top of flash and are write protected (NVPROT). Application with secondary interrupts vectors table (or interrupts jump table) occupy the rest of free flash. Application vectors table is at addressews just below the bootloader. Bootloader starts first, checks if loaded app is OK, takes application reset vector and jumps to app.

 

 

 

0 项奖励
回复

1,116 次查看
Seppel
Contributor I

Ok, i will try it in this way.

- Can i use vector relocation in my app project for the "Application with secondary interrupts vectors table"?

- How can i load these 2 projects (two *.s19 Files) as one file in my microcontroller? I work with Codewarrior and f.e. when i first load bootloader and secondary load application, the app will overwrite the bootloader-segments.

0 项奖励
回复