The same MCCI ABP example works in Arduino IDE but not in Platformio

Hello, guys.

I’m trying to run an ABP example using PlatformIO + VS Code, but I’m getting an error about the lmic_pins. The pins configuration used for a heltec lora v2 is:

const lmic_pinmap lmic_pins = {
.nss = 18, // chip select on feather (rf95module) CS
.rxtx = LMIC_UNUSED_PIN,
.rst = 14, // reset pin
.dio = {26, 35,34},
};

FAILURE
.pio\libdeps\heltec_wifi_kit_32_v2\MCCI LoRaWAN LMIC library\src\lmic\oslmic.c:53
This happens on was called the function os_init.

void os_init() {
if (os_init_ex((const void *)&lmic_pins))
return;
ASSERT(0);
}

The same code works fine in Arduino IDE. Both are using the version 4.1.0 (I tried 4.1.1).
I also add the build_flags as the documentation recommended:

build_flags =
; Use platformio.ini for settings instead lmic_project_config.h.
-D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS
-D DISABLE_PING
-D DISABLE_BEACONS
-D LMIC_DEBUG_LEVEL=2 ; 0, 1 or 2
-D CFG_sx1276_radio=1 ; Use for SX1276 radio
-D CFG_au915=1

Thanks,
Mateus Maruzka

I found the error. The platformio doesn’t get correct header pins_arduino.h for the Heltec Wifi V2. So, when I call os_init(), LMIC gets the wrong miso and mosi pins. I checked my configuration file and it was OK.

I don’t know how to fix this properly, so I added before calling os_init() SPI.begin() with the right values.