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.