Last active
January 19, 2016 03:46
-
-
Save Gnurou/482fb0ee8b685348041c to your computer and use it in GitHub Desktop.
Netlist firmware extraction script for use with Nouveau
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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