-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…fs size WARNING: Updating from inside of Heads is NOT possible! Changing the IFD format requires flashing from the outside (once). This is because we only flash the bios region and whatever IFD format is _currently_ in flash is used again. For this update, more regions need to get flashed. Either: * flash ifd, me and bios regions from userspace manually, or * split up a new coreboot build to 4M and 8M and flash externally This requires blobs for the x230 similar to the x220 now. They must be modified by me_cleaner to be able to have 0xbe5000 of CBFS size. An extract.sh script is provided, to be run before building Heads. This should create enough room to keep the x230 supported by Heads in the long run (when vboot or more tools might be desired). add extract.sh
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
util |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0+ | ||
# Copyright (C) 2019, Martin Kepplinger <[email protected]> | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")" | ||
|
||
IFDTOOL=./util/ifdtool/ifdtool | ||
ME_CLEANER=./util/me_cleaner/me_cleaner.py | ||
have_input_image=0 | ||
|
||
usage() | ||
{ | ||
echo "EXPERIMENTAL" | ||
echo "" | ||
echo "This generates files for building Heads from your original 12M backup:" | ||
echo " (cat bottom.bin top.bin > full_backup_image.rom)" | ||
echo " ifd/me will be shrinked by me_cleaner and unlocked" | ||
echo "" | ||
echo " http://osresearch.net" | ||
echo "" | ||
echo "Usage: $0 -f <full_backup_image>.rom -i <ifdtool>(optional) -m <me_cleaner.py(optional)" | ||
} | ||
|
||
args=$(getopt -o f:m:i:h -- "$@") | ||
if [ $? -ne 0 ] ; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
eval set -- "$args" | ||
while [ $# -gt 0 ] | ||
do | ||
case "$1" in | ||
-f) | ||
INPUT_IMAGE_PATH=$2 | ||
have_input_image=1 | ||
shift | ||
;; | ||
-m) | ||
ME_CLEANER=$2 | ||
shift | ||
;; | ||
-i) | ||
IFDTOOL=$2 | ||
shift | ||
;; | ||
-h) | ||
usage | ||
exit 1 | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
*) | ||
echo "Invalid option: $1" | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ ! "$have_input_image" -gt 0 ] ; then | ||
echo "No image file specified. Please add -f <file>" | ||
echo "" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [ ! -e ${IFDTOOL} ] ; then | ||
if [ ! -d util/ifdtool ] ; then | ||
echo "Please specify -i <ifdtool>" | ||
exit 1 | ||
fi | ||
make -C util/ifdtool | ||
if [ ! -e ${IFDTOOL} ] ; then | ||
echo "Failed to build ifdtool" | ||
exit 1 | ||
fi | ||
fi | ||
if [ ! -e ${ME_CLEANER} ] ; then | ||
mkdir -p util/me_cleaner | ||
curl -L https://raw.githubusercontent.com/corna/me_cleaner/v1.2/me_cleaner.py -o util/me_cleaner/me_cleaner.py | ||
if [ ! -e ${ME_CLEANER} ] ; then | ||
echo "Failed to download me_cleaner" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
OUTPUT_PATH=output | ||
INPUT_IMAGE_NAME=$(basename "${INPUT_IMAGE_PATH}") | ||
WORK_IMAGE_NAME=${INPUT_IMAGE_NAME%%.*}_prepared.rom | ||
|
||
input_filesize=$(wc -c <"$INPUT_IMAGE_PATH") | ||
reference_filesize=12582912 | ||
if [ ! "$input_filesize" -eq "$reference_filesize" ] ; then | ||
echo "Error: input file must be 12MB of size" | ||
exit 1 | ||
fi | ||
|
||
rm -rf ${OUTPUT_PATH} | ||
mkdir ${OUTPUT_PATH} | ||
cp "${INPUT_IMAGE_PATH}" "${OUTPUT_PATH}/${WORK_IMAGE_NAME}" | ||
|
||
${IFDTOOL} -x "${OUTPUT_PATH}/${WORK_IMAGE_NAME}" | ||
mv flashregion*bin "${OUTPUT_PATH}/" | ||
cp "${OUTPUT_PATH}/flashregion_3_gbe.bin" "${OUTPUT_PATH}/gbe.bin" | ||
rm ${OUTPUT_PATH}/flashregion*bin | ||
|
||
python ${ME_CLEANER} -r -t -d -S -O "${OUTPUT_PATH}/unneeded_cleaned_image.bin" -D "${OUTPUT_PATH}/ifd_shrinked.bin" -M "${OUTPUT_PATH}/me.bin" "${OUTPUT_PATH}/${WORK_IMAGE_NAME}" | ||
rm "${OUTPUT_PATH}/unneeded_cleaned_image.bin" | ||
|
||
${IFDTOOL} -u "${OUTPUT_PATH}/ifd_shrinked.bin" | ||
mv "${OUTPUT_PATH}/ifd_shrinked.bin.new" "${OUTPUT_PATH}/descriptor.bin" | ||
rm "${OUTPUT_PATH}/ifd_shrinked.bin" | ||
|
||
rm "${OUTPUT_PATH}/${WORK_IMAGE_NAME}" | ||
|
||
echo "done. this is what a layout file should look like:" | ||
echo "0x00000000:0x00000fff ifd" | ||
echo "0x00001000:0x00002fff gbe" | ||
echo "0x00003000:0x0001afff me" | ||
echo "0x0001b000:0x00bfffff bios" | ||
|
||
mv ${OUTPUT_PATH}/* . && rm -rf ${OUTPUT_PATH} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
To build for X230 we need to have the following files in this folder: | ||
* `me.bin` - ME binary that has been stripped and truncated with me_cleaner | ||
* `gbe.bin` - Network card blob from the original firmware | ||
* `descriptor.bin` - Flash layout file modified by me_cleaner | ||
|
||
To get the binaries, start with a copy of the original 12M Lenovo firmware image. | ||
If you do not have one already, you can read one out from the laptops SPI flash. | ||
Make sure to boot Linux with the "iomem=relaxed" option on the commandline. | ||
|
||
``` | ||
flashrom --programmer internal -r original.bin | ||
``` | ||
|
||
Once you have the image, the provided extraction script will extract the files needed. | ||
|
||
``` | ||
./extract.sh -f <romdump> -i <ifdtool> | ||
``` | ||
|
||
The flash layout will be automatically adjusted and the ME image cleaned and truncated. | ||
|
||
You can now compile the image with: | ||
|
||
make BOARD=x230 |
7 comments
on commit 4cbab95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
- add the 4/8M split after building Heads again.
- remove "x230-flash" board (docs too)
- write an "install" script in case people have already coreboot/ifd-unlocked running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts here.
If the flash.sh script still reprograms only the BIOS region as it is currently done, we could catch the error (too big image to fit) and suggest external programming. That seems to me the most easy way out.
Another option would be to bundle ifdtool in heads and output regions throw preemptive error, or even better, deal with full flash reprogramming instead of just flashing the BIOS region?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts here.
If the flash.sh script still reprograms only the BIOS region as it is currently done, we could catch the error (too big image to fit) and suggest external programming. That seems to me the most easy way out.
sounds good but how would we detect that (without ifdtool)? libflashrom can do it, or am I missing something?
Another option would be to bundle ifdtool in heads and output regions throw preemptive error, or even better, deal with full flash reprogramming instead of just flashing the BIOS region?
I guess flashing all regions is trivial and if we detect IFD mismatch, we should just do it, right? We just cannot do it unconditionally because current 12M images only have valid bios regions. Also, easily reverting (flashing) back to an old Heads-build would not work, but that might be acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merge the CBFS region specified in coreboot file must match ME feed space (new BIOS region to flash, being also specified in corrected IFD descriptor)
The 3 size must match (freed neutered+deacrivated ME blob, corresponding IFD expended BIOS and reduced ME regions and CBFS BIOS regions in coreboot, here)
That is also what I was talking about in skulls repo issue in regard of CBFS region, that was related to your commit id here. Sorry about that.
As a consequence, if the flash.sh script, as of now, asks to reflash only the BIOS region, and BIOS sizes mismatches, flashrom should gracefully fail, but that needs to be of course tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was pointing to the lowest part, to compare with the x230.config.
By including a valid IFD and ME, we can now produce x230-top.rom and x230-bottom.rom rom from coreboot.rom. The user can now externally flash both chips at once and remove the need to have a x230-flash board configuration. (Resolving an old debate).
@tlaurion