Browse Source

image: add cameo-factory command

This command enables factory image generation for Cameo boards. On
upgrade the vendor firmware will check the size of the provided image
and if a specific string is located at the end of the binary.
cameo-factory will generate an image that the vendor firmware accepts.

Tested on a D-Link DIR-825 C1 with vendor firmwares 3.01 and 3.04.

Signed-off-by: Sebastian Kemper <[email protected]>
Sebastian Kemper 7 years ago
parent
commit
247fdceab6
1 changed files with 12 additions and 0 deletions
  1. 12 0
      include/image-commands.mk

+ 12 - 0
include/image-commands.mk

@@ -44,6 +44,18 @@ define Build/buffalo-dhp-image
 	mv [email protected] $@
 endef
 
+# blow up binary to given size and put a given string at its end:
+# cameo-factory <size[k]> <string>
+define Build/cameo-factory
+	factory_stamp=$(word 2,$(1)); \
+	((reduced_size=$(subst k,*1024,$(word 1,$(1)))-$${#factory_stamp})); \
+	( \
+		dd if=$@ bs=$$reduced_size conv=sync; \
+		echo -n $$factory_stamp; \
+	) > [email protected] && \
+	mv [email protected] $@
+endef
+
 define Build/eva-image
 	$(STAGING_DIR_HOST)/bin/lzma2eva $(KERNEL_LOADADDR) $(KERNEL_LOADADDR) $@ [email protected]
 	mv [email protected] $@