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.87k stars 782 forks source link

[HELP WANTED] Linker script in case of loading from memory. #216

Open zq649 opened 1 year ago

zq649 commented 1 year ago

Arch: cortex_m7 Toolchain: GNU

Hi, I have general question regarding linker script. If the module is fetched in a dynamic memory from a file system, how can I identify the starting address for FLASH or RAM to write in my linker script?

goldscott commented 1 year ago

You can use any address you want for the linker script. For example, here we use 0x00030000.

zq649 commented 1 year ago

@goldscott Thanks for the response. About the regions, I guess I can only use one or both FLASH and RAM would be required?

goldscott commented 1 year ago

@zq649 you can execute a module from flash or RAM. It's up to you to determine where to place it. If you are going to read a module from a file and flash it, you would need to implement the code necessary to write to your chip's flash. Then you should call txm_module_manager_in_place_load. If you want to execute from RAM, you can simply call txm_module_manager_file_load and it will read the module from the file and place the module in RAM

qasim-ublox commented 1 year ago

@goldscott as for the ARMCC --first option is used to place the preamble at start of the execution region. What is the alternative for GCC? I am using the this linker script but the preamble is being placed at 0x000301d0.

goldscott commented 1 year ago

@qasim-ublox ah, you need to add ".section .preamble" to the preamble assembly file like is done here: https://github.com/azure-rtos/threadx/blob/master/ports_module/cortex_m0%2B/gnu/example_build/sample_threadx_module/txm_module_preamble.S#L4

qasim-ublox commented 1 year ago

@goldscott thanks. Any specific reason that this line is not added in preamble file for cortexm7?

goldscott commented 1 year ago

@qasim-ublox I think it was just forgotten in the M3/M4/M7 ports. I'll make a note to add it for our next release.

qasim-ublox commented 1 year ago

@goldscott this line and the line above is also not added for M7. What is the reason for + 0x80?

goldscott commented 1 year ago

@qasim-ublox 0x80 is the length of the preamble in bytes.

wangwen-4220 commented 1 year ago

@qasim-ublox, we have a module(cm7,gcc) project here https://github.com/wangwen-4220/stm32f746-disco-module/blob/main/stm32cubeide/sample_threadx_module/cm7/sample_threadx_module.ld

we have done some fix about the sample_threadx_module.ld and txm_module_preamble.S.

please let us know if it is helpful and we can close the issue.