| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- DEVICE_VARS += SERCOMM_KERNEL_OFFSET SERCOMM_ROOTFS_OFFSET
- DEVICE_VARS += SERCOMM_KERNEL2_OFFSET SERCOMM_ROOTFS2_OFFSET
- define Build/sercomm-append-tail
- printf 16 | dd seek=$$((0x90)) of=$@ bs=1 conv=notrunc 2>/dev/null
- printf 11223344556677889900112233445566 | \
- sed 's/../\\x&/g' | xargs -d . printf >> $@
- endef
- define Build/sercomm-crypto
- $(TOPDIR)/scripts/sercomm-crypto.py \
- --input-file $@ \
- --key-file [email protected] \
- --output-file [email protected] \
- --version $(SERCOMM_SWVER)
- $(STAGING_DIR_HOST)/bin/openssl enc -md md5 -aes-256-cbc \
- -in $@ \
- -out [email protected] \
- -K `cat [email protected]` \
- -iv 00000000000000000000000000000000
- dd [email protected] >> [email protected] 2>/dev/null
- mv [email protected] $@
- rm -f [email protected] [email protected]
- endef
- define Build/sercomm-factory-cpj
- dd bs=$$((0x1fff00)) count=1 if=$@ [email protected] conv=notrunc \
- 2>/dev/null
- dd bs=$$((0x1fff00)) skip=1 if=$@ [email protected] conv=notrunc \
- 2>/dev/null
- cp [email protected] [email protected]
- $(TOPDIR)/scripts/sercomm-kernel-header.py \
- --kernel-image [email protected] \
- --kernel-offset $(SERCOMM_KERNEL_OFFSET) \
- --rootfs-image [email protected] \
- --rootfs-offset $(SERCOMM_ROOTFS_OFFSET) \
- --output-header [email protected]
- $(TOPDIR)/scripts/sercomm-kernel-header.py \
- --kernel-image [email protected] \
- --kernel-offset $(SERCOMM_KERNEL2_OFFSET) \
- --rootfs-image [email protected] \
- --rootfs-offset $(SERCOMM_ROOTFS2_OFFSET) \
- --output-header [email protected]
- cat [email protected] [email protected] > [email protected]
- cat [email protected] [email protected] > [email protected]
- rm [email protected] [email protected] [email protected]
- $(call Build/sercomm-part-tag-common,kernel [email protected])
- $(call Build/sercomm-part-tag-common,kernel2 [email protected])
- $(call Build/sercomm-part-tag-common,rootfs [email protected])
- $(call Build/sercomm-part-tag-common,rootfs2 [email protected])
- cat [email protected] [email protected] [email protected] [email protected] > $@
- rm [email protected] [email protected] [email protected] [email protected]
- endef
- define Build/sercomm-factory-cqr
- $(TOPDIR)/scripts/sercomm-pid.py \
- --hw-version $(SERCOMM_HWVER) \
- --hw-id $(SERCOMM_HWID) \
- --sw-version $(SERCOMM_SWVER) \
- --pid-file [email protected] \
- --extra-padding-size 0x190
- printf $$(stat -c%s $(IMAGE_KERNEL)) | \
- dd seek=$$((0x70)) [email protected] bs=1 conv=notrunc 2>/dev/null
- printf $$(($$(stat -c%s $@)-$$(stat -c%s $(IMAGE_KERNEL))-$$((0x200)))) | \
- dd seek=$$((0x80)) [email protected] bs=1 conv=notrunc 2>/dev/null
- dd if=$@ >> [email protected] 2>/dev/null
- mv [email protected] $@
- endef
- define Build/sercomm-kernel
- $(TOPDIR)/scripts/sercomm-kernel-header.py \
- --kernel-image $@ \
- --kernel-offset $(SERCOMM_KERNEL_OFFSET) \
- --rootfs-offset $(SERCOMM_ROOTFS_OFFSET) \
- --output-header [email protected]
- dd if=$@ >> [email protected] 2>/dev/null
- mv [email protected] $@
- endef
- define Build/sercomm-kernel-factory
- $(TOPDIR)/scripts/sercomm-kernel-header.py \
- --kernel-image $@ \
- --kernel-offset $(SERCOMM_KERNEL_OFFSET) \
- --rootfs-offset $(SERCOMM_ROOTFS_OFFSET) \
- --output-header [email protected]
- $(TOPDIR)/scripts/sercomm-kernel-header.py \
- --kernel-image $@ \
- --kernel-offset $(SERCOMM_KERNEL2_OFFSET) \
- --rootfs-offset $(SERCOMM_ROOTFS2_OFFSET) \
- --output-header [email protected]
- cat [email protected] [email protected] > [email protected]
- dd if=$@ >> [email protected] 2>/dev/null
- mv [email protected] $@
- endef
- define Build/sercomm-mkhash
- dd bs=$$((0x400)) skip=1 if=$@ conv=notrunc 2>/dev/null | \
- $(MKHASH) md5 | awk '{print $$1}' | tr -d '\n' | \
- dd seek=$$((0x1e0)) of=$@ bs=1 conv=notrunc 2>/dev/null
- endef
- define Build/sercomm-part-tag
- $(call Build/sercomm-part-tag-common,$(word 1,$(1)) $@)
- endef
- define Build/sercomm-part-tag-common
- $(eval file=$(word 2,$(1)))
- $(TOPDIR)/scripts/sercomm-partition-tag.py \
- --input-file $(file) \
- --output-file $(file).tmp \
- --part-name $(word 1,$(1)) \
- --part-version $(SERCOMM_SWVER)
- mv $(file).tmp $(file)
- endef
- define Build/sercomm-payload
- $(TOPDIR)/scripts/sercomm-pid.py \
- --hw-version $(SERCOMM_HWVER) \
- --hw-id $(SERCOMM_HWID) \
- --sw-version $(SERCOMM_SWVER) \
- --pid-file [email protected] \
- --extra-padding-size 0x10 \
- --extra-padding-first-byte 0x0a
- $(TOPDIR)/scripts/sercomm-payload.py \
- --input-file $@ \
- --output-file [email protected] \
- --pid-file [email protected]
- mv [email protected] $@
- rm [email protected]
- endef
- define Build/sercomm-pid-setbit
- printf 1 | dd seek=$$(($(1))) of=$@ bs=1 conv=notrunc 2>/dev/null
- endef
- define Build/sercomm-prepend-tagged-kernel
- $(CP) $(IMAGE_KERNEL) $(IMAGE_KERNEL).tagged
- $(call Build/sercomm-part-tag-common,$(word 1,$(1)) \
- $(IMAGE_KERNEL).tagged)
- dd if=$@ >> $(IMAGE_KERNEL).tagged 2>/dev/null
- mv $(IMAGE_KERNEL).tagged $@
- endef
- define Build/sercomm-reset-slot1-chksum
- printf "\xff\xff\xff\xff" | \
- dd of=$@ seek=$$((0x118)) bs=1 conv=notrunc 2>/dev/null
- endef
- define Build/sercomm-sysupgrade-cpj
- dd bs=$$((0x1fff00)) count=1 if=$@ [email protected] conv=notrunc \
- 2>/dev/null
- dd bs=$$((0x1fff00)) skip=1 if=$@ [email protected] conv=notrunc \
- 2>/dev/null
- $(TOPDIR)/scripts/sercomm-kernel-header.py \
- --kernel-image [email protected] \
- --kernel-offset $(SERCOMM_KERNEL_OFFSET) \
- --rootfs-image [email protected] \
- --rootfs-offset $(SERCOMM_ROOTFS_OFFSET) \
- --output-header [email protected]
- cat [email protected] [email protected] [email protected] > $@
- rm [email protected] [email protected] [email protected]
- endef
- define Device/sercomm
- $(Device/nand)
- LOADER_TYPE := bin
- IMAGES += factory.img
- endef
- define Device/sercomm_cpj
- SOC := mt7620a
- DEVICE_VENDOR := Rostelecom
- DEVICE_ALT0_VENDOR := Sercomm
- IMAGE_SIZE := 7743k
- SERCOMM_HWID := CPJ
- SERCOMM_HWVER := 10000
- SERCOMM_SWVER := 1001
- SERCOMM_KERNEL_OFFSET := 0x70100
- SERCOMM_ROOTFS_OFFSET := 0x270000
- SERCOMM_KERNEL2_OFFSET := 0x800100
- SERCOMM_ROOTFS2_OFFSET := 0xa00000
- IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
- sercomm-sysupgrade-cpj | pad-rootfs | check-size | \
- append-metadata
- ARTIFACTS := initramfs-factory.img
- DEVICE_PACKAGES := kmod-mt76x2
- endef
- define Device/sercomm_cxx_dxx
- $(Device/sercomm)
- KERNEL_SIZE := 6144k
- KERNEL_LOADADDR := 0x81001000
- LZMA_TEXT_START := 0x82800000
- SERCOMM_KERNEL_OFFSET := 0x400100
- SERCOMM_ROOTFS_OFFSET := 0x1000000
- endef
- define Device/sercomm_cxx
- $(Device/sercomm_cxx_dxx)
- SERCOMM_KERNEL2_OFFSET := 0xa00100
- SERCOMM_ROOTFS2_OFFSET := 0x3000000
- KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma -a0 | \
- uImage lzma
- IMAGE/sysupgrade.bin := append-kernel | sercomm-kernel | \
- sysupgrade-tar kernel=$$$$@ | append-metadata
- IMAGE/factory.img := append-kernel | sercomm-kernel-factory | \
- append-ubi | sercomm-factory-cqr | sercomm-mkhash
- endef
- define Device/sercomm_dxx
- $(Device/sercomm_cxx_dxx)
- KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma -a0 | \
- uImage lzma | sercomm-kernel
- KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \
- lzma -a0 | uImage lzma
- IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
- IMAGE/factory.img := append-ubi | check-size | \
- sercomm-part-tag rootfs | sercomm-prepend-tagged-kernel kernel | \
- gzip | sercomm-payload | sercomm-crypto
- endef
- define Device/sercomm_s1500
- $(Device/sercomm)
- SERCOMM_KERNEL_OFFSET := 0x1700100
- SERCOMM_ROOTFS_OFFSET := 0x1f00000
- SERCOMM_KERNEL2_OFFSET := 0x1b00100
- KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma -a0 | \
- uImage lzma
- KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \
- lzma -a0 | uImage lzma
- IMAGE/sysupgrade.bin := append-kernel | sercomm-kernel | \
- sysupgrade-tar kernel=$$$$@ | append-metadata
- DEVICE_PACKAGES := kmod-mt76x2 kmod-usb3
- endef
|