Sometime we may need to generate random number in SBL3, for example we may need a random number generator for burning the secondary HW key.
Normally we use the C standard library function rand() to generate a random number, and to get non repeating random numbers, we usually calls the srand (time(NULL)) to initialize the random number generator, but unfortunately the time(NULL) doesn't work in SBL3.
Since the RPM's timer0, timer1 and MPM timer is started running when device running the SBL3, so we can use those timers to initialize the random number generator, below is the example which use the MPM timer to initialize the random number generator in SBL3
a.. srand (HWIO_IN(TIMETICK_CLK));
b.. random_number = rand();
No comments:
Post a Comment