espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.7k stars 7.29k forks source link

Flashed code differs from same in .elf file (IDFGH-13546) #14436

Closed denizzzka closed 2 months ago

denizzzka commented 2 months ago

Answers checklist.

IDF version.

v5.3 and origin/release/v5.3 (0bbd728196)

Espressif SoC revision.

ESP32-C3

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

LuatOS ESP32-C3

Power Supply used.

USB

What is the expected behavior?

Code should be executed

What is the actual behavior?

Illegal instruction panic header invoked in components/esp_driver_spi/src/gpspi/spi_common.c:683

Compiled binary file looks good, llvm-objdump -S builddir/mcu_software.elf says (see 0x4203b47a):

;         if (bus_config->quadhd_io_num >= 0) {
4203b472: 08 48         lw      a0, 0x10(s0)
4203b474: 63 50 05 24   bgez    a0, 0x4203b6b4 <spicommon_bus_initialize_io+0x6b8>
;         if (bus_config->sclk_io_num >= 0) {
4203b478: 08 44         lw      a0, 0x8(s0)
4203b47a: 63 4e 05 04   bltz    a0, 0x4203b4d6 <spicommon_bus_initialize_io+0x4da>
;             if (sclk_need_output) {
4203b47e: 63 0d 0c 26   beqz    s8, 0x4203b6f8 <spicommon_bus_initialize_io+0x6fc>
;                 gpio_set_direction(bus_config->sclk_io_num, GPIO_MODE_INPUT_OUTPUT);
4203b482: 8d 45         li      a1, 0x3
4203b484: ef c0 8f fd   jal     0x42037c5c <gpio_set_direction>

But during to debug .insn is displayed in the same place:

 0x4203b472  spicommon_bus_initialize_io+1142 lw    a0,16(s0)
 0x4203b474  spicommon_bus_initialize_io+1144 bge   a0,a6,0x4203bbb4 <spi_master_deinit_driver+222>
 0x4203b478  spicommon_bus_initialize_io+1148 li    a0,-9
 0x4203b47a  spicommon_bus_initialize_io+1150 .insn 4, 0x55555f77
 0x4203b47e  spicommon_bus_initialize_io+1154 .insn 4, 0xffff5d77
 0x4203b482  spicommon_bus_initialize_io+1158 .insn 4, 0xffffffff
 0x4203b486  spicommon_bus_initialize_io+1162 .insn 4, 0xffffffff

__

Steps to reproduce.

Build and flash project with esp_driver_spi:

> idf.py --build-dir=builddir -D CMAKE_BUILD_TYPE=Debug set-target esp32c3 build flash

(no flashing or CRC issues reported)

Debug Logs.

> idf.py --build-dir=builddir -D CMAKE_BUILD_TYPE=Debug set-target esp32c3 build flash
[...]
esptool.py --chip esp32c3 -p /dev/ttyACM0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 2MB 0x0 bootloader/bootloader.bin 0x10000 mcu_software.bin 0x8000 partition_table/partition-table.bin
esptool.py v4.8.dev4
Serial port /dev/ttyACM0
Connecting....
Chip is ESP32-C3 (QFN32) (revision v0.4)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 9c:9e:6e:09:7f:c8
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00005fff...
Flash will be erased from 0x00010000 to 0x00170fff...
Flash will be erased from 0x00008000 to 0x00008fff...
SHA digest in image updated
Compressed 20864 bytes to 12783...
Writing at 0x00000000... (100 %)
Wrote 20864 bytes (12783 compressed) at 0x00000000 in 0.2 seconds (effective 1043.4 kbit/s)...
Hash of data verified.
Compressed 1444496 bytes to 458502...
Writing at 0x0016965d... (100 %)
Wrote 1444496 bytes (458502 compressed) at 0x00010000 in 4.3 seconds (effective 2672.0 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 105...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (105 compressed) at 0x00008000 in 0.0 seconds (effective 701.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Done

More Information.

I tried to replace MCU to exclude possible broken flash but nothing changed

denizzzka commented 2 months ago

SPI memory is connected via the same wire and glitch occurs