- Add get_last_bytes.sh to extract final 2 bytes from IUM files - Add read_bytes.sh for reading specific byte offsets from binaries - Add pack_resources.sh to package and upload CP02S resources to S3 - Add signer_new.py for firmware and bootloader signing with custom SHA1 - Update extract_firmware.sh to use fixed output filenames - Update README.md with comprehensive documentation for new tools
28 lines
684 B
Bash
Executable File
28 lines
684 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script to get the last two bytes of ium file
|
|
# Returns the bytes in 0x format
|
|
# Usage: ./get_last_bytes.sh [ium_file_path]
|
|
|
|
# Use provided path or default to ium.bin
|
|
ium_file=${1:-ium.bin}
|
|
|
|
if [ ! -f "$ium_file" ]; then
|
|
echo "Error: $ium_file file not found"
|
|
exit 1
|
|
fi
|
|
|
|
# Get file size
|
|
file_size=$(stat -f%z "$ium_file")
|
|
|
|
if [ "$file_size" -lt 2 ]; then
|
|
echo "Error: File is too small (less than 2 bytes)"
|
|
exit 1
|
|
fi
|
|
|
|
# Extract last 2 bytes and reverse byte order
|
|
last_bytes=$(xxd -s -2 "$ium_file" | cut -d' ' -f2 | tr -d '\n')
|
|
# Reverse the byte order (swap first and second byte)
|
|
byte1=${last_bytes:0:2}
|
|
byte2=${last_bytes:2:2}
|
|
echo "${byte2}${byte1}" |