mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
Given a specification of bitfields defined e.g. as follows:
specfile:
{
"field1" : 8,
"field2" : 4,
"field3" : 4
}
and a set of values for setting defaults:
setterfile:
{
"field1" = 0xff,
"field2" = 0xf,
"field3" = 0xf
}
You can generate a binary packed blob as follows:
./blobtool specfile setterfile binaryoutput
binaryoutput: ff ff
The reverse is also possible, i.e. you can regenerate the setter:
./blobtool -d specfile binaryoutput setterorig
setterorig:
# AUTOGENERATED SETTER BY BLOBTOOL
{
"field1" = 0xff,
"field2" = 0xf,
"field3" = 0xf
}
This tool comes with spec/set files for X200 flash descriptor
and ICH9M GbE region, and can be extended or used to decompile
other data blobs with known specs.
BUG=none
BRANCH=none
TEST=none
Change-Id: Ie8421c67f404631376d83e26f18301b34881cb5a
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 0685322f4a
Original-Change-Id: I744d6b421003feb4fc460133603af7e6bd80b1d6
Original-Signed-off-by: Damien Zammit <damien@zamaudio.com>
Original-Reviewed-on: https://review.coreboot.org/17445
Original-Tested-by: build bot (Jenkins)
Original-Reviewed-by: Jonathan Neuschfer <j.neuschaefer@gmx.net>
Original-Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://chromium-review.googlesource.com/438059
29 lines
767 B
Makefile
29 lines
767 B
Makefile
CC = gcc
|
|
YACC = bison
|
|
LEX = flex
|
|
TARGET=blobtool
|
|
|
|
$(TARGET): $(TARGET).lex.o $(TARGET).tab.o
|
|
$(CC) $^ -Wall -Wno-unused-function -g -lfl -o $@
|
|
|
|
$(TARGET).lex.c: $(TARGET).l $(TARGET).tab.h
|
|
$(LEX) -o $(patsubst $(TARGET).l,$(TARGET).lex.c,$<) $<
|
|
|
|
$(TARGET).tab.c $(TARGET).tab.h: $(TARGET).y
|
|
$(YACC) -d $<
|
|
|
|
# Use this target to generate GbE for X200
|
|
gen-gbe-ich9m:
|
|
./blobtool gbe-ich9m.spec gbe-ich9m.set gbe1.bin
|
|
# duplicate binary as per spec
|
|
cat gbe1.bin gbe1.bin > flashregion_3_gbe.bin
|
|
rm -f gbe1.bin
|
|
|
|
# Use this target to generate IFD for X200
|
|
gen-ifd-x200:
|
|
./blobtool ifd-x200.spec ifd-x200.set flashregion_0_fd.bin
|
|
|
|
.PHONY: clean gen-gbe-ich9m gen-ifd-x200
|
|
|
|
clean:
|
|
rm -f *.lex.c *.tab.c *.tab.h *.o blobtool flashregion_0_fd.bin flashregion_3_gbe.bin
|