I have an STM32G071 running FreeRTOS CMSIS v2 compiled with STM32CubeIDE. In one of the threads I want to generate a pseudo-random number. (I don’t need anything sophisticated and the STM32G071 doesn’t have an RNG anyway; pseudo-random is absolutely fine for my purposes).
If I call rand() or random() from anywhere in main() before I call osKernelStart(), all is well but if I call rand() or random() from anywhere within a thread they return 0.
I can call rand() or random() in a thread if I call srand(), srandom(), rand() or random() from main before I start the kernel.
As far as I can tell, it doesn’t matter which function so long as something calls one of those functions before attempting to call rand() or random() from a thread.
Why would I have to do that?