Errors with "ESP32_LoRaWAN" library working with PlatformIO

Hello everybody,
I have got 2 WiFi LoRa 32 (V2) Notes. I use platform IO (PIO) with Visual Studio Code to program the notes.
Until now I always used the LMIC library for communication with TTN. I wanted to to switch to the ESP_LoRaWAN library of Heltec. The library is available in the library Manager of PIO. Just trying to find how everything works a used one of the provided sample sketches (OTAA).
When compiling it gives several errors, of with some of them I was able to solve

I’m stuck with these last errors. I hope someone can help me solve them.

.pio\build\heltec_wifi_lora_32_V2\lib9b9\libESP32_LoRaWAN.a(rtc-board.S.o): In function TimerGetTimerValue': D:\61722\Documents\Arduino\hardware\heltec\esp32\libraries\ESP32_LoRaWAN\src/rtc-board.c:120:(.text.TimerGetTimerValue+0x31): dangerous relocation: call8: call target out of range: __udivdi3 .pio\build\heltec_wifi_lora_32_V2\lib9b9\libESP32_LoRaWAN.a(rtc-board.S.o): In functionTimerGetElapsedAlarmTime’:
D:\61722\Documents\Arduino\hardware\heltec\esp32\libraries\ESP32_LoRaWAN\src/rtc-board.c:120:(.text.TimerGetElapsedAlarmTime+0x32): dangerous relocation: call8: call target out of range: __udivdi3
.pio\build\heltec_wifi_lora_32_V2\lib9b9\libESP32_LoRaWAN.a(rtc-board.S.o): In function `TimerComputeElapsedTime’:
D:\61722\Documents\Arduino\hardware\heltec\esp32\libraries\ESP32_LoRaWAN\src/rtc-board.c:134:(.text.TimerComputeElapsedTime+0x32):
dangerous relocation: call8: call target out of range: __udivdi3
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\heltec_wifi_lora_32_V2\firmware.elf] Error 1

Below are the files and modifications I a made to solve other errors.

[platformio.ini]
[env:heltec_wifi_lora_32_V2]
platform = espressif32
board = heltec_wifi_lora_32_V2
framework = arduino
monitor_speed = 115200

lib_deps =

Using a library name

ESP32_LoRaWAN

[Main.cpp]
/*

  • HelTec Automation™ LoRaWAN 1.0.2 OTAA example use OTAA, CLASS A
  • Function summary:
    • use internal RTC(15KHz);
    • Include stop mode and deep sleep mode;
    • 60S data send cycle;
    • Informations output via serial(115200);
    • Debug log message can be configed in board.h(DebugLevel);
    • Only ESP32 + LoRa series boards can use this library, need a license
  • to make the code run(check you license here:
  • You can change some definition in “Commissioning.h” and “LoRaMac-definitions.h”
  • HelTec AutoMation, Chengdu, China.
  • 成都惠利特自动化科技有限公司

*this project also release in GitHub:
*https://github.com/HelTecAutomation/ESP32_LoRaWAN
*/

#include “Arduino.h”
#include “board.h”
#include “LoRaMac.h”
#include “Commissioning.h”
#include <SPI.h>
#include <LoRa.h>
#include <Mcu.h>

*// start added to the example *
#define V2
#define CLASS CLASS_A
// end added

#define SCK 5 // GPIO5 – SX127x’s SCK
#define MISO 19 // GPIO19 – SX127x’s MISO
#define MOSI 27 // GPIO27 – SX127x’s MOSI
#define SS 18 // GPIO18 – SX127x’s CS
#define RST 14 // GPIO14 – SX127x’s RESET
#define DIO0 26 // GPIO26 – SX127x’s IRQ(Interrupt Request)
#define DIO1 35 // GPIO33 – SX127x’s IRQ(Interrupt Request)

// I changed the licence key for my own one, not printed here
uint32_t LICENSE[4] = {0xDD251C39,0x44C5F937,0xBB160873,0x072EB7C8};

void setup()
{
// Add your initialization code here
Serial.begin(115200);
while (!Serial);
SPI.begin(SCK,MISO,MOSI,SS);
Mcu.begin(SS,RST,DIO0,DIO1,LICENSE);
DeviceState = DEVICE_STATE_INIT;
}

// The loop function is called in an endless loop
void loop()
{
switch( DeviceState )
{
case DEVICE_STATE_INIT:
{
LoRa.DeviceStateInit(CLASS); // Added “CLASS” between the brackets
if(IsLoRaMacNetworkJoined==false)
{DeviceState = DEVICE_STATE_JOIN;}
else
{DeviceState = DEVICE_STATE_SEND;}
break;
}
case DEVICE_STATE_JOIN:
{
LoRa.DeviceStateJion();
break;
}
case DEVICE_STATE_SEND:
{
lora_printf(“Into send state\n”);
PrepareTxFrame( AppPort );
LoRa.DeviceStateSend();
DeviceState = DEVICE_STATE_CYCLE;
break;
}
case DEVICE_STATE_CYCLE:
{
// Schedule next packet transmission
TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
TimerStart( &TxNextPacketTimer );
DeviceState = DEVICE_STATE_SLEEP;
break;
}
case DEVICE_STATE_SLEEP:
{
//LoRa.DeviceSleep(IsLowPowerOn,DebugLevel); --> original
LoRa.DeviceSleep(CLASS,DebugLevel); // -> modified

  break;
}
default:
{
  DeviceState = DEVICE_STATE_INIT;
  break;
}

}
}

[sx1276.c]
line 236: static void RxChainCalibration( void ) // removed static

[sx1276.h]
line 469: static void RxChainCalibration( void ) // removed static

sorry. We currently do not provide PIO support for ESP32

That’s a disappointing answer and a bit strange, because the ESP32_LoRawan library is available as one of the standard libraries in PIO.


Also is the Heltec Wifi Lora 32 (v2) one of the available boards in PIO

Or do I misunderstand you?

hi,

This is developed by our customers. We did not participate in the development.

Check on GitHub Waldmensch1 Git. There is a repo for a TTN Mapper for TTGO T-Beam and Heltec Wireless Stick. You just have to define the Target in PIO.ini

Thank you for your response, I will look at is.
For the moment I’ve switched to TTN_esp32 library from manuelbl on Git.
It solved my problems trying to combine otaa activation and the use of deep sleep to save power