rgot-org / EzLoRaWAN

ESP 32 port of the Arduino TheThingsNetwork library.
4 stars 5 forks source link

Hang on esp32c3 (esp32c3-devkit-lipo) #4

Open ignisf opened 1 month ago

ignisf commented 1 month ago

Hey, is this lib expected to work on the riscv esp32s? I get a hang when I call begin() and openocd does not offer any useful info. Using a SX1276-based MOD-LoRa.

board_config.h

#pragma once

#define BRD_sx1276_radio  1

// https://github.com/espressif/arduino-esp32/blob/cbe0f2ff0dd772edaf6aabfa4cc018021c0e3364/variants/esp32c3-devkit-lipo/pins_arduino.h#L22-L25

#define RADIO_SCLK_PIN    SCK  //4
#define RADIO_MISO_PIN    MISO //5
#define RADIO_MOSI_PIN    MOSI //6
#define RADIO_CS_PIN      SS   //7
#define RADIO_DIO0_PIN    3
#define RADIO_DIO1_PIN    10
#define RADIO_DIO2_PIN    1
#define RADIO_RST_PIN     0
#define RADIO_BUSY_PIN    LMIC_UNUSED_PIN      
#define RADIO_TCXO_PIN    LMIC_UNUSED_PIN
#define RADIO_TX_PIN      LMIC_UNUSED_PIN
#define RADIO_RX_PIN      LMIC_UNUSED_PIN

const lmic_pinmap lmic_pins = {
    .nss = RADIO_CS_PIN,
    .tx = RADIO_TX_PIN,
    .rx = RADIO_RX_PIN,
    .rst = RADIO_RST_PIN,
    .dio = {RADIO_DIO0_PIN , RADIO_DIO1_PIN, RADIO_DIO2_PIN},
    .busy = RADIO_BUSY_PIN,
    .tcxo = RADIO_TCXO_PIN,
};
(gdb) thread apply all bt

Thread 1 (Remote target "Current Execution"):
#0  0x42000bd2 in HardwareSerial::_uartEventTask (args=0x3fc94fcc) at /home/ignisf/.arduino15/packages/esp32/hardware/esp32/3.0.4/cores/esp32/HardwareSerial.cpp:236
#1  0x42000d66 in HardwareSerial::_uartEventTask (args=0x0) at /home/ignisf/.arduino15/packages/esp32/hardware/esp32/3.0.4/cores/esp32/HardwareSerial.cpp:257
#2  0x42002d68 in uartSetRxTimeout (uart=0x3fc94fcc, numSymbTimeout=84 'T') at /home/ignisf/.arduino15/packages/esp32/hardware/esp32/3.0.4/cores/esp32/esp32-hal-uart.c:585
#3  0x3c030154 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) 
wouterbt commented 6 days ago

I also tried using a SX1276 radio (on a LilyGO TTGO board) and also got a hang on ttn.begin(). I turned on debugging by uncommenting lines 142, 144 en 146 in Arduino/libraries/EzLoRaWAN/src/target-config.h and commenting lines 841-851 in Arduino/libraries/EzLoRaWAN/src/EzLoRaWAN.cpp. This helped in diagnosing the problem. It turned out that although I specified the SX1276 radio, the library defaulted to the SX1262 radio because of line 129 in Arduino/libraries/EzLoRaWAN/src/target-config.h. I added the line
#define BRD_sx1276_radio
to the beginning of that file instead of board_config.h and then it worked.

I don't know if you have the same problem, but the debugging feature will help a lot.