mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-28 22:15:42 +00:00
embed: more cleanup
This commit is contained in:
parent
7653eb699d
commit
7babde646e
@ -11,8 +11,19 @@
|
|||||||
#define IMAGE_MAGIC 0x425A5254 // TRZB
|
#define IMAGE_MAGIC 0x425A5254 // TRZB
|
||||||
#define IMAGE_MAXSIZE (1 * 64 * 1024 + 7 * 128 * 1024)
|
#define IMAGE_MAXSIZE (1 * 64 * 1024 + 7 * 128 * 1024)
|
||||||
|
|
||||||
void pendsv_isr_handler(void) {
|
#include STM32_HAL_H
|
||||||
__fatal_error("pendsv", __FILE__, __LINE__, __FUNCTION__);
|
|
||||||
|
// reference RM0090 section 35.12.1 Figure 413
|
||||||
|
#define USB_OTG_HS_DATA_FIFO_RAM (USB_OTG_HS_PERIPH_BASE + 0x20000U)
|
||||||
|
#define USB_OTG_HS_DATA_FIFO_SIZE (4096U)
|
||||||
|
|
||||||
|
void clear_otg_hs_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
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_sdcard(void)
|
bool check_sdcard(void)
|
||||||
@ -146,7 +157,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
__stack_chk_guard = rng_get();
|
__stack_chk_guard = rng_get();
|
||||||
|
|
||||||
clear_peripheral_local_memory();
|
clear_otg_hs_memory();
|
||||||
periph_init();
|
periph_init();
|
||||||
|
|
||||||
if (0 != display_init()) {
|
if (0 != display_init()) {
|
||||||
|
@ -17,11 +17,6 @@
|
|||||||
#define IMAGE_MAGIC 0x465A5254 // TRZF
|
#define IMAGE_MAGIC 0x465A5254 // TRZF
|
||||||
#define IMAGE_MAXSIZE (7 * 128 * 1024)
|
#define IMAGE_MAXSIZE (7 * 128 * 1024)
|
||||||
|
|
||||||
void pendsv_isr_handler(void)
|
|
||||||
{
|
|
||||||
__fatal_error("pendsv", __FILE__, __LINE__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
void display_vendor(const uint8_t *vimg, const char *vstr, uint32_t vstr_len, uint32_t fw_version)
|
void display_vendor(const uint8_t *vimg, const char *vstr, uint32_t vstr_len, uint32_t fw_version)
|
||||||
{
|
{
|
||||||
display_clear();
|
display_clear();
|
||||||
|
@ -86,6 +86,10 @@ void __attribute__((noreturn)) nlr_jump_fail(void *val) {
|
|||||||
__fatal_error("uncaught exception", NULL, 0, NULL);
|
__fatal_error("uncaught exception", NULL, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PendSV_Handler(void) {
|
||||||
|
pendsv_isr_handler();
|
||||||
|
}
|
||||||
|
|
||||||
// MicroPython file I/O stubs
|
// MicroPython file I/O stubs
|
||||||
|
|
||||||
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
||||||
|
@ -62,15 +62,3 @@ void hal_delay(uint32_t ms)
|
|||||||
{
|
{
|
||||||
HAL_Delay(ms);
|
HAL_Delay(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
#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)
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
extern void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
|
extern void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
|
||||||
|
|
||||||
void clear_peripheral_local_memory(void);
|
|
||||||
|
|
||||||
void periph_init(void);
|
void periph_init(void);
|
||||||
|
|
||||||
void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file, int line, const char *func);
|
void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file, int line, const char *func);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include STM32_HAL_H
|
#include STM32_HAL_H
|
||||||
|
|
||||||
#include "pendsv.h"
|
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
|
|
||||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||||
@ -37,10 +36,6 @@ void SystemInit(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendSV_Handler(void) {
|
|
||||||
pendsv_isr_handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SysTick_Handler(void) {
|
void SysTick_Handler(void) {
|
||||||
// Instead of calling HAL_IncTick we do the increment here of the counter.
|
// Instead of calling HAL_IncTick we do the increment here of the counter.
|
||||||
// This is purely for efficiency, since SysTick is called 1000 times per
|
// This is purely for efficiency, since SysTick is called 1000 times per
|
||||||
@ -69,4 +64,3 @@ void SysTick_Handler(void) {
|
|||||||
// dma_idle_handler(uwTick);
|
// dma_idle_handler(uwTick);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user