Hello,
I am aware this is an old issue, but just for the record, I bump into the same issue and tried to solve it without success as there is egg and chicken, the `SystemInitHook` is called before the idata is copied from flash to RAM, while the entire codegen of the init PIN and clocks is using global variables in idata, so these functions cannot be called during the `SystemInitHook`, and the SDRAM cannot be initialized without these.
It took me a while to figure this out as nothing is properly documented, while there is a simple solution it is just not documented in any place I could find, I will appreciate references.
The solution is to initialize the SEMC without code before the section copy is executed, luckily it is supported as DCD (device configuration data), I I bump into this while trying to understand the sequence and reading all the sources and hints. The DCD can be used to initialize the SDRAM before the program is initialized, by using field of values and not code.
Step to enable:
1. select "Enable DCD Code" in the SEMC configuration of the peripheral tool
2. define `XIP_BOOT_HEADER_ENABLE=1` and `XIP_BOOT_HEADER_DCD_ENABLE=1` in C pre-processor to enable the DCD header.
3. Use `static __DATA(BOARD_SDRAM) int xxx = 5` as expected.
I hope this will be helpful to someone in future, as after reading this long thread there seems that there is no solution.
Regards,