Skip to content
Permalink
Browse files

firmware-utils: mksercommfw: overhaul image creation

Move the zip compression into a build recipe. Pad the image using the
existing build recipes as well to remove duplicate functionality

Change the code to append header and footer in two steps. Allow to use a
fixed filename as the netgear update image does.

Use a fixed timestamp within the zip archive to make the images
reproducible.

Due to the changes we are now compatible to the gnu89 c standard used by
default on the buildbots and we don't need to force a more recent
standard anymore.

Beside all changes, the footer still looks wrong in compare to the
netgear update image.

Signed-off-by: Mathias Kresin <dev@kresin.me>
  • Loading branch information...
mkresin committed Jan 12, 2019
1 parent 18c9faa commit 26a016731d1fc1e2bd6b5f8d3af0fdbd631363ff
Showing with 135 additions and 281 deletions.
  1. +10 −0 include/image-commands.mk
  2. +14 −9 target/linux/ramips/image/mt76x8.mk
  3. +1 −1 tools/firmware-utils/Makefile
  4. +110 −271 tools/firmware-utils/src/mksercommfw.c
@@ -168,6 +168,16 @@ define Build/gzip
@mv $@.new $@
endef

define Build/zip
mkdir $@.tmp
mv $@ $@.tmp/$(1)

zip -j -X \
$(if $(SOURCE_DATE_EPOCH),--mtime="$(SOURCE_DATE_EPOCH)") \
$@ $@.tmp/$(if $(1),$(1),$@)
rm -rf $@.tmp
endef

define Build/jffs2
rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
@@ -2,17 +2,22 @@
# MT76x8 Profiles
#

DEVICE_VARS += SERCOMM_KERNEL_OFFSET SERCOMM_HWID SERCOMM_HWVER SERCOMM_SWVER
DEVICE_VARS += SERCOMM_HWID SERCOMM_HWVER SERCOMM_SWVER

define Build/mksercommfw
define Build/sercom-seal
$(STAGING_DIR_HOST)/bin/mksercommfw \
$@ \
$(SERCOMM_KERNEL_OFFSET) \
$(SERCOMM_HWID) \
$(SERCOMM_HWVER) \
$(SERCOMM_SWVER)
-i $@ \
-b $(SERCOMM_HWID) \
-r $(SERCOMM_HWVER) \
-v $(SERCOMM_SWVER) \
$(1)
endef

define Build/sercom-footer
$(call Build/sercom-seal,-f)
endef


define Device/tplink
TPLINK_FLASHLAYOUT :=
TPLINK_HWID :=
@@ -116,14 +121,14 @@ define Device/netgear_r6120
IMAGE_SIZE := $(ralink_default_fw_size_16M)
DEVICE_TITLE := Netgear AC1200 R6120
DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci
SERCOMM_KERNEL_OFFSET := 0x90000
SERCOMM_HWID := CGQ
SERCOMM_HWVER := A001
SERCOMM_SWVER := 0x0040
IMAGES += factory.img
IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE)| append-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | check-size $$$$(IMAGE_SIZE)
IMAGE/factory.img := $$(IMAGE/default) | mksercommfw
IMAGE/factory.img := pad-extra 576k | $$(IMAGE/default) | \
sercom-footer | pad-to 128 | zip R6120.bin | sercom-seal
endef
TARGET_DEVICES += netgear_r6120

@@ -84,7 +84,7 @@ define Host/Compile
$(call cc,mkdhpimg buffalo-lib, -Wall)
$(call cc,mkdlinkfw mkdlinkfw-lib, -lz -Wall --std=c99)
$(call cc,dns313-header, -Wall)
$(call cc,mksercommfw, -Wall --std=gnu99)
$(call cc,mksercommfw, -Wall)
endef

define Host/Install

0 comments on commit 26a0167

Please sign in to comment.
You can’t perform that action at this time.