Heltec LORAWAN build error

Having issues with a Heltec board trying to build and upload a basic example.
I’m getting the following error?

   Linking .pio\build\heltec_wireless_stick\firmware.elf
.pio\build\heltec_wireless_stick\lib166\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_wireless_stick\lib166\libESP32_LoRaWAN.a(rtc-board.S.o): In function `TimerGetElapsedAlarmTime':
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_wireless_stick\lib166\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_wireless_stick\firmware.elf] Error 1

This is whats in my .ini file.

[env:heltec_wireless_stick]

platform = espressif32

board = heltec_wireless_stick

framework = arduino

monitor_speed = 115200

Any ideas
Thanks
~Bob

Hi there! I am facing the same issue. Did you get it solved?

Cheers

Can you upload the exact project (platformio.ini and code) that reproduces this problem?

Sure.

This is my platformio.ini file:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:heltec_wireless_stick]
platform = espressif32
board = heltec_wireless_stick
framework = arduino
monitor_speed = 115200
lib_deps = 
	heltecautomation/Heltec ESP32 Dev-Boards@^1.1.1
	heltecautomation/ESP32_LoRaWAN@^2.1.1
build_flags = 
	-D REGION_EU868
	-D ACTIVE_REGION=LORAMAC_REGION_EU868
	-D LoRaWAN_DEBUG_LEVEL=0

And ESP32_LoRaWAN/OTAA.ino at master · HelTecAutomation/ESP32_LoRaWAN · GitHub is your src/code?

Exactly. I am just using the example code.

Indeed, I’m getting the same behavior with all-updated versions.

Linking .pio\build\heltec_wireless_stick\firmware.elf
.pio\build\heltec_wireless_stick\lib815\libESP32_LoRaWAN.a(rtc-board.S.o): in function `TimerGetTimerValue':
D:\\61722\\Documents\\Arduino\\libraries\\ESP32_LoRaWAN_VASR\\src\/rtc-board.c:95:(.text.TimerGetTimerValue+0x27): dangerous relocation: call8: call target out of range: __udivdi3
.pio\build\heltec_wireless_stick\lib815\libESP32_LoRaWAN.a(rtc-board.S.o): in function `TimerGetElapsedAlarmTime':
D:\\61722\\Documents\\Arduino\\libraries\\ESP32_LoRaWAN_VASR\\src\/rtc-board.c:108:(.text.TimerGetElapsedAlarmTime+0x3a): dangerous relocation: call8: call target out of range: __udivdi3
.pio\build\heltec_wireless_stick\lib815\libESP32_LoRaWAN.a(rtc-board.S.o): in function `TimerComputeElapsedTime':
D:\\61722\\Documents\\Arduino\\libraries\\ESP32_LoRaWAN_VASR\\src\/rtc-board.c:135:(.text.TimerComputeElapsedTime+0x32): dangerous relocation: call8: call target out of range: __udivdi3
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\heltec_wireless_stick\firmware.elf] Error 1
============================================= [FAILED] Took 15.54 seconds =============================================

Problem is, it stems from a proecompiled library libESP32_LoRaWAN.a and that cannot be easily recompiled or fixed up – not sure what to do here. Maybe moving the target call site closer to the library. But that requires a bit of magic. No, PlatformIO compiles this library, the source is at ESP32_LoRaWAN/rtc-board.S at master · HelTecAutomation/ESP32_LoRaWAN · GitHub. It likely needs to be compiled / linked with -mlongcalls or needs a slight assembly modifications with those four call8 __udivdi3 lines.

Well I can get it to compile by following the Xtensa Call Relaxation (Using as) instructions.

Use

[env:heltec_wireless_stick]
platform = espressif32
board = heltec_wireless_stick
framework = arduino
monitor_speed = 115200
lib_deps = 
	heltecautomation/Heltec ESP32 Dev-Boards@^1.1.1
	https://github.com/maxgerhardt/ESP32_LoRaWAN.git
build_flags = 
	-D REGION_EU868
	-D ACTIVE_REGION=LORAMAC_REGION_EU868
	-D LoRaWAN_DEBUG_LEVEL=0

instead. Does it build now? Does it work or crash?

See Hotfix linker error by maxgerhardt · Pull Request #83 · HelTecAutomation/ESP32_LoRaWAN · GitHub

1 Like

Did that work? ------