Disabling the functions to carry out the initialization of RW and BSS data sections

cancel
Showing results for 
Search instead for 
Did you mean: 

Disabling the functions to carry out the initialization of RW and BSS data sections

316 Views
zorrotz
Contributor III

Hi,

Working with 8-bit microcontrollers and CodeWarrior the define __ONLY_INIT_SP is used to enable or disable the execution of Init() function in the startup routine; in order to enable or disable the initialization of zero out RAM areas and copy initialization data from ROM to RAM.

My question is:

Working with kinetis and MCUXpresso, how can I disable the execution of the functions to carry out the initialization of RW and BSS data sections?

Thanks in advance

3 Replies

84 Views
zorrotz
Contributor III

I have to do a variable memory test after microcontroller reset.

Instead of using IEC60730B_CM4_CM7_RAM_AfterResetTest() function provided by the core self-test library for Kinetis CM4 devices (this function is not destructive because it does a backup of the tested memory area) I was thinking about using IEC60730B_CM4_CM7_RAM_SegmentMarchC() function.

After execution of IEC60730B_CM4_CM7_RAM_SegmentMarchC() function all variable memory contains 0's, so I don't need the startup to carry out the initialization of RW and BSS data sections.

I now that I can use the startup as is, but I only wanted to know if it was possible.

Thanks

Regards,

Igor Vicente

0 Kudos

84 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Although you can prevent data initialisation as Jorge says about, you want to be very careful doing this. C - both your own code, and also code being pulled from the C library - will assume that variables have been initialised correctly. 

And if they haven't then make sure your code doesn't assume they have. What exactly are you trying to achieve?

Regards,

MCUXpresso IDE Support

84 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Pablo Igor Vicente

In MCUXpresso IDE, in your Kinetis projects, you can find under the startup folder a file that takes care for the initialization. In this startup_mkxxxx.c file you can find the ResetISR, and in this code you can modify the initialization of RW and BSS data sections:

// Copy the data sections from flash to SRAM.
while (SectionTableAddr < &__data_section_table_end) {
     LoadAddr = *SectionTableAddr++;
     ExeAddr = *SectionTableAddr++;
     SectionLen = *SectionTableAddr++;
     data_init(LoadAddr, ExeAddr, SectionLen);
}

// At this point, SectionTableAddr = &__bss_section_table;
// Zero fill the bss segment
while (SectionTableAddr < &__bss_section_table_end) {
     ExeAddr = *SectionTableAddr++;
     SectionLen = *SectionTableAddr++;
     bss_init(ExeAddr, SectionLen);
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope this could help you.

Best Regards

Jorge Alcala

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

0 Kudos