Skip to content

Wire crash with last version of Arduino Framework ESP32 #33

@hpsaturn

Description

@hpsaturn

Summary

With two libraries of SparkFun, SCD30 and GCJA5 we have the same issue with the last versions of Espressif32 and Arduino Framework. The issue is the same in the same implementation:

SparkFun_SCD30_Arduino_Library.cpp:398

https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/blob/main/src/SparkFun_SCD30_Arduino_Library.cpp#L398

(also for the library GCJA5)

In my project the both libraries compiling ok but I have a execute crash, and the backtrace show the next issue (similiar in the both libraries). Other libraries with i2c implementation works fine.

esp32decode -e firmware.elf 0x4008398d:0x3ffcdd000x40094205:0x3ffcdd20 0x40099845:0x3ffcdd40 0x40094ca2:0x3ffcde70 0x401de512:0x3ffcdeb0 0x401de65d:0x3ffcded0 0x401e286d:0x3ffcdef0 0x401e2923:0x3ffcdf20 0x401e2a7f:0x3ffcdf50 0x400e63c5:0x3ffcdf70 0x400e6a7e:0x3ffcdfb0 0x400d7c2b:0x3ffce000 0x400d81da:0x3ffce060 0x400eeb42:0x3ffce0d0
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c:402
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c:85
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:821 (discriminator 2)
/home/avp/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp:339
/home/avp/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp:503
/home/avp/pio/canairio_firmware/.pio/libdeps/TTGO_TDISPLAY/SparkFun SCD30 Arduino Library/src/SparkFun_SCD30_Arduino_Library.cpp:398
/home/avp/pio/canairio_firmware/.pio/libdeps/TTGO_TDISPLAY/SparkFun SCD30 Arduino Library/src/SparkFun_SCD30_Arduino_Library.h:88
/home/avp/pio/canairio_firmware/.pio/libdeps/TTGO_TDISPLAY/SparkFun SCD30 Arduino Library/src/SparkFun_SCD30_Arduino_Library.cpp:61
/home/avp/pio/canairio_firmware/lib/sensorlib/src/Sensors.cpp:1427 (discriminator 1)
/home/avp/pio/canairio_firmware/lib/sensorlib/src/Sensors.cpp:109

The high level implementation is:

void Sensors::CO2scd30Init() {
    sensorAnnounce(SENSORS::SSCD30);
    #ifdef ESP32
    if (!scd30.begin() && !scd30.begin(Wire1,false,true)) return;
    #else
    if (!scd30.begin()) return;
    #endif
    delay(10);

    DEBUG("-->[SLIB] SCD30 Temp offset\t:",String(scd30.getTemperatureOffset()).c_str());
    DEBUG("-->[SLIB] SCD30 Altitude offset\t:", String(scd30.getAltitudeCompensation()).c_str());

    if(scd30.getAltitudeCompensation() != uint16_t(altoffset)){
        DEBUG("-->[SLIB] SCD30 altitude offset to\t:", String(altoffset).c_str());
        setSCD30AltitudeOffset(altoffset);
        delay(10);
    }

    if(uint16_t((scd30.getTemperatureOffset()*100)) != (uint16_t(toffset*100))) {
        setSCD30TempOffset(toffset);
        delay(10);
    }
    sensorRegister(SENSORS::SSCD30);
}

Fails in the line:

   if (!scd30.begin() && !scd30.begin(Wire1,false,true)) return;

Environment

Resolving TTGO_TDISPLAY environment packages...
Platform espressif32 @ 4.2.0 (required: espressif32)
├── framework-arduinoespressif32 @ 3.20002.220503 (required: platformio/framework-arduinoespressif32 @ ~3.20002.0)
├── framework-espidf @ 3.40302.0 (required: platformio/framework-espidf @ ~3.40302.0)
├── tool-cmake @ 3.16.4 (required: platformio/tool-cmake @ ~3.16.0)
├── tool-esptoolpy @ 1.30300.0 (required: platformio/tool-esptoolpy @ ~1.30300.0)
├── tool-mkfatfs @ 2.0.1 (required: platformio/tool-mkfatfs @ ~2.0.0)
├── tool-mklittlefs @ 1.203.210628 (required: platformio/tool-mklittlefs @ ~1.203.0)
├── tool-mkspiffs @ 2.230.0 (required: platformio/tool-mkspiffs @ ~2.230.0)
├── tool-ninja @ 1.7.1 (required: platformio/tool-ninja @ ^1.7.0)
├── toolchain-esp32ulp @ 1.22851.191205 (required: platformio/toolchain-esp32ulp @ ~1.22851.0)
├── toolchain-riscv32-esp @ 8.4.0+2021r2-patch3 (required: espressif/toolchain-riscv32-esp @ 8.4.0+2021r2-patch3)
├── toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3 (required: espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3)
└── toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch3 (required: espressif/toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch3)

I will try to replicate the same issue with a basic example. But like I mentioned, the other i2c libraries works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions