eclipse-threadx / threadx

Eclipse ThreadX is an advanced real-time operating system (RTOS) designed specifically for deeply embedded applications.
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/threadx/index.md
MIT License
2.82k stars 773 forks source link

Unable to create static variable in module #288

Open stdiehl opened 1 year ago

stdiehl commented 1 year ago

Hey,

I have tried to create a static variable in a module content but the variable gets initialized with a random number from anywhere.

I have tried it with a STM32F407-DISCO and with a MIMXRT1062-EVKB with Release 6.1.1, 6.1.10 and 6.2.1 of ThreadX.

For the STM controller I build it with the CubeIDE, for MIMXRT1062 with MCUXpressoIDE and with cmake in VSCode with gcc-arm-none-eabi-10.3-2021.10 - same result.

My example for the CubeIDE is attached.

The Memory config is:

Module Flags:

What I did not find is, where the register r9 is set before the gcc_setup.S of the module gets executed? In my case, r9 is set to 0x20000c00 but for my understanding, r9 must be set to 0x20010000. Where comes 0x20000c00 from? In flash memory, the values of the static variables are set correctly but the copy of the flash data to RAM is not correct.

What am I doing wrong? Is there a flag missing or is there a problem with the load of the module from the module manager?

Many thanks for any help and BR

cubeide.zip

williamelamie commented 5 months ago

How is the module being loaded via the module manager? Generally, ThreadX modules should be built in a PIC and PID fashion so the R9 data area address should be determined when the module is loaded.