mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-13 19:18:56 +00:00
boardloader: issue 34 (#36)
This commit is contained in:
parent
61db821c7a
commit
ead626404b
@ -130,6 +130,7 @@ void check_and_jump(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
clear_peripheral_local_memory();
|
||||
periph_init();
|
||||
|
||||
if (0 != display_init()) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "display.h"
|
||||
#include "rng.h"
|
||||
|
||||
void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file, int line, const char *func) {
|
||||
for (volatile uint32_t delay = 0; delay < 10000000; delay++) {}
|
||||
@ -58,3 +59,12 @@ void hal_delay(uint32_t ms)
|
||||
{
|
||||
HAL_Delay(ms);
|
||||
}
|
||||
|
||||
void clear_peripheral_local_memory(void)
|
||||
{
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_OTGHSEN; // enable USB_OTG_HS peripheral clock so that the peripheral memory is accessible
|
||||
const uint32_t unpredictable = rng_get();
|
||||
memset_reg((volatile void *) USB_OTG_HS_DATA_FIFO_RAM, (volatile void *) (USB_OTG_HS_DATA_FIFO_RAM + USB_OTG_HS_DATA_FIFO_SIZE), unpredictable);
|
||||
memset_reg((volatile void *) USB_OTG_HS_DATA_FIFO_RAM, (volatile void *) (USB_OTG_HS_DATA_FIFO_RAM + USB_OTG_HS_DATA_FIFO_SIZE), 0);
|
||||
RCC->AHB1ENR &= ~RCC_AHB1ENR_OTGHSEN; // disable USB OTG_HS peripheral clock as the peripheral is not needed right now
|
||||
}
|
||||
|
@ -8,6 +8,13 @@
|
||||
#define FIRMWARE_START 0x08020000
|
||||
#define HEADER_SIZE 0x200
|
||||
|
||||
#define USB_OTG_HS_DATA_FIFO_RAM (USB_OTG_HS_PERIPH_BASE + 0x20000U) // reference RM0090 section 35.12.1 Figure 413
|
||||
#define USB_OTG_HS_DATA_FIFO_SIZE (4096U)
|
||||
|
||||
extern void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
|
||||
|
||||
void clear_peripheral_local_memory(void);
|
||||
|
||||
void periph_init(void);
|
||||
|
||||
void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file, int line, const char *func);
|
||||
|
Loading…
Reference in New Issue
Block a user