summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki2024-07-12 09:36:48 +0000
committerRafał Miłecki2024-07-26 11:41:25 +0000
commita67b20e3d59adbfb9a699cdfad3e7370fd3696ca (patch)
tree804abc8a4ebc24c7e71b614fe2e370da74f7e249
parent73832e1a489b30133113b511fd1643b69d66a18b (diff)
downloadopenwrt-a67b20e3d59adbfb9a699cdfad3e7370fd3696ca.tar.gz
base-files: upgrade: nand: allow custom fw extraction in nand_do_upgrade()
By default nand_do_upgrade() can only deal with raw and gzipped firmware files. Vendors often use custom firmware containers. Allow passing custom extraction command to allow using nand_do_upgrade() with vendor firmwares. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-rw-r--r--package/base-files/files/lib/upgrade/nand.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh
index e868ba9537..9fa3cd2ddd 100644
--- a/package/base-files/files/lib/upgrade/nand.sh
+++ b/package/base-files/files/lib/upgrade/nand.sh
@@ -387,9 +387,11 @@ nand_verify_tar_file() {
nand_do_flash_file() {
local file="$1"
+ local cmd="$2"
+ local file_type
- local cmd="$(identify_if_gzip "$file")cat"
- local file_type="$(identify "$file" "$cmd" "")"
+ [ -z "$cmd" ] && cmd="$(identify_if_gzip "$file")cat"
+ file_type="$(identify "$file" "$cmd" "")"
[ ! "$(find_mtd_index "$CI_UBIPART")" ] && CI_UBIPART=rootfs
@@ -423,17 +425,22 @@ nand_do_restore_config() {
# Supported firmware containers:
# 1. Raw file
# 2. Gzip
+# 3. Custom (requires passing extracting command)
#
# Supported data formats:
# 1. Tar with kernel/rootfs
# 2. UBI image (built using "ubinized")
# 3. UBIFS image (to update UBI volume with)
# 4. FIT image (to update UBI volume with)
+#
+# $(1): firmware file path
+# $(2): (optional) pipe command to extract firmware
nand_do_upgrade() {
local file="$1"
+ local cmd="$2"
sync
- nand_do_flash_file "$file" && nand_do_upgrade_success
+ nand_do_flash_file "$file" "$cmd" && nand_do_upgrade_success
nand_do_upgrade_failed
}