RTEMS_SYSINIT_ITEM not working sometimes?

Karel Gardas karel at functional.vision
Fri Jun 30 22:41:21 UTC 2023


   Hello,

while working on STM32H7 I've noticed that rng is not working well. 
Tracked that down to stm32h7_rng_enable function not being properly 
called as it should be. The function call should be enforced by:

RTEMS_SYSINIT_ITEM(
   stm32h7_rng_enable,
   RTEMS_SYSINIT_DEVICE_DRIVERS,
   RTEMS_SYSINIT_ORDER_LAST_BUT_5
);

but it is not. The problematic code is here: 
https://git.rtems.org/rtems/tree/bsps/arm/stm32h7/start/getentropy-rng.c

So far it looks like linker is GCing whole file. The only workaround for 
the issue which I've found so far is to add some "hook" function in the 
file and call that hook from BSP starting code. This way linker is 
enforced to link the file in and then RTEMS_SYSININT_ITEM is correctly 
doing its business.

I'm using following tool-chain:

gcc version 12.2.1 20230224 (RTEMS 6, RSB 
7153c2f1dcfb83b154b976298699c26e793a33dd, Newlib 17ac400) (GCC)

GNU assembler version 2.40 (arm-rtems6) using BFD version (GNU Binutils) 
2.40

GNU ld (GNU Binutils) 2.40

I'm using following configuration of the testing app:

#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_MAXIMUM_TASKS            1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_VERBOSE_SYSTEM_INITIALIZATION
#define CONFIGURE_INIT
#include <rtems/confdefs.h>


Since RTEMS_SYSINIT_ITEM & Co. are used quite a lot thorough source code 
I cannot believe that just H7 BSP is that unlucky to be hit by this issue.

Has anybody seeing similar behavior? Or am I doing anything stupid?

Thanks!
Karel


More information about the devel mailing list