Skip to content

Commit

Permalink
spacemit: apply quoting to fix more glaring problems
Browse files Browse the repository at this point in the history
- add a TODO for the original author of a "if $(...)" statement which I can't understand; it's still wrong
  • Loading branch information
rpardini committed Nov 30, 2024
1 parent d1625e9 commit 3016a66
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions config/sources/families/spacemit.conf
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,32 @@ write_uboot_platform() {

declare -A d
d=(
[${1}/bootinfo_emmc.bin]="0:$(du -b ${1}/bootinfo_emmc.bin | awk '{print $1}')"
[${1}/FSBL.bin]="512:$(du -b ${1}/FSBL.bin | awk '{print $1}')"
["${1}/bootinfo_emmc.bin"]="0:$(du -b "${1}/bootinfo_emmc.bin" | awk '{print $1}')"
["${1}/FSBL.bin"]="512:$(du -b "${1}/FSBL.bin" | awk '{print $1}')"
)

if [ -b ${2}boot0 ]; then
device=${2}boot0
echo 0 > /sys/block/$(basename ${device})/force_ro
echo 0 > "/sys/block/$(basename "${device}")/force_ro"
sync
fi

for f in "${!d[@]}"
do
# @TODO: "if $(...)" works by accident, should be "if ..." instead
if $(dd if=${device} bs=1 skip="${d[$f]%:*}" count="${d[$f]#*:}" \
conv=notrunc status=noxfer 2>/dev/null | cmp --quiet "${f}")
then
echo "Skip $(basename $f), it is equal to the existing one"
else
echo "# Write =: $(basename $f) to ${device}"
dd if=$f of=${device} bs=1 seek="${d[$f]%:*}" conv=notrunc status=noxfer
dd "if=$f" "of=${device}" bs=1 seek="${d[$f]%:*}" conv=notrunc status=noxfer
sync
fi
done

dd if=$1/fw_dynamic.itb of=${2} bs=512 seek=1280 conv=notrunc
dd "if=$1/fw_dynamic.itb" "of=${2}" bs=512 seek=1280 conv=notrunc
sync
dd if=$1/u-boot.itb of=${2} bs=512 seek=2048 conv=notrunc
dd "if=$1/u-boot.itb of=${2}" bs=512 seek=2048 conv=notrunc
sync
}

0 comments on commit 3016a66

Please sign in to comment.