Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target_linker_script with ULP firmware (IDFGH-14115) #14921

Closed
3 tasks done
chrisruk opened this issue Nov 22, 2024 · 5 comments
Closed
3 tasks done

target_linker_script with ULP firmware (IDFGH-14115) #14921

chrisruk opened this issue Nov 22, 2024 · 5 comments
Assignees
Labels
Status: Opened Issue is new

Comments

@chrisruk
Copy link

chrisruk commented Nov 22, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

I'm able to make use of the following syntax in my main/CMakeLists.txt
in order to add a custom linker script configuration to my main application.

target_linker_script(${COMPONENT_LIB} INTERFACE "script.ld.in" )

However it doesn't appear to be possible to do the same for the ULP firmware I'm creating.

I tried something like:

target_linker_script("__idf_ulp" INTERFACE "script.ld.in" )

But that doesn't appear to have any effect.

I've found I can apply my changes to IDF itself, by modifying components/ulp/ld/lp_core_riscv.ld and have them take effect, but I don't want to modify IDF itself.

Just wondering if anyone could point me in the right direction.

Many thanks.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 22, 2024
@github-actions github-actions bot changed the title target_linker_script with ULP firmware target_linker_script with ULP firmware (IDFGH-14115) Nov 22, 2024
@o-marshmallow
Copy link
Collaborator

Hello @chrisruk ,

Which target are you using? ESP32-S3 or ESP32-C6? Also, which version of IDF are you working on?

On the latest version of IDF, you can add your own linker scripts to the linking phase with plain CMake commands. For example, let's say you have a file new.ld that you want to include in your LP project, add this to its CMakeLists.txt file:

add_custom_target(my_ld_script DEPENDS "${CMAKE_CURRENT_LIST_DIR}/new.ld")
add_dependencies(${ULP_APP_NAME} my_ld_script)
target_link_options(${ULP_APP_NAME} PRIVATE "-T${CMAKE_CURRENT_LIST_DIR}/new.ld")

Assuming that new.ld is in the same directory as your CMakeLists.txt file.

Make sure to add is in the LP CMakeLists.txt and not the HP CMakeLists.txt file!

@chrisruk
Copy link
Author

Hi @o-marshmallow,

Thanks a lot for your reply, I'm using ESP32-C6 and esp-idf master, ce60853.

I will try your suggestion, but I'm not quite sure where to put your text.

For example, my repo is structured similar to this repo - https://github.com/espressif/esp-idf/tree/master/examples/system/ulp/lp_core/lp_uart/lp_uart_print

But I assume you're saying your text doesn't go in -
https://github.com/espressif/esp-idf/blob/master/examples/system/ulp/lp_core/lp_uart/lp_uart_print/main/CMakeLists.txt ?

If so, where would I place it? Many thanks for the reply!

@o-marshmallow
Copy link
Collaborator

Hello @chrisruk !

Thanks for the confirmation. I see what you mean, the function ulp_embed_binary doesn't let you customize the build for the LP core.

I was relying on the build_system example which has a more complete CMakeLists.txt file for the ULP program and lets you customize the build even more: https://github.com/espressif/esp-idf/blob/master/examples/system/ulp/lp_core/build_system/main/ulp/CMakeLists.txt

In such file, you can add the snippet I sent previously and you should be able to integrate your lienr script file to your linking.

@chrisruk
Copy link
Author

Hi @o-marshmallow,

Thanks a lot for your help! I just tried the build system you pointed me to and added the text you gave
me previously.

It worked well, I was able to add sections that appeared in both:
lp_core_build_system_example.map and ulp_build_system_example.map

Will close this issue now, thanks again!

@o-marshmallow
Copy link
Collaborator

@chrisruk Thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new
Projects
None yet
Development

No branches or pull requests

3 participants