[OpenWrt-Devel] [PATCH 2/2] brcm47xx: extend firmware validation

Rafał Miłecki zajec5 at gmail.com
Fri Aug 23 02:15:24 EDT 2019


From: Rafał Miłecki <rafal at milecki.pl>

This provides TRX validation result, so final JSON may look like:
{
        "tests": {
                "fwtool_signature": true,
                "fwtool_device_match": true,
                "trx_valid": true
        },
        "valid": true,
        "forceable": true
}

It also prevents users from installing broken firmware files, e.g.:

$ sysupgrade -F /tmp/dhcp.leases
Image metadata not found
Invalid image type. Please use firmware specific for this device.
Image check failed. This firmware can't be installed.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 .../brcm47xx/base-files/lib/upgrade/platform.sh      | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
index dfd4e97ed2..cc3fabb7f4 100644
--- a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
@@ -98,7 +98,10 @@ platform_check_image() {
 
 			if ! otrx check "$1" -o "$header_len"; then
 				echo "No valid TRX firmware in the CHK image"
+				notify_check_test_result "trx_valid" 0
 				error=1
+			else
+				notify_check_test_result "trx_valid" 1
 			fi
 		;;
 		"cybertan")
@@ -113,17 +116,24 @@ platform_check_image() {
 
 			if ! otrx check "$1" -o 32; then
 				echo "No valid TRX firmware in the CyberTAN image"
+				notify_check_test_result "trx_valid" 0
 				error=1
+			else
+				notify_check_test_result "trx_valid" 1
 			fi
 		;;
 		"trx")
 			if ! otrx check "$1"; then
 				echo "Invalid (corrupted?) TRX firmware"
+				notify_check_test_result "trx_valid" 0
 				error=1
+			else
+				notify_check_test_result "trx_valid" 1
 			fi
 		;;
 		*)
-			echo "Invalid image type. Please use only .trx files"
+			echo "Invalid image type. Please use firmware specific for this device."
+			notify_check_broken
 			error=1
 		;;
 	esac
-- 
2.21.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list