From 9c6931a17cb2bf9b5d5b26f20a33f1d60398314c Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sat, 21 Mar 2020 22:28:50 +0200 Subject: [PATCH] Bugfixes The fan driver change ensures power off in any situation where a chainload software re-enables the 5V regulator. --- bootloader/main.c | 2 +- bootloader/storage/nx_emmc.c | 2 +- nyx/nyx_gui/frontend/fe_emmc_tools.c | 2 ++ nyx/nyx_gui/nyx.c | 4 +--- nyx/nyx_gui/storage/nx_emmc.c | 2 +- nyx/nyx_gui/thermal/fan.c | 8 +++++++- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bootloader/main.c b/bootloader/main.c index 583a512..9abd4e4 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -1317,7 +1317,7 @@ void ipl_main() heap_init(IPL_HEAP_START); #ifdef DEBUG_UART_PORT - uart_send(DEBUG_UART_PORT, (u8 *)"Hekate: Hello!\r\n", 16); + uart_send(DEBUG_UART_PORT, (u8 *)"hekate: Hello!\r\n", 16); uart_wait_idle(DEBUG_UART_PORT, UART_TX_IDLE); #endif diff --git a/bootloader/storage/nx_emmc.c b/bootloader/storage/nx_emmc.c index c35177e..2cae846 100644 --- a/bootloader/storage/nx_emmc.c +++ b/bootloader/storage/nx_emmc.c @@ -31,7 +31,7 @@ void nx_emmc_gpt_parse(link_t *gpt, sdmmc_storage_t *storage) for (u32 i = 0; i < hdr->num_part_ents; i++) { gpt_entry_t *ent = (gpt_entry_t *)(buf + (hdr->part_ent_lba - 1) * NX_EMMC_BLOCKSIZE + i * sizeof(gpt_entry_t)); - emmc_part_t *part = (emmc_part_t *)malloc(sizeof(emmc_part_t)); + emmc_part_t *part = (emmc_part_t *)calloc(sizeof(emmc_part_t), 1); part->lba_start = ent->lba_start; part->lba_end = ent->lba_end; part->attrs = ent->attrs; diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 4ad4eff..0ce64d7 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -300,6 +300,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 sdFileSector += num; sparseShouldVerify++; + // Check for cancellation combo. btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP)) { @@ -660,6 +661,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t bytesWritten = 0; } + // Check for cancellation combo. btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP)) { diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index d4d2857..d7b0e60 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -400,8 +400,6 @@ void nyx_init_load_res() h_cfg.rcm_patched = fuse_check_patched_rcm(); } -extern void pivot_stack(u32 stack_top); - #if (LV_LOG_PRINTF == 1) #include "soc/clock.h" #include "soc/gpio.h" @@ -427,7 +425,7 @@ void ipl_main() clock_enable_uart(UART_B); uart_init(UART_B, 115200); - uart_send(UART_B, (u8 *)"Hekate-NYX: Hello!\r\n", 20); + uart_send(UART_B, (u8 *)"hekate-NYX: Hello!\r\n", 20); uart_wait_idle(UART_B, UART_TX_IDLE); #endif diff --git a/nyx/nyx_gui/storage/nx_emmc.c b/nyx/nyx_gui/storage/nx_emmc.c index 01bb694..b801f1a 100644 --- a/nyx/nyx_gui/storage/nx_emmc.c +++ b/nyx/nyx_gui/storage/nx_emmc.c @@ -30,7 +30,7 @@ void nx_emmc_gpt_parse(link_t *gpt, sdmmc_storage_t *storage) for (u32 i = 0; i < hdr->num_part_ents; i++) { gpt_entry_t *ent = (gpt_entry_t *)(buf + (hdr->part_ent_lba - 1) * NX_EMMC_BLOCKSIZE + i * sizeof(gpt_entry_t)); - emmc_part_t *part = (emmc_part_t *)malloc(sizeof(emmc_part_t)); + emmc_part_t *part = (emmc_part_t *)calloc(sizeof(emmc_part_t), 1); part->lba_start = ent->lba_start; part->lba_end = ent->lba_end; part->attrs = ent->attrs; diff --git a/nyx/nyx_gui/thermal/fan.c b/nyx/nyx_gui/thermal/fan.c index 7d3fe17..e2cfdcb 100644 --- a/nyx/nyx_gui/thermal/fan.c +++ b/nyx/nyx_gui/thermal/fan.c @@ -37,7 +37,6 @@ void set_fan_duty(u32 duty) PINMUX_AUX(PINMUX_AUX_CAM1_PWDN) = PINMUX_TRISTATE | PINMUX_INPUT_ENABLE | PINMUX_PULL_UP | 1; gpio_config(GPIO_PORT_S, GPIO_PIN_7, GPIO_MODE_GPIO); gpio_output_enable(GPIO_PORT_S, GPIO_PIN_7, GPIO_OUTPUT_DISABLE); - gpio_write(GPIO_PORT_S, GPIO_PIN_7, GPIO_LOW); PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (1 << 24); // Max PWM to disable fan. @@ -58,12 +57,19 @@ void set_fan_duty(u32 duty) { PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (1 << 24); // Bit 24 is absolute 0%. regulator_disable_5v(REGULATOR_5V_FAN); + + // Disable fan. + PINMUX_AUX(PINMUX_AUX_LCD_GPIO2) = + PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_TRISTATE | PINMUX_PULL_DOWN; // Set source to PWM1. } else // Set PWM duty. { // Fan power supply. regulator_enable_5v(REGULATOR_5V_FAN); PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (inv_duty << 16); + + // Enable fan. + PINMUX_AUX(PINMUX_AUX_LCD_GPIO2) = 1; // Set source to PWM1. } curr_duty = duty;