About debugger option "uninitialized data", something is wrong

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

About debugger option "uninitialized data", something is wrong

732件の閲覧回数
cencongsu
Contributor I

During my debug work for my project with Codewarrior Development Studio 10.6, I found something I can't understand:

 

When I create a debug configuration for my target, there is an option name "download uninitialized data":

146007_146007.pngpastedImage_0.png

By my understanding, the uninitialized data refers to .bss section, but the .bss section won't be included in the target file(bin or elf), then what's meaning of this option "download unintialized data" ?  What will the debugger do to the MCU flash if I click this option on ?

 

 

Then I do an experiment using FNET project, I leave this option selected, both first and subsequent, then start the debug session, the result is the program will get stuck here, function copy_rom_section in startup.c:

146008_146008.pngpastedImage_1.png

I step into this function and check the value of "__S_romp" passed to the function:

146036_146036.pngpastedImage_5.png

So , It seems there is something wrong with "__S_romp".

 

 

After that, I did a little research about "__S_romp", it is a section name defined in .lcf file and is used to copy the code in flash to ram:

146040_146040.pngpastedImage_9.png

 

Then I open my .xmap file to check the content of "__S_romp":

146038_146038.pngpastedImage_7.png

 

From the .xmap file, I can know at the address 0xCCEC of my program, the data will be, 0x0000BE14, 0x1FFF0410, I open my .bin file to check if my assumption is correct:

146039_146039.pngpastedImage_8.png

The data of .bin file is correct, that means the data of "__S_romp" shall be correct.

 

OK, now I need to check the data in my MCU flash, I use my J-Flash to read the data out, it turns out, the data in flash is incorrect:

146041_146041.pngpastedImage_10.png

 

 

Until now, it seems like:

The option of codewarrior "download uninitialized data" will lead to abnormal debug session (maybe abnormal downloading flash).

146007_146007.pngpastedImage_0.png

 

 

My question are:

1) what is the purpose of this option :

146042_146042.pngpastedImage_11.png

Why try to download .bss section?

 

 

2) What codewarrior or debugger will do if this option is selected? According to my above analyzation, it definitely does something unexpected to the MCU flash.

ラベル(1)
0 件の賞賛
返信
1 返信

574件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

HI,

For test I create a demo code for kl25, define global variable

unsigned int view_bss;

the variable "view_bss" should be allocated in bss.

from what I see, checking or unchecking  this option doesn’t affect debug and executing startup code.

the S19 record doesn't include bss section. But it's not true for other format. for instance Intel hex or normal elf file does include bss section.

if "uninitialized data" is checked, the debugger will initialize the uninitialized data. otherwise, debugger will not do it.

Professor Eich has a good document on text, data and bss. you can also check it if you want.

https://mcuoneclipse.com/2013/04/14/text-data-and-bss-code-and-data-size-explained/


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信