Install: Hekate 8GB after copy (fuse >4GiB), dram_fuse helper, RAM test target
All checks were successful
Build / Build (push) Successful in 14s

- Add dram_fuse.c/h for shared fuse-to-MiB mapping
- After successful update/clean install copy: if hekate_8gb.bin exists and
  fuse reports more than 4 GiB, copy to sd:/payload.bin and
  sd:/bootloader/update.bin, then remove source; otherwise remove helper only
- Makefile: make ram-test builds output/RAM-Test.bin (tools/ram_test_main.c)

Made-with: Cursor
This commit is contained in:
2026-03-31 00:05:30 +02:00
parent ef104bce41
commit d1fc24dae8
5 changed files with 282 additions and 92 deletions

46
source/dram_fuse.c Normal file
View File

@@ -0,0 +1,46 @@
/*
* DRAM capacity from fuse (SKU), not physical probe.
*/
#include "dram_fuse.h"
#include <soc/fuse.h>
#include <soc/hw_init.h>
#include <soc/t210.h>
static int mariko_dram_mib(u32 dram_id)
{
switch (dram_id) {
case 9:
case 13:
case 18:
case 21:
case 23:
case 28:
return 8192;
default:
if (dram_id >= 3 && dram_id <= 28)
return 4096;
return -1;
}
}
static int erista_dram_mib(u32 dram_id)
{
if (dram_id == 4)
return 6144;
if (dram_id <= 6)
return 4096;
return -1;
}
int dram_capacity_mib_from_fuse(void)
{
u32 nid = fuse_read_dramid(false);
u32 chip = hw_get_chip_id();
if (chip == GP_HIDREV_MAJOR_T210)
return erista_dram_mib(nid);
if (chip == GP_HIDREV_MAJOR_T210B01)
return mariko_dram_mib(nid);
return -1;
}

6
source/dram_fuse.h Normal file
View File

@@ -0,0 +1,6 @@
#pragma once
#include <utils/types.h>
/* DRAM capacity in MiB from fuse DRAM ID + SoC (same table as RAM test payload). */
int dram_capacity_mib_from_fuse(void);

View File

@@ -3,6 +3,7 @@
*/
#include "install.h"
#include "dram_fuse.h"
#include "fs.h"
#include "version.h"
#include "gfx.h"
@@ -618,6 +619,50 @@ int delete_path_list(const char* paths[], const char* description) {
return (failed == 0) ? FR_OK : FR_DISK_ERR;
}
#define HEKATE_8GB_SRC "sd:/bootloader/hekate_8gb.bin"
#define PAYLOAD_BIN_DST "sd:/payload.bin"
#define UPDATE_BIN_DST "sd:/bootloader/update.bin"
static void unlink_ignore_err(const char *path)
{
FILINFO fno;
if (f_stat(path, &fno) != FR_OK)
return;
if (fno.fattrib & AM_RDO)
f_chmod(path, fno.fattrib & ~AM_RDO, AM_RDO);
f_unlink(path);
}
/* After pack copy: if >4 GiB fuse RAM, install 8GB Hekate to payload.bin + bootloader/update.bin; always remove hekate_8gb.bin when done or if not used. */
static void install_hekate_8gb_post_copy(void)
{
if (!install_path_exists(HEKATE_8GB_SRC))
return;
int mib = dram_capacity_mib_from_fuse();
if (mib > 4096) {
install_set_color(COLOR_CYAN);
gfx_printf("\nMehr als 4 GB RAM erkannt (Fuse). Die 8-GB-Hekate-Variante wird verwendet.\n");
gfx_printf("Kopiere nach payload.bin und bootloader/update.bin...\n");
install_set_color(COLOR_WHITE);
int r1 = file_copy(HEKATE_8GB_SRC, PAYLOAD_BIN_DST);
int r2 = file_copy(HEKATE_8GB_SRC, UPDATE_BIN_DST);
if (r1 == FR_OK && r2 == FR_OK) {
install_set_color(COLOR_GREEN);
gfx_printf(" [OK] Hekate 8 GB installiert.\n");
install_set_color(COLOR_WHITE);
unlink_ignore_err(HEKATE_8GB_SRC);
} else {
install_set_color(COLOR_ORANGE);
gfx_printf(" [WARN] Kopie fehlgeschlagen (payload: %d, update: %d). hekate_8gb.bin bleibt.\n", r1, r2);
install_set_color(COLOR_WHITE);
}
} else {
unlink_ignore_err(HEKATE_8GB_SRC);
}
}
// Main installation function
int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) {
int res;
@@ -637,7 +682,9 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) {
install_set_color(COLOR_WHITE);
res = update_mode_install(pack_variant);
if (res != FR_OK) return res;
install_hekate_8gb_post_copy();
install_check_and_clear_screen_if_needed();
// Remove staging directory (installed pack)
res = cleanup_staging_directory(pack_variant);
@@ -676,7 +723,9 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) {
install_set_color(COLOR_WHITE);
res = clean_mode_install(pack_variant);
if (res != FR_OK) return res;
install_hekate_8gb_post_copy();
install_check_and_clear_screen_if_needed();
// Remove staging directory (installed pack)
res = cleanup_staging_directory(pack_variant);