STM32 new update error on RTC library

Platformio updated to the latest platform-ststm32 from a few days ago and now it does not work with RTC library (see error output bellow). What’s the problem and how should I solve it?

Thanks in advance

.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:77:17: error: 'HOUR_FORMAT_12' was not declared in this scope
   77 |       HOUR_12 = HOUR_FORMAT_12,
      |                 ^~~~~~~~~~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:78:17: error: 'HOUR_FORMAT_24' was not declared in this scope
   78 |       HOUR_24 = HOUR_FORMAT_24
      |                 ^~~~~~~~~~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:82:12: error: 'HOUR_AM' was not declared in this scope; did you mean 'HOUR_24'?
   82 |       AM = HOUR_AM,
      |            ^~~~~~~
      |            HOUR_24
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:83:12: error: 'HOUR_PM' was not declared in this scope; did you mean 'HOUR_24'?
   83 |       PM = HOUR_PM
      |            ^~~~~~~
      |            HOUR_24
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:87:28: error: 'OFF_MSK' was not declared in this scope
   87 |       MATCH_OFF          = OFF_MSK,                          // Never
      |                            ^~~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:88:28: error: 'SS_MSK' was not declared in this scope
   88 |       MATCH_SS           = SS_MSK,                           // Every Minute
      |                            ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:89:28: error: 'SS_MSK' was not declared in this scope
   89 |       MATCH_MMSS         = SS_MSK | MM_MSK,                  // Every Hour
      |                            ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:89:37: error: 'MM_MSK' was not declared in this scope
   89 |       MATCH_MMSS         = SS_MSK | MM_MSK,                  // Every Hour
      |                                     ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:90:28: error: 'SS_MSK' was not declared in this scope
   90 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day

.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:90:37: error: 'MM_MSK' was not declared in this scope
   90 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day
      |                                     ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:90:46: error: 'HH_MSK' was not declared in this scope
   90 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day
      |                                              ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:91:28: error: 'SS_MSK' was not declared in this scope
   91 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                            ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:91:37: error: 'MM_MSK' was not declared in this scope
   91 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                     ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:91:46: error: 'HH_MSK' was not declared in this scope
   91 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                              ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:91:55: error: 'D_MSK' was not declared in this scope
   91 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                                       ^~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:94:28: error: 'SS_MSK' was not declared in this scope
   94 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                            ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:94:37: error: 'MM_MSK' was not declared in this scope
   94 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                     ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:94:46: error: 'HH_MSK' was not declared in this scope
   94 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                              ^~~~~~
.pio\libdeps\genericSTM32F103RE\STM32duino RTC\src/STM32RTC.h:94:55: error: 'D_MSK' was not declared in this scope
   94 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,

What’s the platformio.ini and example code?

Before updating to v14, I could program STM32 board without any problem, today I made a change in one of my codes and I got this error, after that I checked the other codes and I found out that it has a problem with RTC library. I created an empty project and I just added STM32RTC library and I got the same error.

This is the platformio.ini code. Without any code just added RTC library in main.cpp.

[env:genericSTM32F103RE]
platform = ststm32
board_build.mcu = stm32f103ret6
framework = arduino
upload_protocol = serial
upload_speed = 115200
lib_deps =
	khoih.prog/TimerInterrupt_Generic@^1.5.0
	fmalpartida/LiquidCrystal@^1.5.0
	stm32duino/STM32duino RTC@^1.1.0

I downgraded ststm platform to version 13 and it works fine, but with version 14 I got this problem again.

platform = ststm32@13.0.0

How is it possible that this is working at all when you don’t have a board = ... line specified? You cannot just specify a mcu, there needs to be a board. Is this the full platformio..ini?

Yeah I found the problem. The version that is uploaded in the PlatformIO registry library is over 1 year old

grafik
whereas the real 1.1.0 was released 2 months ago, not last year. The version you’re getting with

lib_deps =
	khoih.prog/TimerInterrupt_Generic@^1.5.0
	stm32duino/STM32duino RTC@^1.1.0

is too old.

I will open an issue for this.

If you use

[env:genericSTM32F103RE]
platform = ststm32
board = genericSTM32F103RE
framework = arduino
upload_protocol = serial
upload_speed = 115200
lib_deps =
	khoih.prog/TimerInterrupt_Generic@^1.5.0
	fmalpartida/LiquidCrystal@^1.5.0
	https://github.com/stm32duino/STM32RTC/archive/refs/tags/1.1.0.zip

with the example STM32RTC sketch code

/*
  SimpleRTC

  This sketch shows how to configure the RTC and to display
  the date and time periodically

  Creation 12 Dec 2017
  by Wi6Labs
  Modified 03 Jul 2020
  by Frederic Pillon for STMicroelectronics

  This example code is in the public domain.

  https://github.com/stm32duino/STM32RTC
*/
#include <LiquidCrystal_I2C.h>
#include <STM32RTC.h>

/* Get the rtc object */
STM32RTC& rtc = STM32RTC::getInstance();

/* Change these values to set the current initial time */
const byte seconds = 0;
const byte minutes = 0;
const byte hours = 16;

/* Change these values to set the current initial date */
/* Monday 15th June 2015 */
const byte weekDay = 1;
const byte day = 15;
const byte month = 6;
const byte year = 15;

void setup()
{
  Serial.begin(9600);

  // Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
  // By default the LSI is selected as source.
  //rtc.setClockSource(STM32RTC::LSE_CLOCK);

  rtc.begin(); // initialize RTC 24H format

  // Set the time
  rtc.setHours(hours);
  rtc.setMinutes(minutes);
  rtc.setSeconds(seconds);

  // Set the date
  rtc.setWeekDay(weekDay);
  rtc.setDay(day);
  rtc.setMonth(month);
  rtc.setYear(year);

  // you can use also
  //rtc.setTime(hours, minutes, seconds);
  //rtc.setDate(weekDay, day, month, year);
}

