hekate/nyx: remove coreboot support

Everything external is finally updated and beyond parity with old things that needed it.
This commit is contained in:
CTCaer
2026-01-12 04:04:08 +02:00
parent 8ab6f04243
commit f0dde780f4
5 changed files with 49 additions and 122 deletions

View File

@@ -1,7 +1,7 @@
/* /*
* L4T Loader for Tegra X1 * L4T Loader for Tegra X1
* *
* Copyright (c) 2020-2025 CTCaer * Copyright (c) 2020-2026 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -271,7 +271,7 @@ typedef struct _l4t_ctxt_t
int ram_oc_opt; int ram_oc_opt;
u32 serial_port; u32 serial_port;
u32 sld_type; bool sld_type;
u32 sc7entry_size; u32 sc7entry_size;
@@ -863,7 +863,7 @@ static void _l4t_set_config(l4t_ctxt_t *ctxt, const ini_sec_t *ini_sec, int entr
char val[4] = {0}; char val[4] = {0};
// Set default SLD type. // Set default SLD type.
ctxt->sld_type = BL_MAGIC_L4TLDR_SLD; ctxt->sld_type = true;
// Parse ini section and prepare BL33 env. // Parse ini section and prepare BL33 env.
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link) LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
@@ -899,7 +899,7 @@ static void _l4t_set_config(l4t_ctxt_t *ctxt, const ini_sec_t *ini_sec, int entr
else if (!strcmp("uart_port", kv->key)) else if (!strcmp("uart_port", kv->key))
ctxt->serial_port = atoi(kv->val); ctxt->serial_port = atoi(kv->val);
else if (!strcmp("sld_type", kv->key)) else if (!strcmp("sld_type", kv->key))
ctxt->sld_type = strtol(kv->val, NULL, 16); ctxt->sld_type = atoi(kv->val);
// Set key/val to BL33 env. // Set key/val to BL33 env.
_l4t_bl33_cfg_set_key(bl33_env, kv->key, kv->val); _l4t_bl33_cfg_set_key(bl33_env, kv->key, kv->val);
@@ -1166,7 +1166,7 @@ void launch_l4t(const ini_sec_t *ini_sec, int entry_idx, int is_list, bool t210b
_l4t_mc_config_carveout(t210b01); _l4t_mc_config_carveout(t210b01);
// Deinit any unneeded HW. // Deinit any unneeded HW.
hw_deinit(false, ctxt->sld_type); hw_deinit(ctxt->sld_type);
// Do late hardware config. // Do late hardware config.
_l4t_late_hw_config(t210b01); _l4t_late_hw_config(t210b01);

View File

@@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* *
* Copyright (c) 2018-2025 CTCaer * Copyright (c) 2018-2026 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -97,29 +97,17 @@ static void _check_power_off_from_hos()
#define PATCHED_RELOC_ENTRY 0x40010000 #define PATCHED_RELOC_ENTRY 0x40010000
#define EXT_PAYLOAD_ADDR 0xC0000000 #define EXT_PAYLOAD_ADDR 0xC0000000
#define RCM_PAYLOAD_ADDR (EXT_PAYLOAD_ADDR + ALIGN(PATCHED_RELOC_SZ, 0x10)) #define RCM_PAYLOAD_ADDR (EXT_PAYLOAD_ADDR + ALIGN(PATCHED_RELOC_SZ, 0x10))
#define COREBOOT_END_ADDR 0xD0000000
#define COREBOOT_VER_OFF 0x41
#define CBFS_DRAM_EN_ADDR 0x4003E000
#define CBFS_DRAM_MAGIC 0x4452414D // "DRAM"
static void *coreboot_addr; static void _reloc_append(u32 payload_dst, u32 payload_src, u32 payload_size)
static void _reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size)
{ {
memcpy((u8 *)payload_src, (u8 *)IPL_LOAD_ADDR, PATCHED_RELOC_SZ); memcpy((u8 *)payload_src, (u8 *)IPL_LOAD_ADDR, PATCHED_RELOC_SZ);
reloc_meta_t *relocator = (reloc_meta_t *)(payload_src + RELOC_META_OFF); volatile reloc_meta_t *relocator = (reloc_meta_t *)(payload_src + RELOC_META_OFF);
relocator->start = payload_dst - ALIGN(PATCHED_RELOC_SZ, 0x10); relocator->start = payload_dst - ALIGN(PATCHED_RELOC_SZ, 0x10);
relocator->stack = PATCHED_RELOC_STACK; relocator->stack = PATCHED_RELOC_STACK;
relocator->end = payload_dst + payload_size; relocator->end = payload_dst + payload_size;
relocator->ep = payload_dst; relocator->ep = payload_dst;
if (payload_size == 0x7000)
{
memcpy((u8 *)(payload_src + ALIGN(PATCHED_RELOC_SZ, 0x10)), coreboot_addr, 0x7000); // Bootblock.
*(vu32 *)CBFS_DRAM_EN_ADDR = CBFS_DRAM_MAGIC;
}
} }
bool is_ipl_updated(void *buf, u32 size, const char *path, bool force) bool is_ipl_updated(void *buf, u32 size, const char *path, bool force)
@@ -183,67 +171,43 @@ static void _launch_payload(char *path, bool update, bool clear_screen)
if (update && is_ipl_updated(buf, size, path, false)) if (update && is_ipl_updated(buf, size, path, false))
goto out; goto out;
// Check if it safely fits IRAM.
// Set payload address. if (size > 0x30000)
void *payload;
if (size < 0x30000)
payload = (void *)RCM_PAYLOAD_ADDR;
else
{ {
coreboot_addr = (void *)(COREBOOT_END_ADDR - size); gfx_con.mute = false;
payload = coreboot_addr; EPRINTF("Payload is too big!");
if (h_cfg.t210b01)
{
gfx_con.mute = false;
EPRINTF("Coreboot not allowed on Mariko!");
goto out; goto out;
}
} }
sd_end(); sd_end();
// Copy the payload to our chosen address. // Copy the payload to our chosen address.
memcpy(payload, buf, size); memcpy((void *)RCM_PAYLOAD_ADDR, buf, size);
if (size < 0x30000) // Append relocator or set config.
{ void (*payload_ptr)();
if (update)
memcpy((u8 *)(RCM_PAYLOAD_ADDR + PATCHED_RELOC_SZ), &b_cfg, sizeof(boot_cfg_t)); // Transfer boot cfg.
else
_reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
hw_deinit(false, byte_swap_32(*(u32 *)(payload + size - sizeof(u32))));
}
else
{
_reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, 0x7000);
// Get coreboot seamless display magic.
u32 magic = 0;
char *magic_ptr = payload + COREBOOT_VER_OFF;
memcpy(&magic, magic_ptr + strlen(magic_ptr) - 4, 4);
hw_deinit(true, magic);
}
void (*update_ptr)() = (void *)RCM_PAYLOAD_ADDR;
void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR;
// Launch our payload.
if (!update) if (!update)
{ {
// Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. _reloc_append(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
sdmmc_storage_init_wait_sd();
(*ext_payload_ptr)(); payload_ptr = (void *)EXT_PAYLOAD_ADDR;
} }
else else
{ {
memcpy((u8 *)(RCM_PAYLOAD_ADDR + PATCHED_RELOC_SZ), &b_cfg, sizeof(boot_cfg_t)); // Transfer boot cfg.
// Set updated flag to skip check on launch. // Set updated flag to skip check on launch.
EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD; EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD;
(*update_ptr)();
payload_ptr = (void *)RCM_PAYLOAD_ADDR;
} }
hw_deinit(false);
// Launch our payload.
(*payload_ptr)();
out: out:
free(buf); free(buf);
if (!update) if (!update)
@@ -1354,7 +1318,7 @@ static void _r2c_get_config_t210b01()
static void _ipl_reload() static void _ipl_reload()
{ {
hw_deinit(false, 0); hw_deinit(false);
// Reload hekate. // Reload hekate.
void (*ipl_ptr)() = (void *)IPL_LOAD_ADDR; void (*ipl_ptr)() = (void *)IPL_LOAD_ADDR;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2025 CTCaer * Copyright (c) 2018-2026 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -935,7 +935,7 @@ static void _launch_hos(u8 autoboot, u8 autoboot_list)
sd_end(); sd_end();
hw_deinit(false, 0); hw_deinit(false);
(*main_ptr)(); (*main_ptr)();
} }
@@ -970,7 +970,7 @@ void reload_nyx(lv_obj_t *obj, bool force)
sd_end(); sd_end();
hw_deinit(false, 0); hw_deinit(false);
(*main_ptr)(); (*main_ptr)();
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2025 CTCaer * Copyright (c) 2019-2026 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -1174,7 +1174,7 @@ static lv_res_t _action_reboot_recovery(lv_obj_t * btns, const char * txt)
// Deinit hardware. // Deinit hardware.
sd_end(); sd_end();
hw_deinit(false, 0); hw_deinit(false);
// Chainload to hekate main. // Chainload to hekate main.
(*main_ptr)(); (*main_ptr)();

View File

@@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* *
* Copyright (c) 2018-2025 CTCaer * Copyright (c) 2018-2026 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -96,13 +96,8 @@ create_dir:
#define PATCHED_RELOC_ENTRY 0x40010000 #define PATCHED_RELOC_ENTRY 0x40010000
#define EXT_PAYLOAD_ADDR 0xC0000000 #define EXT_PAYLOAD_ADDR 0xC0000000
#define RCM_PAYLOAD_ADDR (EXT_PAYLOAD_ADDR + ALIGN(PATCHED_RELOC_SZ, 0x10)) #define RCM_PAYLOAD_ADDR (EXT_PAYLOAD_ADDR + ALIGN(PATCHED_RELOC_SZ, 0x10))
#define COREBOOT_END_ADDR 0xD0000000
#define CBFS_DRAM_EN_ADDR 0x4003E000
#define CBFS_DRAM_MAGIC 0x4452414D // "DRAM"
static void *coreboot_addr; static void _reloc_append(u32 payload_dst, u32 payload_src, u32 payload_size)
void reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size)
{ {
memcpy((u8 *)payload_src, (u8 *)nyx_str->hekate, PATCHED_RELOC_SZ); memcpy((u8 *)payload_src, (u8 *)nyx_str->hekate, PATCHED_RELOC_SZ);
@@ -112,12 +107,6 @@ void reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size)
relocator->stack = PATCHED_RELOC_STACK; relocator->stack = PATCHED_RELOC_STACK;
relocator->end = payload_dst + payload_size; relocator->end = payload_dst + payload_size;
relocator->ep = payload_dst; relocator->ep = payload_dst;
if (payload_size == 0x7000)
{
memcpy((u8 *)(payload_src + ALIGN(PATCHED_RELOC_SZ, 0x10)), coreboot_addr, 0x7000); // Bootblock.
*(vu32 *)CBFS_DRAM_EN_ADDR = CBFS_DRAM_MAGIC;
}
} }
lv_res_t launch_payload(lv_obj_t *list) lv_res_t launch_payload(lv_obj_t *list)
@@ -135,63 +124,37 @@ lv_res_t launch_payload(lv_obj_t *list)
if (!sd_mount()) if (!sd_mount())
goto out; goto out;
FIL fp; // Read payload.
if (f_open(&fp, path, FA_READ)) u32 size = 0;
void *buf = sd_file_read(path, &size);
if (!buf)
{ {
EPRINTFARGS("Payload file is missing!\n(%s)", path); EPRINTFARGS("Payload file is missing!\n(%s)", path);
goto out; goto out;
} }
// Read and copy the payload to our chosen address // Check if it safely fits IRAM.
void *buf; if (size > 0x30000)
u32 size = f_size(&fp);
if (size < 0x30000)
buf = (void *)RCM_PAYLOAD_ADDR;
else
{ {
coreboot_addr = (void *)(COREBOOT_END_ADDR - size); EPRINTF("Payload is too big!");
buf = coreboot_addr;
if (h_cfg.t210b01)
{
f_close(&fp);
EPRINTF("Coreboot not allowed on Mariko!");
goto out;
}
}
if (f_read(&fp, buf, size, NULL))
{
f_close(&fp);
goto out; goto out;
} }
f_close(&fp);
sd_end(); sd_end();
if (size < 0x30000) // Copy the payload to our chosen address.
{ memcpy((void *)RCM_PAYLOAD_ADDR, buf, size);
reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
hw_deinit(false, byte_swap_32(*(u32 *)(buf + size - sizeof(u32))));
}
else
{
reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, 0x7000);
hw_deinit(true, 0);
}
void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR; // Append relocator.
_reloc_append(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
// Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. hw_deinit(false);
sdmmc_storage_init_wait_sd();
// Launch our payload. // Launch our payload.
(*ext_payload_ptr)(); void (*payload_ptr)() = (void *)EXT_PAYLOAD_ADDR;
(*payload_ptr)();
out: out:
sd_unmount(); sd_unmount();