diff --git a/sw/bootloader/src/init.c b/sw/bootloader/src/init.c index b475d3a..21a47ee 100644 --- a/sw/bootloader/src/init.c +++ b/sw/bootloader/src/init.c @@ -26,7 +26,7 @@ void init (init_tv_type_t tv_type, init_reset_type_t reset_type) { exception_enable_interrupts(); if ((error = sc64_set_config(CFG_ID_BOOTLOADER_SWITCH, false)) != SC64_OK) { - error_display("Command SET_CONFIG [BOOTLOADER_SWITCH] failed: %d", error); + error_display("Command CONFIG_SET [BOOTLOADER_SWITCH] failed: %d", error); } if (test_check()) { @@ -36,7 +36,8 @@ void init (init_tv_type_t tv_type, init_reset_type_t reset_type) { } void deinit (void) { - sc64_lock(); exception_disable_interrupts(); exception_disable_watchdog(); + + sc64_lock(); } diff --git a/sw/controller/src/cic.c b/sw/controller/src/cic.c index a676232..30511e1 100644 --- a/sw/controller/src/cic.c +++ b/sw/controller/src/cic.c @@ -12,6 +12,9 @@ typedef enum { } cic_region_t; +static bool cic_initialized = false; + + static void cic_irq_reset_falling (void) { led_clear_error(LED_ERROR_CIC); } @@ -65,18 +68,26 @@ void cic_set_dd_mode (bool enabled) { void cic_init (void) { - while (!rtc_is_initialized()); - cic_reset_parameters(); hw_gpio_irq_setup(GPIO_ID_N64_RESET, GPIO_IRQ_FALLING, cic_irq_reset_falling); } void cic_process (void) { + if (!cic_initialized) { + if (rtc_is_initialized()) { + cic_reset_parameters(); + cic_initialized = true; + } else { + return; + } + } + uint32_t cic_config_0 = fpga_reg_get(REG_CIC_0); if (cic_config_0 & CIC_INVALID_REGION_DETECTED) { cic_config_0 ^= CIC_REGION; - fpga_reg_set(REG_CIC_0, (cic_config_0 | CIC_INVALID_REGION_RESET)); + cic_config_0 |= CIC_INVALID_REGION_RESET; + fpga_reg_set(REG_CIC_0, cic_config_0); if (cic_config_0 & CIC_REGION) { rtc_set_region(REGION_PAL); diff --git a/sw/controller/src/rtc.c b/sw/controller/src/rtc.c index 99e251b..f3fa23a 100644 --- a/sw/controller/src/rtc.c +++ b/sw/controller/src/rtc.c @@ -200,8 +200,6 @@ static void rtc_init (void) { rtc_write(RTC_ADDRESS_SRAM_VERSION, (uint8_t *) (&settings_version), 4); rtc_write_settings(); } - - rtc_initialized = true; } @@ -275,6 +273,8 @@ void rtc_task (void) { rtc_read_region(); rtc_read_settings(); + rtc_initialized = true; + while (1) { if (rtc_time_pending) { rtc_time_pending = false;