mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-26 17:53:59 -04:00
HAL_ChibiOS: enable RNG only for H7 based boards off for the rest by default
This commit is contained in:
parent
fc4d59c5a4
commit
f298ea406e
@ -610,7 +610,7 @@ void Util::uart_info(ExpandingString &str)
|
|||||||
*/
|
*/
|
||||||
bool Util::get_random_vals(uint8_t* data, size_t size)
|
bool Util::get_random_vals(uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
#ifdef RNG
|
#if HAL_USE_HW_RNG && defined(RNG)
|
||||||
size_t true_random_vals = stm32_rand_generate_nonblocking(data, size);
|
size_t true_random_vals = stm32_rand_generate_nonblocking(data, size);
|
||||||
if (true_random_vals == size) {
|
if (true_random_vals == size) {
|
||||||
return true;
|
return true;
|
||||||
@ -638,7 +638,7 @@ bool Util::get_random_vals(uint8_t* data, size_t size)
|
|||||||
*/
|
*/
|
||||||
bool Util::get_true_random_vals(uint8_t* data, size_t size, uint32_t timeout_us)
|
bool Util::get_true_random_vals(uint8_t* data, size_t size, uint32_t timeout_us)
|
||||||
{
|
{
|
||||||
#ifdef RNG
|
#if HAL_USE_HW_RNG && defined(RNG)
|
||||||
if (stm32_rand_generate_blocking(data, size, timeout_us)) {
|
if (stm32_rand_generate_blocking(data, size, timeout_us)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -255,7 +255,7 @@ void __late_init(void) {
|
|||||||
/*
|
/*
|
||||||
* Initialize RNG
|
* Initialize RNG
|
||||||
*/
|
*/
|
||||||
#ifdef RNG
|
#if HAL_USE_HW_RNG && defined(RNG)
|
||||||
rccEnableAHB2(RCC_AHB2ENR_RNGEN, 0);
|
rccEnableAHB2(RCC_AHB2ENR_RNGEN, 0);
|
||||||
RNG->CR |= RNG_CR_IE;
|
RNG->CR |= RNG_CR_IE;
|
||||||
RNG->CR |= RNG_CR_RNGEN;
|
RNG->CR |= RNG_CR_RNGEN;
|
||||||
|
@ -480,7 +480,7 @@ uint32_t stack_free(void *stack_base)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RNG
|
#if HAL_USE_HW_RNG && defined(RNG)
|
||||||
static bool stm32_rand_generate(uint32_t *val)
|
static bool stm32_rand_generate(uint32_t *val)
|
||||||
{
|
{
|
||||||
uint32_t error_bits = 0;
|
uint32_t error_bits = 0;
|
||||||
@ -548,4 +548,4 @@ unsigned int stm32_rand_generate_nonblocking(unsigned char* output, unsigned int
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifdef RNG
|
#endif // #if HAL_USE_HW_RNG && defined(RNG)
|
||||||
|
@ -132,7 +132,7 @@ uint32_t stack_free(void *stack_base);
|
|||||||
* Generates a block of random values, returns total values generated
|
* Generates a block of random values, returns total values generated
|
||||||
* if nonblocking, for blocking returns if successful or not
|
* if nonblocking, for blocking returns if successful or not
|
||||||
*/
|
*/
|
||||||
#ifdef RNG
|
#if HAL_USE_HW_RNG && defined(RNG)
|
||||||
bool stm32_rand_generate_blocking(unsigned char* output, unsigned int sz, uint32_t timeout_us);
|
bool stm32_rand_generate_blocking(unsigned char* output, unsigned int sz, uint32_t timeout_us);
|
||||||
unsigned int stm32_rand_generate_nonblocking(unsigned char* output, unsigned int sz);
|
unsigned int stm32_rand_generate_nonblocking(unsigned char* output, unsigned int sz);
|
||||||
#endif
|
#endif
|
||||||
|
@ -737,6 +737,13 @@ def write_mcu_config(f):
|
|||||||
for d in defines.keys():
|
for d in defines.keys():
|
||||||
v = defines[d]
|
v = defines[d]
|
||||||
f.write("#ifndef %s\n#define %s %s\n#endif\n" % (d, d, v))
|
f.write("#ifndef %s\n#define %s %s\n#endif\n" % (d, d, v))
|
||||||
|
else:
|
||||||
|
defines = {}
|
||||||
|
# enable RNG for all H7 chips
|
||||||
|
if mcu_series.startswith("STM32H7") and 'HAL_USE_HW_RNG' not in defines.keys():
|
||||||
|
f.write("#define HAL_USE_HW_RNG TRUE\n")
|
||||||
|
elif 'HAL_USE_HW_RNG' not in defines.keys():
|
||||||
|
f.write("#define HAL_USE_HW_RNG FALSE\n")
|
||||||
|
|
||||||
if get_config('PROCESS_STACK', required=False):
|
if get_config('PROCESS_STACK', required=False):
|
||||||
env_vars['PROCESS_STACK'] = get_config('PROCESS_STACK')
|
env_vars['PROCESS_STACK'] = get_config('PROCESS_STACK')
|
||||||
|
Loading…
Reference in New Issue
Block a user