|
@ -123,40 +123,40 @@ else |
|
|
exit 1 |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
TEMP_DIR=`mktemp -d` |
|
|
|
|
|
|
|
|
TEMP_DIR=$(mktemp -d) |
|
|
if [ ! -d "$TEMP_DIR" ]; then |
|
|
if [ ! -d "$TEMP_DIR" ]; then |
|
|
echo -e "${RED}Error:${NC} Could not create temp dir" |
|
|
echo -e "${RED}Error:${NC} Could not create temp dir" |
|
|
rm -rf ${TEMP_DIR} |
|
|
|
|
|
|
|
|
rm -rf "${TEMP_DIR}" |
|
|
exit 1 |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
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 ${programmer} &> ${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 |
|
|
usage |
|
|
usage |
|
|
echo "-------------- flashrom error: ---------------" |
|
|
echo "-------------- flashrom error: ---------------" |
|
|
cat ${TEMP_DIR}/chips |
|
|
|
|
|
rm -rf ${TEMP_DIR} |
|
|
|
|
|
|
|
|
cat "${TEMP_DIR}"/chips |
|
|
|
|
|
rm -rf "${TEMP_DIR}" |
|
|
exit 1 |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
CHIPNAME="" |
|
|
CHIPNAME="" |
|
|
chip_found=0 |
|
|
chip_found=0 |
|
|
CHIPNAME=$(cat ${TEMP_DIR}/chips | grep Found | grep "MX25L6406E/MX25L6408E" | grep -o '".*"' || true) |
|
|
|
|
|
|
|
|
CHIPNAME=$(cat "${TEMP_DIR}"/chips | grep Found | grep "MX25L6406E/MX25L6408E" | grep -o '".*"' || true) |
|
|
if [ ! -z "${CHIPNAME}" ] ; then |
|
|
if [ ! -z "${CHIPNAME}" ] ; then |
|
|
chip_found=1 |
|
|
chip_found=1 |
|
|
fi |
|
|
fi |
|
|
CHIPNAME=$(cat ${TEMP_DIR}/chips | grep Found | grep "EN25QH64" | grep -o '".*"' || true) |
|
|
|
|
|
|
|
|
CHIPNAME=$(cat "${TEMP_DIR}"/chips | grep Found | grep "EN25QH64" | grep -o '".*"' || true) |
|
|
if [ ! -z "${CHIPNAME}" ] ; then |
|
|
if [ ! -z "${CHIPNAME}" ] ; then |
|
|
chip_found=1 |
|
|
chip_found=1 |
|
|
fi |
|
|
fi |
|
|
if [ ! "$chip_found" -gt 0 ] ; then |
|
|
if [ ! "$chip_found" -gt 0 ] ; then |
|
|
echo "chip not detected." |
|
|
echo "chip not detected." |
|
|
flashrom -p ${programmer} |
|
|
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 |
|
|
else |
|
|
else |
|
@ -185,17 +185,17 @@ fi |
|
|
if [ "$me_clean" -gt 0 ] ; then |
|
|
if [ "$me_clean" -gt 0 ] ; then |
|
|
if [ ! -e ${ME_CLEANER_PATH} ] ; then |
|
|
if [ ! -e ${ME_CLEANER_PATH} ] ; then |
|
|
echo "me_cleaner not found at ${ME_CLEANER_PATH}" |
|
|
echo "me_cleaner not found at ${ME_CLEANER_PATH}" |
|
|
rm -rf ${TEMP_DIR} |
|
|
|
|
|
|
|
|
rm -rf "${TEMP_DIR}" |
|
|
exit 1 |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
echo "Start reading 2 times. Please be patient..." |
|
|
echo "Start reading 2 times. Please be patient..." |
|
|
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 |
|
|
|
|
|
|
|
|
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 |
|
|
if [ "$have_backupname" -gt 0 ] ; then |
|
|
if [ "$have_backupname" -gt 0 ] ; then |
|
|
cp ${TEMP_DIR}/test1.rom ${BACKUPNAME} |
|
|
|
|
|
|
|
|
cp "${TEMP_DIR}"/test1.rom "${BACKUPNAME}" |
|
|
echo "current image saved as ${BACKUPNAME}" |
|
|
echo "current image saved as ${BACKUPNAME}" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
@ -203,7 +203,7 @@ reference_size=8388608 |
|
|
TEMP_SIZE=$(wc -c <"$TEMP_DIR/test1.rom") |
|
|
TEMP_SIZE=$(wc -c <"$TEMP_DIR/test1.rom") |
|
|
if [ ! "$reference_size" -eq "$TEMP_SIZE" ] ; then |
|
|
if [ ! "$reference_size" -eq "$TEMP_SIZE" ] ; then |
|
|
echo -e "${RED}Error:${NC} didn't read 8M. You might be at the wrong chip." |
|
|
echo -e "${RED}Error:${NC} didn't read 8M. You might be at the wrong chip." |
|
|
rm -rf ${TEMP_DIR} |
|
|
|
|
|
|
|
|
rm -rf "${TEMP_DIR}" |
|
|
exit 1 |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
@ -211,20 +211,20 @@ echo -e "${GREEN}connection ok${NC}" |
|
|
|
|
|
|
|
|
echo "start unlocking ..." |
|
|
echo "start unlocking ..." |
|
|
if [ "$me_clean" -gt 0 ] ; then |
|
|
if [ "$me_clean" -gt 0 ] ; then |
|
|
${ME_CLEANER_PATH} -S -O ${TEMP_DIR}/work.rom ${TEMP_DIR}/test1.rom |
|
|
|
|
|
|
|
|
${ME_CLEANER_PATH} -S -O "${TEMP_DIR}"/work.rom "${TEMP_DIR}"/test1.rom |
|
|
else |
|
|
else |
|
|
cp ${TEMP_DIR}/test1.rom ${TEMP_DIR}/work.rom |
|
|
|
|
|
|
|
|
cp "${TEMP_DIR}"/test1.rom "${TEMP_DIR}"/work.rom |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if [ ! "$lock" -gt 0 ] ; then |
|
|
if [ ! "$lock" -gt 0 ] ; then |
|
|
${IFDTOOL_PATH} -u ${TEMP_DIR}/work.rom |
|
|
|
|
|
|
|
|
${IFDTOOL_PATH} -u "${TEMP_DIR}"/work.rom |
|
|
else |
|
|
else |
|
|
${IFDTOOL_PATH} -l ${TEMP_DIR}/work.rom |
|
|
|
|
|
|
|
|
${IFDTOOL_PATH} -l "${TEMP_DIR}"/work.rom |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if [ ! -e ${TEMP_DIR}/work.rom.new ] ; then |
|
|
|
|
|
|
|
|
if [ ! -e "${TEMP_DIR}"/work.rom.new ] ; then |
|
|
echo -e "${RED}Error:${NC} ifdtool failed. ${TEMP_DIR}/work.rom.new not found." |
|
|
echo -e "${RED}Error:${NC} ifdtool failed. ${TEMP_DIR}/work.rom.new not found." |
|
|
rm -rf ${TEMP_DIR} |
|
|
|
|
|
|
|
|
rm -rf "${TEMP_DIR}" |
|
|
exit 1 |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
if [ "$me_clean" -gt 0 ] ; then |
|
|
if [ "$me_clean" -gt 0 ] ; then |
|
@ -236,6 +236,6 @@ make clean -C util/ifdtool |
|
|
|
|
|
|
|
|
echo "start writing..." |
|
|
echo "start writing..." |
|
|
|
|
|
|
|
|
flashrom -p ${programmer} -c ${CHIPNAME} -w ${TEMP_DIR}/work.rom.new |
|
|
|
|
|
rm -rf ${TEMP_DIR} |
|
|
|
|
|
|
|
|
flashrom -p ${programmer} -c "${CHIPNAME}" -w "${TEMP_DIR}"/work.rom.new |
|
|
|
|
|
rm -rf "${TEMP_DIR}" |
|
|
echo -e "${GREEN}DONE${NC}" |
|
|
echo -e "${GREEN}DONE${NC}" |