Skip to content

Commit

Permalink
add image-update postinst dir and u-boot update script (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
webconn authored Jan 20, 2022
1 parent db66874 commit 74d5774
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ BINDIR = $(DESTDIR)/$(prefix)/bin
LIBDIR = $(DESTDIR)/$(prefix)/lib/wb-utils
PREPARE_LIBDIR = $(LIBDIR)/prepare
RTC_LIBDIR = $(LIBDIR)/wb-gsm-rtc
IMAGEUPDATE_POSTINST_DIR = $(DESTDIR)/$(prefix)/lib/wb-image-update/postinst

install:
install -m 0755 -d $(BINDIR) $(LIBDIR) $(PREPARE_LIBDIR) $(RTC_LIBDIR)
install -m 0755 -d $(BINDIR) $(LIBDIR) $(PREPARE_LIBDIR) $(RTC_LIBDIR) $(IMAGEUPDATE_POSTINST_DIR)

install -m 0644 utils/etc_wb_env.sh $(DESTDIR)/etc/wb_env.sh

Expand Down Expand Up @@ -48,6 +49,9 @@ install:
utils/bin/wb-watch-update \
utils/bin/wb-run-update

install -m 0755 -t $(IMAGEUPDATE_POSTINST_DIR) \
utils/lib/wb-image-update/postinst/10update-u-boot

clean:
@echo Nothing to do

Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-utils (3.4.0) stable; urgency=medium

* image-postinst: add script to update u-boot during factory reset

-- Nikita Maslov <[email protected]> Thu, 20 Jan 2022 23:29:28 +0300

wb-utils (3.3.0) stable; urgency=medium

* support for factory restore fit on eMMC and new update mode in bootloader
Expand Down
35 changes: 35 additions & 0 deletions utils/lib/wb-image-update/postinst/10update-u-boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh -e

# Called from install_update.sh with arguments
# /path/to/script /path/to/new/rootfs [flag1 [flag2 ...]]
#
# This script may run in Busybox initramfs environment,
# so if you need some special tools or features, use ones from rootfs.
#
# /dev, /proc and /sys are already bind-mounted
# from host system to rootfs tree.

if [ $# -lt 1 ]; then
echo "Usage: $0 path/to/rootfs [flag1 [flag2 ...]]"
exit 2
fi

ROOTFS="$1"
shift
FLAGS="$*"

flag_set() {
echo "$FLAGS" | grep -- "--$1" >/dev/null 2>&1
}

if ! flag_set "factoryreset" ; then
echo "Skipping u-boot update (use factory reset to do it)"
exit
fi

if [ -e "$ROOTFS/usr/bin/u-boot-install-wb" ] ; then
echo "Trying to install u-boot using u-boot-install-wb from new rootfs"
chroot "$ROOTFS" /usr/bin/u-boot-install-wb --force
else
echo "No u-boot installer found in new rootfs, skipping step"
fi
20 changes: 20 additions & 0 deletions utils/lib/wb-image-update/postinst/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Wiren Board image update postinst scripts
=========================================

Scripts from this directory are called in FIT image installation process
after rootfs is extracted and device certificates are recovered.

Scripts from NEW rootfs are used.

Scripts are called NOT from this rootfs environment. They may be even
called from Busybox minimal environment (initramfs in FIT images).
If you need some tools from rootfs, use chroot.
/dev, /proc and /sys are already mounted to rootfs here.

Scripts are called in alphabetic order; you can use it by adding numeric
prefixes to script names (e.g. 99-install-uboot.sh).

Invokation of these scripts is performed in install_image.sh script
(see https://github.com/wirenboard/wirenboard repo for more details).

See 10update-u-boot script as an example.

0 comments on commit 74d5774

Please sign in to comment.