From c386343206eac94f1b41d9166c5d135e7de5e77d Mon Sep 17 00:00:00 2001 From: Aleksey Smirnov Date: Sun, 24 Aug 2025 19:10:36 +0300 Subject: [PATCH 1/2] Update extract-firmware-nouveau python --- nouveau/extract-firmware-nouveau.py | 36 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/nouveau/extract-firmware-nouveau.py b/nouveau/extract-firmware-nouveau.py index abfeb43e1..06330ba06 100755 --- a/nouveau/extract-firmware-nouveau.py +++ b/nouveau/extract-firmware-nouveau.py @@ -120,6 +120,7 @@ def bootloader(gpu, fuse): global version GPU = gpu.upper() + FUSE = fuse.upper() filename = f"src/nvidia/generated/g_bindata_kgspGetBinArchiveGspRmBoot_{GPU}.c" print(f"Creating nvidia/{gpu}/gsp/bootloader-{version}.bin") @@ -127,12 +128,12 @@ def bootloader(gpu, fuse): with open(f"{outputpath}/nvidia/{gpu}/gsp/bootloader-{version}.bin", "wb") as f: # Extract the actual bootloader firmware - array = f"kgspBinArchiveGspRmBoot_{GPU}_ucode_image{fuse}data" + array = f"kgspBinArchiveGspRmBoot_{GPU}_BINDATA_LABEL_UCODE_IMAGE{FUSE}data" firmware = getbytes(filename, array) firmware_size = len(firmware) # Extract the descriptor (RM_RISCV_UCODE_DESC) - array = f"kgspBinArchiveGspRmBoot_{GPU}_ucode_desc{fuse}data" + array = f"kgspBinArchiveGspRmBoot_{GPU}_BINDATA_LABEL_UCODE_DESC{FUSE}data" descriptor = getbytes(filename, array) descriptor_size = len(descriptor) @@ -154,6 +155,7 @@ def booter(gpu, load, sigsize, fuse = "prod"): GPU = gpu.upper() LOAD = load.capitalize() + FUSE = fuse.upper() filename = f"src/nvidia/generated/g_bindata_kgspGetBinArchiveBooter{LOAD}Ucode_{GPU}.c" @@ -162,12 +164,12 @@ def booter(gpu, load, sigsize, fuse = "prod"): with open(f"{outputpath}/nvidia/{gpu}/gsp/booter_{load}-{version}.bin", "wb") as f: # Extract the actual booter firmware - array = f"kgspBinArchiveBooter{LOAD}Ucode_{GPU}_image_{fuse}_data" + array = f"kgspBinArchiveBooter{LOAD}Ucode_{GPU}_BINDATA_LABEL_IMAGE_{FUSE}_data" firmware = getbytes(filename, array) firmware_size = len(firmware) # Extract the signatures - array = f"kgspBinArchiveBooter{LOAD}Ucode_{GPU}_sig_{fuse}_data" + array = f"kgspBinArchiveBooter{LOAD}Ucode_{GPU}_BINDATA_LABEL_SIG_{FUSE}_data" signatures = getbytes(filename, array) signatures_size = len(signatures) if signatures_size % sigsize: @@ -195,12 +197,12 @@ def booter(gpu, load, sigsize, fuse = "prod"): f.write(signatures) # Extract the patch location - array = f"kgspBinArchiveBooter{LOAD}Ucode_{GPU}_patch_loc_data" + array = f"kgspBinArchiveBooter{LOAD}Ucode_{GPU}_BINDATA_LABEL_PATCH_LOC_data" bytes = getbytes(filename, array) patchloc = struct.unpack(" Date: Sun, 24 Aug 2025 19:28:10 +0300 Subject: [PATCH 2/2] Update extract-firmware-nouveau rust --- nouveau/extract-firmware-nouveau/src/main.rs | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/nouveau/extract-firmware-nouveau/src/main.rs b/nouveau/extract-firmware-nouveau/src/main.rs index f3140015e..e6d37b9d1 100644 --- a/nouveau/extract-firmware-nouveau/src/main.rs +++ b/nouveau/extract-firmware-nouveau/src/main.rs @@ -404,6 +404,7 @@ fn round_up_to_base(x: u32, base: u32) -> u32 { fn bootloader(output: &Path, version: &str, gpu: &str, prod: &str) -> Result<(), String> { let gpu_upper = gpu.to_uppercase(); + let prod_upper = prod.to_uppercase(); let filename = PathBuf::from(format!( "src/nvidia/generated/g_bindata_kgspGetBinArchiveGspRmBoot_{gpu_upper}.c" )); @@ -415,12 +416,12 @@ fn bootloader(output: &Path, version: &str, gpu: &str, prod: &str) -> Result<(), .map_err(|err| format!("Could not create nvidia/{gpu}/gsp/: {err}"))?; // Extract the actual bootloader firmware - let array = format!("kgspBinArchiveGspRmBoot_{gpu_upper}_ucode_image_{prod}data"); + let array = format!("kgspBinArchiveGspRmBoot_{gpu_upper}_BINDATA_LABEL_UCODE_IMAGE_{prod_upper}data"); let firmware = get_bytes(&filename, &array, None)?; let firmware_size: u32 = firmware.len() as u32; // Extract the descriptor (RM_RISCV_UCODE_DESC) - let array = format!("kgspBinArchiveGspRmBoot_{gpu_upper}_ucode_desc_{prod}data"); + let array = format!("kgspBinArchiveGspRmBoot_{gpu_upper}_BINDATA_LABEL_UCODE_DESC_{prod_upper}data"); let descriptor = get_bytes(&filename, &array, None)?; let descriptor_size: u32 = descriptor.len() as u32; @@ -486,12 +487,12 @@ fn booter(output: &Path, version: &str, gpu: &str, load: &str, sigsize: u32) -> .map_err(|err| format!("Could not create nvidia/{gpu}/gsp/: {err}"))?; // Extract the actual booter firmware - let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_image_prod_data"); + let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_BINDATA_LABEL_IMAGE_PROD_data"); let firmware = get_bytes(&filename, &array, None)?; let firmware_size = firmware.len() as u32; // Extract the signatures - let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_sig_prod_data"); + let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_BINDATA_LABEL_SIG_PROD_data"); let signatures = get_bytes(&filename, &array, None)?; let signatures_size = signatures.len() as u32; if (signatures_size % sigsize) != 0 { @@ -503,12 +504,12 @@ fn booter(output: &Path, version: &str, gpu: &str, load: &str, sigsize: u32) -> } // Extract the patch location - let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_patch_loc_data"); + let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_BINDATA_LABEL_PATCH_LOC_data"); let patch_loc_data = get_bytes(&filename, &array, Some(4))?; let patch_loc = LittleEndian::read_u32(&patch_loc_data); // Extract the patch meta variables - let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_patch_meta_data"); + let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_BINDATA_LABEL_PATCH_META_data"); let patch_meta_data = get_bytes(&filename, &array, Some(12))?; let (fuse_ver, engine_id, ucode_id) = patch_meta_data @@ -569,7 +570,7 @@ fn booter(output: &Path, version: &str, gpu: &str, load: &str, sigsize: u32) -> .map_err(|err| format!("Could not write to {}: {err}", filename.display()))?; // Extract the descriptor (nvkm_gsp_booter_fw_hdr) - let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_header_prod_data"); + let array = format!("kgspBinArchiveBooter{load_upper}Ucode_{gpu_upper}_BINDATA_LABEL_HEADER_PROD_data"); let descriptor = get_bytes(&filename, &array, Some(36))?; // Fifth, the descriptor @@ -603,12 +604,12 @@ fn scrubber(output: &Path, version: &str, gpu: &str, sigsize: u32) -> Result<(), .map_err(|err| format!("Could not create nvidia/{gpu}/gsp/: {err}"))?; // Extract the actual scrubber firmware - let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_image_prod_data"); + let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_BINDATA_LABEL_IMAGE_PROD_data"); let firmware = get_bytes(&filename, &array, None)?; let firmware_size = firmware.len() as u32; // Extract the signatures - let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_sig_prod_data"); + let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_BINDATA_LABEL_SIG_PROD_data"); let signatures = get_bytes(&filename, &array, None)?; let signatures_size = signatures.len() as u32; if (signatures_size % sigsize) != 0 { @@ -620,12 +621,12 @@ fn scrubber(output: &Path, version: &str, gpu: &str, sigsize: u32) -> Result<(), } // Extract the patch location - let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_patch_loc_data"); + let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_BINDATA_LABEL_PATCH_LOC_data"); let patch_loc_data = get_bytes(&filename, &array, Some(4))?; let patch_loc = LittleEndian::read_u32(&patch_loc_data); // Extract the patch meta variables - let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_patch_meta_data"); + let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_BINDATA_LABEL_PATCH_META_data"); let patch_meta_data = get_bytes(&filename, &array, Some(12))?; let (fuse_ver, engine_id, ucode_id) = patch_meta_data @@ -686,7 +687,7 @@ fn scrubber(output: &Path, version: &str, gpu: &str, sigsize: u32) -> Result<(), .map_err(|err| format!("Could not write to {}: {err}", filename.display()))?; // Extract the descriptor (nvkm_gsp_booter_fw_hdr) - let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_header_prod_data"); + let array = format!("ksec2BinArchiveSecurescrubUcode_{gpux}_BINDATA_LABEL_HEADER_PROD_data"); let descriptor = get_bytes(&filename, &array, Some(36))?; // Fifth, the descriptor