mirror of
https://github.com/feyisay07/meta-bsp-imx8mm.git
synced 2026-09-24 14:20:07 +01:00
Add utility cl-migrate-env
The of the utility is purposed for automated migration of an environment block during a u-boot update. Signed-off-by: Kirill Kapranov <kirill.kapranov@compulab.co.il>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# Simple recipe to add executable to run automated
|
||||
# CompuLab Environment Migration Tool
|
||||
|
||||
DESCRIPTION = "CompuLab Environment Migrate Tool"
|
||||
LICENSE = "BSD3"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"
|
||||
MAINTAINER = "Kirill Kapranov <kirill.kapranov@compulab.com>"
|
||||
|
||||
PR = "r0"
|
||||
|
||||
SRC_URI = " \
|
||||
file://cl-migrate-env \
|
||||
"
|
||||
S = "${WORKDIR}"
|
||||
|
||||
do_install() {
|
||||
sed -i -e "s/\(ENV_OFF=\)[[:alnum:]]*/\1${UBOOT_ENV_OFFSET}/" \
|
||||
-e "s/\(ENV_SIZE=\)[[:alnum:]]*/\1${UBOOT_ENV_SIZE}/" \
|
||||
${S}/cl-migrate-env
|
||||
|
||||
mkdir -p ${D}/usr/local/bin/
|
||||
install -m 0755 ${S}/cl-migrate-env ${D}/usr/local/bin/
|
||||
}
|
||||
|
||||
FILES_${PN} = " \
|
||||
/usr/local/bin/* \
|
||||
/usr/share/* \
|
||||
"
|
||||
|
||||
RDEPENDS_${PN} = "bash dialog util-linux cl-uboot"
|
||||
PACKAGE_ARCH = "${MACHINE_ARCH}"
|
||||
COMPATIBLE_MACHINE = "(ucm-imx8m-mini)"
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh -u
|
||||
|
||||
readonly ENV_DEV_LEGACY=/dev/mmcblk2
|
||||
readonly ENV_OFF_LEGACY=0x400000
|
||||
readonly ENV_DEV=${1:-${ENV_DEV_LEGACY}}
|
||||
readonly ENV_OFF=0x4400
|
||||
readonly ENV_SIZE=0x1000
|
||||
|
||||
readonly FW_CONF=$(mktemp /tmp/fw_XXXX.conf)
|
||||
readonly ENV_FILE=$(mktemp /tmp/env_XXXX)
|
||||
|
||||
trap "rm $ENV_FILE $FW_CONF" EXIT
|
||||
|
||||
function move_env()
|
||||
{
|
||||
echo $ENV_DEV $ENV_OFF $ENV_SIZE > $FW_CONF
|
||||
local err_mesage=$(set -o pipefail;\
|
||||
fw_setenv --config $FW_CONF --script $ENV_FILE 2>&1\
|
||||
| sed -ne'/Warning:/p' -e '/Error:/p')
|
||||
local retval=$?
|
||||
if [[ $retval -eq 0 ]] && [[ -z "${err_mesage}" ]]; then
|
||||
dialog --infobox "Environment migration successfull" 0 0
|
||||
else
|
||||
dialog --msgbox "Environment migration ERROR $retval\n$err_mesage" 0 0
|
||||
fi
|
||||
}
|
||||
|
||||
######## MAIN ########
|
||||
echo $ENV_DEV_LEGACY $ENV_OFF_LEGACY $ENV_SIZE > $FW_CONF
|
||||
err_count=$(set -o pipefail; fw_printenv -c $FW_CONF 2>&1 >$ENV_FILE \
|
||||
| awk 'BEGIN{i=0}/Warning:|Error:/{i++}END{print i}')
|
||||
retval=$?
|
||||
|
||||
if [[ $retval -eq 0 ]] && [[ $err_count -eq 0 ]]; then
|
||||
while :; do
|
||||
dialog --extra-button --extra-label View --ok-label Move \
|
||||
--yesno "\nA legacy environment found on ${ENV_DEV_LEGACY}@${ENV_OFF_LEGACY}\n\n\
|
||||
Move it to the new location ${ENV_DEV}@${ENV_OFF}?\n" 0 0
|
||||
btn_pressed=$?
|
||||
case $btn_pressed in
|
||||
0)
|
||||
move_env
|
||||
break
|
||||
;;
|
||||
3)
|
||||
dialog --textbox $ENV_FILE 0 0
|
||||
;;
|
||||
*)
|
||||
dialog --infobox "Cancelled by User" 0 0
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
@@ -44,7 +44,7 @@ eof
|
||||
|
||||
mod_local() {
|
||||
# Modify local.conf
|
||||
CORE_IMAGE_EXTRA_INSTALL+=" dhcp-client memtester cl-uboot cl-deploy cl-launcher cl-stest cl-camera u-boot-fw-utils imx-gpu-viv-demos"
|
||||
CORE_IMAGE_EXTRA_INSTALL+=" dhcp-client memtester cl-uboot cl-deploy cl-migrate-env cl-launcher cl-stest cl-camera u-boot-fw-utils imx-gpu-viv-demos"
|
||||
CORE_IMAGE_EXTRA_INSTALL+=" htop iotop tmux iperf3"
|
||||
IMAGE_FEATURES+=" package-management ssh-server-openssh "
|
||||
cat << eof | tee -a ${LOCAL_CONF} > /dev/null
|
||||
|
||||
Reference in New Issue
Block a user