Incorrect static const data behavior in native module on esp32.
Checks
-
I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.
-
I've searched for existing issues matching this bug, and didn't find any.
Port, board and/or hardware
esp32
MicroPython version
MicroPython v1.22.2 on 2024-02-22; Generic ESP32 module with ESP32
Reproduction
I have a medium-complex native module that performs lossless data compression/decompression.
My code as a native modules has been tested to work on x64 and armv6m. I'm currently testing on esp32 and my code is not longer working; I have narrowed it down to the following:
I have a few static const variables defined here. If I remove the static, the code works fine. However, I tried adding static to examples/natmod/features1, and that code works fine with a static. So I have no idea what's going on here.
I found this out because write_to_bit_buffer was being invoked with n_bits=32 at one point, and I traced this down to huffman_bits[0] == 32, but obviously the value should be the constant 0x2.
Expected behaviour
If my library is operating correctly, it should have the following behavior:
>>> import tamp
>>> tamp.compress(b"foo")
b'X\xb3\x04\x18'
>>> tamp.decompress(tamp.compress(b"foo"))
bytearray(b'foo')
Observed behaviour
Accessing the RO data results in incorrect values.
Additional Information
No, I've provided everything above.
Build micropython for ESP32 ports & ESP-IDF v5.06. failed with static-assert
Checks
-
I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.
-
I've searched for existing issues matching this bug, and didn't find any.
Port, board and/or hardware
esp32 port, ESP32-boards, all variants
MicroPython version
MicroPython v1.22.2-dirty on 2024-04-18; Generic ESP32 module with ESP32; ESP-IDF v.5.0.6
Reproduction
make
Expected behaviour
Build micrpopython port for ESP32, simply make. ;))
Observed behaviour
Build process failed by the static assert with message:
"Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h"
Additional Information
I discover this trouble and detect, that Espressif upgrade it's code in all 5.x.y branches.
Now:
- location in file: - ports/esp32/network_common.c
- line: 171
- source code:
#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 1, 1)
_Static_assert(WIFI_AUTH_MAX == 11, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
#else
_Static_assert(WIFI_AUTH_MAX == 10, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
#endif
- Solition: update code as below:
#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 1, 1)
_Static_assert(WIFI_AUTH_MAX == 11, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
//-- Upd begin -----------------------------------------------------------------------
#elif ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0, 4)
_Static_assert(WIFI_AUTH_MAX == 11, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
//-- Upd end -------------------------------------------------------------------------
#else
_Static_assert(WIFI_AUTH_MAX == 10, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
#endif
Upd: I'm detect, that in ESP-IDF, branch v5.2.x - WIFI_AUTH_MAX == 13