diff --git a/x230/README.md b/x230/README.md index b97102f..e1351cd 100644 --- a/x230/README.md +++ b/x230/README.md @@ -86,25 +86,6 @@ a hardware flasher [supported by flashrom](https://www.flashrom.org/Flashrom/0.9.9/Supported_Hardware#USB_Devices) but we currently only support using a Raspberry Pi -### preparation: flashrom chip config -We (or our scripts) use [flashrom](https://flashrom.org/) for flashing. Connect -the programmer to the chip and run -`flashrom -p ` (for [example](#how-to-flash) -`flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128` for the -Raspberry Pi) to let flashrom detect the chip. If `-c` is omitted, the scripts -will run this for you. - -It will probably list a few you need to choose from when flashing -(by adding `-c `). Please review the chip model for your device. -In case you are unsure what to specify, here's some examples we find out there: - -#### 4MB chip -* `MX25L3206E` seems to mostly be in use - -#### 8MB chip -* `MX25L6406E/MX25L6408E` is used in [this guide](https://github.com/mfc/flashing-docs/blob/master/walkthrough%20for%20flashing%20heads%20on%20an%20x230.md#neutering-me) -* `MX25L3206E/MX25L3208E` is seen working with various X230 models. -* `EN25QH64` is used sometimes ### ifd unlock and me_cleaner: the 8MB chip @@ -129,7 +110,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 -c -k + sudo ./flashrom_rpi_bottom_unlock.sh -m -k That's it. Keep the backup safe. @@ -143,14 +124,31 @@ yourself (and others) to hardware-flashing externally. is roughly what's going on: - flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -r ifdmegbe.rom - flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -r ifdmegbe2.rom + flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -r ifdmegbe.rom + flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -r ifdmegbe2.rom diff ifdmegbe.rom ifdmegbe2.rom git clone https://github.com/corna/me_cleaner.git && cd me_cleaner ./me_cleaner.py -S -O ifdmegbe_meclean.rom ifdmegbe.rom ifdtool -u ifdmegbe_meclean.rom - flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -w ifdmegbe_meclean.rom.new + flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -w ifdmegbe_meclean.rom.new + +* We (or our scripts) use [flashrom](https://flashrom.org/) for flashing. If our +scripts don't detect the chip automatically, connect +the programmer to the chip and run +`flashrom -p ` (for [example](#how-to-flash) +`flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128` for the +Raspberry Pi) to let flashrom detect the chip. If `-c` is omitted, the scripts +will run this for you. It will probably list a few you need to choose from when flashing +(by adding `-c `). +In case you are unsure what to specify, here's some examples we find out there: + + * 4MB chip + * `MX25L3206E` seems to mostly be in use + * 8MB chip + * `MX25L6406E/MX25L6408E` is used in [this guide](https://github.com/mfc/flashing-docs/blob/master/walkthrough%20for%20flashing%20heads%20on%20an%20x230.md#neutering-me) + * `MX25L3206E/MX25L3208E` is seen working with various X230 models. + * `EN25QH64` is used sometimes ### BIOS: the 4MB chip (internally, memory of the two chips is mapped together, the 8MB being the lower @@ -159,7 +157,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 -c -k + sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios__top.rom -k That's it. Keep the backup safe. @@ -259,7 +257,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 -c + sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios__top.rom That's it. diff --git a/x230/flashrom_rpi_bottom_unlock.sh b/x230/flashrom_rpi_bottom_unlock.sh index 819ce7a..29aa926 100755 --- a/x230/flashrom_rpi_bottom_unlock.sh +++ b/x230/flashrom_rpi_bottom_unlock.sh @@ -13,20 +13,18 @@ have_chipname=0 have_backupname=0 me_clean=0 lock=0 -autodetect_chip=0 usage() { echo "Usage: $0 [-c ] [-a] [-m] [-k ] [-l]" echo "" echo "-c flashrom chip description to use" - echo "-a try to autodetect the chipname" 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:ak:h -- "$@") +args=$(getopt -o mlc:k:h -- "$@") if [ $? -ne 0 ] ; then usage exit 1 @@ -42,9 +40,6 @@ do -l) lock=1 ;; - -a) - autodetect_chip=1 - ;; -c) CHIPNAME=$2 have_chipname=1 @@ -73,42 +68,34 @@ done TEMP_DIR=`mktemp -d` if [ ! "$have_chipname" -gt 0 ] ; then - if [ ! "$autodetect_chip" -gt 0 ] ; then - echo -e "${RED}no chipname provided${NC}. To get it, we run:" - echo "flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128" + echo "trying to detect the chip..." + flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 &> ${TEMP_DIR}/chips || true + flashrom_error="" + flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true) + if [ ! -z "${flashrom_error}" ] ; then + cat ${TEMP_DIR}/chips + rm -rf ${TEMP_DIR} + exit 1 + fi + + CHIPNAME="" + chip_found=0 + CHIPNAME=$(cat ${TEMP_DIR}/chips | grep Found | grep "MX25L6406E/MX25L6408E" | grep -o '".*"' || true) + if [ ! -z "${CHIPNAME}" ] ; then + chip_found=1 + fi + CHIPNAME=$(cat ${TEMP_DIR}/chips | grep Found | grep "EN25QH64" | grep -o '".*"' || true) + if [ ! -z "${CHIPNAME}" ] ; then + chip_found=1 + fi + if [ ! "$chip_found" -gt 0 ] ; then + echo "chip not detected." flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 - usage rm -rf ${TEMP_DIR} + echo "chip not detected. Please find it manually and rerun with the -c parameter." exit 1 else - echo "trying to detect the chip..." - flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 &> ${TEMP_DIR}/chips || true - flashrom_error="" - flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true) - if [ ! -z "${flashrom_error}" ] ; then - cat ${TEMP_DIR}/chips - rm -rf ${TEMP_DIR} - exit 1 - fi - - CHIPNAME="" - chip_found=0 - CHIPNAME=$(cat ${TEMP_DIR}/chips | grep Found | grep "MX25L6406E/MX25L6408E" | grep -o '".*"' || true) - if [ ! -z "${CHIPNAME}" ] ; then - chip_found=1 - fi - CHIPNAME=$(cat ${TEMP_DIR}/chips | grep Found | grep "EN25QH64" | grep -o '".*"' || true) - if [ ! -z "${CHIPNAME}" ] ; then - chip_found=1 - fi - if [ ! "$chip_found" -gt 0 ] ; then - echo -e "${RED}Error:${NC} chip not detected. Please find it manually:" - flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 - rm -rf ${TEMP_DIR} - exit 1 - else - echo -e "Detected ${GREEN}${CHIPNAME}${NC}." - fi + echo -e "Detected ${GREEN}${CHIPNAME}${NC}." fi fi diff --git a/x230/flashrom_rpi_top_write.sh b/x230/flashrom_rpi_top_write.sh index e255b9e..b220303 100755 --- a/x230/flashrom_rpi_top_write.sh +++ b/x230/flashrom_rpi_top_write.sh @@ -10,19 +10,17 @@ set -e have_input_image=0 have_chipname=0 have_backupname=0 -autodetect_chip=0 usage() { - echo "Usage: $0 -i [-c ] [-a] [-k ]" + echo "Usage: $0 -i [-c ] [-k ]" echo "" echo " -i " - echo " -c for flashrom" - echo " -a ... try autodetecting the chipname" + echo " -c to use for flashrom" echo " -k " } -args=$(getopt -o i:c:ak:h -- "$@") +args=$(getopt -o i:c:k:h -- "$@") if [ $? -ne 0 ] ; then usage exit 1 @@ -42,9 +40,6 @@ do have_chipname=1 shift ;; - -a) - autodetect_chip=1 - ;; -k) BACKUPNAME=$2 have_backupname=1 @@ -74,38 +69,30 @@ fi TEMP_DIR=`mktemp -d` if [ ! "$have_chipname" -gt 0 ] ; then - if [ ! "$autodetect_chip" -gt 0 ] ; then - echo -e "${RED}no chipname provided${NC}. To get it, we run:" - echo "flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128" + echo "trying to detect the chip..." + flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 &> ${TEMP_DIR}/chips || true + flashrom_error="" + flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true) + if [ ! -z "${flashrom_error}" ] ; then + cat ${TEMP_DIR}/chips + rm -rf ${TEMP_DIR} + exit 1 + fi + + CHIPNAME="" + chip_found=0 + CHIPNAME=$(cat ${TEMP_DIR}/chips | grep Found | grep "MX25L3206E" | grep -o '".*"' || true) + if [ ! -z "${CHIPNAME}" ] ; then + chip_found=1 + fi + if [ ! "$chip_found" -gt 0 ] ; then + echo "chip not detected." flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 - usage rm -rf ${TEMP_DIR} + echo "Please find it manually in the list above and rerun with the -c parameter." exit 1 else - echo "trying to detect the chip..." - flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 &> ${TEMP_DIR}/chips || true - flashrom_error="" - flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true) - if [ ! -z "${flashrom_error}" ] ; then - cat ${TEMP_DIR}/chips - rm -rf ${TEMP_DIR} - exit 1 - fi - - CHIPNAME="" - chip_found=0 - CHIPNAME=$(cat ${TEMP_DIR}/chips | grep Found | grep "MX25L3206E" | grep -o '".*"' || true) - if [ ! -z "${CHIPNAME}" ] ; then - chip_found=1 - fi - if [ ! "$chip_found" -gt 0 ] ; then - echo -e "${RED}Error:${NC} chip not detected. Please find it manually:" - flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 - rm -rf ${TEMP_DIR} - exit 1 - else - echo -e "Detected ${GREEN}${CHIPNAME}${NC}." - fi + echo -e "Detected ${GREEN}${CHIPNAME}${NC}." fi fi