Browse Source

x230: remove -a option and autodetect the chip by default

Also, this updates our script commands in the documentation and moves the
"flashrom chip config" section under the "background" section.

Closes #26
pull/35/head
Martin Kepplinger 6 years ago
parent
commit
4a50b3383a
3 changed files with 71 additions and 99 deletions
  1. +23
    -25
      x230/README.md
  2. +25
    -38
      x230/flashrom_rpi_bottom_unlock.sh
  3. +23
    -36
      x230/flashrom_rpi_top_write.sh

+ 23
- 25
x230/README.md View File

@ -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 <your_hardware>` (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 <chipname>`). 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 <chipname> -k <backup.bin>
sudo ./flashrom_rpi_bottom_unlock.sh -m -k <backup.bin>
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 <your_hardware>` (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 <chipname>`).
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_<hash>_top.rom -c <chipname> -k <backup>
sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios_<hash>_top.rom -k <backup>
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_<hash>_top.rom -c <chipname>
sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios_<hash>_top.rom
That's it.


+ 25
- 38
x230/flashrom_rpi_bottom_unlock.sh View File

@ -13,20 +13,18 @@ have_chipname=0
have_backupname=0
me_clean=0
lock=0
autodetect_chip=0
usage()
{
echo "Usage: $0 [-c <chipname>] [-a] [-m] [-k <backup_filename>] [-l]"
echo ""
echo "-c <chipname> 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 <file> save the read image as <file>"
}
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


+ 23
- 36
x230/flashrom_rpi_top_write.sh View File

@ -10,19 +10,17 @@ set -e
have_input_image=0
have_chipname=0
have_backupname=0
autodetect_chip=0
usage()
{
echo "Usage: $0 -i <image.rom> [-c <chipname>] [-a] [-k <backup_filename>]"
echo "Usage: $0 -i <image.rom> [-c <chipname>] [-k <backup_filename>]"
echo ""
echo " -i <path to image to flash>"
echo " -c <chipname> for flashrom"
echo " -a ... try autodetecting the chipname"
echo " -c <chipname> to use for flashrom"
echo " -k <path to backup to save>"
}
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


Loading…
Cancel
Save