DISCO-L072CZ-LRWAN1 ST demo code

Hi all,

I’ve been working on ST demo code for the disco_l072cz_lrwan1, however I can not get it to compile…
The project is quite messy and I wanted to make it work first before removing all the useless stuff bit by bit. At the moment I just dumped everything into the pio root project folder and indicated file location to the compiler using build_flags.
The error appears during the linking stage:

CONFIGURATION: Redirecting...
PLATFORM: ST STM32 (15.6.0) > ST DISCO-L072CZ-LRWAN1
HARDWARE: STM32L0XX 32MHz, 20KB RAM, 192KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:

  • toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Linking .pio\build\disco_l072cz_lrwan1\firmware.elf
    .pio\build\disco_l072cz_lrwan1\src\LoRaWAN\App\src\main.o: In function OnledEvent': main.c:(.text.OnledEvent+0x4): undefined reference to TimerStart’
    .pio\build\disco_l072cz_lrwan1\src\LoRaWAN\App\src\main.o: In function OnTxDone': main.c:(.text.OnTxDone+0x10): undefined reference to TraceSend’
    main.c:(.text.OnTxDone+0x18): undefined reference to Radio' .pio\build\disco_l072cz_lrwan1\src\LoRaWAN\App\src\main.o: In function OnTxTimeout’:
    main.c:(.text.OnTxTimeout+0x10): undefined reference to `TraceSend’

    collect2.exe: error: ld returned 1 exit status
    *** [.pio\build\disco_l072cz_lrwan1\firmware.elf] Error 1

I have reduced the number of error lines to maintain readability, but you get the idea, compiler seems unable to find some variables/functions during the linking stage.

Here is my platformio.ini configuration, if it is of any help:

[env:disco_l072cz_lrwan1]
build_flags =
    -D USE_STM32L0XX_NUCLEO
    -D USE_BAND_868
    -D USE_MODEM_LORA
    -I src/LoRaWAN/App/inc
    -I src/Core/inc
    -I Drivers/STM32L0xx_HAL_Driver/Inc
    -I Drivers/STM32L0xx_HAL_Driver/Src
    -I Drivers/CMSIS/Device/ST/STM32L0xx/Include
    -I Drivers/CMSIS/Device/ST/STM32L0xx/Source
    -I Drivers/CMSIS/Include
    -I Drivers/CMSIS/Source
    -I Drivers/BSP/STM32L0xx_Nucleo
    -I Middlewares/Third_Party/LoRaWAN/Utilities
    -I Middlewares/Third_Party/LoRaWAN/Phy
platform = ststm32
board_build.mcu = STM32L0xx
board = disco_l072cz_lrwan1
extra_scripts = add_nanolib.py

Can any of you point me in the right direction to solve this ?

Thanks in advance,

Well, in which C file are those functions defined?

TimerStart
TraceSend

hard to say without seeing the code.

Thanks for your response.
Both are defined in separated files that are inclued in the main.

An example with TimerStart() which is implemented in the timeServer.h/.c files:

#include "timeServer.h"
// a lot of stuff here

static void OnledEvent(void)
{
  LED_Toggle(LED_BLUE);
  LED_Toggle(LED_RED1);
  LED_Toggle(LED_RED2);
  LED_Toggle(LED_GREEN);

  TimerStart(&timerLed);
}

As there are several errors of the this type, It looks to me like it’s a compiler/platformio configuration issue.

This is the usage point of a function, but where is its definition?

in a separate file named timeServer.h/.c:

in .c
void TimerStart( TimerEvent_t *obj )
{
// some stuff
}

in .h

void TimerStart(TimerEvent_t *obj);

The path to both these file is given to the compiler with the following build_flag:

-I Middlewares/Third_Party/LoRaWAN/Utilities

Only sources in src/ and lib/<subfolder> are built. If they aren’t in there, they won’t be contributing to the generated object files at all, and will all miss their implementations.

Put the middlewares in one of these places.

ooh I’ve been noobed once again…
Okay thanks for the help, it’s all good now !