void loop()
{
  // Print date...
  Serial.printf("%02d/%02d/%02d ", rtc.getDay(), rtc.getMonth(), rtc.getYear());

  // ...and time
  Serial.printf("%02d:%02d:%02d.%03d\n", rtc.getHours(), rtc.getMinutes(), rtc.getSeconds(), rtc.getSubSeconds());

  delay(1000);
}

you should get a successful compilation.

RAM:   [          ]   1.5% (used 988 bytes from 65536 bytes)
Flash: [          ]   3.5% (used 18104 bytes from 524288 bytes)
Building .pio\build\genericSTM32F103RE\firmware.bin
============= [SUCCESS] Took 6.16 seconds =============
1 Like

Issue at PlatformIO library registry has wrong version · Issue #50 · stm32duino/STM32RTC · GitHub has been opened.

1 Like

Thanks for your reply, you’re right. As far as I know in github you can delete a tag for a repository and add a new tag with the same ID. STM32Duino updated RTC library with the same tag as it was in the last year so that I suppose in this case we have to delete the library and download it manually or add repository URL just as you mentioned in order to see changes. Another thing that platformIO needs to check is the date of uploading library even if the tag is the same as it was, cause as you can see this tag updated multiple times but platformIO is downloading an old repository.
It’s better to open an issue in platformIO in github.

Well they nonchalantly said they wouldn’t re-publish the correct version, which is done by executing one command, so I asked @ivankravets to fix-up the wrong version from the PlatformIO library registry side ^-^.

1 Like

Please remove .pio folder from a project, run pio system prune -f command, and try to build project again.

Does it work now?

1 Like

I removed .pio folder and used this command as you mentioned but I still got the same error with v14.0 of platform-ststm32. I can still use v13.0 without any problem.

Not reproducable. Using

[env:genericSTM32F103RE]
platform = ststm32
board = genericSTM32F103RE
framework = arduino
upload_protocol = serial
upload_speed = 115200
lib_deps =
	khoih.prog/TimerInterrupt_Generic@^1.5.0
	fmalpartida/LiquidCrystal@^1.5.0
    stm32duino/STM32duino RTC @ ^1.1.0

and

#include <LiquidCrystal_I2C.h>
#include <STM32RTC.h>

/* Get the rtc object */
STM32RTC& rtc = STM32RTC::getInstance();

/* Change these values to set the current initial time */
const byte seconds = 0;
const byte minutes = 0;
const byte hours = 16;

/* Change these values to set the current initial date */
/* Monday 15th June 2015 */
const byte weekDay = 1;
const byte day = 15;
const byte month = 6;
const byte year = 15;

void setup()
{
  Serial.begin(9600);

  // Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
  // By default the LSI is selected as source.
  //rtc.setClockSource(STM32RTC::LSE_CLOCK);

  rtc.begin(); // initialize RTC 24H format

  // Set the time
  rtc.setHours(hours);
  rtc.setMinutes(minutes);
  rtc.setSeconds(seconds);

  // Set the date
  rtc.setWeekDay(weekDay);
  rtc.setDay(day);
  rtc.setMonth(month);
  rtc.setYear(year);

  // you can use also
  //rtc.setTime(hours, minutes, seconds);
  //rtc.setDate(weekDay, day, month, year);
}

void loop()
{
  // Print date...
  Serial.printf("%02d/%02d/%02d ", rtc.getDay(), rtc.getMonth(), rtc.getYear());

  // ...and time
  Serial.printf("%02d:%02d:%02d.%03d\n", rtc.getHours(), rtc.getMinutes(), rtc.getSeconds(), rtc.getSubSeconds());

  delay(1000);
}

the result is

PLATFORM: ST STM32 (14.0.0) > STM32F103RE (64k RAM. 512k Flash)
HARDWARE: STM32F103RET6 72MHz, 64KB RAM, 512KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
 - framework-arduinoststm32 4.20000.210603 (2.0.0)
 - framework-cmsis 2.50700.210515 (5.7.0)
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 13 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <TimerInterrupt_Generic> 1.6.0
|-- <LiquidCrystal> 1.5.0
|   |-- <Wire> 1.0
|-- <STM32duino RTC> 1.1.0
Building in release mode
Compiling .pio\build\genericSTM32F103RE\FrameworkArduinoVariant\PeripheralPins.c.o
[..]
Linking .pio\build\genericSTM32F103RE\firmware.elf
Checking size .pio\build\genericSTM32F103RE\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.5% (used 988 bytes from 65536 bytes)
Flash: [          ]   3.5% (used 18104 bytes from 524288 bytes)
Building .pio\build\genericSTM32F103RE\firmware.bin
============= [SUCCESS] Took 11.17 seconds =============

Make sure the platform, framework and library version match what’s in my build log above.

I have checked my projects in which I’ve used RTC library and as Ivan mentioned I used pio system prune -f command in terminal, I removed .pio folder of each projects and rebuilt them again, all of them except one were fixed.
In this project I’ve used multiple cpp files and this project had Clock.cpp, Clock.h files and all of RTC functions were in Clock.cpp. Whenever I rebuilt this project I got the same error.
I removed RTC library and deleted Clock.cpp and Clock.h files from the project and the error disappeared. I created another cpp file for RTC functions with this name (RTC_Clock.cpp), added RTC library and rebuilt the project. I found out there was a confliction in names of files and I suppose Clock.cpp is a part of RTC library.
I don’t know how ststm v13 could build this project.