# # Copyright (C) 2008-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/image.mk IMAGE_PROFILE:=$(if $(PROFILE),$(PROFILE),Default) JFFS2_BLOCKSIZE = 64k 128k 256k KERNEL_LOADADDR = 0x80060000 DEVICE_VARS += NETGEAR_KERNEL_MAGIC NETGEAR_BOARD NETGEAR_ID CMDLINE CONSOLE define Build/netgear-squashfs rm -rf $@.fs $@.squashfs mkdir -p $@.fs/image cp $@ $@.fs/image/uImage $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \ $@.fs $@.squashfs \ -noappend -root-owned -be -b 65536 dd if=/dev/zero bs=1k count=1 >> $@.squashfs mkimage \ -A mips -O linux -T filesystem -C none \ -M $(NETGEAR_KERNEL_MAGIC) \ -a 0xbf070000 -e 0xbf070000 \ -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \ -d $@.squashfs $@ rm -rf $@.squashfs $@.fs endef define Build/netgear-uImage $(call Build/uImage,$(1) -M $(NETGEAR_KERNEL_MAGIC)) endef define Build/netgear-image $(STAGING_DIR_HOST)/bin/mkdniimg \ -B $(NETGEAR_BOARD) -v OpenWrt.$(REVISION) \ $(if $(NETGEAR_ID),-H $(NETGEAR_ID)) \ -r "$(1)" \ -i $@ -o $@.new mv $@.new $@ endef define Device/Default BOARDNAME := DEVICE_PROFILE = $$(BOARDNAME) PROFILES = Default Minimal $$(DEVICE_PROFILE) MTDPARTS := IMAGES := sysupgrade.bin BLOCKSIZE := 64k FILESYSTEMS = $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-$$(BLOCKSIZE) CONSOLE = ttyS0,115200 CMDLINE = $$(if $$(BOARDNAME),board=$$(BOARDNAME)) $$(if $$(MTDPARTS),mtdparts=$$(MTDPARTS)) $$(if $$(CONSOLE),console=$$(CONSOLE)) KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma IMAGES := sysupgrade.bin IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE) endef define Device/carambola2 BOARDNAME = CARAMBOLA2 IMAGE_SIZE = 16000k CONSOLE = ttyATH0,115200 MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,16000k(firmware),64k(art)ro endef TARGET_DEVICES += carambola2 define Device/wndr3700 BOARDNAME = WNDR3700 NETGEAR_KERNEL_MAGIC = 0x33373030 NETGEAR_BOARD = WNDR3700 MTDPARTS = spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,7680k(firmware),64k(art)ro IMAGES := sysupgrade.bin factory.img factory-NA.img KERNEL := kernel-bin | patch-cmdline | lzma -d20 | netgear-uImage lzma IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | netgear-squashfs | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE) IMAGE/factory.img = $$(IMAGE/sysupgrade.bin) | netgear-image IMAGE/factory-NA.img = $$(IMAGE/sysupgrade.bin) | netgear-image NA endef define Device/wndr3700v2 $(Device/wndr3700) NETGEAR_BOARD = WNDR3700v2 NETGEAR_KERNEL_MAGIC = 0x33373031 NETGEAR_ID = 29763654+16+64 MTDPARTS = spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,15872k(firmware),64k(art)ro IMAGES := sysupgrade.bin factory.img endef define Device/wndr3800 $(Device/wndr3700v2) NETGEAR_BOARD = WNDR3800 NETGEAR_ID = 29763654+16+128 endef define Device/wndr3800ch $(Device/wndr3800) NETGEAR_BOARD = WNDR3800CH endef define Device/wndrmac $(Device/wndr3700v2) NETGEAR_BOARD = WNDRMAC endef define Device/wndrmacv2 $(Device/wndr3800) NETGEAR_BOARD = WNDRMACv2 endef TARGET_DEVICES += wndr3700 wndr3700v2 wndr3800 wndr3800ch wndrmac wndrmacv2 rootfs_type=$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1))) # $(1): rootfs type. # $(2): board name. define imgname $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(call rootfs_type,$(1)) endef define rootfs_align $(patsubst %-256k,0x40000,$(patsubst %-128k,0x20000,$(patsubst %-64k,0x10000,$(patsubst squashfs%,0x4,$(patsubst root.%,%,$(1)))))) endef define sysupname $(call imgname,$(1),$(2))-sysupgrade.bin endef define factoryname $(call imgname,$(1),$(2))-factory.bin endef COMMA:=, define mkcmdline $(if $(1),board=$(1) )$(if $(2),console=$(2)$(COMMA)$(3)) endef define mtdpartsize $(shell sz=`echo '$(2)' | sed -ne 's/.*[:$(COMMA)]\([0-9]*\)k[@]*[0-9a-zx]*($(1)).*/\1/p'`; [ -n "$$sz" ] && echo $$(($$sz * 1024))) endef SINGLE_PROFILES:= # $(1) : name of image build method to be used, e.g., TPLINK-LZMA, AthLzma. # $(2) : name of the build template to be used, e.g. 64k, 64kraw, 128k, etc. # $(3) : name of the profile to be defined. # $(4) : board name. # $(5)~$(7) : arguments for $(mkcmdline) # board=$(1) console=$(2),$(3) # $(8)~$(14): extra arguments. define SingleProfile # $(1): action name, e.g. loader, buildkernel, squashfs, etc. define Image/Build/Profile/$(3) $$(call Image/Build/Template/$(2)/$$(1),$(1),$(4),$$(call mkcmdline,$(5),$(6),$(7)),$(8),$(9),$(10),$(11),$(12),$(13),$(14)) endef SINGLE_PROFILES += $(3) endef # $(1), name of the MultiProfile to be added. # $(2), name of Profiles to be included in the MultiProfile. define MultiProfile define Image/Build/Profile/$(1) $(foreach p,$(2), $$(call Image/Build/Profile/$p,$$(1)) ) endef endef LOADER_MAKE := $(NO_TRACE_MAKE) -C lzma-loader KDIR=$(KDIR) KDIR_TMP:=$(KDIR)/tmp VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage # $(1): input file. # $(2): output file. # $(3): extra arguments for lzma. define CompressLzma $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(3) $(2) endef define PatchKernel cp $(KDIR)/vmlinux$(3) $(KDIR_TMP)/vmlinux$(3)-$(1) $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(3)-$(1) "$(strip $(2))" endef define PatchKernel/initramfs $(call PatchKernel,$(1),$(2),-initramfs) cp $(KDIR_TMP)/vmlinux-initramfs-$(1) $(call imgname,initramfs,$(1)).bin endef # $(1): board name. # $(2): kernel command line. # $(3): extra argumetns for lzma. # $(4): name suffix, e.g. "-initramfs". define PatchKernelLzma cp $(KDIR)/vmlinux$(4) $(KDIR_TMP)/vmlinux$(4)-$(1) $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(4)-$(1) "$(strip $(2))" $(call CompressLzma,$(KDIR_TMP)/vmlinux$(4)-$(1),$(KDIR_TMP)/vmlinux$(4)-$(1).bin.lzma,$(3)) endef define PatchKernelGzip cp $(KDIR)/vmlinux$(3) $(KDIR_TMP)/vmlinux$(3)-$(1) $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(3)-$(1) "$(strip $(2))" gzip -9 -c $(KDIR_TMP)/vmlinux$(3)-$(1) > $(KDIR_TMP)/vmlinux$(3)-$(1).bin.gz endef ifneq ($(SUBTARGET),mikrotik) # $(1): compression method of the data. # $(2): extra arguments. # $(3): input data file. # $(4): output file. define MkuImage mkimage -A mips -O linux -T kernel -a 0x80060000 -C $(1) $(2) \ -e 0x80060000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \ -d $(3) $(4) endef # $(1): board name. # $(2): kernel command line. # $(3): extra arguments for lzma. # $(4): name suffix, e.g. "-initramfs". # $(5): extra arguments for mkimage. define MkuImageLzma $(call PatchKernelLzma,$(1),$(2),$(3),$(4)) $(call MkuImage,lzma,$(5),$(KDIR_TMP)/vmlinux$(4)-$(1).bin.lzma,$(KDIR_TMP)/vmlinux$(4)-$(1).uImage) endef define MkuImageLzma/initramfs $(call PatchKernelLzma,$(1),$(2),$(3),-initramfs) $(call MkuImage,lzma,$(4),$(KDIR_TMP)/vmlinux-initramfs-$(1).bin.lzma,$(call imgname,initramfs,$(1))-uImage.bin) endef define MkuImageGzip $(call PatchKernelGzip,$(1),$(2)) $(call MkuImage,gzip,,$(KDIR_TMP)/vmlinux-$(1).bin.gz,$(KDIR_TMP)/vmlinux-$(1).uImage) endef define MkuImageGzip/initramfs $(call PatchKernelGzip,$(1),$(2),-initramfs) $(call MkuImage,gzip,,$(KDIR_TMP)/vmlinux-initramfs-$(1).bin.gz,$(call imgname,initramfs,$(1))-uImage.bin) endef define MkuImageOKLI $(call MkuImage,lzma,-M 0x4f4b4c49,$(KDIR)/vmlinux.bin.lzma,$(KDIR_TMP)/vmlinux-$(1).okli) endef endif # $(1): name of the 1st file. # $(2): size limit of the 1st file if it is greater than 262144, or # the erase size of the flash if it is greater than zero and less # than 262144 # $(3): name of the 2nd file. # $(4): size limit of the 2nd file if $(2) is greater than 262144, otherwise # it is the size limit of the output file # $(5): name of the output file. # $(6): padding size. define CatFiles if [ $(2) -eq 0 ]; then \ filename="$(3)"; fstype=$$$${filename##*\.}; \ case "$$$${fstype}" in \ "jffs2-64k") bs=65536;; \ "jffs2-128k") bs=131072;; \ "jffs2-256k") bs=262144;; \ *) bs=`stat -c%s $(1)`;; \ esac; \ ( dd if=$(1) bs=$$$${bs} conv=sync; cat $(3) ) > $(5); \ if [ -n "$(6)" ]; then \ case "$$$${fstype}" in \ squashfs*) \ padjffs2 $(5) $(6); \ ;; \ esac; \ fi; \ if [ `stat -c%s $(5)` -gt $(4) ]; then \ echo "Warning: $(5) is too big (> $(4) bytes)" >&2; \ rm -f $(5); \ fi; \ else if [ $(2) -gt 262144 ]; then \ if [ `stat -c%s "$(1)"` -gt $(2) ]; then \ echo "Warning: $(1) is too big (> $(2) bytes)" >&2; \ else if [ `stat -c%s $(3)` -gt $(4) ]; then \ echo "Warning: $(3) is too big (> $(4) bytes)" >&2; \ else \ ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \ fi; fi; \ else \ ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \ if [ `stat -c%s $(5)` -gt $(4) ]; then \ echo "Warning: $(5) is too big (> $(4) bytes)" >&2; \ rm -f $(5); \ fi; \ fi; fi endef # $(1): rootfs type. # $(2): board name. # $(3): kernel image size limit. # $(4): rootfs image size limit. # $(5): padding argument for padjffs2. Sysupgrade/KR=$(call CatFiles,$(2),$(3),$(KDIR)/root.$(1),$(4),$(call sysupname,$(1),$(5))) Sysupgrade/KRuImage=$(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).uImage,$(3),$(KDIR)/root.$(1),$(4),$(call sysupname,$(1),$(2)),$(5)) Sysupgrade/RKuImage=$(call CatFiles,$(KDIR)/root.$(1),$(4),$(KDIR_TMP)/vmlinux-$(2).uImage,$(3),$(call sysupname,$(1),$(2))) # $(1): ubinize ini file # $(2): working directory # $(3): output file # $(4): physical erase block size # $(5): minimum I/O unit size # $(6): custom options define ubinize $(CP) $(1) $(2) ( cd $(2); $(STAGING_DIR_HOST)/bin/ubinize -o $(3) -p $(4) -m $(5) $(6) $(1)) endef # # Embed lzma-compressed kernel inside lzma-loader. # # $(1), suffix of output filename, e.g. generic, lowercase board name, etc. # $(2), suffix of target file to build, e.g. bin, gz, elf # $(3), kernel command line to pass from lzma-loader to kernel # $(4), unused here # $(5), suffix of kernel filename, e.g. -initramfs, or empty define Image/BuildLoader -rm -rf $(KDIR)/lzma-loader $(LOADER_MAKE) LOADER=loader-$(1).$(2) KERNEL_CMDLINE="$(3)"\ LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \ LOADER_DATA="$(KDIR)/vmlinux$(5).bin.lzma" BOARD="$(1)" \ compile loader.$(2) -$(CP) $(KDIR)/loader-$(1).$(2) $(KDIR)/loader-$(1)$(5).$(2) endef # # Build lzma-loader alone which will search for lzma-compressed kernel identified by # uImage header with magic "OKLI" at boot time. # # $(4), offset into the flash space to start searching uImage magic "OKLI". # $(5), size of search range starting at $(4). With 0 as the value, uImage # header is expected to be at precisely $(4) define Image/BuildLoaderAlone -rm -rf $(KDIR)/lzma-loader $(LOADER_MAKE) LOADER=loader-$(1).$(2) KERNEL_CMDLINE="$(3)" \ LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \ BOARD="$(1)" FLASH_OFFS=$(4) FLASH_MAX=$(5) \ compile loader.$(2) endef define Build/Clean $(LOADER_MAKE) clean endef alfa_ap96_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13312k(rootfs),2048k(kernel),512k(caldata)ro,15360k@0x80000(firmware) alfa_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1600k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware) alfa_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,15936k(firmware),64k(nvram),64k(art)ro all0258n_mtdlayout=mtdparts=spi0.0:256k(u-boot),64k(u-boot-env),6272k(firmware),1536k(failsafe),64k(art) all0315n_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env),13568k(firmware),2048k(failsafe),256k(art)ro ap81_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,5120k(rootfs),2688k(kernel),64k(art)ro,7808k@0x50000(firmware) ap83_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,128k(u-boot-env)ro,4096k(rootfs),3648k(kernel),64k(art)ro,7744k@0x60000(firmware) ap96_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1728k(kernel),64k(art)ro,7872k@0x40000(firmware) ap113_mtd_layout=mtdparts=spi0.0:64k(u-boot),3008k(rootfs),896k(uImage),64k(NVRAM),64k(ART),3904k@0x10000(firmware) ap121_mtdlayout_2M=mtdparts=spi0.0:64k(u-boot)ro,1216k(rootfs),704k(kernel),64k(art)ro,1920k@0x10000(firmware) ap121_mtdlayout_4M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware) ap132_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),6400k(rootfs),64k(art),7808k@0x50000(firmware) ap135_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k@0x50000(firmware) ap136_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(mib0),64k(art)ro,7744k@0x50000(firmware) bxu2000n2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),8448k(rootfs),6016k(user),64k(cfg),64k(oem),64k(art)ro cameo_ap81_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(config)ro,3840k(firmware),64k(art)ro cameo_ap91_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,3712k(firmware),64k(mac)ro,64k(art)ro cameo_ap99_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,3520k(firmware),64k(mac)ro,192k(lp)ro,64k(art)ro cameo_ap121_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,192k(language)ro,3648k(firmware) cameo_ap121_mtdlayout_8M=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,256k(language)ro,7680k@0x80000(firmware) cameo_db120_mtdlayout=mtdparts=spi0.0:64k(uboot)ro,64k(nvram)ro,15936k(firmware),192k(lang)ro,64k(mac)ro,64k(art)ro cameo_db120_mtdlayout_8M=mtdparts=spi0.0:64k(uboot)ro,64k(nvram)ro,7872k(firmware),128k(lang)ro,64k(art)ro cap4200ag_mtdlayout=mtdparts=spi0.0:256k(u-boot),64k(u-boot-env),320k(custom)ro,1536k(kernel),12096k(rootfs),2048k(failsafe),64k(art),13632k@0xa0000(firmware) cpe510_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(pation-table)ro,64k(product-info)ro,1536k(kernel),6144k(rootfs),192k(config)ro,64k(ART)ro,7680k@0x40000(firmware) eap300v2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),320k(custom),13632k(firmware),2048k(failsafe),64k(art)ro db120_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware) dgl_5500_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,15296k(firmware),192k(lang)ro,512k(my-dlink)ro,64k(mac)ro,64k(art)ro cameo_ap94_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,6208k(firmware),64k(caldata)ro,1600k(unknown)ro,64k@0x7f0000(caldata_copy) cameo_ap94_mtdlayout_fat=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,7808k(firmware),64k(caldata)ro,64k@0x660000(caldata_orig),6208k@0x50000(firmware_orig) esr900_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),13248k(rootfs),1024k(manufacture)ro,64k(backup)ro,320k(storage)ro,64k(caldata)ro,14656k@0x40000(firmware) esr1750_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),13248k(rootfs),1024k(manufacture)ro,64k(backup)ro,320k(storage)ro,64k(caldata)ro,14656k@0x40000(firmware) ew-dorin_mtdlayout_4M=mtdparts=spi0.0:256k(u-boot)ro,6 reg = <0x30000 0x10000>; read-only; }; factory: partition@40000 { label = "factory"; reg = <0x40000 0x10000>; read-only; }; partition@50000 { label = "firmware"; reg = <0x50000 0x3b0000>; }; }; }; gpio1: gpio@660 { status = "okay"; }; }; pinctrl { state_default: pinctrl0 { gpio { ralink,group = "jtag", "rgmii", "mdio", "uartf"; ralink,function = "gpio"; }; }; }; ethernet@10100000 { mtd-mac-address = <&factory 0x4>; }; esw@10110000 { mediatek,portmap = <0x2f>; mediatek,led_polarity = <0x17>; }; wmac@10180000 { ralink,mtd-eeprom = <&factory 0>; }; ehci@101c0000 { status = "okay"; }; ohci@101c1000 { status = "okay"; }; };