replace custom fw_savenev script with mkenvimage

Signed-off-by: Michel Stempin <michel.stempin@wanadoo.fr>
This commit is contained in:
Michel Stempin 2020-10-17 18:35:43 +02:00
parent 2d456ef6c7
commit fb18542bef
2 changed files with 1 additions and 57 deletions

View File

@ -1,57 +0,0 @@
#!/bin/sh
# Uncomment the following line to get debug info
#set -xv
source /usr/local/lib/utils
fw_saveenv () {
# Check arguments
if [ $# -ne 1 ]; then
die 1 "usage: fw_saveenv filename"
fi
# Save the input file name
local input_file="${1}"
# Read the fw_env config file
local config=$(sed -e 's/#.*$//' -e '/^$/d' /etc/fw_env.config)
set ${config}
local of=${1}
local seek=$((${2} / 1024))
local count=$((${3} / 1024))
# Create 2 temporary files
local blob_file=$(mktemp /tmp/fw_saveenv.XXXXXX)
local env_file=$(mktemp /tmp/fw_saveenv.XXXXXX)
# Convert the provided file to a null-terminated string blob
cat "${input_file}" | tr '\n' '\0' > ${blob_file}
# Compute the blob length in bytes
set -- $(ls -l ${blob_file})
local length=${5}
# Compute the padding size in bytes
let padding=${count}*1024-4-${length}
# Pad the blob file with zeros up to the total size
dd if=/dev/zero bs=1 count=${padding} >>${blob_file} 2>/dev/null
# Compute the CRC32 for the padded blob and store it at the beginning of the env file
set $(cat ${blob_file} | gzip -1 | tail -c 8 | head -c 4 | hexdump -e '4/1 "%02X "')
printf "\\x$1\\x$2\\x$3\\x$4" > ${env_file}
# Append the binary blob file to the env file
cat ${blob_file} >> ${env_file}
# Write the final env file to the raw device
dd if=${env_file} of=${of} bs=1k count=${count} seek=${seek} 2>/dev/null
# Remove the temporay files
rm ${blob_file} ${env_file}
return 0
}
fw_saveenv $*

View File

@ -64,6 +64,7 @@ BR2_PACKAGE_GPTFDISK_SGDISK=y
BR2_PACKAGE_PARTED=y
BR2_PACKAGE_SYSSTAT=y
BR2_PACKAGE_UBOOT_TOOLS=y
BR2_PACKAGE_UBOOT_TOOLS_MKENVIMAGE=y
BR2_PACKAGE_LIBQRENCODE=y
BR2_PACKAGE_LIBQRENCODE_TOOLS=y
BR2_PACKAGE_LIBNL=y