Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PN532 module panics (IDFGH-14257) #15051

Open
3 tasks done
ImDevinC opened this issue Dec 18, 2024 · 2 comments
Open
3 tasks done

PN532 module panics (IDFGH-14257) #15051

ImDevinC opened this issue Dec 18, 2024 · 2 comments
Labels
Awaiting Response awaiting a response from the author Status: Opened Issue is new Type: Bug bugs in IDF

Comments

@ImDevinC
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

5.3.1

Espressif SoC revision.

ESP32-D0WD-V3 (revision v3.1)

Operating System used.

Linux

How did you build your project?

Other (please specify in More Information)

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

None

Development Kit.

DOIT ESP32 DEVKIT V1

Power Supply used.

USB

What is the expected behavior?

Module should startup correctly

What is the actual behavior?

Module panics and prevents booting regularly

Steps to reproduce.

Create the following yaml file for use with esphome and run esphome run <file.yaml> --device <USB_DEVICE>

esphome:
  name: pn532-sample-esphome
esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf
    version: 5.3.1
    platform_version: 6.9.0
spi:
  - clk_pin: GPIO14
    miso_pin: GPIO12
    mosi_pin: GPIO13
    interface: spi2
    id: SPI2
pn532_spi:
  cs_pin: GPIO16
  update_interval: 750ms
  spi_id: SPI2
  data_rate: 200kHz
logger:
  level: VERBOSE

Debug Logs.

