From 1f5b3716083c8622b5a07c64eb7c386818db7e0b Mon Sep 17 00:00:00 2001 From: CTCaer Date: Fri, 23 Oct 2020 06:32:24 +0300 Subject: [PATCH] Refactor some names Additionally: - Do not retry to init sd if all modes failed in Nyx. - Do not try to read/write if sdmmc controller and card are not initialized. --- bdk/gfx/di.c | 7 ++++--- bdk/gfx/di.inl | 41 +++++++++++++++++++++++++++++-------- bdk/storage/sdmmc.c | 17 ++++++++++++++- bdk/storage/sdmmc.h | 1 + bdk/storage/sdmmc_driver.c | 18 +++++++--------- bdk/usb/usb_descriptors.h | 2 +- bdk/usb/usb_t210.h | 2 +- bdk/usb/usbd.c | 35 ++++++++++++++++--------------- bdk/usb/usbd.h | 2 +- bdk/utils/util.h | 2 +- bootloader/main.c | 12 +++++------ nyx/nyx_gui/nyx.c | 2 +- nyx/nyx_gui/storage/nx_sd.c | 2 +- 13 files changed, 91 insertions(+), 52 deletions(-) diff --git a/bdk/gfx/di.c b/bdk/gfx/di.c index 692daa3..f95e288 100644 --- a/bdk/gfx/di.c +++ b/bdk/gfx/di.c @@ -56,7 +56,7 @@ static void _display_dsi_send_cmd(u8 cmd, u32 param, u32 wait) void display_init() { // Check if display is already initialized. - if (CLOCK(CLK_RST_CONTROLLER_CLK_ENB_L_SET) & 0x18000000) + if (CLOCK(CLK_RST_CONTROLLER_CLK_ENB_L_SET) & (BIT(CLK_L_DISP1) | BIT(CLK_L_HOST1X))) display_end(); // Power on. @@ -180,14 +180,15 @@ void display_init() _display_dsi_send_cmd(MIPI_DSI_DCS_SHORT_WRITE, MIPI_DCS_SET_DISPLAY_ON, 20000); // Configure PLLD for DISP1. - plld_div = (1 << 20) | (24 << 11) | 1; // DIVM: 1, DIVN: 24, DIVP: 1. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 460.8 MHz. + plld_div = (1 << 20) | (24 << 11) | 1; // DIVM: 1, DIVN: 24, DIVP: 1. PLLD_OUT: 768 MHz, PLLD_OUT0 (DSI): 230.4 MHz. CLOCK(CLK_RST_CONTROLLER_PLLD_BASE) = PLLCX_BASE_ENABLE | PLLCX_BASE_LOCK | plld_div; CLOCK(CLK_RST_CONTROLLER_PLLD_MISC1) = 0x20; CLOCK(CLK_RST_CONTROLLER_PLLD_MISC) = 0x2DFC00; // Use new PLLD_SDM_DIN. // Finalize DSI configuration. exec_cfg((u32 *)DSI_BASE, _display_dsi_packet_config, 21); - DISPLAY_A(_DIREG(DC_DISP_DISP_CLOCK_CONTROL)) = 4; // PCD1 | div3. + // Set pixel clock dividers: 230.4 / 3 / 1 = 76.8 MHz. 60 Hz. + DISPLAY_A(_DIREG(DC_DISP_DISP_CLOCK_CONTROL)) = PIXEL_CLK_DIVIDER_PCD1 | SHIFT_CLK_DIVIDER(4); // 4: div3. exec_cfg((u32 *)DSI_BASE, _display_dsi_mode_config, 10); usleep(10000); diff --git a/bdk/gfx/di.inl b/bdk/gfx/di.inl index ef3b1b0..c153881 100644 --- a/bdk/gfx/di.inl +++ b/bdk/gfx/di.inl @@ -96,7 +96,7 @@ static const cfg_op_t _display_dc_setup_win_config[94] = { {DC_DISP_DISP_INTERFACE_CONTROL, DISP_DATA_FORMAT_DF1P1C}, {DC_COM_PIN_OUTPUT_POLARITY(1), 0x1000000}, {DC_COM_PIN_OUTPUT_POLARITY(3), 0}, - {0x4E4, 0}, + {DC_DISP_BLEND_BACKGROUND_COLOR, 0}, {DC_COM_CRC_CONTROL, 0}, {DC_CMD_STATE_CONTROL, GENERAL_UPDATE | WIN_A_UPDATE | WIN_B_UPDATE | WIN_C_UPDATE}, {DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ | WIN_A_ACT_REQ | WIN_B_ACT_REQ | WIN_C_ACT_REQ}, @@ -253,7 +253,7 @@ static const cfg_op_t _display_dsi_packet_config[21] = { {DSI_PKT_LEN_2_3, 0x87001A2}, {DSI_PKT_LEN_4_5, 0x190}, {DSI_PKT_LEN_6_7, 0x190}, - {DSI_HOST_CONTROL, 0}, + {DSI_HOST_CONTROL, 0} }; //DSI mode config. @@ -372,16 +372,16 @@ static const cfg_op_t _display_video_disp_controller_enable_config[113] = { {DC_DISP_DISP_INTERFACE_CONTROL, DISP_DATA_FORMAT_DF1P1C}, {DC_COM_PIN_OUTPUT_POLARITY(1), 0x1000000}, {DC_COM_PIN_OUTPUT_POLARITY(3), 0}, - {0x4E4, 0}, + {DC_DISP_BLEND_BACKGROUND_COLOR, 0}, {DC_COM_CRC_CONTROL, 0}, {DC_CMD_STATE_CONTROL, GENERAL_UPDATE | WIN_A_UPDATE | WIN_B_UPDATE | WIN_C_UPDATE}, {DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ | WIN_A_ACT_REQ | WIN_B_ACT_REQ | WIN_C_ACT_REQ}, {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_A_SELECT}, - {0x716, 0x10000FF}, + {DC_WINBUF_BLEND_LAYER_CONTROL, 0x10000FF}, {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_B_SELECT}, - {0x716, 0x10000FF}, + {DC_WINBUF_BLEND_LAYER_CONTROL, 0x10000FF}, {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_C_SELECT}, - {0x716, 0x10000FF}, + {DC_WINBUF_BLEND_LAYER_CONTROL, 0x10000FF}, {DC_CMD_DISPLAY_COMMAND_OPTION0, 0}, {DC_CMD_DISPLAY_WINDOW_HEADER, WINDOW_A_SELECT}, {DC_WIN_WIN_OPTIONS, 0}, @@ -394,14 +394,37 @@ static const cfg_op_t _display_video_disp_controller_enable_config[113] = { {DC_CMD_STATE_CONTROL, GENERAL_UPDATE | WIN_A_UPDATE | WIN_B_UPDATE | WIN_C_UPDATE}, {DC_CMD_STATE_CONTROL, GENERAL_ACT_REQ | WIN_A_ACT_REQ | WIN_B_ACT_REQ | WIN_C_ACT_REQ}, {DC_CMD_STATE_ACCESS, 0}, - /* Set Display timings */ + + /* Set Display timings + * + * DC_DISP_REF_TO_SYNC: + * V_REF_TO_SYNC - 1 + * H_REF_TO_SYNC - 0 + * + * DC_DISP_SYNC_WIDTH: + * V_SYNC_WIDTH - 1 + * H_SYNC_WIDTH - 72 + * + * DC_DISP_BACK_PORCH: + * V_BACK_PORCH - 9 + * H_BACK_PORCH - 72 + * + * DC_DISP_ACTIVE: + * V_DISP_ACTIVE - 1280 + * H_DISP_ACTIVE - 720 + * + * DC_DISP_FRONT_PORCH: + * V_FRONT_PORCH - 10 + * H_FRONT_PORCH - 136 + */ {DC_DISP_DISP_TIMING_OPTIONS, 0}, - {DC_DISP_REF_TO_SYNC, (1 << 16)}, // h_ref_to_sync = 0, v_ref_to_sync = 1. + {DC_DISP_REF_TO_SYNC, 0x10000}, {DC_DISP_SYNC_WIDTH, 0x10048}, {DC_DISP_BACK_PORCH, 0x90048}, {DC_DISP_ACTIVE, 0x50002D0}, - {DC_DISP_FRONT_PORCH, 0xA0088}, // Sources say that this should be above the DC_DISP_ACTIVE cmd. + {DC_DISP_FRONT_PORCH, 0xA0088}, // Sources say that this should happen before DC_DISP_ACTIVE cmd. /* End of Display timings */ + {DC_DISP_SHIFT_CLOCK_OPTIONS, SC1_H_QUALIFIER_NONE | SC0_H_QUALIFIER_NONE}, {DC_COM_PIN_OUTPUT_ENABLE(1), 0}, {DC_DISP_DATA_ENABLE_OPTIONS, DE_SELECT_ACTIVE | DE_CONTROL_NORMAL}, diff --git a/bdk/storage/sdmmc.c b/bdk/storage/sdmmc.c index 8b7b7d6..2003ad2 100644 --- a/bdk/storage/sdmmc.c +++ b/bdk/storage/sdmmc.c @@ -169,6 +169,8 @@ int sdmmc_storage_end(sdmmc_storage_t *storage) sdmmc_end(storage->sdmmc); + storage->initialized = 0; + return 1; } @@ -179,6 +181,10 @@ static int _sdmmc_storage_readwrite(sdmmc_storage_t *storage, u32 sector, u32 nu u32 sct_total = num_sectors; bool first_reinit = true; + // Exit if not initialized. + if (!storage->initialized) + return 0; + while (sct_total) { u32 blkcnt = 0; @@ -213,7 +219,8 @@ reinit_try: sd_error_count_increment(SD_ERROR_INIT_FAIL); } - // Reset retries to a lower number. + // Reset values for a retry. + blkcnt = 0; retries = 3; first_reinit = false; @@ -228,6 +235,7 @@ reinit_try: } } + // Failed. return 0; out: @@ -631,6 +639,8 @@ DPRINTF("[MMC] succesfully switched to HS mode\n"); sdmmc_card_clock_ctrl(storage->sdmmc, SDMMC_AUTO_CAL_ENABLE); + storage->initialized = 1; + return 1; } @@ -643,6 +653,7 @@ int sdmmc_storage_set_mmc_partition(sdmmc_storage_t *storage, u32 partition) return 0; storage->partition = partition; + return 1; } @@ -1306,6 +1317,8 @@ DPRINTF("[SD] enabled HS\n"); DPRINTF("[SD] got sd status\n"); } + storage->initialized = 1; + return 1; } @@ -1357,5 +1370,7 @@ DPRINTF("[gc] after tuning\n"); sdmmc_card_clock_ctrl(sdmmc, SDMMC_AUTO_CAL_ENABLE); + storage->initialized = 1; + return 1; } diff --git a/bdk/storage/sdmmc.h b/bdk/storage/sdmmc.h index 225171c..cfa8a50 100644 --- a/bdk/storage/sdmmc.h +++ b/bdk/storage/sdmmc.h @@ -116,6 +116,7 @@ typedef struct _sdmmc_storage_t mmc_ext_csd_t ext_csd; sd_scr_t scr; sd_ssr_t ssr; + int initialized; } sdmmc_storage_t; int sdmmc_storage_end(sdmmc_storage_t *storage); diff --git a/bdk/storage/sdmmc_driver.c b/bdk/storage/sdmmc_driver.c index b2bbb85..46a8525 100644 --- a/bdk/storage/sdmmc_driver.c +++ b/bdk/storage/sdmmc_driver.c @@ -241,8 +241,9 @@ static int _sdmmc_dll_cal_execute(sdmmc_t *sdmmc) } #ifdef SDMMC_EMMC_OC + // Add -4 TX_DLY_CODE_OFFSET if HS533. if (sdmmc->id == SDMMC_4 && overclock) - sdmmc->regs->vendllcalcfg = sdmmc->regs->vendllcalcfg &= 0xFFFFC07F | (0x7C << 7); // Add -4 TX_DLY_CODE_OFFSET if HS533. + sdmmc->regs->vendllcalcfg = sdmmc->regs->vendllcalcfg &= 0xFFFFC07F | (0x7C << 7); #endif sdmmc->regs->vendllcalcfg |= TEGRA_MMC_DLLCAL_CFG_EN_CALIBRATE; @@ -399,9 +400,8 @@ void sdmmc_card_clock_ctrl(sdmmc_t *sdmmc, int auto_cal_enable) sdmmc->auto_cal_enabled = auto_cal_enable; if (auto_cal_enable) { - if (!(sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN)) - return; - sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN; + if (sdmmc->regs->clkcon & SDHCI_CLOCK_CARD_EN) + sdmmc->regs->clkcon &= ~SDHCI_CLOCK_CARD_EN; return; } @@ -725,7 +725,6 @@ static int _sdmmc_autocal_config_offset(sdmmc_t *sdmmc, u32 power) off_pu = 5; break; case SDMMC_1: - case SDMMC_3: if (power == SDMMC_POWER_1_8) { off_pd = 123; @@ -995,7 +994,7 @@ DPRINTF("rsp(%d): %08X, %08X, %08X, %08X\n", result, if (!result) { #ifdef ERROR_EXTRA_PRINTING - EPRINTFARGS("SDMMC: Unknown response %08X!", sdmmc->rsp[0]); + EPRINTF("SDMMC: Unknown response type!"); #endif } } @@ -1117,10 +1116,7 @@ static void _sdmmc_config_emmc(u32 id) case SDMMC_4: // Unset park for pads. APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) &= 0xF8003FFF; - // Set default pad cfg. - APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) = (APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) & 0xFFFFC003) | 0x1040; - - // Enabled schmitt trigger. + // Enable schmitt trigger. APB_MISC(APB_MISC_GP_EMMC4_PAD_CFGPADCTRL) |= 1; // Enable Schmitt trigger. break; } @@ -1130,7 +1126,7 @@ int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int a { const u32 trim_values[] = { 2, 8, 3, 8 }; - if (id > SDMMC_4) + if (id > SDMMC_4 || id == SDMMC_3) return 0; memset(sdmmc, 0, sizeof(sdmmc_t)); diff --git a/bdk/usb/usb_descriptors.h b/bdk/usb/usb_descriptors.h index b57e41b..6610d00 100644 --- a/bdk/usb/usb_descriptors.h +++ b/bdk/usb/usb_descriptors.h @@ -75,7 +75,7 @@ typedef struct _usb_dev_descr_t u8 bNumConfigs; // Number of possible configuration. } __attribute__((packed)) usb_dev_descr_t; -/* Device Qualigier descriptor structure */ +/* Device Qualifier descriptor structure */ typedef struct _usb_dev_qual_descr_t { u8 bLength; // Size of this descriptor in bytes. diff --git a/bdk/usb/usb_t210.h b/bdk/usb/usb_t210.h index d670317..3bc83b1 100644 --- a/bdk/usb/usb_t210.h +++ b/bdk/usb/usb_t210.h @@ -1,5 +1,5 @@ /* - * USB driver for Tegra X1 + * Enhanced USB (EHCI) device driver for Tegra X1 * * Copyright (c) 2019 CTCaer * diff --git a/bdk/usb/usbd.c b/bdk/usb/usbd.c index 96c91b2..4bb06e2 100644 --- a/bdk/usb/usbd.c +++ b/bdk/usb/usbd.c @@ -1,5 +1,5 @@ /* - * USB Device driver for Tegra X1 + * Enhanced USB (EHCI) Device driver for Tegra X1 * * Copyright (c) 2019 CTCaer * @@ -312,7 +312,7 @@ static void _usb_charger_detect() gpio_config(GPIO_PORT_V, GPIO_PIN_3, GPIO_MODE_GPIO); // Configure charger pin. - PINMUX_AUX(PINMUX_AUX_USB_VBUS_EN0) &= + PINMUX_AUX(PINMUX_AUX_USB_VBUS_EN1) &= ~(PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_TRISTATE | PINMUX_PULL_MASK); gpio_config(GPIO_PORT_CC, GPIO_PIN_5, GPIO_MODE_GPIO); gpio_output_enable(GPIO_PORT_CC, GPIO_PIN_5, GPIO_OUTPUT_ENABLE); @@ -335,10 +335,10 @@ int usb_device_init() return 0; // Configure PLLU. - CLOCK(CLK_RST_CONTROLLER_PLLU_MISC) = CLOCK(CLK_RST_CONTROLLER_PLLU_MISC) | 0x20000000; // Disable reference clock. - u32 pllu_cfg = (((((CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) >> 8 << 8) | 2) & 0xFFFF00FF) | ((0x19 << 8) & 0xFFFF)) & 0xFFE0FFFF) | (1<< 16) | 0x1000000; + CLOCK(CLK_RST_CONTROLLER_PLLU_MISC) |= (1 << 29); // Disable reference clock. + u32 pllu_cfg = (((((CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) >> 8 << 8) | 2) & 0xFFFF00FF) | ((0x19 << 8) & 0xFFFF)) & 0xFFE0FFFF) | (1 << 16) | (1 << 24); CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) = pllu_cfg; - CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) = pllu_cfg | 0x40000000; // Enable. + CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) = pllu_cfg | (1 << 30); // Enable. // Wait for PLL to stabilize. u32 timeout = (u32)TMR(TIMERUS_CNTR_1US) + 1300; @@ -348,7 +348,7 @@ int usb_device_init() usleep(10); // Enable PLLU USB/HSIC/ICUSB/48M. - CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) = CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) | 0x2600000 | 0x800000; + CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) |= 0x2E00000; // Enable USBD clock. CLOCK(CLK_RST_CONTROLLER_CLK_ENB_L_SET) = BIT(CLK_L_USBD); @@ -1175,17 +1175,17 @@ static int _usbd_handle_ep0_control_transfer() switch (_bmRequestType) { - case (USB_SETUP_HOST_TO_DEVICE | USB_SETUP_RECIPIENT_DEVICE | USB_SETUP_TYPE_STANDARD): + case (USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_DEVICE): ret = _usbd_handle_set_request(&ep_stall); break; - case (USB_SETUP_HOST_TO_DEVICE | USB_SETUP_RECIPIENT_INTERFACE | USB_SETUP_TYPE_STANDARD): + case (USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_INTERFACE): ret = _usbd_ep_ack(USB_EP_CTRL_IN); if (!ret) usbd_otg->interface = _wValue; break; - case (USB_SETUP_HOST_TO_DEVICE | USB_SETUP_RECIPIENT_ENDPOINT | USB_SETUP_TYPE_STANDARD): + case (USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT): switch (_bRequest) { case USB_REQUEST_CLEAR_FEATURE: @@ -1227,10 +1227,12 @@ static int _usbd_handle_ep0_control_transfer() break; } break; - case (USB_SETUP_HOST_TO_DEVICE | USB_SETUP_RECIPIENT_INTERFACE | USB_SETUP_TYPE_CLASS): + + case (USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_CLASS | USB_SETUP_RECIPIENT_INTERFACE): _usbd_handle_get_class_request(&transmit_data, descriptor, &size, &ep_stall); break; - case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_RECIPIENT_DEVICE | USB_SETUP_TYPE_STANDARD): + + case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_DEVICE): switch (_bRequest) { case USB_REQUEST_GET_STATUS: @@ -1253,7 +1255,7 @@ static int _usbd_handle_ep0_control_transfer() } break; - case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_RECIPIENT_INTERFACE | USB_SETUP_TYPE_STANDARD): + case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_INTERFACE): if (_bRequest == USB_REQUEST_GET_INTERFACE) { descriptor = (void *)&usbd_otg->interface; @@ -1287,7 +1289,7 @@ static int _usbd_handle_ep0_control_transfer() transmit_data = 1; break; - case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_RECIPIENT_ENDPOINT | USB_SETUP_TYPE_STANDARD): + case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT): if (_bRequest == USB_REQUEST_GET_STATUS) { int ep_req; @@ -1324,14 +1326,15 @@ static int _usbd_handle_ep0_control_transfer() _usbd_stall_reset_ep1(3, USB_EP_CFG_STALL); break; - case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_RECIPIENT_INTERFACE | USB_SETUP_TYPE_CLASS): + case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_TYPE_CLASS | USB_SETUP_RECIPIENT_INTERFACE): memset(descriptor, 0, _wLength); _usbd_handle_get_class_request(&transmit_data, descriptor, &size, &ep_stall); size = _wLength; break; - case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_RECIPIENT_INTERFACE | USB_SETUP_TYPE_VENDOR): - case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_RECIPIENT_DEVICE | USB_SETUP_TYPE_VENDOR): + + case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_TYPE_VENDOR | USB_SETUP_RECIPIENT_INTERFACE): + case (USB_SETUP_DEVICE_TO_HOST | USB_SETUP_TYPE_VENDOR | USB_SETUP_RECIPIENT_DEVICE): if (_bRequest == USB_REQUEST_GET_MS_DESCRIPTOR) { switch (_wIndex) diff --git a/bdk/usb/usbd.h b/bdk/usb/usbd.h index 82a73e2..fb64949 100644 --- a/bdk/usb/usbd.h +++ b/bdk/usb/usbd.h @@ -1,5 +1,5 @@ /* - * USB Device driver for Tegra X1 + * Enhanced USB (EHCI) Device driver for Tegra X1 * * Copyright (c) 2019 CTCaer * diff --git a/bdk/utils/util.h b/bdk/utils/util.h index e716aae..36e65e0 100644 --- a/bdk/utils/util.h +++ b/bdk/utils/util.h @@ -35,7 +35,7 @@ typedef enum ERR_LIBSYS_MTC = (1 << 2), ERR_SD_BOOT_EN = (1 << 3), ERR_L4T_KERNEL = (1 << 24), - ERR_EXCEPT_ENB = (1 << 31), + ERR_EXCEPTION = (1 << 31), } hekate_errors_t; #define byte_swap_32(num) (((num >> 24) & 0xff) | ((num << 8) & 0xff0000) | \ diff --git a/bootloader/main.c b/bootloader/main.c index 28c1a93..4aa7534 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -1156,7 +1156,7 @@ static void _show_errors() u32 *excp_lr = (u32 *)EXCP_LR_ADDR; if (*excp_enabled == EXCP_MAGIC) - h_cfg.errors |= ERR_EXCEPT_ENB; + h_cfg.errors |= ERR_EXCEPTION; //! FIXME: Find a better way to identify if that scratch has proper data. if (0 && PMC(APBDEV_PMC_SCRATCH37) & PMC_SCRATCH37_KERNEL_PANIC_FLAG) @@ -1173,23 +1173,23 @@ static void _show_errors() display_backlight_brightness(150, 1000); if (h_cfg.errors & ERR_SD_BOOT_EN) - WPRINTF("Failed to init SD!\n"); + WPRINTF("Failed to mount SD!\n"); if (h_cfg.errors & ERR_LIBSYS_LP0) WPRINTF("Missing LP0 (sleep mode) lib!\n"); if (h_cfg.errors & ERR_LIBSYS_MTC) WPRINTF("Missing or old Minerva lib!\n"); - if (h_cfg.errors & ~(ERR_EXCEPT_ENB | ERR_L4T_KERNEL)) + if (h_cfg.errors & (ERR_LIBSYS_LP0 | ERR_LIBSYS_MTC)) WPRINTF("\nUpdate bootloader folder!\n\n"); - if (h_cfg.errors & ERR_EXCEPT_ENB) + if (h_cfg.errors & ERR_EXCEPTION) { WPRINTFARGS("An exception occurred (LR %08X):\n", *excp_lr); switch (*excp_type) { case EXCP_TYPE_RESET: - WPRINTF("RST"); + WPRINTF("RESET"); break; case EXCP_TYPE_UNDEF: WPRINTF("UNDEF"); @@ -1207,7 +1207,7 @@ static void _show_errors() *excp_enabled = 0; } - if (h_cfg.errors & ERR_L4T_KERNEL) + if (0 && h_cfg.errors & ERR_L4T_KERNEL) { WPRINTF("Panic occurred while running L4T.\n"); if (!sd_save_to_file((void *)PSTORE_ADDR, PSTORE_SZ, "L4T_panic.bin")) diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index 127d106..d604f1f 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -307,7 +307,7 @@ static void _show_errors() switch (*excp_type) { case EXCP_TYPE_RESET: - WPRINTF("RST"); + WPRINTF("RESET"); break; case EXCP_TYPE_UNDEF: WPRINTF("UNDEF"); diff --git a/nyx/nyx_gui/storage/nx_sd.c b/nyx/nyx_gui/storage/nx_sd.c index 175ec3e..78f3547 100644 --- a/nyx/nyx_gui/storage/nx_sd.c +++ b/nyx/nyx_gui/storage/nx_sd.c @@ -174,7 +174,7 @@ bool sd_mount() static void _sd_deinit(bool deinit) { - if (sd_mode == SD_INIT_FAIL) + if (deinit && sd_mode == SD_INIT_FAIL) sd_mode = SD_UHS_SDR104; if (sd_init_done && sd_mounted)