From 6600121ed34d8da4a58574254932c4e9ecab62b7 Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Fri, 18 May 2018 09:51:24 +0200 Subject: [PATCH] x230: rename scripts and prepare to support more hardware flashers Now our scripts start with _where_ it should be run. x230_*.sh should be run on the x230 where Skulls should be installed. external_*.sh obviously not. This also adds the -f option and an interactive menu if not specified. --- x230/README.md | 18 +++--- ...m_unlock.sh => external_install_bottom.sh} | 61 +++++++++++++++++-- ...i_top_write.sh => external_install_top.sh} | 51 +++++++++++++++- x230/release.sh | 8 +-- ...lation.sh => x230_before_first_install.sh} | 8 ++- ...re_internal_flashing.sh => x230_update.sh} | 5 ++ 6 files changed, 129 insertions(+), 22 deletions(-) rename x230/{flashrom_rpi_bottom_unlock.sh => external_install_bottom.sh} (75%) rename x230/{flashrom_rpi_top_write.sh => external_install_top.sh} (74%) rename x230/{prepare_before_installation.sh => x230_before_first_install.sh} (89%) rename x230/{prepare_internal_flashing.sh => x230_update.sh} (91%) diff --git a/x230/README.md b/x230/README.md index 9bd6243..a055291 100644 --- a/x230/README.md +++ b/x230/README.md @@ -25,17 +25,17 @@ That's the preferred way to use coreboot. The git revision we use is always incl ## TL;DR For first-time flashing, remove the keyboard and palmrest, and (using a Raspberry Pi with a SPI 8-pin chip clip connected), run -`flashrom_rpi_bottom_unlock.sh` on the lower chip -and `flashrom_rpi_top_write.sh` on the top chip of the two. +`external_install_bottom.sh` on the lower chip +and `external_install_top.sh` on the top chip of the two. -For updating later, run `prepare_internal_flashing.sh`. No need to disassemble. +For updating later, run `x230_update.sh`. No need to disassemble. And always use the latest [released](https://github.com/merge/coreboot-x230/releases) package. This will be tested. The git master branch is _not_ meant to be stable. Use it for testing only. ## Flashing for the first time -* Before doing anything, run Linux, install `dmidecode` and run `prepare_before_installation.sh` +* Before doing anything, run Linux, install `dmidecode` and run `x230_before_first_install.sh` It simply prints valuable system information. * Make sure you have RAM that uses 1,5V, not 1,35V. Check the specification of your RAM module(s). @@ -112,7 +112,7 @@ And finally unlock the 8M chip by using the included script (be patient). Again, this doesn't replace much; it reads the original, unlocks and flashes back: - sudo ./flashrom_rpi_bottom_unlock.sh -m -k + sudo ./external_install_bottom.sh -m -k That's it. Keep the backup safe. @@ -159,7 +159,7 @@ here. We assume you have the unpacked release tarball ready, see above. Use the following included script: - sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios__top.rom -k + sudo ./external_install_top.sh -i x230_coreboot_seabios__top.rom -k That's it. Keep the backup safe. @@ -172,13 +172,13 @@ and any of the following examples are possible. Otherwise you cannot use ### Example: internal * Only for _updating_! You have to have your 8MB chip flashed externally using -our `flashrom_rpi_bottom_unlock.sh` script (`ifdtool -u`) before this, once +our `external_install_bottom.sh` script (`ifdtool -u`) before this, once * very convenient: just install flashrom on your X230 but according to the [flashrom manpage](https://manpages.debian.org/stretch/flashrom/flashrom.8.en.html) this is very dangerous! * Boot Linux with the `iomem=relaxed` boot parameter (for example set in /etc/default/grub) * download the latest release tarball (4MB "top" BIOS image is included) and extract it -* run `prepare_internal_flashing.sh` for generating all necessary files and instructions +* run `x230_update.sh` for generating all necessary files and instructions ### Example: Raspberry Pi 3 @@ -259,7 +259,7 @@ Unpack it: Connect the SPI clip to the "top" chip, and run: - sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios__top.rom + sudo ./external_install_top.sh -f rpi -i x230_coreboot_seabios__top.rom That's it. diff --git a/x230/flashrom_rpi_bottom_unlock.sh b/x230/external_install_bottom.sh similarity index 75% rename from x230/flashrom_rpi_bottom_unlock.sh rename to x230/external_install_bottom.sh index 29aa926..b7d018b 100755 --- a/x230/flashrom_rpi_bottom_unlock.sh +++ b/x230/external_install_bottom.sh @@ -13,18 +13,27 @@ have_chipname=0 have_backupname=0 me_clean=0 lock=0 +have_flasher=0 usage() { + echo "Skulls for the X230" + echo " Run this script on an external computer with a flasher" + echo " connected to the X230's bottom chip (farther away from" + echo " the display, closer to you)." + echo "" echo "Usage: $0 [-c ] [-a] [-m] [-k ] [-l]" echo "" - echo "-c flashrom chip description to use" - echo "-m apply me_cleaner -S" - echo "-l lock the flash instead of unlocking it" - echo "-k save the read image as " + echo " -f " + echo " supported flashers: rpi" + echo "" + echo " -c flashrom chip description to use" + echo " -m apply me_cleaner -S" + echo " -l lock the flash instead of unlocking it" + echo " -k save the read image as " } -args=$(getopt -o mlc:k:h -- "$@") +args=$(getopt -o f:mlc:k:h -- "$@") if [ $? -ne 0 ] ; then usage exit 1 @@ -34,6 +43,11 @@ eval set -- "$args" while [ $# -gt 0 ] do case "$1" in + -f) + FLASHER=$2 + have_flasher=1 + shift + ;; -m) me_clean=1 ;; @@ -60,12 +74,47 @@ do ;; *) echo "Invalid option: $1" + usage exit 1 ;; esac shift done +if [ ! "$have_flasher" -gt 0 ] ; then + echo "Skulls for the X230" + echo "" + echo "Please select the hardware you use:" + PS3='Please select the hardware flasher: ' + options=("Raspberry Pi" "CH341A" "Exit") + select opt in "${options[@]}" + do + case $opt in + "Raspberry Pi") + FLASHER="rpi" + break + ;; + "CH341A") + FLASHER="ch341a" + break + ;; + "Exit") + exit 0 + ;; + *) echo invalid option;; + esac + done +fi + +if [ "${FLASHER}" = "rpi" ] ; then + echo "Ok. Run this on a Rasperry Pi." +elif [ "${FLASHER}" = "ch341a" ] ; then + echo "The CH341A is not yet supported" + exit 0 +else + exit 1 +fi + TEMP_DIR=`mktemp -d` if [ ! "$have_chipname" -gt 0 ] ; then echo "trying to detect the chip..." @@ -73,6 +122,8 @@ if [ ! "$have_chipname" -gt 0 ] ; then flashrom_error="" flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true) if [ ! -z "${flashrom_error}" ] ; then + usage + echo "-------------- flashrom error: ---------------" cat ${TEMP_DIR}/chips rm -rf ${TEMP_DIR} exit 1 diff --git a/x230/flashrom_rpi_top_write.sh b/x230/external_install_top.sh similarity index 74% rename from x230/flashrom_rpi_top_write.sh rename to x230/external_install_top.sh index b220303..773e944 100755 --- a/x230/flashrom_rpi_top_write.sh +++ b/x230/external_install_top.sh @@ -10,17 +10,26 @@ set -e have_input_image=0 have_chipname=0 have_backupname=0 +have_flasher=0 usage() { + echo "Skulls for the X230" + echo " Run this script on an external computer with a flasher" + echo " connected to the X230's top chip (closer to the display" + echo " and farther from you)" + echo "" echo "Usage: $0 -i [-c ] [-k ]" echo "" + echo " -f " + echo " supported flashers: rpi" + echo "" echo " -i " echo " -c to use for flashrom" echo " -k " } -args=$(getopt -o i:c:k:h -- "$@") +args=$(getopt -o f:i:c:k:h -- "$@") if [ $? -ne 0 ] ; then usage exit 1 @@ -30,6 +39,11 @@ eval set -- "$args" while [ $# -gt 0 ] do case "$1" in + -f) + FLASHER=$2 + have_flasher=1 + shift + ;; -i) INPUT_IMAGE_PATH=$2 have_input_image=1 @@ -62,11 +76,44 @@ do done if [ ! "$have_input_image" -gt 0 ] ; then - echo "no input image provided" + echo "Image file to flash is needed. Please add -i " + echo "" usage exit 1 fi +if [ ! "$have_flasher" -gt 0 ] ; then + echo "Please select the hardware you use:" + PS3='Please select the hardware flasher: ' + options=("Raspberry Pi" "CH341A" "Quit") + select opt in "${options[@]}" + do + case $opt in + "Raspberry Pi") + FLASHER="rpi" + break + ;; + "CH341A") + FLASHER="ch341a" + break + ;; + "Quit") + exit 0 + ;; + *) echo invalid option;; + esac + done +fi + +if [ "${FLASHER}" = "rpi" ] ; then + echo "Ok. Run this on a Rasperry Pi." +elif [ "${FLASHER}" = "ch341a" ] ; then + echo "The CH341A is not yet supported" + exit 0 +else + exit 1 +fi + TEMP_DIR=`mktemp -d` if [ ! "$have_chipname" -gt 0 ] ; then echo "trying to detect the chip..." diff --git a/x230/release.sh b/x230/release.sh index 01a4a16..ac70a61 100755 --- a/x230/release.sh +++ b/x230/release.sh @@ -104,10 +104,10 @@ tar -cJf skulls-x230-${version}.tar.xz \ NEWS \ util \ LICENSE* \ - prepare_internal_flashing.sh \ - prepare_before_intallation.sh \ - flashrom_rpi_bottom_unlock.sh \ - flashrom_rpi_top_write.sh \ + x230_update.sh \ + x230_before_first_install.sh \ + external_install_bottom.sh \ + external_install_top.sh \ sources \ ${RELEASE_IMAGE_FILE} diff --git a/x230/prepare_before_installation.sh b/x230/x230_before_first_install.sh similarity index 89% rename from x230/prepare_before_installation.sh rename to x230/x230_before_first_install.sh index 0771c24..0d34681 100755 --- a/x230/prepare_before_installation.sh +++ b/x230/x230_before_first_install.sh @@ -9,9 +9,13 @@ set -e usage() { - echo "Usage: $0" + echo "Skulls for the X230" + echo " Run this script on the X230 directly." + echo " It checks BIOS and hardware for relevant" + echo " things if you plan to install Skulls" + echo " please make sure dmidecode is installed" echo "" - echo "please make sure dmidecode is installed" + echo "Usage: $0" } args=$(getopt -o h -- "$@") diff --git a/x230/prepare_internal_flashing.sh b/x230/x230_update.sh similarity index 91% rename from x230/prepare_internal_flashing.sh rename to x230/x230_update.sh index 4a2bb77..494a1ab 100755 --- a/x230/prepare_internal_flashing.sh +++ b/x230/x230_update.sh @@ -10,6 +10,11 @@ have_input_image=0 usage() { + echo "Skulls for the X230" + echo " Run this script on the X230 directly." + echo " It updates Skulls to the image you want." + echo " Make sure you booted Linux with iomem=relaxed" + echo "" echo "Usage: $0 -i <4mb_top_image>.rom" }