[22:41:14]x\x80\x80xxx\x80xxQ),boot:0x13 (SPI_FAST_FLASH_BOOT)                      
[22:41:14]configsip: 0, SPIWP:0xee                                                                        
[22:41:14]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00                         
[22:41:14]mode:DIO, clock div:2                    
[22:41:14]load:0x3fff0030,len:7176                                                                        
[22:41:14]load:0x40078000,len:15564         
[22:41:14]ho 0 tail 12 room 4                  
[22:41:14]load:0x40080400,len:4             
[22:41:14]load:0x40080404,len:3904                
[22:41:14]entry 0x40080638                                                                                
[22:41:14]I (31) boot: ESP-IDF 5.3.1 2nd stage bootloader                                                 
[22:41:14]I (31) boot: compile time Dec 17 2024 22:41:03                                                  
[22:41:14]I (31) boot: Multicore bootloader                                                               
[22:41:14]I (35) boot: chip revision: v3.1                                                                
[22:41:14]I (39) boot.esp32: SPI Speed      : 40MHz                                                                                                                                                                  
[22:41:14]I (44) boot.esp32: SPI Mode       : DIO
[22:41:14]I (48) boot.esp32: SPI Flash Size : 4MB                                                         
[22:41:14]I (53) boot: Enabling RNG early entropy source...                                                                                                                                                          
[22:41:14]I (58) boot: Partition Table:                                                                                                                                                                              
[22:41:14]I (62) boot: ## Label            Usage          Type ST Offset   Length                         
[22:41:14]I (69) boot:  0 otadata          OTA data         01 00 00009000 00002000                                                                                                                                  
[22:41:14]I (77) boot:  1 phy_init         RF data          01 01 0000b000 00001000                                                                                                                                  
[22:41:14]I (84) boot:  2 app0             OTA app          00 10 00010000 001c0000                                                                                                                                  
[22:41:14]I (92) boot:  3 app1             OTA app          00 11 001d0000 001c0000                                                                                                                                  
[22:41:14]I (99) boot:  4 nvs              WiFi data        01 02 00390000 0006d000                                                                                                                                  
[22:41:14]I (107) boot: End of partition table                                                                                                                                                                       
[22:41:14]I (111) boot: No factory image, trying OTA 0                                                                                                                                                               
[22:41:14]I (116) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0e264h ( 57956) map                                                                                                                       
[22:41:14]I (144) esp_image: segment 1: paddr=0001e28c vaddr=3ffb0000 size=01d8ch (  7564) load           
[22:41:14]I (147) esp_image: segment 2: paddr=00020020 vaddr=400d0020 size=26bf4h (158708) map                                                                                                                       
[22:41:14]I (204) esp_image: segment 3: paddr=00046c1c vaddr=3ffb1d8c size=006a8h (  1704) load           
[22:41:14]I (205) esp_image: segment 4: paddr=000472cc vaddr=40080000 size=0e190h ( 57744) load                                                                                                                      
[22:41:14]I (240) boot: Loaded app from partition at offset 0x10000                                                                                                                                                  
[22:41:15]I (245) boot: Set actual ota_seq=1 in otadata[0]                                                                                                                                                           
[22:41:15]I (245) boot: Disabling RNG early entropy source...                                             
[22:41:15]I (257) cpu_start: Multicore app                                                                                                                                                                           
[22:41:15]I (265) cpu_start: Pro cpu start user code
[22:41:15]I (265) cpu_start: cpu freq: 160000000 Hz                                                                                                                                                                  
[22:41:15]I (265) app_init: Application information:                                                                                                                                                                 
[22:41:15]I (268) app_init: Project name:     pn532-sample-esphome                                                                                                                                                   
[22:41:15]I (274) app_init: App version:      2024.11.3                                                                                                                                                              
[22:41:15]I (279) app_init: Compile time:     Dec 17 2024 22:40:51                                                                                                                                                   
[22:41:15]I (285) app_init: ELF file SHA256:  53c3b4a43...
[22:41:15]I (291) app_init: ESP-IDF:          5.3.1
[22:41:15]I (295) efuse_init: Min chip rev:     v0.0
[22:41:15]I (300) efuse_init: Max chip rev:     v3.99 
[22:41:15]I (305) efuse_init: Chip rev:         v3.1
[22:41:15]I (310) heap_init: Initializing. RAM available for dynamic allocation:
[22:41:15]I (317) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
[22:41:15]I (323) heap_init: At 3FFB2E90 len 0002D170 (180 KiB): DRAM
[22:41:15]I (329) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
[22:41:15]I (336) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
[22:41:15]I (342) heap_init: At 4008E190 len 00011E70 (71 KiB): IRAM
[22:41:15]I (350) spi_flash: detected chip: generic
[22:41:15]I (353) spi_flash: flash io: dio
[22:41:15]I (358) main_task: Started on CPU0
[22:41:15]I (361) main_task: Calling app_main()
[22:41:15]I [I][logger:171]: Log initialized
[22:41:15][I][app:029]: Running through setup()...
[22:41:15][V][app:030]: Sorting components by setup priority...
[22:41:15][D][spi:035]: Setting up SPI bus...
[22:41:15][I][pn532_spi:015]: PN532Spi setup started!
[22:41:15][D][spi_device:362]: mode 0, data_rate 200kHz
[22:41:15][V][esp-idf:000]: I (507) gpio: GPIO[16]| InputEn: 0| OutputEn:
[22:41:15]assert failed: spi_hal_setup_trans /IDF/components/hal/spi_hal_iram.c:44 (spi_ll_get_running_cmd(hw) == 0)
[22:41:15]
[22:41:15]
[22:41:15]Backtrace: 0x400830a6:0x3ffb9240 0x40087401:0x3ffb9260 0x4008cdc9:0x3ffb9280 0x4008b049:0x3ffb93a0 0x400818bf:0x3ffb93e0 0x40081c91:0x3ffb9430 0x400d6885:0x3ffb9460 0x400f4fe7:0x3ffb94b0 0x400f4df5:0x3ff
b94d0 0x400d5d09:0x3ffb9500 0x400d4389:0x3ffb9540 0x400d45b1:0x3ffb9570 0x400d601d:0x3ffb95f0 0x400d7da8:0x3ffb9610 0x400f511f:0x3ffb9630 0x400d79fe:0x3ffb9650 0x400d8fc2:0x3ffb9680 0x400d1783:0x3ffb9700
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x400830a6: panic_abort at /home/devin/.platformio/packages/framework-espidf/components/esp_system/panic.c:463
WARNING Decoded 0x40087401: esp_system_abort at /home/devin/.platformio/packages/framework-espidf/components/esp_system/port/esp_system_chip.c:92
WARNING Decoded 0x4008cdc9: __assert_func at /home/devin/.platformio/packages/framework-espidf/components/newlib/assert.c:80
WARNING Decoded 0x4008b049: spi_ll_master_set_line_mode at /home/devin/.platformio/packages/framework-espidf/components/hal/esp32/include/hal/spi_ll.h:550
 (inlined by) spi_hal_setup_trans at /home/devin/.platformio/packages/framework-espidf/components/hal/spi_hal_iram.c:46
