Browse Source

x230: add preliminary support for CH341A based programmers

pull/35/head
Martin Kepplinger 6 years ago
parent
commit
0f377d8753
3 changed files with 34 additions and 21 deletions
  1. +8
    -5
      x230/README.md
  2. +14
    -8
      x230/external_install_bottom.sh
  3. +12
    -8
      x230/external_install_top.sh

+ 8
- 5
x230/README.md View File

@ -83,8 +83,7 @@ or alternatively hooks, for example from
[jumper wires](https://en.wikipedia.org/wiki/Jump_wire) to connect the clip to [jumper wires](https://en.wikipedia.org/wiki/Jump_wire) to connect the clip to
a hardware flasher a hardware flasher
* a hardware flasher * 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](https://www.raspberrypi.org/products/)
[supported by flashrom](https://www.flashrom.org/Flashrom/0.9.9/Supported_Hardware#USB_Devices), see below for the examples we support
#### open up the X230 #### open up the X230
Remove the 7 screws of your X230 to remove the keyboard (by pushing it towards the Remove the 7 screws of your X230 to remove the keyboard (by pushing it towards the
@ -102,7 +101,7 @@ below. This is how the SPI connection looks on both of the X230's chips:
Edge (closest to you) Edge (closest to you)
... choose one of the following supported flashing hardware examples:
... choose __one of the following__ supported flashing hardware examples:
#### Hardware Example: Raspberry Pi 3 #### Hardware Example: Raspberry Pi 3
A Raspberry Pi can directly be a flasher through it's I/O pins, see below. A Raspberry Pi can directly be a flasher through it's I/O pins, see below.
@ -141,9 +140,13 @@ or ethernet to `sudo apt-get install flashrom`
Now copy the Skulls release tarball over to the Rasperry Pi and continue on the Pi. Now copy the Skulls release tarball over to the Rasperry Pi and continue on the Pi.
#### Hardware Example: CH341A based #### Hardware Example: CH341A based
CH341A, a USB interface chip, is used by some cheap memory programmers.
The CH341A from [Winchiphead](http://www.wch.cn/), a USB interface chip,
is used by some cheap memory programmers.
The one we describe can be bought
[here](http://www.aliexpress.com/item/Free-Shipping-CH341A-24-25-Series-EEPROM-Flash-BIOS-DVD-USB-Programmer-DVD-programmer-router-Nine/32583059603.html)
TODO
* Connect the programmer to your PC's USB port
* Connect your clip or hooks to the programmer's SPI pins
#### unpack the Skulls release archive #### unpack the Skulls release archive


+ 14
- 8
x230/external_install_bottom.sh View File

@ -25,7 +25,7 @@ usage()
echo "Usage: $0 [-c <chipname>] [-a] [-m] [-k <backup_filename>] [-l]" echo "Usage: $0 [-c <chipname>] [-a] [-m] [-k <backup_filename>] [-l]"
echo "" echo ""
echo " -f <hardware_flasher>" echo " -f <hardware_flasher>"
echo " supported flashers: rpi"
echo " supported flashers: rpi, ch341a"
echo "" echo ""
echo " -c <chipname> flashrom chip description to use" echo " -c <chipname> flashrom chip description to use"
echo " -m apply me_cleaner -S" echo " -m apply me_cleaner -S"
@ -106,12 +106,16 @@ if [ ! "$have_flasher" -gt 0 ] ; then
done done
fi fi
programmer=""
if [ "${FLASHER}" = "rpi" ] ; then if [ "${FLASHER}" = "rpi" ] ; then
echo "Ok. Run this on a Rasperry Pi." echo "Ok. Run this on a Rasperry Pi."
programmer="linux_spi:dev=/dev/spidev0.0,spispeed=128"
elif [ "${FLASHER}" = "ch341a" ] ; then elif [ "${FLASHER}" = "ch341a" ] ; then
echo "The CH341A is not yet supported"
exit 0
echo "Ok. Connect a CH341A programmer"
programmer="ch341a_spi"
else else
echo "invalid flashrom programmer"
usage
exit 1 exit 1
fi fi
@ -120,7 +124,7 @@ hash flashrom || echo -e "${RED}Please install flashrom and run as root${NC}"
TEMP_DIR=`mktemp -d` TEMP_DIR=`mktemp -d`
if [ ! "$have_chipname" -gt 0 ] ; then if [ ! "$have_chipname" -gt 0 ] ; then
echo "trying to detect the chip..." echo "trying to detect the chip..."
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 &> ${TEMP_DIR}/chips || true
flashrom -p ${programmer} &> ${TEMP_DIR}/chips || true
flashrom_error="" flashrom_error=""
flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true) flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true)
if [ ! -z "${flashrom_error}" ] ; then if [ ! -z "${flashrom_error}" ] ; then
@ -143,7 +147,7 @@ if [ ! "$have_chipname" -gt 0 ] ; then
fi fi
if [ ! "$chip_found" -gt 0 ] ; then if [ ! "$chip_found" -gt 0 ] ; then
echo "chip not detected." echo "chip not detected."
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128
flashrom -p ${programmer}
rm -rf ${TEMP_DIR} rm -rf ${TEMP_DIR}
echo "chip not detected. Please find it manually and rerun with the -c parameter." echo "chip not detected. Please find it manually and rerun with the -c parameter."
exit 1 exit 1
@ -186,8 +190,9 @@ if [[ ! "$TEMP_DIR" || ! -d "$TEMP_DIR" ]]; then
rm -rf ${TEMP_DIR} rm -rf ${TEMP_DIR}
exit 1 exit 1
fi fi
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c ${CHIPNAME} -r ${TEMP_DIR}/test1.rom
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c ${CHIPNAME} -r ${TEMP_DIR}/test2.rom
flashrom -p ${programmer} -c ${CHIPNAME} -r ${TEMP_DIR}/test1.rom
flashrom -p ${programmer} -c ${CHIPNAME} -r ${TEMP_DIR}/test2.rom
cmp --silent ${TEMP_DIR}/test1.rom ${TEMP_DIR}/test2.rom cmp --silent ${TEMP_DIR}/test1.rom ${TEMP_DIR}/test2.rom
if [ "$have_backupname" -gt 0 ] ; then if [ "$have_backupname" -gt 0 ] ; then
cp ${TEMP_DIR}/test1.rom ${BACKUPNAME} cp ${TEMP_DIR}/test1.rom ${BACKUPNAME}
@ -230,6 +235,7 @@ fi
make clean -C util/ifdtool make clean -C util/ifdtool
echo "start writing..." echo "start writing..."
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c ${CHIPNAME} -w ${TEMP_DIR}/work.rom.new
flashrom -p ${programmer} -c ${CHIPNAME} -w ${TEMP_DIR}/work.rom.new
rm -rf ${TEMP_DIR} rm -rf ${TEMP_DIR}
echo -e "${GREEN}DONE${NC}" echo -e "${GREEN}DONE${NC}"

+ 12
- 8
x230/external_install_top.sh View File

@ -22,7 +22,7 @@ usage()
echo "Usage: $0 -i <image.rom> [-c <chipname>] [-k <backup_filename>]" echo "Usage: $0 -i <image.rom> [-c <chipname>] [-k <backup_filename>]"
echo "" echo ""
echo " -f <hardware_flasher>" echo " -f <hardware_flasher>"
echo " supported flashers: rpi"
echo " supported flashers: rpi, ch341a"
echo "" echo ""
echo " -i <path to image to flash>" echo " -i <path to image to flash>"
echo " -c <chipname> to use for flashrom" echo " -c <chipname> to use for flashrom"
@ -125,12 +125,16 @@ if [ ! "$have_flasher" -gt 0 ] ; then
done done
fi fi
programmer=""
if [ "${FLASHER}" = "rpi" ] ; then if [ "${FLASHER}" = "rpi" ] ; then
echo "Ok. Run this on a Rasperry Pi." echo "Ok. Run this on a Rasperry Pi."
programmer="linux_spi:dev=/dev/spidev0.0,spispeed=128"
elif [ "${FLASHER}" = "ch341a" ] ; then elif [ "${FLASHER}" = "ch341a" ] ; then
echo "The CH341A is not yet supported"
exit 0
echo "Ok. Connect a CH341A programmer"
programmer="ch341a_spi"
else else
echo "invalid flashrom programmer"
usage
exit 1 exit 1
fi fi
@ -139,7 +143,7 @@ hash flashrom || echo -e "${RED}Please install flashrom and run as root${NC}"
TEMP_DIR=`mktemp -d` TEMP_DIR=`mktemp -d`
if [ ! "$have_chipname" -gt 0 ] ; then if [ ! "$have_chipname" -gt 0 ] ; then
echo "trying to detect the chip..." echo "trying to detect the chip..."
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 &> ${TEMP_DIR}/chips || true
flashrom -p ${programmer} &> ${TEMP_DIR}/chips || true
flashrom_error="" flashrom_error=""
flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true) flashrom_error=$(cat ${TEMP_DIR}/chips | grep -i error || true)
if [ ! -z "${flashrom_error}" ] ; then if [ ! -z "${flashrom_error}" ] ; then
@ -156,7 +160,7 @@ if [ ! "$have_chipname" -gt 0 ] ; then
fi fi
if [ ! "$chip_found" -gt 0 ] ; then if [ ! "$chip_found" -gt 0 ] ; then
echo "chip not detected." echo "chip not detected."
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128
flashrom -p ${programmer}
rm -rf ${TEMP_DIR} rm -rf ${TEMP_DIR}
echo "Please find it manually in the list above and rerun with the -c parameter." echo "Please find it manually in the list above and rerun with the -c parameter."
exit 1 exit 1
@ -178,8 +182,8 @@ if [[ ! "$TEMP_DIR" || ! -d "$TEMP_DIR" ]]; then
echo "Could not create temp dir" echo "Could not create temp dir"
exit 1 exit 1
fi fi
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c ${CHIPNAME} -r ${TEMP_DIR}/test1.rom
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c ${CHIPNAME} -r ${TEMP_DIR}/test2.rom
flashrom -p ${programmer} -c ${CHIPNAME} -r ${TEMP_DIR}/test1.rom
flashrom -p ${programmer} -c ${CHIPNAME} -r ${TEMP_DIR}/test2.rom
cmp --silent ${TEMP_DIR}/test1.rom ${TEMP_DIR}/test2.rom cmp --silent ${TEMP_DIR}/test1.rom ${TEMP_DIR}/test2.rom
if [ "$have_backupname" -gt 0 ] ; then if [ "$have_backupname" -gt 0 ] ; then
cp ${TEMP_DIR}/test1.rom ${BACKUPNAME} cp ${TEMP_DIR}/test1.rom ${BACKUPNAME}
@ -193,5 +197,5 @@ fi
rm -rf ${TEMP_DIR} rm -rf ${TEMP_DIR}
echo -e "${GREEN}connection ok${NC}. flashing ${INPUT_IMAGE_NAME}" echo -e "${GREEN}connection ok${NC}. flashing ${INPUT_IMAGE_NAME}"
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c ${CHIPNAME} -w ${INPUT_IMAGE_PATH}
flashrom -p ${programmer} -c ${CHIPNAME} -w ${INPUT_IMAGE_PATH}
echo -e "${GREEN}DONE${NC}" echo -e "${GREEN}DONE${NC}"

Loading…
Cancel
Save