forked from mendersoftware/meta-mender-community
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding mender tegra-state-script to align boot and rootfs partition
The mender boot slot values are not in sync with nvbootctrl slot values. The values are updated correctly in the mender_boot_part variable, but the nvbootctrl fails to sync up with the latest boot partition to use on the next reboot after a mender update sometimes. This commit would rectify the issue by identifying the mismatch and giving a Warning and dumping all the data for debug. At the same time it would set the active boot partition based on the value in mender_boot_partition, so that there is no mismatch going forward. This script would run after every mender update.
- Loading branch information
Siddhant Jajoo
committed
Nov 6, 2020
1 parent
1683cf7
commit d47757d
Showing
6 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
meta-mender-tegra/recipes-mender/mender-client/files/mender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
echo "Starting mender wrapper" | ||
mender_override $@ | ||
|
||
rc=$? | ||
if [ $rc -eq 0 ]; then | ||
if [ $1 = "install" || $1 = "-install" ]; then | ||
This comment has been minimized.
Sorry, something went wrong. |
||
touch /var/lib/mender/mender-install-success | ||
fi | ||
fi | ||
|
10 changes: 10 additions & 0 deletions
10
meta-mender-tegra/recipes-mender/mender-client/files/mender-client-commit.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=Automatice Mender Commit Service | ||
After=basic.target | ||
|
||
[Service] | ||
ExecStart=/etc/mender/mender-client-commit.sh | ||
Type=oneshot | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
11 changes: 11 additions & 0 deletions
11
meta-mender-tegra/recipes-mender/mender-client/files/mender-client-commit.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
/etc/mender/verify-boot-rootfs-slot-alignment-uboot | ||
|
||
if [ -f /var/lib/mender/mender-install-success ]; then | ||
/usr/bin/mender -commit | ||
rc=$? | ||
if [ $rc -eq 0 ]; then | ||
rm /var/lib/mender/mender-install-success | ||
fi | ||
fi |
21 changes: 21 additions & 0 deletions
21
meta-mender-tegra/recipes-mender/mender-client/mender-client_%.bbappend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
RDEPENDS_${PN}_append_tegra = "${@' tegra-bup-payload libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else ''}" | ||
|
||
FILESEXTRAPATHS_prepend := "${THISDIR}/files:" | ||
SRC_URI += " \ | ||
file://mender \ | ||
file://mender-client-commit.service \ | ||
file://mender-client-commit.sh \ | ||
" | ||
|
||
FILES_${PN} += "${systemd_system_unitdir}/mender-client-commit.service" | ||
FILES_${PN} += "${sysconfdir}/mender/mender-client-commit.sh" | ||
FILES_${PN} += "${bindir}/mender" | ||
|
||
SYSTEMD_SERVICE_${PN} = "mender-client-commit.service" | ||
|
||
do_install_append_mender-uboot() { | ||
mv ${D}${bindir}/mender ${D}${bindir}/mender_override | ||
install -m 0755 ${WORKDIR}/mender ${D}${bindir}/mender | ||
install -d ${D}${sysconfdir}/mender/scripts | ||
install -m 0755 ${WORKDIR}/mender-client-commit.sh ${D}${sysconfdir}/mender/mender-client-commit.sh | ||
install -m 0644 ${WORKDIR}/mender-client-commit.service ${D}${systemd_system_unitdir}/mender-client-commit.service | ||
} |
47 changes: 47 additions & 0 deletions
47
...mender/tegra-state-scripts/files/redundant-boot-install-script-uboot-check-boot-partition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
echo "Verify if nvbootctrl slot matches rootfs partition" | ||
|
||
# This variable will be populated with the partition number to boot from | ||
mender_boot_partition=`fw_printenv -n mender_boot_part` | ||
devnam=`grep -h "$mender_boot_partition" /etc/mender/mender.conf /var/lib/mender/mender.conf | tr -d '" ' | sed "s/RootfsPart//" | cut -f1 -d":"` | ||
|
||
# Fetching corresponding boot slot | ||
if [ $devnam = A ]; then | ||
mender_boot_slot=0 | ||
elif [ $devnam = B ]; then | ||
mender_boot_slot=1 | ||
fi | ||
|
||
# Have default value here | ||
nvbootctrl_slot=`nvbootctrl get-current-slot` | ||
priority_slot0=`nvbootctrl dump-slots-info | grep 'priority' | awk 'FNR == 1 {print $4}' | cut -d ',' -f 1` | ||
priority_slot1=`nvbootctrl dump-slots-info | grep 'priority' | awk 'FNR == 2 {print $4}' | cut -d ',' -f 1` | ||
|
||
# Determining the boot slot that would be used after reboot | ||
# Whichever boot slot would have the higher priority, that would be used in the next boot. | ||
if [ $priority_slot1 -gt $priority_slot0 ]; then | ||
nvbootctrl_slot=1 | ||
fi | ||
|
||
# Checking if the mender and nvbootctrl align to the same boot slots | ||
# if not set nvbootctrl active boot slot sane as mender_boot_slot | ||
# Dumping Warning prints to stderr since mender state scripts logs only read stderr. | ||
if [ $mender_boot_slot -ne $nvbootctrl_slot ]; then | ||
echo "********************* WARNING!!!!! *********************" >&2 | ||
echo "Partition mismatch for boot and rootfs on reboot" >&2 | ||
echo "mender boot slot: ${mender_boot_slot}" >&2 | ||
echo "nvbootctrl slot: ${nvbootctrl_slot}" >&2 | ||
echo "Setting the current nvbootctrl slot manually to the value of mender boot slot" >&2 | ||
nvbootctrl set-active-boot-slot ${mender_boot_slot} | ||
|
||
echo "Dumping partition information" >&2 | ||
echo `nvbootctrl get-current-slot` >&2 | ||
echo `nvbootctrl dump-slots-info` >&2 | ||
echo `fw_printenv -n mender_boot_part` >&2 | ||
|
||
echo "Rebooting the device to set the active slot before proceeding for an update" >&2 | ||
echo "Entire process would be required again to mender update" | ||
reboot | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jajoosiddhant In think install can be after global options, so it would probably be better to grep for " install " or " -install ", so I think you could use: