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":
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:
I step into this function and check the value of "__S_romp" passed to the function:
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:
Then I open my .xmap file to check the content of "__S_romp":
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:
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:
Until now, it seems like:
The option of codewarrior "download uninitialized data" will lead to abnormal debug session (maybe abnormal downloading flash).
My question are:
1) what is the purpose of this option :
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.
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!
-----------------------------------------------------------------------------------------------------------------------