RTEMS_SYSINIT_ITEM not working sometimes?

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jul 3 07:13:28 UTC 2023


Hello Karel,

On 01.07.23 00:41, Karel Gardas wrote:
> 
>    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 linker garbage collection doesn't work on a file granularity. It 
operates with linker input section. This is why we use the 
-ffunction-sections and -fdata-sections GCC options.

> 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.

Do you use a custom linker command file? It is important that the KEEP() 
directive is used for the linker set:

KEEP (*(SORT(.rtemsroset.*)))

You can look at the linker map file to get more information about what 
is going on.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


More information about the devel mailing list