Skip to content

Commit

Permalink
swupdate-scripts: add a script to report the mmc / storage size
Browse files Browse the repository at this point in the history
This script reports the size of the flash chip. Since it will report
a valid value for any block device it is booted from and to make clear
it is not a partition size, it is named storage-size.

The script will fail when the root partition is not a block device, e.g.
on the devices using ubi.
  • Loading branch information
jhofstee committed Feb 24, 2025
1 parent 7bc70ad commit 0b67422
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions meta-venus/recipes-support/swupdate-scripts/files/storage-size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# only block devices are supported at the moment
rootpart="$(mount | grep ' on / ' | awk '{print $1}')"
parentdev=$(echo $rootpart | sed -n -r 's,^/dev/([a-zA-Z0-9]+)p[0-9]$,\1,p')
if [ "$parentdev" = "" ]; then
echo "$rootdev doesn't seem to be a block device" 1>&2
exit 1
fi

sysdir="/sys/block/$parentdev"
if [ ! -d $sysdir ]; then
echo "$sysdir doesn't exist" 1>&2
exit 1
fi

awk '{print $1*512}' "$sysdir/size"

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SRC_URI = " \
file://set-feed.sh \
file://set-swu-feed.sh \
file://set-version.sh \
file://storage-size.sh \
"

S = "${WORKDIR}/sources"
Expand All @@ -37,6 +38,7 @@ do_install () {
install -m 0755 ${UNPACKDIR}/set-feed.sh ${DEST}/set-feed.sh
install -m 0755 ${UNPACKDIR}/set-swu-feed.sh ${DEST}/set-swu-feed.sh
install -m 0755 ${UNPACKDIR}/set-version.sh ${DEST}/set-version.sh
install -m 0755 ${UNPACKDIR}/storage-size.sh ${DEST}/storage-size.sh

DEST=${D}${sysconfdir}/init.d
install -d ${DEST}
Expand Down

0 comments on commit 0b67422

Please sign in to comment.