Hello,
COMPONENT_EMBED_FILES := xyz.bin
Included files are stored to .rodata but no 4-byte alignment.
How can i change this?
4-byte alignment for embedded files
4-byte alignment for embedded files
Creator of Smart Connected Devices - for EcSUHA.de Project
Re: 4-byte alignment for embedded files
Hmm that is interesting
Seems like it should be. Maybe this is related to people reporting certificate parsing errors.
Code: Select all
--rename-section .data=.rodata.embedded
Code: Select all
*(.rodata.*)
...
. = ALIGN(4);
Re: 4-byte alignment for embedded files
Hi SpenZerX,
Unfortunately embedding files in this way doesn't guarantee alignment. The esp-idf build system uses objcopy which generates an object file with alignment == 0 - so the linker applies no alignment constraints when linking the symbol. (There's a stackoverflow thread that explains it pretty well here: http://stackoverflow.com/questions/8822 ... es#8858950 )
In your own project, here are a few ideas that may handle this:
(BTW, we reproduced the certificate parsing errors on OS X - embedding text files didn't work as expected there because of different "echo" behaviour. A fix is on its way.)
Unfortunately embedding files in this way doesn't guarantee alignment. The esp-idf build system uses objcopy which generates an object file with alignment == 0 - so the linker applies no alignment constraints when linking the symbol. (There's a stackoverflow thread that explains it pretty well here: http://stackoverflow.com/questions/8822 ... es#8858950 )
In your own project, here are a few ideas that may handle this:
- Memcpy the data to an aligned buffer in RAM.
- Call out to "xxd -i" (which installs as part of vim) to code generate a header file with the bytes of your file. You can apply "const __attribute__(((aligned(4)))" to the variable in the header in order to tell the compiler to align it to a 4 byte boundary (even though it's 'char' data) and store it in flash.
- If you need to regenerate the file as part of the build process, so the embedded content changes automatically when the binary file changes, then you can use xxd from your component makefile. A very similar example is documented here: http://esp-idf.readthedocs.io/en/latest ... generation
The code generated header won't have alignment and const constraints applied, but you can (very hackily) apply them at include-time like this:
Code: Select all
const __attribute__(((aligned(4))) #include <my_binary_file.h>
Unfortunately the ALIGN constraint in linker scripts only applies to the next symbol/marker in the script, not all symbols in a section.WiFive wrote: Seems like it should be. Maybe this is related to people reporting certificate parsing errors.
(BTW, we reproduced the certificate parsing errors on OS X - embedding text files didn't work as expected there because of different "echo" behaviour. A fix is on its way.)
Who is online
Users browsing this forum: No registered users and 342 guests