Skip to content

Commit

Permalink
board/pluto/update_frm: Add update firmware script
Browse files Browse the repository at this point in the history
This script can be called from an USB storage using the runme.sh script

#!/bin/sh
/sbin/update_frm.sh pluto.frm

Signed-off-by: Michael Hennerich <[email protected]>
  • Loading branch information
mhennerich committed Aug 20, 2018
1 parent 2bf8687 commit 04dceb2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
1 change: 1 addition & 0 deletions board/pluto/post-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ mkdir -p ${TARGET_DIR}/www/img
mkdir -p ${TARGET_DIR}/etc/wpa_supplicant/

${INSTALL} -D -m 0755 ${BOARD_DIR}/update.sh ${TARGET_DIR}/sbin/
${INSTALL} -D -m 0755 ${BOARD_DIR}/update_frm.sh ${TARGET_DIR}/sbin/
${INSTALL} -D -m 0755 ${BOARD_DIR}/udc_handle_suspend.sh ${TARGET_DIR}/sbin/
${INSTALL} -D -m 0755 ${BOARD_DIR}/S10mdev ${TARGET_DIR}/etc/init.d/
${INSTALL} -D -m 0755 ${BOARD_DIR}/S15watchdog ${TARGET_DIR}/etc/init.d/
Expand Down
12 changes: 6 additions & 6 deletions board/pluto/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ process_ini() {
}

handle_boot_frm () {
FILE=$1
FILE="$1"
rm -f /mnt/BOOT_SUCCESS /mnt/BOOT_FAILED /mnt/FAILED_MTD_PARTITION_ERROR /mnt/FAILED_BOOT_CHSUM_ERROR
head -3 /proc/mtd | sed 's/00010000/00001000/g' > /opt/mtd

Expand Down Expand Up @@ -170,8 +170,8 @@ handle_boot_frm () {


handle_frimware_frm () {
FILE=$1
MAGIC=$2
FILE="$1"
MAGIC="$2"
rm -f /mnt/SUCCESS /mnt/FAILED /mnt/FAILED_FIRMWARE_CHSUM_ERROR
md5=`tail -c 33 ${FILE}`
head -c -33 ${FILE} > /opt/firmware.frm
Expand All @@ -180,7 +180,7 @@ handle_frimware_frm () {
if [ "$frm" = "$md5" ]
then
flash_indication_on
grep -q ${MAGIC} /opt/firmware.frm && dd if=/opt/firmware.frm of=/dev/mtdblock3 bs=64k && fw_setenv fit_size ${FRM_SIZE} && do_reset=1 && touch /mnt/SUCCESS || touch /mnt/FAILED
grep -q "${MAGIC}" /opt/firmware.frm && dd if=/opt/firmware.frm of=/dev/mtdblock3 bs=64k && fw_setenv fit_size ${FRM_SIZE} && do_reset=1 && touch /mnt/SUCCESS || touch /mnt/FAILED
flash_indication_off
else
echo $frm $md5 > /mnt/FAILED_FIRMWARE_CHSUM_ERROR
Expand Down Expand Up @@ -211,12 +211,12 @@ do

if [[ -s ${FIRMWARE} ]]
then
handle_frimware_frm ${FIRMWARE} ${FRM_MAGIC}
handle_frimware_frm "${FIRMWARE}" "${FRM_MAGIC}"
fi

if [[ -s ${bootimage} ]]
then
handle_boot_frm ${bootimage}
handle_boot_frm "${bootimage}"
fi

md5sum -c /opt/config.md5 || process_ini $conf
Expand Down
49 changes: 49 additions & 0 deletions board/pluto/update_frm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

#set -x

source /etc/device_config

FRM_FILE="$1"

flash_indication_on() {
echo timer > /sys/class/leds/led0:green/trigger
echo 40 > /sys/class/leds/led0:green/delay_off
echo 40 > /sys/class/leds/led0:green/delay_on
}

flash_indication_off() {
echo heartbeat > /sys/class/leds/led0:green/trigger
}

handle_frimware_frm () {
FILE="$1"
MAGIC="$2"
md5=`tail -c 33 ${FILE}`
head -c -33 ${FILE} > /opt/firmware.frm
FRM_SIZE=`cat /opt/firmware.frm | wc -c | xargs printf "%X\n"`
frm=`md5sum /opt/firmware.frm | cut -d ' ' -f 1`
if [ "$frm" = "$md5" ]
then
flash_indication_on
grep -q "${MAGIC}" /opt/firmware.frm && dd if=/opt/firmware.frm of=/dev/mtdblock3 bs=64k && fw_setenv fit_size ${FRM_SIZE} && echo "Done" || echo "Failed"
flash_indication_off
rm -f /opt/firmware.frm
sync
exit 0
else
rm -f /opt/firmware.frm
echo Failed Checksum error: $frm $md5
exit 1
fi
}



if [[ -f ${FRM_FILE} ]] && [[ ${FRM_FILE: -4} == ".frm" ]] && [[ -s ${FRM_FILE} ]]
then
handle_frimware_frm "${FRM_FILE}" "${FRM_MAGIC}"
else
echo "Failed"
exit 1
fi

0 comments on commit 04dceb2

Please sign in to comment.