KDS 3.2.0 with SDK 2.1 and VLLS mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KDS 3.2.0 with SDK 2.1 and VLLS mode

Jump to solution
637 Views
Ryssus
Contributor II

I am currently using KDS 3.2.0 with SDK v2.1.0 for Kinetis KL15z128. As far as I have found, the initialization for my device is placed in startup directory in startup_MKL15Z4. I have found 2 sections in that file:

/* Loop to copy data from read only memory to RAM. The ranges
 * of copy from/to are specified by following symbols evaluated in
 * linker script.
 * __etext: End of code section, i.e., begin of data sections to copy from.
 * __data_start__/__data_end__: RAM address range that data should be
 * copied to. Both must be aligned to 4 bytes boundary. */

this part is used for ROM data in global variables. There is also section for zeroing BSS sector just after that

#ifdef __STARTUP_CLEAR_BSS
/* This part of work usually is done in C library startup code. Otherwise,
 * define this macro to enable it in this startup.
 *
 * Loop to zero out BSS section, which uses following symbols
 * in linker script:
 * __bss_start__: start of BSS section. Must align to 4
 * __bss_end__: end of BSS section. Must align to 4
 */
 
#endif

Comment says that defining a macro should disable/enable initialization. 

Unfortunately it does not work for me when exiting VLLS3 mode. Af far as I know, in VLLS3 mode RAM is powered and after wakeup all data should be available. I have defined global variable (uninitialized so in BSS sector if I understand correctly) and even though I have __STARTUP_CLEAR_BSS  macro undefined, this variable is being zeroed after wakeup. Maybe I am wrong and someone can help with that? Where is initialization procedure during VLLS3 wakeup, and how to keep RAM values? 

Tags (2)
0 Kudos
1 Solution
441 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hello Ryssus

As you can see in the comments:

This part of work usually is done in C library startup code. Otherwise,
 * define this macro to enable it in this startup.

This mean that there is a part inside the GCC libraries where the BSS section is initialized as 0, and you cannot access to this part and modify it. So, if this part doesn't set your BSS as cero, C libraries will do this.

If you want to conserve RAM data after a Reset, you will need to define a new section that is not initilized as cero by the startup code, for this you will have to modify the linker file and the way to initilized your variable will have to change. I recommend you to check the following document:

Relocating Code and Data Using the KDS GCC Linker File for Kinetis 

In this document he shows you how you can change the location of your data to your custom address, so you only have to be sure that your data will not be inside BSS (m_data in the linker file), so it will not be initilized. Other references are:

https://community.nxp.com/thread/322632 

sleep VLLS mode retain sram not working? 

There are some examples codes, and also they explain how to modify your linker and your variables to have them after a wakeup from VLLS.

Hope this information could help you.
Have a great day,
Jorge Alcala

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

View solution in original post

1 Reply
442 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hello Ryssus

As you can see in the comments:

This part of work usually is done in C library startup code. Otherwise,
 * define this macro to enable it in this startup.

This mean that there is a part inside the GCC libraries where the BSS section is initialized as 0, and you cannot access to this part and modify it. So, if this part doesn't set your BSS as cero, C libraries will do this.

If you want to conserve RAM data after a Reset, you will need to define a new section that is not initilized as cero by the startup code, for this you will have to modify the linker file and the way to initilized your variable will have to change. I recommend you to check the following document:

Relocating Code and Data Using the KDS GCC Linker File for Kinetis 

In this document he shows you how you can change the location of your data to your custom address, so you only have to be sure that your data will not be inside BSS (m_data in the linker file), so it will not be initilized. Other references are:

https://community.nxp.com/thread/322632 

sleep VLLS mode retain sram not working? 

There are some examples codes, and also they explain how to modify your linker and your variables to have them after a wakeup from VLLS.

Hope this information could help you.
Have a great day,
Jorge Alcala

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