Good morning,
Thank you for reading me.
I have a Lilygo TTGO T3 V1.6.1 card and I would like to communicate with the Lorawan protocol.
I installed the MCCI_LoRaWAN_LMIC_library.
I work with the sketch: “ttn-otaa.ino”.
I defined the pinmaps:
I had this exact same problem a few weeks ago on an esp32-c3 board and solved it after a lot of hard debugging. Once you get it running then the ttn_otaa example works extremely well. But the setup is buggy
Here’s what’s missing… even though you set up your pinmap, it never gets loaded. Even worse, when the ASSERT to detect the missing pinmap gets triggered, there’s a bug that causes the processor to segfault. So any useful information gets buried in a never-end log dump. Here are two things that you’ll want to do to fix this:
Open MCCI_LoRaWAN_LMIC_library/src/hal/hal.cpp in the libraries directory. On my Mac, that folder is in ${HOME}/Documents/Arduino/libraries. If you’re using the Arduino IDE and can’t open the file then just try another editor. Once you have the file open, look for a call to hal_disableIRQs around line 479. Comment that out and try again. That should take care of the never-ending segfault loop. I still have to investigate, but it seems that IRQs are not turned on by default and trying to turn them off when displaying the error in the ASSERT function is what causes the processor to crash and restart the MCU
The root cause for the ASSERT is that your pinmap never gets loaded. That’s right, despite how everything appears and any build errors that you worked through to get this far, that pinmap that you worked so hard to adjust never gets loaded. That’s because the setup() function uses os_init to initialize the LMIC library and os_init depends on a global lmic_pins which is never set. Hence the call to ASSERT. If you want to use the predefined HAL configs in the library (after tweaking them like you did), you can put #include <arduino_lmic_hal_boards.h> at the top of your file and then replace the os_init() call in the setup function to this…
And with that change you should either start working or get meaningful errors if something is still wrong
One final note… instead of using GetPinmap_ThisBoard, I just copied one of the pinmaps from the library, made my changes, and included it directly into the ttn_otaa.ino file. Then, instead of calling GetPinmap_ThisBoard to get your pinmap you can pass your custom pinmap directly to the os_init_ex function