From: Pawel Dembicki Date: Thu, 19 Apr 2018 17:36:55 +0000 (+0200) Subject: firmware-utils: mkdlinkfw: add kernel image offset X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1f149fcad38677cc917d249e32b4b791cde95702;p=openwrt%2Fstaging%2Fyousong.git firmware-utils: mkdlinkfw: add kernel image offset Some boards with JBOOT have partiton between bootloader and kernel image. This patch add possibility to change kernel partition start address. Signed-off-by: Pawel Dembicki --- diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index 33c4f3132f..6eef596caf 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -114,6 +114,7 @@ define Build/mkdlinkfw -k $(IMAGE_KERNEL) \ -r $(IMAGE_ROOTFS) \ -o $@ \ + $(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \ -s $(DLINK_FIRMWARE_SIZE) endef @@ -122,6 +123,7 @@ define Build/mkdlinkfw-factory -m $(DLINK_ROM_ID) -f $(DLINK_FAMILY_MEMBER) \ -F $@ \ -o $@.new \ + $(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \ -s $(DLINK_FIRMWARE_SIZE) mv $@.new $@ endef diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 0098613c27..234b6df098 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -3,7 +3,7 @@ # DEVICE_VARS += TPLINK_FLASHLAYOUT TPLINK_HWID TPLINK_HWREV TPLINK_HWREVADD TPLINK_HVERSION \ - DLINK_ROM_ID DLINK_FAMILY_MEMBER DLINK_FIRMWARE_SIZE + DLINK_ROM_ID DLINK_FAMILY_MEMBER DLINK_FIRMWARE_SIZE DLINK_IMAGE_OFFSET define Build/elecom-header cp $@ $(KDIR)/v_0.0.0.bin @@ -60,6 +60,15 @@ define Device/alfa-network_tube-e4g endef TARGET_DEVICES += alfa-network_tube-e4g +define Device/amit_jboot + DLINK_IMAGE_OFFSET := 0x10000 + KERNEL := $(KERNEL_DTB) + IMAGES += factory.bin + IMAGE/sysupgrade.bin := mkdlinkfw | pad-rootfs | append-metadata + IMAGE/factory.bin := mkdlinkfw | pad-rootfs | mkdlinkfw-factory + DEVICE_PACKAGES := jboot-tools kmod-usb2 kmod-usb-ohci +endef + define Device/Archer TPLINK_HWREVADD := 0 TPLINK_HVERSION := 3 @@ -182,60 +191,46 @@ endef TARGET_DEVICES += dir-810l define Device/dlink_dwr-116-a1 + $(Device/amit_jboot) DTS := DWR-116-A1 DEVICE_TITLE := D-Link DWR-116 A1/A2 - DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci jboot-tools DLINK_ROM_ID := DLK6E3803001 DLINK_FAMILY_MEMBER := 0x6E38 DLINK_FIRMWARE_SIZE := 0x7E0000 - KERNEL := $(KERNEL_DTB) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := mkdlinkfw | pad-rootfs | append-metadata - IMAGE/factory.bin := mkdlinkfw | pad-rootfs | mkdlinkfw-factory endef TARGET_DEVICES += dlink_dwr-116-a1 define Device/dlink_dwr-118-a1 + $(Device/amit_jboot) DTS := DWR-118-A1 DEVICE_TITLE := D-Link DWR-118 A1 - DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci jboot-tools kmod-mt76x0e + DEVICE_PACKAGES += kmod-mt76x0e DLINK_ROM_ID := DLK6E3811001 DLINK_FAMILY_MEMBER := 0x6E38 DLINK_FIRMWARE_SIZE := 0xFE0000 - KERNEL := $(KERNEL_DTB) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := mkdlinkfw | pad-rootfs | append-metadata - IMAGE/factory.bin := mkdlinkfw | pad-rootfs | mkdlinkfw-factory endef TARGET_DEVICES += dlink_dwr-118-a1 define Device/dlink_dwr-118-a2 + $(Device/amit_jboot) DTS := DWR-118-A2 DEVICE_TITLE := D-Link DWR-118 A2 - DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci jboot-tools + DEVICE_PACKAGES += kmod-mt76x2 DLINK_ROM_ID := DLK6E3814001 DLINK_FAMILY_MEMBER := 0x6E38 DLINK_FIRMWARE_SIZE := 0xFE0000 - KERNEL := $(KERNEL_DTB) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := mkdlinkfw | pad-rootfs | append-metadata - IMAGE/factory.bin := mkdlinkfw | pad-rootfs | mkdlinkfw-factory endef TARGET_DEVICES += dlink_dwr-118-a2 define Device/dlink_dwr-921-c1 + $(Device/amit_jboot) DTS := DWR-921-C1 IMAGE_SIZE := $(ralink_default_fw_size_16M) DEVICE_TITLE := D-Link DWR-921 C1 DLINK_ROM_ID := DLK6E2414001 DLINK_FAMILY_MEMBER := 0x6E24 DLINK_FIRMWARE_SIZE := 0xFE0000 - KERNEL := $(KERNEL_DTB) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := mkdlinkfw | pad-rootfs | append-metadata - IMAGE/factory.bin := mkdlinkfw | pad-rootfs | mkdlinkfw-factory - DEVICE_PACKAGES := jboot-tools \ - kmod-usb2 kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi + DEVICE_PACKAGES += kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi endef TARGET_DEVICES += dlink_dwr-921-c1 @@ -248,18 +243,14 @@ endef TARGET_DEVICES += dlink_dwr-921-c3 define Device/dlink_dwr-922-e2 + $(Device/amit_jboot) DTS := DWR-922-E2 IMAGE_SIZE := $(ralink_default_fw_size_16M) DEVICE_TITLE := D-Link DWR-922 E2 DLINK_ROM_ID := DLK6E2414005 DLINK_FAMILY_MEMBER := 0x6E24 DLINK_FIRMWARE_SIZE := 0xFE0000 - KERNEL := $(KERNEL_DTB) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := mkdlinkfw | pad-rootfs | append-metadata - IMAGE/factory.bin := mkdlinkfw | pad-rootfs | mkdlinkfw-factory - DEVICE_PACKAGES := jboot-tools \ - kmod-usb2 kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi + DEVICE_PACKAGES += kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi endef TARGET_DEVICES += dlink_dwr-922-e2 @@ -430,16 +421,13 @@ endef TARGET_DEVICES += microwrt define Device/lava_lr-25g001 + $(Device/amit_jboot) DTS := LR-25G001 DEVICE_TITLE := LAVA LR-25G001 DLINK_ROM_ID := LVA6E3804001 DLINK_FAMILY_MEMBER := 0x6E38 DLINK_FIRMWARE_SIZE := 0xFE0000 - KERNEL := $(KERNEL_DTB) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := mkdlinkfw | pad-rootfs | append-metadata - IMAGE/factory.bin := mkdlinkfw | pad-rootfs | mkdlinkfw-factory - DEVICE_PACKAGES := jboot-tools kmod-usb2 kmod-usb-ohci kmod-mt76x0e + DEVICE_PACKAGES += kmod-mt76x0e endef TARGET_DEVICES += lava_lr-25g001 diff --git a/tools/firmware-utils/src/mkdlinkfw.c b/tools/firmware-utils/src/mkdlinkfw.c index 71828bd91a..3b59a5d2df 100644 --- a/tools/firmware-utils/src/mkdlinkfw.c +++ b/tools/firmware-utils/src/mkdlinkfw.c @@ -99,6 +99,7 @@ struct file_info image_info; char *ofname; char *progname; uint32_t firmware_size; +uint32_t image_offset; uint16_t family_member; char *rom_id[12] = { 0 }; char image_type; @@ -403,7 +404,7 @@ int fill_sch2(struct sch2_header *header, char *kernel_ptr, char *rootfs_ptr) header->image_crc32 = crc32(0, (uint8_t *) kernel_ptr, kernel_info.file_size); header->start_addr = RAM_ENTRY_ADDR; header->rootfs_addr = - JBOOT_SIZE + STAG_SIZE + SCH2_SIZE + kernel_info.file_size; + image_offset + STAG_SIZE + SCH2_SIZE + kernel_info.file_size; header->rootfs_len = rootfs_info.file_size; header->rootfs_crc32 = crc32(0, (uint8_t *) rootfs_ptr, rootfs_info.file_size); header->header_crc32 = 0; @@ -446,9 +447,9 @@ int fill_auh(struct auh_header *header, uint32_t length) header->lpvs = AUH_LVPS; header->mbz = 0; header->time_stamp = jboot_timestamp(); - header->erase_start = JBOOT_SIZE; + header->erase_start = image_offset; header->erase_length = firmware_size; - header->data_offset = JBOOT_SIZE; + header->data_offset = image_offset; header->data_length = length; header->space4 = 0; header->space5 = 0; @@ -603,11 +604,12 @@ int main(int argc, char *argv[]) image_type = SYSUPGRADE; family_member = 0; firmware_size = 0; + image_offset = JBOOT_SIZE; while (1) { int c; - c = getopt(argc, argv, "f:F:i:hk:m:o:r:s:"); + c = getopt(argc, argv, "f:F:i:hk:m:o:O:r:s:"); if (c == -1) break; @@ -632,6 +634,9 @@ int main(int argc, char *argv[]) case 'r': rootfs_info.file_name = optarg; break; + case 'O': + sscanf(optarg, "0x%x", &image_offset); + break; case 'o': ofname = optarg; break;