RPI4B bare metal RNG

74 views Asked by At

I am working on a bare metal operating system for the Raspberry Pi 4B, and have run into a bit of an issue. I need a random 64bit number to use as a guard value for the stack smashing protector. I have seen online that some chips used in other RPI models have "undocumented" random number generators, but have been unable to anything for the BCM2711 that the RPI4B uses. Any help is highly appreciated

TL;DR Need a way to generate random numbers on RPI4B in a bare metal enviroment

EDIT 1

Looking through circle's source code I came accros a file named "bcmrandom200.h" and its respective cpp file. Apparently there is a "RNG200" hardware random number generator mapped to address 0xFE104000. The header file defines addresses for some registers, namely:

  • RNG_CTRL (+0x0 from base address of RNG200)
  • RNG_TOTAL_BIT_COUNT (+0x0C)
  • RNG_TOTAL_BIT_COUNT_THRESHOLD (+0x10)
  • RNG_FIFO_DATA (+0x20)
  • RNG_FIFO_COUNT (+0x24)

I am not sure how to use this RNG200, and doing the same thing that is done in circle's source yields no results.

0

There are 0 answers