Xtimer error with the latest release

There is a LoRaWAN Packet Sniffer project based on RIOT and STMicroelectronics (B-L072Z-LRWAN1) lora board

I decide to compile it and put it in a real board. My host is a debian 10 system. First I installed the recent RIOT OS (2022.01). It seems, there is problem with the xtimer/ztimer changes. My error messages is here, reffering to this problem:

janos@debian10:~/LoRa-Packet/b-l072z$ make
Building application "LoRa_Scanner" for "b-l072z-lrwan1" with MCU "stm32".
"make" -C /home/janos/RIOT/pkg/fatfs/ 
"make" -C /home/janos/RIOT/build/pkg/fatfs/source -f /home/janos/RIOT/Makefile.base MODULE=fatfs
/home/janos/LoRa-Packet/b-l072z/radio.c: In function '_file_start_thread':
/home/janos/LoRa-Packet/b-l072z/radio.c:170:27: error: request for member 'ticks32' in something not a structure or union
  start_time = xtimer_now().ticks32;
                           ^
/home/janos/LoRa-Packet/b-l072z/radio.c: In function 'processPacket':
/home/janos/LoRa-Packet/b-l072z/radio.c:323:35: error: request for member 'ticks32' in something not a structure or union
   uint32_t now_time = xtimer_now().ticks32;
                                   ^
make[1]: *** [/home/janos/RIOT/Makefile.base:146: /home/janos/LoRa-Packet/b-l072z/bin/b-l072z-lrwan1/application_LoRa_Scanner/radio.o] Error 1
make: *** [/home/janos/RIOT/Makefile.include:737: application_LoRa_Scanner.module] Error 2

After this I downloaded the previous RIOT system, this is the 2021-04 release. Agains this was successful compile the Sniffer project. Maybe, the easier solution is to change the code in the Sniffer program, but is it the real solution? t.janos , hg5apz

Xtimer uses ztimer_xtimer_compat now so the xtimer API is just a thin wrapper around ztimer. Ztimer will always expose a (virtual) 1 MHz timer, so the ticks were dropped.

There are two possible solutions:

  • Use xtimer_on_ztimer. This will use the old xtimer code but with Ztimer as a backend. This will cause some overhead
  • Use two different code paths if you want to be compatible with old RIOT versions:
#if RIOT_VERSION_CODE > RIOT_VERSION_NUM(2022, 4, 0, 0)
    uint32_t now_time = xtimer_now();
#else
    uint32_t now_time = xtimer_now().ticks32;
#endif