uTasker / uTasker-Kinetis

uTasker V1.4.11 based open source version for Kinetis and STM32 parts
60 stars 35 forks source link

FRDM_KL25Z: hard fault in fnInitialiseRND() #12

Open ned-pcs opened 2 years ago

ned-pcs commented 2 years ago

The dereference of ptrSeed in line 603 of Hardware/Kinetis/kinetis.c causes a hard fault when built for the FRDM_KL25Z (which does not have RNG hardware), because ptrSeed is 0.

In Hardware/STM32/STM32.c, ptrSeed is initialized to point to RANDOM_SEED_LOCATION, but it isn't initialized that way in Hardware/Kinetis/kinetis.c.

uTasker commented 2 years ago

Hi The flow (for Kinetis parts that don't have RNG):

  1. unsigned short *ptrSeed; This is a global variable that is initailised to 0 (which is what you are seeing)

  2. Immediately after main() is called fnInitHW() is executed and in this function there is (line 793 of kinetis.c) static unsigned short usRandomSeed = 0; ptrSeed = &usRandomSeed;

which means that ptrSeed is set to point to the address of usRandomSeed and is no longer 0.

Therefore I don't see that it fail due to a null pointer at line 603 of kinetis.c.

I didn't experience this issue and also haven't heard of it being a problem. Which compiler is used? (IAR has a slightly different startup flow but the same is essentially true). Can you see whether ptrSeed is being initialised before it hard faults? If it is does it get overwritten back to 0 again?