Could someone please enlighten me.
Does the ESP32-S3 and other ESP32 chips align data on 32bit words.
In other words.
Does a unint32_t and a uint8_t take the same amount of memory space?
Thank you.
ESP32-S3 and 32 Bit data alignment
-
- Posts: 1734
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: ESP32-S3 and 32 Bit data alignment
No, the chips don't align any data. The compiler does.
The flash and DRAM are byte-addressable/-accessible in hardware, hence gcc (usually) does 1-byte alignment on 8-bit values.
You can check the value of sizeof(uint8_t) or sizeof(uint32_t) yourself.
However,
will occupy 8 bytes due to gcc's (on ESPs mostly unnecessary) padding/alignment of the uint32_t.
The flash and DRAM are byte-addressable/-accessible in hardware, hence gcc (usually) does 1-byte alignment on 8-bit values.
You can check the value of sizeof(uint8_t) or sizeof(uint32_t) yourself.
However,
Code: Select all
struct {
uint8_t u8;
uint32_t u32;
} x;
-
- Posts: 24
- Joined: Sun Nov 01, 2020 1:51 am
Re: ESP32-S3 and 32 Bit data alignment
Thanks I did check another way by adding an array to some code and checking the upload size and it did follow your explanation.MicroController wrote: ↑Thu Sep 14, 2023 12:46 pmNo, the chips don't align any data. The compiler does.
The flash and DRAM are byte-addressable/-accessible in hardware, hence gcc (usually) does 1-byte alignment on 8-bit values.
You can check the value of sizeof(uint8_t) or sizeof(uint32_t) yourself.
However,will occupy 8 bytes due to gcc's (on ESPs mostly unnecessary) padding/alignment of the uint32_t.Code: Select all
struct { uint8_t u8; uint32_t u32; } x;
Thank you I couldn't find any specific information elsewhere.
Who is online
Users browsing this forum: Bing [Bot], Gaston1980 and 77 guests