threadx icon indicating copy to clipboard operation
threadx copied to clipboard

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

Open zq649 opened this issue 3 years ago • 10 comments

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?

zq649 avatar Nov 07 '22 15:11 zq649

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

goldscott avatar Nov 07 '22 18:11 goldscott

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

zq649 avatar Nov 07 '22 18:11 zq649

@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

goldscott avatar Nov 08 '22 19:11 goldscott

@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.

qasim-ublox avatar Dec 14 '22 17:12 qasim-ublox

@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

goldscott avatar Dec 14 '22 19:12 goldscott

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

qasim-ublox avatar Dec 14 '22 19:12 qasim-ublox

@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.

goldscott avatar Dec 14 '22 19:12 goldscott

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

qasim-ublox avatar Dec 14 '22 20:12 qasim-ublox

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

goldscott avatar Dec 14 '22 23:12 goldscott

@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.

wangwen-4220 avatar Jun 27 '23 07:06 wangwen-4220