http://patchwork.openwrt.org/patch/2046/
On 06.04.2012 18:31, Matthias Buecher / Germany wrote: > Add an image option for the Orion Generic targets, that allows to > specify the kernel mtd partition size. > The option takes care for necessary size extension when building with > symbols. > The value is also used for image generation (padding). > > Plus: > - creation of ARM uImage generalized in image makefile > - sanitizing pathes in image makefile > - rebase of "300-dns323_partition_map.patch" for current 3.0.18 kernel > > Signed-off-by: Matthias Bücher <[email protected]> > > > Patch is attached to prevent mail mangling and inline for comments: > > Index: target/linux/orion/image/Config.in > =================================================================== > --- target/linux/orion/image/Config.in (revision 0) > +++ target/linux/orion/image/Config.in (revision 0) > @@ -0,0 +1,18 @@ > +config KERNEL_OPENWRT_KERNEL_MTD_SIZE > + int > + prompt "Kernel MTD partition size in KiB (512 - 2048 in steps of 128)" > + range 512 2048 > + depends TARGET_orion > + default 1152 if TARGET_orion_generic && KERNEL_KALLSYMS > + default 1024 if TARGET_orion_generic > + default 1536 if TARGET_orion_dns323 > + help > + Defines the size of the kernel's MTD partition in KiB (1 KiB = > 1024 > bytes). > + This value is used in the device patches for defining the MTD > partitions. > + Make sure that all patches for all devices make use of this > value. > + The value is also used in the image file for correct padding > and more. > + It is recommended to choose a size in 128KiB steps (biggest > erase size, > + e.g. Netgear WNR854T). > + Orion Generic target: > + Before kernel 2.6.35: 1024KiB for all > + Since kernel 2.6.35: 1152KiB for kernel with symbols > Index: target/linux/orion/patches/020-flexible_kernel_mtd_size.patch > =================================================================== > --- target/linux/orion/patches/020-flexible_kernel_mtd_size.patch > (revision 0) > +++ target/linux/orion/patches/020-flexible_kernel_mtd_size.patch > (revision 0) > @@ -0,0 +1,16 @@ > +--- a/arch/arm/mach-orion5x/Kconfig > ++++ b/arch/arm/mach-orion5x/Kconfig > +@@ -155,6 +155,13 @@ config MACH_RD88F6183AP_GE > + Say 'Y' here if you want your kernel to support the > + Marvell Orion-1-90 (88F6183) AP GE RD. > + > ++config OPENWRT_KERNEL_MTD_SIZE > ++ int > ++ prompt "OpenWrt hack: Kernel MTD partition size in KiB" > ++ default 1024 > ++ help > ++ Defines the size of the kernel's MTD partition in KiB (1 KiB = > 1024 > bytes). > ++ This is just a help construct for OpenWrt to pass a value to the > kernel build process. > + endmenu > + > + endif > Index: target/linux/orion/patches/100-wrt350nv2_openwrt_partition_map.patch > =================================================================== > --- > target/linux/orion/patches/100-wrt350nv2_openwrt_partition_map.patch > (revision 31201) > +++ > target/linux/orion/patches/100-wrt350nv2_openwrt_partition_map.patch > (working copy) > @@ -5,13 +5,13 @@ > .name = "kernel", > .offset = 0x00000000, > - .size = 0x00760000, > -+ .size = 0x00100000, // change to kernel mtd size > here (1/3) > ++ .size = (CONFIG_OPENWRT_KERNEL_MTD_SIZE * 1024), > // original was > 0x001A0000 (1664KiB) > }, { > .name = "rootfs", > - .offset = 0x001a0000, > - .size = 0x005c0000, > -+ .offset = 0x00100000, // change to kernel mtd size > here (2/3) > -+ .size = 0x00650000, // adopt to kernel mtd size > here (3/3) = > 0x00750000 - <kernel mtd size> > ++ .offset = (CONFIG_OPENWRT_KERNEL_MTD_SIZE * 1024), > // original was > 0x001A0000 (1664KiB) > ++ .size = (0x00750000 - (CONFIG_OPENWRT_KERNEL_MTD_SIZE > * 1024)), // > exclude area with eRcOmM signature > }, { > .name = "lang", > .offset = 0x00760000, > Index: target/linux/orion/patches/101-wnr854t_partition_map.patch > =================================================================== > --- target/linux/orion/patches/101-wnr854t_partition_map.patch > (revision > 31201) > +++ target/linux/orion/patches/101-wnr854t_partition_map.patch (working > copy) > @@ -1,6 +1,18 @@ > --- a/arch/arm/mach-orion5x/wnr854t-setup.c > +++ b/arch/arm/mach-orion5x/wnr854t-setup.c > -@@ -67,6 +67,10 @@ static struct mtd_partition wnr854t_nor_ > +@@ -58,15 +58,19 @@ static struct mtd_partition wnr854t_nor_ > + { > + .name = "kernel", > + .offset = 0x00000000, > +- .size = 0x00100000, > ++ .size = (CONFIG_OPENWRT_KERNEL_MTD_SIZE * 1024), > + }, { > + .name = "rootfs", > +- .offset = 0x00100000, > +- .size = 0x00660000, > ++ .offset = (CONFIG_OPENWRT_KERNEL_MTD_SIZE * 1024), > ++ .size = (0x00760000 - (CONFIG_OPENWRT_KERNEL_MTD_SIZE > * 1024)), > + }, { > .name = "uboot", > .offset = 0x00760000, > .size = 0x00040000, > Index: target/linux/orion/patches/300-dns323_partition_map.patch > =================================================================== > --- target/linux/orion/patches/300-dns323_partition_map.patch (revision > 31201) > +++ target/linux/orion/patches/300-dns323_partition_map.patch (working copy) > @@ -1,6 +1,6 @@ > --- a/arch/arm/mach-orion5x/dns323-setup.c > +++ b/arch/arm/mach-orion5x/dns323-setup.c > -@@ -99,6 +99,13 @@ > +@@ -114,6 +114,13 @@ > * 0x00020000-0x001a0000 : "Linux Kernel" > * 0x001a0000-0x007d0000 : "File System" > * 0x007d0000-0x00800000 : "u-boot" > @@ -14,7 +14,7 @@ > */ > > #define DNS323_NOR_BOOT_BASE 0xf4000000 > -@@ -114,11 +121,11 @@ > +@@ -129,11 +136,11 @@ > .size = 0x00010000, > .offset = 0x00010000, > }, { > Index: target/linux/orion/image/generic.mk > =================================================================== > --- target/linux/orion/image/generic.mk (revision 31201) > +++ target/linux/orion/image/generic.mk (working copy) > @@ -1,5 +1,5 @@ > # > -# Copyright (C) 2008-2011 OpenWrt.org > +# Copyright (C) 2008-2012 OpenWrt.org > # > # This is free software, licensed under the GNU General Public License v2. > # See /LICENSE for more information. > @@ -12,71 +12,103 @@ > > ### use round brackets for make variables, and curly brackets for shell > variables > > +## convert value from KiB to bytes for shell commands > +KERNEL_MTD_SIZE_BYTES:=$(shell echo $$(( > $(CONFIG_KERNEL_OPENWRT_KERNEL_MTD_SIZE) * 1024 )) ) > + > +# Netgear WNR854T: erase size is 128KiB = 0x00020000 = 131072 > +ERASE_SIZE_WNR854T:=128 > +UIMAGE_FILE_NAME_WNR854T:=uImage > + > +# Linksys WRT350N v2: erase size is 64KiB = 0x00010000 = 65536 > +ERASE_SIZE_WRT350Nv2:=64 > + > + > +### > +### Image/Prepare > +### > + > define Image/Prepare > ### Dummy comment for indented calls of Image/Prepare > - cp $(LINUX_DIR)/arch/arm/boot/uImage $(KDIR)/uImage > + cp '$(LINUX_DIR)/arch/arm/boot/zImage' '$(BIN_DIR)/$(IMG_PREFIX)-zImage' > + cp '$(LINUX_DIR)/arch/arm/boot/uImage' '$(KDIR)/uImage' > endef > > + > +### > +### Image/BuildKernel > +### > + > define Image/BuildKernel > ### Dummy comment for indented calls of Image/BuildKernel > - # Orion Kernel uImages > - # WRT350N v2: mach id 1633 (0x661) > - echo -en "\x06\x1c\xa0\xe3\x61\x10\x81\xe3" > $(KDIR)/wrt350nv2-zImage > - cat $(LINUX_DIR)/arch/arm/boot/zImage >> $(KDIR)/wrt350nv2-zImage > - $(STAGING_DIR_HOST)/bin/mkimage -A arm -O linux -T kernel \ > + > + ## Netgear WNR854T: mach id 1801 (0x0709) > +$(call > Image/BuildKernel/Default,wnr854t,"\x07\x1c\xa0\xe3\x09\x10\x81\xe3") > + > + ## Linksys WRT350N v2: mach id 1633 (0x0661) > +$(call > Image/BuildKernel/Default,wrt350nv2,"\x06\x1c\xa0\xe3\x61\x10\x81\xe3") > + > +endef > + > +define Image/BuildKernel/Default > + # parameters: 1 = machine name, 2 = machine id as string > + # Orion Kernel uImage for $(1) > + # merge machine id and regular zImage into one file > + echo -en $(2) > '$(KDIR)/$(1)-zImage' > + cat '$(LINUX_DIR)/arch/arm/boot/zImage' >> '$(KDIR)/$(1)-zImage' > + # create uImage from file created in previous steps > + '$(STAGING_DIR_HOST)/bin/mkimage' -A arm -O linux -T kernel \ > -C none -a 0x00008000 -e 0x00008000 -n 'Linux-$(LINUX_VERSION)' \ > - -d $(KDIR)/wrt350nv2-zImage $(KDIR)/wrt350nv2-uImage > - cp $(KDIR)/wrt350nv2-uImage $(BIN_DIR)/openwrt-wrt350nv2-uImage > - # WNR854T: mach id 1801 (0x709) > - echo -en "\x07\x1c\xa0\xe3\x09\x10\x81\xe3" > $(KDIR)/wnr854t-zImage > - cat $(LINUX_DIR)/arch/arm/boot/zImage >> $(KDIR)/wnr854t-zImage > - $(STAGING_DIR_HOST)/bin/mkimage -A arm -O linux -T kernel \ > - -C none -a 0x00008000 -e 0x00008000 -n 'Linux-$(LINUX_VERSION)' \ > - -d $(KDIR)/wnr854t-zImage $(KDIR)/wnr854t-uImage > - cp $(KDIR)/wnr854t-uImage $(BIN_DIR)/openwrt-wnr854t-uImage > + -d '$(KDIR)/$(1)-zImage' '$(KDIR)/$(1)-uImage' > + # copy uImage to bin dir > + cp '$(KDIR)/$(1)-uImage' '$(BIN_DIR)/openwrt-$(1)-uImage' > endef > > + > +### > +### Image/Build > +### > + > define Image/Build/Netgear > # Orion Netgear Images > - mkdir $(KDIR)/netgear_image > - cp $(KDIR)/wnr854t-uImage $(KDIR)/netgear_image/uImage > - $(STAGING_DIR_HOST)/bin/mkfs.jffs2 -m none -p -l -q -e 128KiB -o > $(KDIR)/wnr854t-uImage.jffs2 -d $(KDIR)/netgear_image > - rm -rf $(KDIR)/netgear_image > + mkdir '$(KDIR)/netgear_image' > + cp '$(KDIR)/wnr854t-uImage' > '$(KDIR)/netgear_image/$(UIMAGE_FILE_NAME_WNR854T)' > + '$(STAGING_DIR_HOST)/bin/mkfs.jffs2' -m none -p -l -q -e > $(ERASE_SIZE_WNR854T)KiB -o '$(KDIR)/wnr854t-uImage.jffs2' -d > '$(KDIR)/netgear_image' > + rm -rf '$(KDIR)/netgear_image' > ( \ > - dd if=$(KDIR)/wnr854t-uImage.jffs2 bs=1024k conv=sync; \ > - dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \ > - ) > $(BIN_DIR)/openwrt-$(2)-$(1).img > - $(STAGING_DIR_HOST)/bin/add_header $(3) > $(BIN_DIR)/openwrt-$(2)-$(1).img $(BIN_DIR)/openwrt-$(2)-$(1)-webupgrade.img > + dd if='$(KDIR)/wnr854t-uImage.jffs2' bs=$(KERNEL_MTD_SIZE_BYTES) > conv=sync; \ > + dd if='$(KDIR)/root.$(1)' bs=$(ERASE_SIZE_WNR854T)k conv=sync; \ > + ) > '$(BIN_DIR)/openwrt-$(2)-$(1).img' > + '$(STAGING_DIR_HOST)/bin/add_header' $(3) > '$(BIN_DIR)/openwrt-$(2)-$(1).img' > '$(BIN_DIR)/openwrt-$(2)-$(1)-webupgrade.img' > endef > > define Image/Build/Linksys > # Orion Linksys Images > # sysupgrade image > ( \ > - dd if="${KDIR}/$2-uImage" bs=$5 conv=sync; \ > - dd if="${KDIR}/root.$1" bs=64k conv=sync; \ > - ) > "${BIN_DIR}/openwrt-$2-$1.img" > + dd if='$(KDIR)/$(2)-uImage' bs=$(KERNEL_MTD_SIZE_BYTES) > conv=sync; \ > + dd if='$(KDIR)/root.$(1)' bs=$(ERASE_SIZE_WRT350Nv2)k > conv=sync; \ > + ) > '$(BIN_DIR)/openwrt-$(2)-$(1).img' > # recovery image and webupgrade image for stock firmware > - rm -rf "${TMP_DIR}/$2_webupgrade" > - mkdir "${TMP_DIR}/$2_webupgrade" > + rm -rf '$(TMP_DIR)/$(2)_webupgrade' > + mkdir '$(TMP_DIR)/$(2)_webupgrade' > # create parameter file > - echo ':image 0 $(BIN_DIR)/openwrt-$(2)-$(1).img' >> '$(TMP_DIR)/$(2)_webupgrade/$(2).par' > - [ ! -f "$(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin" ] || ( \ > - echo ":u-boot 0 > $(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin" >>> "${TMP_DIR}/$2_webupgrade/$2.par"; ) > - echo "#version 0x2020" >>"${TMP_DIR}/$2_webupgrade/$2.par" > + echo ':image 0 $(BIN_DIR)/openwrt-$(2)-$(1).img' > > '$(TMP_DIR)/$(2)_webupgrade/$(2).par' > + [ ! -f '$(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin' ] || ( \ > + echo ':u-boot 0 > $(STAGING_DIR_HOST)/share/wrt350nv2-builder/u-boot.bin' >> > '$(TMP_DIR)/$(2)_webupgrade/$(2).par'; ) > + echo '#version 0x2020' >> '$(TMP_DIR)/$(2)_webupgrade/$(2).par' > # create bin file for recovery and webupgrade image > - ( cd "${TMP_DIR}/$2_webupgrade"; \ > - "${STAGING_DIR_HOST}/bin/wrt350nv2-builder" \ > - -v -b "${TMP_DIR}/$2_webupgrade/$2.par"; \ > + ( cd '$(TMP_DIR)/$(2)_webupgrade'; \ > + '$(STAGING_DIR_HOST)/bin/wrt350nv2-builder' \ > + -v -b '$(TMP_DIR)/$(2)_webupgrade/$(2).par'; \ > ) > # copy bin file as recovery image > - $(CP) "${TMP_DIR}/$2_webupgrade/wrt350n.bin" > "$(BIN_DIR)/openwrt-$2-$1-recovery.bin" > + $(CP) '$(TMP_DIR)/$(2)_webupgrade/wrt350n.bin' > '$(BIN_DIR)/openwrt-$(2)-$(1)-recovery.bin' > # create webupgrade image for stock firmware update mechanism > ( cd '$(TMP_DIR)/$(2)_webupgrade'; \ > zip 'wrt350n.zip' 'wrt350n.bin'; \ > ) > - "${STAGING_DIR_HOST}/bin/wrt350nv2-builder" -v -z > "${TMP_DIR}/$2_webupgrade/wrt350n.zip" > "${BIN_DIR}/openwrt-$2-$1-webupgrade.img" > - rm -rf "${TMP_DIR}/$2_webupgrade" > + '$(STAGING_DIR_HOST)/bin/wrt350nv2-builder' -v -z > '$(TMP_DIR)/$(2)_webupgrade/wrt350n.zip' > '$(BIN_DIR)/openwrt-$(2)-$(1)-webupgrade.img' > + rm -rf '$(TMP_DIR)/$(2)_webupgrade' > endef > > define Image/Build > @@ -84,19 +116,23 @@ > $(call Image/Build/$(1),$(1)) > $(call Image/Build/Netgear,$(1),wnr854t,NG_WNR854T,$(1)) > # Leave WRT350Nv2 at last position due to webimage dependency for zip > - # 5th parameter is kernel mtd size, e.g. 0x00100000 = 1048576 or > 0x001A0000 = 1703936 > -$(call Image/Build/Linksys,$(1),wrt350nv2,WNR350Nv2,$(1),1048576) > +$(call Image/Build/Linksys,$(1),wrt350nv2,WNR350Nv2,$(1)) > endef > > define Image/Build/squashfs > $(call prepare_generic_squashfs,$(KDIR)/root.squashfs) > ( \ > - dd if=$(KDIR)/uImage bs=1024k conv=sync; \ > - dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \ > - ) > $(BIN_DIR)/$(IMG_PREFIX)-$(1).img > + dd if='$(KDIR)/uImage' bs=$(KERNEL_MTD_SIZE_BYTES) conv=sync; \ > + dd if='$(KDIR)/root.$(1)' bs=$(ERASE_SIZE_WNR854T)k conv=sync; \ > + ) > '$(BIN_DIR)/$(IMG_PREFIX)-$(1).img' > endef > > -# Dependency for WRT350N v2 webupgrade image > + > +### > +### Image/PreReq > +### > + > +## Dependency for WRT350N v2 webupgrade image > $(eval $(call RequireCommand,zip, \ > Please install zip. \ > )) _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
