Hi everyone,
I’m planning to use the .rodata_custom_desc dedicated memory section to store basic device information. The goal is to allow a third-party software to read the generated .bin and identify this information.
Following the Espressif official documentation, I implemented the following:
typedef struct custom_app {
const char *my_custom_text;
} esp_custom_app_desc_t;
const __attribute__((section(".rodata_custom_desc"))) esp_custom_app_desc_t custom_app_desc = {
.my_custom_text = "Hello World 123",
};
The custom_app_desc is placed in main.c just to speed up testing.
I also ensured that the following line is added to the CMakeLists.txt of main.c:
target_link_libraries(${COMPONENT_TARGET} "-u custom_app_desc")
Result:
I can find the "Hello World 123" string in the generated .bin file, but not at the offset expected according to the Espressif documentation.
Question:
Is there something wrong with my setup, or am I misunderstanding how the .rodata_custom_desc section should be used?
Any suggestions would be greatly appreciated.
IDF version: 5.3.1
Unexpected offset when using .rodata_custom_desc section
-
MicroController
- Posts: 2661
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Unexpected offset when using .rodata_custom_desc section
At what offset did you expect to find the string? According to what documentation?I can find the "Hello World 123" string in the generated .bin file, but not at the offset expected according to the Espressif documentation.
As you don't specify a section to place the string literal in, it should end up in some .rodata section.
-
MicroController
- Posts: 2661
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Unexpected offset when using .rodata_custom_desc section
Try something like this:
Code: Select all
typedef struct custom_app {
const char my_custom_text[32];
} esp_custom_app_desc_t;
Re: Unexpected offset when using .rodata_custom_desc section
At what offset did you expect to find the string? According to what documentation?I can find the "Hello World 123" string in the generated .bin file, but not at the offset expected according to the Espressif documentation.
As you don't specify a section to place the string literal in, it should end up in some .rodata section.
Hello, thanks for reply.
https://docs.espressif.com/projects/esp ... -reference
"Offset for custom structure is sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t)."
I was expecting to see something within the first 100 bytes, but it's placed at 0x3000 +
-
Konstantin
- Espressif staff

- Posts: 15
- Joined: Tue Feb 05, 2019 7:31 am
Re: Unexpected offset when using .rodata_custom_desc section
The custom structure offset is 0x120 = (sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t)).
I double-checked it; it is exactly at 0x120 from the start of the app binary. I do not see an issue with it. If you use `const char *my_custom_text`, then yes, the text itself will be placed at +0x3000 offset. Just make sure that you use the correct type `const char my_custom_text[32]`.
If you are still getting this issue, please provide a simple example that demonstrates it.
I double-checked it; it is exactly at 0x120 from the start of the app binary. I do not see an issue with it. If you use `const char *my_custom_text`, then yes, the text itself will be placed at +0x3000 offset. Just make sure that you use the correct type `const char my_custom_text[32]`.
If you are still getting this issue, please provide a simple example that demonstrates it.
Re: Unexpected offset when using .rodata_custom_desc section
Hello everyone.
const char my_custom_text[32] instead of const char *my_custom_text has moved from the 0x3000+ range to 0x120.
Thank you all for your support.
const char my_custom_text[32] instead of const char *my_custom_text has moved from the 0x3000+ range to 0x120.
Thank you all for your support.
Who is online
Users browsing this forum: Bytespider, ChatGPT-User, Semrush [Bot] and 12 guests