Open jcwren opened 1 year ago
I have exactly the same issue. The same behaviour as jcwren describes. I reinstalled everything including the Arduinio IDE. But did not help. I am using the Arduino IDE 2.0.
Can confirm.
Currently using platformio.org as my IDE/environment and get the following output when running with the ESP32 debugger:
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
[ 332][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 332][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 332][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 337][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
[ 343][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 350][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 355][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 360][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
[ 366][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 372][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 377][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 382][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
ESP32 MCU init...
abort() was called at PC 0x4008239a on core 1
Backtrace:0x40083ab5:0x3ffb24200x4008e495:0x3ffb2440 0x400937c5:0x3ffb2460 0x4008239a:0x3ffb24e0 0x40082970:0x3ffb2530 0x400d4c90:0x3ffb2550 0x400d5315:0x3ffb2570 0x400d3a9d:0x3ffb25a0 0x400ddeb6:0x3ffb2820
#0 0x40083ab5:0x3ffb2420 in panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
#1 0x4008e495:0x3ffb2440 in esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
#2 0x400937c5:0x3ffb2460 in abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c:46
#3 0x4008239a:0x3ffb24e0 in esp_flash_erase_region at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/esp_flash_api.c:541 (discriminator 5)
#4 0x40082970:0x3ffb2530 in spi_flash_erase_range at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/esp_flash_api.c:1173
#5 0x400d4c90:0x3ffb2550 in writelicense() at D:\/D:\\61722\\Documents\\Arduino\\libraries\\ESP32_LoRaWAN_VASR\\src\\Mcu.cpp:33
#6 0x400d5315:0x3ffb2570 in McuClass::init(int, int, int, int, unsigned int*) at D:\/D:\\61722\\Documents\\Arduino\\libraries\\ESP32_LoRaWAN_VASR\\src\\Mcu.cpp:154
#7 0x400d3a9d:0x3ffb25a0 in setup() at src/main.cpp:74
#8 0x400ddeb6:0x3ffb2820 in loopTask(void*) at /home/proffalken/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42
line 74 of src/main.cpp
is copied directly from the OTAA Example and license
is set as shown in that document as well.
OK, I'm now running the latest version of the library thanks to this post on the platformio forums
You need to update your libdeps
in your platformio.ini file to reference the HTTP Clone URL rather than the PlatformIO registry version:
lib_deps =
bblanchon/ArduinoJson@^6.19.4
heltecautomation/Heltec ESP32 Dev-Boards@^1.1.1
https://github.com/HelTecAutomation/ESP32_LoRaWAN.git
You then need to edit all of the files in .pio/libdeps/heltec_wifi_lora_32_V2/ESP32_LoRaWAN/src/region/
as documented at https://github.com/HelTecAutomation/ESP32_LoRaWAN/issues/87.
I'm still getting the same error, but at least I know I'm using the latest version of the library...
OK, it's working here with your changes. You can get around the license server BS by editing .pio/libdeps/heltec_wifi_lora_32_V2/ESP32_LoRaWAN/src/Mcu.s
and adding the retw.n
just after the call8 getLicenseServer
. The reality is that nothing actually checks the license server other than the Mcu.init()
function, which only writes it.
Oh, and there's no reason to edit all the region files. Just add -D LORAWAN_PREAMBLE_LENGTH=8
to your build flags in platformio.ini
Not sure where that comment about changing LORAWAN_PREAMBLE_LENGTH
to 16 came from. That's completely wrong. A device transmitting with a preamble of 16 will be heard by a device expecting 8, but not vice versa. Changing it to 16 means it's expecting to hear at least 16 preamble symbols, and all LoRaWAN regions use 8.
_Z12writelicensev:
.LFB2440:
.loc 1 31 0
entry sp, 32
.LCFI3:
.loc 1 32 0
call8 getLicenseAddress
retw.n # <--- Add this line
.LVL3:
.loc 1 33 0
l32r a11, .LC4
.loc 1 32 0
mov.n a2, a10
.LVL4:
.loc 1 33 0
call8 spi_flash_erase_range
.LVL5:
.loc 1 34 0
l32r a11, .LC5
movi.n a12, 0x10
mov.n a10, a2
call8 spi_flash_write
.LVL6:
retw.n
.LFE2440:
.size _Z12writelicensev, .-_Z12writelicensev
@jcwren perfect, thank you!
Now I just need to get my keys translated from an ArduinoJSON Dict to a uint8_t
and I'll be set!
@jcwren have you got any further with this?
I'm still getting a coredump:
[ 5681][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 5685][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5690][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5695][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
[ 5701][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 5707][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5712][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5717][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
[ 5723][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 5730][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5735][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5740][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
ESP32 MCU init...
ESP32 MCU inited OK!
HEX: CC51E381ABC46680
DevEui=AA51E381ABC46680
LoRaWAN EU868 Class A start!
joining...
LORAMAC_STATUS_OK: 0
Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d7dd3 PS : 0x00060f30 A0 : 0x800d7b7b A1 : 0x3ffb2760
A2 : 0x3ffb2794 A3 : 0x3ffb278c A4 : 0x00000031 A5 : 0x00000000
A6 : 0x3ffb8a28 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000001
A10 : 0x00000000 A11 : 0x3ffc5e00 A12 : 0x3ffc343c A13 : 0x00000000
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x0000000e EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4008af29 LEND : 0x4008af39 LCOUNT : 0xfffffffb
Backtrace:0x400d7dd0:0x3ffb27600x400d7b78:0x3ffb2780 0x400d5275:0x3ffb27c0 0x400d2ff7:0x3ffb2800 0x400e311d:0x3ffb2820
#0 0x400d7dd0:0x3ffb2760 in LoRaMacConfirmQueueAdd at .pio/libdeps/heltec_wifi_lora_32_V2/ESP32_LoRaWAN/src/LoRaMacConfirmQueue.c:134
#1 0x400d7b78:0x3ffb2780 in LoRaMacMlmeRequest at .pio/libdeps/heltec_wifi_lora_32_V2/ESP32_LoRaWAN/src/LoRaMac.c:3181
#2 0x400d5275:0x3ffb27c0 in LoRaWanClass::join() at .pio/libdeps/heltec_wifi_lora_32_V2/ESP32_LoRaWAN/src/ESP32_LoRaWAN.cpp:484
#3 0x400d2ff7:0x3ffb2800 in loop() at src/main.cpp:289
#4 0x400e311d:0x3ffb2820 in loopTask(void*) at /home/proffalken/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
ELF file SHA256: 0000000000000000
This happens regardless of how I define the TTN DevEui/AppEui/AppKey variables, so I'm not too sure what's going on :(
@proffalken, no issues at all right now, it's working fine both in Class A and Class C modes. My sign-on message is a little different, unless your code is printing the HEX: CC51E381ABC46680
. If you're not printing it, perhaps we're using different versions of the library? Here's my libdeps
line:
lib_deps =
bblanchon/ArduinoJson@^6.19.4
heltecautomation/Heltec ESP32 Dev-Boards@^1.1.1
https://github.com/HelTecAutomation/ESP32_LoRaWAN.git
If it's useful to you, I can probably carve everything not useful out of my app and reduce it down to some demo code like the OTAA.ino (although that's basically what I started from).
Ok, thanks.
My setup is fairly unique in that I'm getting the DevEUI etc from a json-based webservice and then trying to convert it from a JsonArray to the hex values expected by the library, so if yours is working fine then it's probably that conversion that's causing the issue.
The HEX
bit is some debugging statements I've added to the library, so I'll reset the library again, remove the licensing stuff, and then try again.
Why it's so difficult to convert a JSON array like {"0xC0", 0xB1, ... }
to the uint8_t DevEui {0xC0, 0xB1, ...}
required by the library is absolutely beyond me! 😅
Still no joy with this.
My current output is as follows (the Dev/App Eui and key have already been cycled since this output, but they matched the values in the TTN console at the time!)
DevEui JSON: CC50E381ABC41242
AppEui JSON: CC50E381ABC41242
AppKey JSON: EFE07F2B338DC55D60CA984E408DE5C3
hexToBin called with string: CC50E381ABC41242. Length of string is 16 and size was set to 16
hexToBin called with string: CC50E381ABC41242. Length of string is 16 and size was set to 16
hexToBin called with string: EFE07F2B338DC55D60CA984E408DE5C3. Length of string is 32 and size was set to 32
DevEui=CC50E381ABC41242
AppEui=CC50E381ABC41242
AppKey=EFE07F2B338DC55D60CA984E408DE5C3[ 5802][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 5802][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5806][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5811][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
[ 5817][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 5823][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5828][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5833][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
[ 5839][E][Wire.cpp:422] beginTransmission(): could not acquire lock
[ 5845][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5850][E][Wire.cpp:526] write(): NULL TX buffer pointer
[ 5855][E][Wire.cpp:448] endTransmission(): NULL TX buffer pointer
ESP32 MCU init...
ESP32 MCU inited OK!
LoRaWAN Initialising
DevEui=CC50E381ABC41242
LoRaWAN EU868 Class A start!
Attempting Join
joining...
Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d803f PS : 0x00060f30 A0 : 0x800d7de7 A1 : 0x3ffb2760
A2 : 0x3ffb2794 A3 : 0x3ffb278c A4 : 0x00000031 A5 : 0x3ffb26a0
A6 : 0x00000003 A7 : 0x00060023 A8 : 0x00000000 A9 : 0x00000001
A10 : 0x00000000 A11 : 0x3ffc5df8 A12 : 0x3ffc3434 A13 : 0x00000000
A14 : 0x00000001 A15 : 0x3ffb08c0 SAR : 0x0000000e EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4008af45 LEND : 0x4008af55 LCOUNT : 0xfffffffd
Backtrace:0x400d803c:0x3ffb27600x400d7de4:0x3ffb2780 0x400d54e7:0x3ffb27c0 0x400d317d:0x3ffb2800 0x400e33c9:0x3ffb2820
#0 0x400d803c:0x3ffb2760 in LoRaMacConfirmQueueAdd at .pio/libdeps/heltec_wifi_lora_32_V2/ESP32_LoRaWAN/src/LoRaMacConfirmQueue.c:134
#1 0x400d7de4:0x3ffb2780 in LoRaMacMlmeRequest at .pio/libdeps/heltec_wifi_lora_32_V2/ESP32_LoRaWAN/src/LoRaMac.c:3181
#2 0x400d54e7:0x3ffb27c0 in LoRaWanClass::join() at .pio/libdeps/heltec_wifi_lora_32_V2/ESP32_LoRaWAN/src/ESP32_LoRaWAN.cpp:484
#3 0x400d317d:0x3ffb2800 in loop() at src/main.cpp:401
#4 0x400e33c9:0x3ffb2820 in loopTask(void*) at /home/mmw/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
I've added in some extra debugging so I can check the length of the bytes etc, but it seems to be when I call LoRaMacConfirmQueueAdd
that the problems start, I just can't work out why!
That's a pretty low level function for user code to be calling. I'd need to see the code that you're setting up to make the call, etc. And what you're trying to accomplish with it :)
That's a fair shout.
I've stripped out some of the cruft I've put in for debugging (it fails with the same error though, so that's all good I guess?! :D ) and uploaded both my code and the relevant sections of the LoRaWAN libraries to https://gist.github.com/proffalken/d7ef6f569cbbfaa2374e7aa6f20ae6a9
In essence, I have a webservice that I have written that the ESP32 device calls via WiFi on startup.
The web service talks to the TTN API and returns the provisioning data in the following format:
{
"dev_eui": "CC50E381ABC41242",
"app_key": "EFE07F2B338DC55D60CA984E408DE5C3",
"app_eui": "CC50E381ABC41242"
}
I then convert these JSON Strings into their HEX equivalents such as {0xCC, 0x50, ...}
and pass them to the appropriate variables so that the LoRaWAN library can use them.
I think i worded things badly in my last post - I'm calling .join()
, and it's the library that filters that call down to LoRaMacConfirmQueueAdd
rather than my code directly. Perhaps a case of me giving too much detail! :)
I'm now at a point where the init() itself works, but the join fails, so I'm happy to split off into another ticket if you'd prefer?
I'm interested in helping you getting this working, but I don't think this is the appropriate forum for a bunch of back and forth. Drop me an email at jcwren@gmail.com and we'll see what we can do.
My first suggestion would be a reduced test case. Strip out all the WiFi stuff, hardcode your license and EUIs, and let's see if that works.
Thanks, appreciate it, I'll do that shortly.
~Fwiw, if I strip everything back and hardcode the values, it works, so it's definitely something to do with the translation from JSON strings to the byte array needed for the uint8_t~
Actually, it doesn't.
I'm now using the code from the examples
directory and the keys from TTN and it's failing on the join.
This seems to be the same issue as #90. I have a license key and replaced that into the OTAA.ino file. After programming, the ESP32 is boot looping with the following output:
If the sentence from the README.md are relevant to PlatformIO, it is COMPLETELY unclear how it would be installed.
platformio.ini:
src/OTAA.ino: