Skip to content

Instantly share code, notes, and snippets.

@Gnurou
Last active Jan 19, 2016
Embed
What would you like to do?
Netlist firmware extraction script for use with Nouveau
#!/usr/bin/python3
# This little tool extracts the GR firmwares from NET*_img.bin files
# Usage: python3 extract_netlist.py NETB_img.bin
# Regions to extract with their file name
regions = {
0 : "fecs_data",
1 : "fecs_inst",
2 : "gpccs_data",
3 : "gpccs_inst",
4 : "sw_bundle_init",
5 : "sw_ctx",
6 : "sw_nonctx",
7 : "sw_method_init",
}
import sys
import struct
f = open(sys.argv[1], 'rb')
data = f.read()
f.close();
version, nb_regions = struct.unpack('II', data[0:8])
for i in range(nb_regions):
offs = 8 + i * 12
region_id, data_size, data_offset = struct.unpack('III', data[offs:offs+12])
if region_id in regions:
region = data[data_offset:data_offset + data_size]
f = open(regions[region_id] + ".bin", 'wb')
f.write(region)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment