Skip to content

drivers: rtc: sam: Missing function rtc_sam_validate_tm #81454

@nandojve

Description

@nandojve

Describe the bug

The #64939 introduced a few convenience functions like rtc_utils_validate_rtc_time. However the PR did not replace all occurrences which result on a build error.

See

if (rtc_sam_validate_tm(timeptr, mask) == false) {

Expected behavior

  • Drivers should be build with all options that are available by Zephyr to detect problems like this.
  • No warning: implicit declaration of function 'rtc_utils_validate_rtc_time'
  • One Atmel SAM board should be added to test coverage.
  • Tests must build the drivers with all options enabled.

Impact
User can not build board and need search for a solution.

Logs and console output

Patch

diff --git a/boards/atmel/sam/sam4e_xpro/sam4e_xpro.dts b/boards/atmel/sam/sam4e_xpro/sam4e_xpro.dts
index 253d5ba48d1..e731302e694 100644
--- a/boards/atmel/sam/sam4e_xpro/sam4e_xpro.dts
+++ b/boards/atmel/sam/sam4e_xpro/sam4e_xpro.dts
@@ -22,6 +22,7 @@
                wdog = &wdt;
                watchdog0 = &wdt;
                sdhc0 = &hsmci;
+               rtc = &rtc;
        };
 
        chosen {
@@ -128,6 +129,10 @@
        clock-frequency = <120000000>;
 };
 
+&rtc {
+       status = "okay";
+};
+
 &afec0 {
        status = "okay";
 
diff --git a/drivers/rtc/rtc_sam0.c b/drivers/rtc/rtc_sam0.c

1- Default option

$> west build -b sam4e_xpro tests/drivers/rtc/rtc_api
...
/home/gfbudke/zephyr/mainline/zephyr/drivers/rtc/rtc_sam.c: In function 'rtc_sam_set_time':
/home/gfbudke/zephyr/mainline/zephyr/drivers/rtc/rtc_sam.c:99:13: warning: implicit declaration of function 'rtc_utils_validate_rtc_time' [-Wimplicit-function-declaration]
   99 |         if (rtc_utils_validate_rtc_time(timeptr, RTC_SAM_TIME_MASK) == false) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
[133/133] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       34797 B         1 MB      3.32%
             RAM:        5824 B       128 KB      4.44%
        IDT_LIST:          0 GB        32 KB      0.00%

2- With CONFIG_RTC_ALARM=y

$> west build -b sam4e_xpro tests/drivers/rtc/rtc_api -DCONFIG_RTC_ALARM=y
...
[128/135] Building C object zephyr/drivers/rtc/CMakeFiles/drivers__rtc.dir/rtc_sam.c.obj
/home/gfbudke/zephyr/mainline/zephyr/drivers/rtc/rtc_sam.c: In function 'rtc_sam_set_time':
/home/gfbudke/zephyr/mainline/zephyr/drivers/rtc/rtc_sam.c:99:13: warning: implicit declaration of function 'rtc_utils_validate_rtc_time' [-Wimplicit-function-declaration]
   99 |         if (rtc_utils_validate_rtc_time(timeptr, RTC_SAM_TIME_MASK) == false) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gfbudke/zephyr/mainline/zephyr/drivers/rtc/rtc_sam.c: In function 'rtc_sam_alarm_set_time':
/home/gfbudke/zephyr/mainline/zephyr/drivers/rtc/rtc_sam.c:361:13: warning: implicit declaration of function 'rtc_sam_validate_tm' [-Wimplicit-function-declaration]
  361 |         if (rtc_sam_validate_tm(timeptr, mask) == false) {
      |             ^~~~~~~~~~~~~~~~~~~
[130/135] Linking C executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /home/gfbudke/zephyr/mainline/zephyr/build/zephyr/zephyr_pre0.map 
: && ccache /home/gfbudke/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc  -gdwarf-4 -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/gfbudke/zephyr/mainline/zephyr/build/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/libarch__arm__core.a  zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a  zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a  zephyr/lib/libc/picolibc/liblib__libc__picolibc.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/subsys/testsuite/ztest/libsubsys__testsuite__ztest.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/rtc/libdrivers__rtc.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  zephyr/drivers/watchdog/libdrivers__watchdog.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L/home/gfbudke/zephyr/mainline/zephyr/build/zephyr  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfp16-format=ieee  -mtp=soft  -fuse-ld=bfd  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie  -specs=picolibc.specs  -DPICOLIBC_LONG_LONG_PRINTF_SCANF -L"/home/gfbudke/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp" -lc -lgcc && cd /home/gfbudke/zephyr/mainline/zephyr/build/zephyr && /usr/bin/cmake -E true
/home/gfbudke/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/rtc/libdrivers__rtc.a(rtc_sam.c.obj): in function `rtc_sam_alarm_set_time':
/home/gfbudke/zephyr/mainline/zephyr/drivers/rtc/rtc_sam.c:361: undefined reference to `rtc_sam_validate_tm'
/home/gfbudke/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/gfbudke/zephyr/mainline/zephyr/drivers/rtc/rtc_sam.c:361: undefined reference to `rtc_sam_validate_tm'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/gfbudke/zephyr/mainline/zephyr/build

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Latest
  • Commit: Mainline

Additional Information:

I recommend take a look on other drivers to avoid same miskate and ensure that no warnings are present.

CC: @bjarki-andreasen

Metadata

Metadata

Labels

area: RTCReal Time ClockbugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions