Skip to content

Commit

Permalink
fit_tools: adjust code a bit, if there's no 64-bit arithmetics in the…
Browse files Browse the repository at this point in the history
… used shell
  • Loading branch information
PeterPawn committed Mar 27, 2022
1 parent 89c867c commit 7476f92
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion fit_tools/fit-add-avm-header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ add_avm_header()
fi
debug "Input file: %s%s%s\n" "$__yf_ansi_bright_green__" "$img" "$__yf_ansi_reset__"
debug "Looking for FDT magic value at offset 0x00 ..."
if ! [ "$(dd if="$img" bs=4 count=1 2>"$null" | b2d)" = "3490578157" ]; then
fdt_magic="$(dd if="$img" bs=4 count=1 2>"$null" | b2d)"
if { [ "$fdt_magic" -gt 0 ] && [ "$fdt_magic" -ne 3490578157 ]; } || { [ "$fdt_magic" -lt 0 ] && [ "$fdt_magic" -ne -804389139 ]; }; then
debug "$(result 1 " failed")"
printf -- "Invalid FDT magic at start of input file '%s'.\a\n" "$img" 1>&2
exit 1
Expand Down
1 change: 0 additions & 1 deletion fit_tools/fit-findfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ find_rootfs_in_fit_image()

img="$1"
magic="$(dd if="$img" bs=4 count=1 2>"$null" | b2d)"
[ "$magic" -lt 0 ] && magic=$(( magic & 0xffffffff ))
if ! [ "$magic" = "218164734" ]; then
printf "Invalid magic value (0x%08x) found at offset 0x%02x.\a\n" "$magic" "0" 1>&2
exit 1
Expand Down
2 changes: 1 addition & 1 deletion fit_tools/fit-remove-avm-header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ remove_avm_header()
size=64
if [ "$dbg" = "1" ] && command -v hexdump 2>"$null" 1>&2; then
debug "\nData at offset 0x%02x, size %u:\n\n%s" "$offset" "$size" "$__yf_ansi_yellow__"
get_data "$img" "$size" "$offset" | hexdump -C | sed -n -e "1,$(( size / 16 ))p" 1>&2
get_data "$img" "$size" "$offset" | hexdump -C | sed -n -e "1,$(( size / 16 ))p" 1>&2 2>"$null"
debug "%s\n" "$__yf_ansi_reset__"
fi
offset=$(( offset + size ))
Expand Down

0 comments on commit 7476f92

Please sign in to comment.