Helium_otaa sketch (MCCI) fails to compile due to multiple definition

Hi everyone,

Im quite new to Arduino, so sorry in advance if it's an obvious fix.

Currently Im trying to get the helium_otaa sketch from the MCCI LoRaWAN Library to work on basically any ESP32 based board, but I always run into the same problem when verifying the code in the Arduino IDE:

c:/users/andre/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\andre\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.17/tools/sdk/esp32/lib\libpp.a(hal_mac.o): in function `hal_init':
(.text.hal_init+0x40): multiple definition of `hal_init'; 
C:\Users\andre\AppData\Local\Temp\arduino\sketches\D1BCD5F904FD40F866E10AFE4F63CCB9\libraries\MCCI_LoRaWAN_LMIC_library\hal\hal.cpp.o:
c:\Users\andre\Documents\Arduino\libraries\MCCI_LoRaWAN_LMIC_library\src\hal/hal.cpp:416: first defined here
collect2.exe: error: ld returned 1 exit status'

I also tried the Arduino Web Dev environment and VS Code with similar results. The problem is, that the first folder (D1BCD5F904FD40F866E10AFE4F63CCB9) is automatically created in the verification process and I cant delete the library, since it is included.

Copying the sketch into a different folder (not opening it directly from the library file) didn't work. Cloning the git repository into a separate folder also didn't.

The only modification in the sketch is this block here (changed the Appkey), which you are welcome to copy in case you dont have EUIs and a key laying around.

static const u1_t PROGMEM APPEUI[8]= {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}

// This should also be in little endian format, see above.
static const u1_t PROGMEM DEVEUI[8]= {0x21, 0x21, 0x29, 0x2A, 0x75, 0x49, 0x24, 0x3F};
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}

// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from the TTN console can be copied as-is.
static const u1_t PROGMEM APPKEY[16] = {0x34, 0x4C, 0x71, 0x49, 0x50, 0x30, 0xD3, 0xCF, 0x79, 0xB4, 0xF6, 0x10, 0x96, 0x87, 0xFA, 0xCF};
void os_getDevKey (u1_t* buf) {  memcpy_P(buf, APPKEY, 16);}

The board I chose is the Heltec Lora ESP32 V2, but as long as I can get any progress, I would be grateful.

If anyone encountered a similar problem and can point me in a direction, it would really help cause I'm kinda out of ideas right now.

Thanks in advance!

Hi @andrejg28. The developers of the "MCCI LoRaWAN LMIC library" are tracking this bug here:

They do suggest a workaround:

https://github.com/mcci-catena/arduino-lmic/issues/714#issuecomment-822051171

add #define hal_init LMICHAL_init in your LMIC project config or on the PlatformIO command line where you define other LMIC options

I'll provide instructions you can follow to perform that workaround:

  1. Open the file at the following path in any text editor:
    c:\Users\andre\Documents\Arduino\libraries\MCCI_LoRaWAN_LMIC_library\project_config\lmic_project_config.h
    
  2. Add the following line to the end of the file:
    #define hal_init LMICHAL_init
    
  3. Save the file.

Now compile your sketch again. This time the "multiple definition of hal_init'`" error should not occur.

Thanks I didnt see that! I will try it later and give an update :slight_smile:

The fix works for me. There is still an error when using PlatformIO, but I will just stick with Arduino IDE for now.

Thanks!

You are welcome. I'm glad it is working now.

Regards,
Per

Hi Andrej,
I am currently working on an open source board based on ESP32 an SX1276 to operate with Helium network for GNSS tracking, various sensors connections and so on. We can discuss our experience if you like. More information can be found here: HELIUM-SENSORS/H2S-Dev V1.1 at main · hobbyiot/HELIUM-SENSORS · GitHub

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.