File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,13 +26,12 @@ extern "C" {
2626}
2727
2828int main (void ){
29- #ifdef STARTUP_CODE
29+ #ifdef STARTUP_CODE
3030 memcpy (_sidata, _sdata, _sdata-_edata); // Copy the data segment initializers
3131 memset (_sbss, 0 , _ebss-_sbss); // zero fill the BSS segment
32- __libc_init_array (); // Call static constructors
3332#endif /* STARTUP_CODE */
3433
35- /* Defined by the linker */
34+ /* Defined by the linker */
3635 extern char _fastheap, _fasteheap; // internal RAM dedicated to heap
3736 extern char _eprogram, _eram; // remaining program space
3837 extern char _heap, _eheap; // external memory
@@ -42,7 +41,11 @@ int main(void){
4241 { ( uint8_t * )&_heap, (size_t )(&_eheap - &_heap) },
4342 { NULL , 0 } /* Terminates the array. */
4443 };
45- vPortDefineHeapRegions ( xHeapRegions );
44+ vPortDefineHeapRegions ( xHeapRegions ); // call before static initialisers to allow heap use
45+
46+ #ifdef STARTUP_CODE
47+ __libc_init_array (); // Call static constructors
48+ #endif /* STARTUP_CODE */
4649
4750 ProgramVector* pv = getProgramVector ();
4851 if (pv->checksum >= PROGRAM_VECTOR_CHECKSUM_V12){
You can’t perform that action at this time.
0 commit comments