WARNING Decoded 0x400818bf: spi_new_trans at /home/devin/.platformio/packages/framework-espidf/components/esp_driver_spi/src/gpspi/spi_master.c:773
WARNING Decoded 0x40081c91: spi_device_polling_start at /home/devin/.platformio/packages/framework-espidf/components/esp_driver_spi/src/gpspi/spi_master.c:1376
WARNING Decoded 0x400d6885: esphome::spi::SPIDelegateHw::transfer(unsigned char const*, unsigned char*, unsigned int) at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/src/esphome/comp
onents/spi/spi_esp_idf.cpp:76
WARNING Decoded 0x400f4fe7: esphome::spi::SPIDelegateHw::write_array(unsigned char const*, unsigned int) at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/src/esphome/components/spi/sp
i_esp_idf.cpp:171
WARNING Decoded 0x400f4df5: esphome::spi::SPIDevice<(esphome::spi::SPIBitOrder)0, (esphome::spi::SPIClockPolarity)0, (esphome::spi::SPIClockPhase)0, (esphome::spi::SPIDataRate)1000000>::write_byte(unsigned char) a
t /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/src/esphome/components/spi/spi.h:440
WARNING Decoded 0x400d5d09: esphome::pn532_spi::PN532Spi::write_data(std::vector<unsigned char, std::allocator<unsigned char> > const&) at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphom
e/src/esphome/components/pn532_spi/pn532_spi.cpp:36
WARNING Decoded 0x400d4389: esphome::pn532::PN532::write_command_(std::vector<unsigned char, std::allocator<unsigned char> > const&) at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/s
rc/esphome/components/pn532/pn532.cpp:278
WARNING Decoded 0x400d45b1: esphome::pn532::PN532::setup() at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/src/esphome/components/pn532/pn532.cpp:21 (discriminator 2)
WARNING Decoded 0x400d601d: esphome::pn532_spi::PN532Spi::setup() at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/src/esphome/components/pn532_spi/pn532_spi.cpp:21
WARNING Decoded 0x400d7da8: esphome::PollingComponent::call_setup() at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/src/esphome/core/component.cpp:212
WARNING Decoded 0x400f511f: esphome::Component::call() at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/src/esphome/core/component.cpp:104
WARNING Decoded 0x400d79fe: esphome::Application::setup() at /home/devin/Projects/OpenSpool/firmware/.esphome/build/pn532-sample-esphome/src/esphome/core/application.cpp:38

More Information.

Building this as part of esphome, wasn't sure if this should be filed here, with platformio, or with esphome.
However I can say that changing the framework from esp-idf to arduino in the esphome config allows the pn532 module to load properly.

@ImDevinC ImDevinC added the Type: Bug bugs in IDF label Dec 18, 2024
@github-actions github-actions bot changed the title PN532 module panics PN532 module panics (IDFGH-14257) Dec 18, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 18, 2024
@wanckl
Copy link
Contributor

wanckl commented Dec 18, 2024

@ImDevinC
Not sure if issue from share interrupt somewhere in esp_home, but I have a patch for share interrupt, you can have a try with patch or replace your esp-idf\components\esp_driver_spi\src\gpspi\spi_master.c file in esp-idf repo with patched one.

spi_master_share_intr.patch
spi_master.c.txt

Waitting for your reply even if fixed or not, thank you.

@ImDevinC
Copy link
Author

It looks like platform.io framework 6.9.0 doesn't support 5.3.2 or above yet as I get a build error with this change (same error if I try to change to using 5.3.2 without your patch). I'll see if I can figure out the best way to test this module using raw esp-idf without esphome and report back. Appreciate the quick reply!

@Alvin1Zhang Alvin1Zhang added the Awaiting Response awaiting a response from the author label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Response awaiting a response from the author Status: Opened Issue is new Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants