Skip to content

Commit

Permalink
fix usage of RNG before setup
Browse files Browse the repository at this point in the history
  • Loading branch information
keepkeyjon committed Feb 19, 2018
1 parent 4531790 commit e4fc493
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions keepkey/local/baremetal/keepkey_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ static void screen_test(void)
*/
int main(void)
{
/* Init board */
board_init();

/* Init for safeguard against stack overflow (-fstack-protector-all) */
__stack_chk_guard = (uintptr_t)random32();

/* Init board */
board_init();
led_func(SET_RED_LED);
dbg_print("Application Version %d.%d.%d\n\r", MAJOR_VERSION, MINOR_VERSION,
PATCH_VERSION);
Expand Down
6 changes: 6 additions & 0 deletions keepkey_board/local/baremetal/keepkey_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include "keepkey_board.h"

#include "rng.h"

/* === Variables =========================================================== */

/* Stack smashing protector (SSP) canary value storage */
Expand Down Expand Up @@ -99,6 +101,10 @@ void reset_rng(void)
RNG_CR |= RNG_CR_IE | RNG_CR_RNGEN;
/* this delay is required before rng data can be read */
delay_us(5);

// to be extra careful and heed the STM32F205xx Reference manual, Section 20.3.1
// we don't use the first random number generated after setting the RNGEN bit in setup
random32();
}

/*
Expand Down

0 comments on commit e4fc493

Please sign in to comment.