diff options
author | blogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-10-05 10:12:53 +0000 |
---|---|---|
committer | blogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-10-05 10:12:53 +0000 |
commit | 5c105d9f3fd086aff195d3849dcf847d6b0bd927 (patch) | |
tree | 1229a11f725bfa58aa7c57a76898553bb5f6654a /target/linux/rb532 | |
download | openwrt-5c105d9f3fd086aff195d3849dcf847d6b0bd927.tar.gz openwrt-5c105d9f3fd086aff195d3849dcf847d6b0bd927.zip |
branch Attitude Adjustment
git-svn-id: svn://svn.openwrt.org/openwrt/branches/attitude_adjustment@33625 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/rb532')
-rw-r--r-- | target/linux/rb532/Makefile | 19 | ||||
-rw-r--r-- | target/linux/rb532/base-files.mk | 11 | ||||
-rw-r--r-- | target/linux/rb532/base-files/etc/config/network | 13 | ||||
-rw-r--r-- | target/linux/rb532/base-files/etc/diag.sh | 19 | ||||
-rwxr-xr-x | target/linux/rb532/base-files/sbin/cf2nand | 67 | ||||
-rwxr-xr-x | target/linux/rb532/base-files/sbin/wget2nand | 71 | ||||
-rw-r--r-- | target/linux/rb532/config-3.3 | 130 | ||||
-rw-r--r-- | target/linux/rb532/image/Makefile | 74 | ||||
-rwxr-xr-x | target/linux/rb532/image/gen_image.sh | 17 | ||||
-rw-r--r-- | target/linux/rb532/modules.mk | 45 | ||||
-rw-r--r-- | target/linux/rb532/patches-3.3/001-cmdline_hack.patch | 20 | ||||
-rw-r--r-- | target/linux/rb532/patches-3.3/002-rb532_nand_fixup.patch | 48 | ||||
-rw-r--r-- | target/linux/rb532/src/patch-cmdline.c | 79 |
13 files changed, 613 insertions, 0 deletions
diff --git a/target/linux/rb532/Makefile b/target/linux/rb532/Makefile new file mode 100644 index 000000000..0504452c4 --- /dev/null +++ b/target/linux/rb532/Makefile @@ -0,0 +1,19 @@ +# +# Copyright (C) 2006-2011 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +ARCH:=mipsel +BOARD:=rb532 +BOARDNAME:=Mikrotik RouterBoard 532 +FEATURES:=jffs2 pci targz broken + +LINUX_VERSION:=3.3.8 + +include $(INCLUDE_DIR)/target.mk +DEFAULT_PACKAGES += wpad-mini kmod-madwifi kmod-input-rb532 + +$(eval $(call BuildTarget)) diff --git a/target/linux/rb532/base-files.mk b/target/linux/rb532/base-files.mk new file mode 100644 index 000000000..afd1220c5 --- /dev/null +++ b/target/linux/rb532/base-files.mk @@ -0,0 +1,11 @@ +define Build/Compile + $(call Build/Compile/Default) + $(TARGET_CC) -o $(PKG_BUILD_DIR)/patch-cmdline $(PLATFORM_DIR)/src/patch-cmdline.c +endef + +define Package/base-files/install-target + mkdir -p $(1)/sbin + $(CP) $(PKG_BUILD_DIR)/patch-cmdline $(1)/sbin +endef + + diff --git a/target/linux/rb532/base-files/etc/config/network b/target/linux/rb532/base-files/etc/config/network new file mode 100644 index 000000000..ee09491c7 --- /dev/null +++ b/target/linux/rb532/base-files/etc/config/network @@ -0,0 +1,13 @@ +# Copyright (C) 2006 OpenWrt.org + +config interface loopback + option ifname lo + option proto static + option ipaddr 127.0.0.1 + option netmask 255.0.0.0 + +config interface lan + option ifname eth2 + option proto static + option ipaddr 192.168.1.1 + option netmask 255.255.255.0 diff --git a/target/linux/rb532/base-files/etc/diag.sh b/target/linux/rb532/base-files/etc/diag.sh new file mode 100644 index 000000000..d8f9a8825 --- /dev/null +++ b/target/linux/rb532/base-files/etc/diag.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2007 OpenWrt.org + +set_led() { + local led="$1" + local state="$2" + [ -d "/sys/class/leds/rb500led:$led" ] && echo "$state" > "/sys/class/leds/rb500led:$led/brightness" +} + +set_state() { + case "$1" in + preinit) + set_led amber 1 + ;; + done) + set_led amber 0 + ;; + esac +} diff --git a/target/linux/rb532/base-files/sbin/cf2nand b/target/linux/rb532/base-files/sbin/cf2nand new file mode 100755 index 000000000..60542de1e --- /dev/null +++ b/target/linux/rb532/base-files/sbin/cf2nand @@ -0,0 +1,67 @@ +#!/bin/sh +. /etc/functions.sh + +copy_kernel() { + local input="$1" + local output="$2" + local cmdline="$3" + size="$(echo -n "$cmdline" | wc -c)" + dd if="$input" bs=3M count=1 > "$output" + /sbin/patch-cmdline "$output" "$cmdline" +} + +fstype="$(mount | grep ' / ' | awk '$5 != "rootfs" {print $5}')" +case "$fstype" in + ext2|jffs2) echo "Copying from $fstype to yaffs2";; + *) echo "Invalid filesystem."; exit 1;; +esac + +[ -d /tmp/cf2nand ] && { + echo "/tmp/cf2nand already exists" + exit 1 +} + +mkdir /tmp/cf2nand +mkdir /tmp/cf2nand/rootfs +mount -t "$fstype" /dev/root /tmp/cf2nand/rootfs || { + echo "Mounting rootfs failed." + exit 1 +} + +boot="$(find_mtd_part 'Routerboard NAND boot')" +main="$(find_mtd_part 'rootfs')" +[ -z "$boot" -o -z "$main" ] && { + echo "Cannot find NAND Flash partitions" + exit 1 +} + +echo "Erasing filesystem..." +mtd erase Boot 2>/dev/null >/dev/null +mtd erase Main 2>/dev/null >/dev/null + +mkdir /tmp/cf2nand/p1 +mkdir /tmp/cf2nand/p2 +mount -t yaffs2 "$boot" /tmp/cf2nand/p1 +mount -t yaffs2 "$main" /tmp/cf2nand/p2 + +echo "Copying kernel..." +copy_kernel /dev/cfa1 /tmp/cf2nand/p1/kernel "root=/dev/mtdblock1 rootfstype=yaffs2 " 2>/dev/null >/dev/null +umount /tmp/cf2nand/p1 +rmdir /tmp/cf2nand/p1 + +echo "Copying filesystem..." +( cd /tmp/cf2nand/rootfs; tar c . ) | ( cd /tmp/cf2nand/p2; tar x ) +echo "chmod ugo+x /" > /tmp/cf2nand/p2/etc/uci-defaults/set_root_permission +sync +# Use kexec is present +[ -x /usr/bin/kexec ] && { + kexec -l /tmp/cf2nand/p1/kernel --command-line="$(cat /proc/cmdline) root=/dev/mtdblock1 rootfstype=yaffs2" + kexec -e +} +umount /tmp/cf2nand/p2 +rmdir /tmp/cf2nand/p2 + +umount /tmp/cf2nand/rootfs +rmdir /tmp/cf2nand/rootfs +rmdir /tmp/cf2nand + diff --git a/target/linux/rb532/base-files/sbin/wget2nand b/target/linux/rb532/base-files/sbin/wget2nand new file mode 100755 index 000000000..57f412864 --- /dev/null +++ b/target/linux/rb532/base-files/sbin/wget2nand @@ -0,0 +1,71 @@ +#!/bin/sh +# wget2nand +# This script can be used to download a TGZ file from your build system which +# contains the files to be installed on the NAND flash on your RB1xx card. +# The one parameter is the URL of the TGZ file to be downloaded. +# Licence GPL V2 +# Author david.goodenough@linkchoose.co.uk +# Based on cf2nand from RB532 support +. /etc/functions.sh + +[ -d /tmp/wget2nand ] && { + echo "/tmp/wget2nand already exists" + exit 1 +} + +# first get an address for br-lan using udhcpc +killall udhcpc +/sbin/udhcpc -i br-lan + +# need to find the wget server from the command line +url=$1 +[ -z "$url" ] && { + echo "No URL specified for image TGZ" + echo "Usage : $0 URL" + exit 1 +} + +boot="$(find_mtd_part 'Routerboard NAND Boot')" +main="$(find_mtd_part 'rootfs')" +[ -z "$boot" -o -z "$main" ] && { + echo "Cannot find NAND Flash partitions" + exit 1 +} + +echo "Erasing filesystem." +mtd erase Boot 2>/dev/null >/dev/null +mtd erase Main 2>/dev/null >/dev/null + +echo "Mounting $main as new root and $boot as boot partition" + +mkdir /tmp/wget2nand/ +mkdir /tmp/wget2nand-boot +mount -t yaffs2 "$main" /tmp/wget2nand/ +mount -t yaffs2 "$boot" /tmp/wget2nand-boot + +echo "Copying filesystem..." +( wget -O - $url/openwrt-rb532-rootfs.tgz) | ( cd /tmp/wget2nand/; tar xvz ) +wget -O /tmp/wget2nand-boot/kernel $url/openwrt-rb532-vmlinux + +# No need to patch the kernel, this was done during the build process +chmod +x /tmp/wget2nand-boot/kernel + +# make sure everything is written before we unmount the partitions +echo "chmod ugo+x /" > /tmp/wget2nand/etc/uci-defaults/set_root_permission +sync +ls /tmp/wget2nand-boot/ +ls /tmp/wget2nand/ +# use kexec if present +[ -x /usr/bin/kexec ] && { + kexec -l /tmp/wget2nand-boot/kernel --command-line="$(cat /proc/cmdline) root=$main rootfstype=yaffs2" + kexec -e +} + +# unmount the partitions and remove the directories into which they were mounted +umount /tmp/wget2nand-boot +umount /tmp/wget2nand +rmdir /tmp/wget2nand-boot +rmdir /tmp/wget2nand + +# all done +echo "Image written, you can now reboot. Remember to change the boot source to Boot from Nand" diff --git a/target/linux/rb532/config-3.3 b/target/linux/rb532/config-3.3 new file mode 100644 index 000000000..1cfc4eacb --- /dev/null +++ b/target/linux/rb532/config-3.3 @@ -0,0 +1,130 @@ +CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y +CONFIG_ARCH_DISCARD_MEMBLOCK=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ATA=y +CONFIG_BCMA_POSSIBLE=y +CONFIG_BLK_DEV_SD=y +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_CEVT_R4K=y +CONFIG_CEVT_R4K_LIB=y +CONFIG_CPU_HAS_PREFETCH=y +CONFIG_CPU_HAS_SYNC=y +CONFIG_CPU_LITTLE_ENDIAN=y +CONFIG_CPU_MIPS32=y +CONFIG_CPU_MIPS32_R1=y +CONFIG_CPU_MIPSR1=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_HIGHMEM=y +CONFIG_CRC16=y +CONFIG_CSRC_R4K=y +CONFIG_CSRC_R4K_LIB=y +CONFIG_DECOMPRESS_LZMA=y +CONFIG_DMA_NONCOHERENT=y +# CONFIG_ENABLE_WARN_DEPRECATED is not set +CONFIG_EXT4_FS=y +CONFIG_FS_MBCACHE=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_GENERIC_GPIO=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y +# CONFIG_HAMRADIO is not set +CONFIG_HARDWARE_WATCHPOINTS=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_HAVE_ARCH_KGDB=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_HAVE_DMA_API_DEBUG=y +CONFIG_HAVE_DMA_ATTRS=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_HAVE_GENERIC_HARDIRQS=y +CONFIG_HAVE_IDE=y +CONFIG_HAVE_IRQ_WORK=y +CONFIG_HAVE_MEMBLOCK=y +CONFIG_HAVE_MEMBLOCK_NODE_MAP=y +CONFIG_HAVE_OPROFILE=y +CONFIG_HAVE_PERF_EVENTS=y +# CONFIG_HIGH_RES_TIMERS is not set +CONFIG_HW_HAS_PCI=y +CONFIG_HW_RANDOM=y +CONFIG_HZ=250 +# CONFIG_HZ_100 is not set +CONFIG_HZ_250=y +CONFIG_IMAGE_CMDLINE_HACK=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_IRQ_CPU=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_JBD2=y +CONFIG_KEXEC=y +CONFIG_KORINA=y +CONFIG_LEDS_MIKROTIK_RB532=y +CONFIG_MIKROTIK_RB532=y +CONFIG_MIPS=y +CONFIG_MIPS_L1_CACHE_SHIFT=4 +# CONFIG_MIPS_MACHINE is not set +CONFIG_MIPS_MT_DISABLED=y +CONFIG_MTD_BLOCK2MTD=y +CONFIG_MTD_CFI_ADV_OPTIONS=y +# CONFIG_MTD_CFI_AMDSTD is not set +CONFIG_MTD_CFI_GEOMETRY=y +# CONFIG_MTD_CFI_INTELEXT is not set +# CONFIG_MTD_COMPLEX_MAPPINGS is not set +CONFIG_MTD_NAND=y +CONFIG_MTD_NAND_ECC=y +CONFIG_MTD_NAND_PLATFORM=y +CONFIG_MTD_NAND_VERIFY_WRITE=y +CONFIG_MTD_PHYSMAP=y +# CONFIG_MTD_ROOTFS_ROOT_DEV is not set +# CONFIG_MTD_ROOTFS_SPLIT is not set +# CONFIG_MTD_SM_COMMON is not set +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_PATA_RB532=y +CONFIG_PCI=y +CONFIG_PCI_DISABLE_COMMON_QUIRKS=y +CONFIG_PCI_DOMAINS=y +CONFIG_PERF_USE_VMALLOC=y +# CONFIG_PREEMPT_RCU is not set +CONFIG_RC32434_WDT=y +CONFIG_SCSI=y +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_PROC_FS is not set +# CONFIG_SWAP is not set +CONFIG_SWAP_IO_SPACE=y +CONFIG_SYS_HAS_CPU_MIPS32_R1=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_ARBIT_HZ=y +CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y +CONFIG_VIA_RHINE=y +CONFIG_VIA_RHINE_MMIO=y +CONFIG_XZ_DEC=y +CONFIG_YAFFS_9BYTE_TAGS=y +# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set +CONFIG_YAFFS_AUTO_YAFFS2=y +# CONFIG_YAFFS_DISABLE_BACKGROUND is not set +# CONFIG_YAFFS_DISABLE_BLOCK_REFRESHING is not set +# CONFIG_YAFFS_DISABLE_TAGS_ECC is not set +# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set +# CONFIG_YAFFS_EMPTY_LOST_AND_FOUND is not set +CONFIG_YAFFS_FS=y +CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y +CONFIG_YAFFS_XATTR=y +CONFIG_YAFFS_YAFFS1=y +CONFIG_YAFFS_YAFFS2=y +CONFIG_ZONE_DMA_FLAG=0 diff --git a/target/linux/rb532/image/Makefile b/target/linux/rb532/image/Makefile new file mode 100644 index 000000000..da4baaa48 --- /dev/null +++ b/target/linux/rb532/image/Makefile @@ -0,0 +1,74 @@ +# +# Copyright (C) 2006-2010 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 + +LOADADDR = 0x81000000 # RAM start + 16M +KERNEL_ENTRY = 0x80101000 +RAMSIZE = 0x00100000 # 1MB +IMAGE_COPY = 1 + +LOADER_MAKEOPTS= \ + KDIR=$(KDIR) \ + LOADADDR=$(LOADADDR) \ + KERNEL_ENTRY=$(KERNEL_ENTRY) \ + RAMSIZE=$(RAMSIZE) \ + IMAGE_COPY=$(IMAGE_COPY) + +define Build/Clean + $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean +endef + +define Image/Prepare + cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma + $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile +endef + +VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux-kernel +ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y) + VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs +endif + +define Image/BuildKernel + $(CP) $(KDIR)/loader.elf $(VMLINUX) +endef + +define Image/cmdline/jffs2-64k +block2mtd.block2mtd=/dev/sda2,65536 root=/dev/mtdblock0 rootfstype=jffs2 +endef + +define Image/cmdline/jffs2-128k +block2mtd.block2mtd=/dev/sda2,131072 root=/dev/mtdblock0 rootfstype=jffs2 +endef + +define Image/cmdline/ext2 +root=/dev/sda2 rootfstype=ext2 +endef + +define Image/cmdline/squashfs +block2mtd.block2mtd=/dev/sda2,65536 root=/dev/mtdblock0 rootfstype=squashfs +endef + +define Image/cmdline/yaffs2 +root=/dev/mtdblock1 rootfstype=yaffs2 +endef + +define Image/Build + $(CP) $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel + $(STAGING_DIR_HOST)/bin/patch-cmdline $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel '$(strip $(call Image/cmdline/$(1))) ' + ./gen_image.sh $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).bin 4 $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1) +endef + +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y) + define Image/Prepare + $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux '$(strip $(call Image/cmdline/yaffs2)) ' + cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma + $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile + endef +endif + +$(eval $(call BuildImage)) diff --git a/target/linux/rb532/image/gen_image.sh b/target/linux/rb532/image/gen_image.sh new file mode 100755 index 000000000..8875834b9 --- /dev/null +++ b/target/linux/rb532/image/gen_image.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +OUTPUT="$1" +KERNELSIZE="$2" +KERNELIMAGE="$3" +ROOTFSSIZE="$4" +ROOTFSIMAGE="$5" + +rm -f "$OUTPUT" + +# create partition table +set `ptgen -o "$OUTPUT" -h 16 -s 32 -t 0x27 -p ${KERNELSIZE}m -t 0x83 -p ${ROOTFSSIZE}m` + +KERNELOFFSET="$(($1 / 512))" +ROOTFSOFFSET="$(($3 / 512))" + +dd if="$KERNELIMAGE" of="$OUTPUT" bs=512 conv=notrunc seek="$KERNELOFFSET" +dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 conv=notrunc seek="$ROOTFSOFFSET" diff --git a/target/linux/rb532/modules.mk b/target/linux/rb532/modules.mk new file mode 100644 index 000000000..0cbbdab3e --- /dev/null +++ b/target/linux/rb532/modules.mk @@ -0,0 +1,45 @@ +# +# Copyright (C) 2010 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define KernelPackage/ata-rb532-cf + SUBMENU:=$(BLOCK_MENU) + TITLE:=RB532 Compact Flash support + DEPENDS:=@TARGET_rb532 @BROKEN + KCONFIG:= \ + CONFIG_PATA_PLATFORM \ + CONFIG_PATA_RB532 + FILES:=\ + $(LINUX_DIR)/drivers/ata/pata_platform.ko \ + $(LINUX_DIR)/drivers/ata/pata_rb532_cf.ko + AUTOLOAD:=$(call AutoLoad,41,pata_platform pata_rb532_cf,1) + $(call AddDepends/ata) +endef + +define KernelPackage/ata-rb532-cf/description + RB532 Compact Flash support. +endef + +$(eval $(call KernelPackage,ata-rb532-cf)) + + +define KernelPackage/input-rb532 + SUBMENU:=$(OTHER_MENU) + TITLE:=RB532 button device support + DEPENDS:=@TARGET_rb532 +kmod-input-polldev + KCONFIG:= \ + CONFIG_INPUT_MISC=y \ + CONFIG_INPUT_RB532_BUTTON + FILES:=$(LINUX_DIR)/drivers/input/misc/rb532_button.ko + AUTOLOAD:=$(call AutoLoad,62,rb532_button) + $(call AddDepends/input) +endef + +define KernelPackage/input-rb532/description + Kernel module for RB532 button +endef + +$(eval $(call KernelPackage,input-rb532)) diff --git a/target/linux/rb532/patches-3.3/001-cmdline_hack.patch b/target/linux/rb532/patches-3.3/001-cmdline_hack.patch new file mode 100644 index 000000000..d27184d34 --- /dev/null +++ b/target/linux/rb532/patches-3.3/001-cmdline_hack.patch @@ -0,0 +1,20 @@ +--- a/arch/mips/rb532/prom.c ++++ b/arch/mips/rb532/prom.c +@@ -67,6 +67,7 @@ static inline unsigned long tag2ul(char + return simple_strtoul(num, 0, 10); + } + ++extern char __image_cmdline[]; + void __init prom_setup_cmdline(void) + { + static char cmd_line[COMMAND_LINE_SIZE] __initdata; +@@ -109,6 +110,9 @@ void __init prom_setup_cmdline(void) + } + *(cp++) = ' '; + ++ strcpy(cp,(__image_cmdline)); ++ cp += strlen(__image_cmdline); ++ + i = strlen(arcs_cmdline); + if (i > 0) { + *(cp++) = ' '; diff --git a/target/linux/rb532/patches-3.3/002-rb532_nand_fixup.patch b/target/linux/rb532/patches-3.3/002-rb532_nand_fixup.patch new file mode 100644 index 000000000..d127979d2 --- /dev/null +++ b/target/linux/rb532/patches-3.3/002-rb532_nand_fixup.patch @@ -0,0 +1,48 @@ +--- a/arch/mips/rb532/devices.c ++++ b/arch/mips/rb532/devices.c +@@ -139,6 +139,19 @@ static struct platform_device cf_slot0 = + }; + + /* Resources and device for NAND */ ++ ++/* ++ * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader ++ * will not be able to find the kernel that we load. So set the oobinfo ++ * when creating the partitions ++ */ ++static struct nand_ecclayout rb532_nand_ecclayout = { ++ .eccbytes = 6, ++ .eccpos = { 8, 9, 10, 13, 14, 15 }, ++ .oobavail = 9, ++ .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } } ++}; ++ + static int rb532_dev_ready(struct mtd_info *mtd) + { + return gpio_get_value(GPIO_RDY); +@@ -274,6 +287,16 @@ static void __init parse_mac_addr(char * + /* NAND definitions */ + #define NAND_CHIP_DELAY 25 + ++static int rb532_nand_fixup(struct mtd_info *mtd) ++{ ++ struct nand_chip *chip = mtd->priv; ++ ++ if (mtd->writesize == 512) ++ chip->ecc.layout = &rb532_nand_ecclayout; ++ ++ return 0; ++} ++ + static void __init rb532_nand_setup(void) + { + switch (mips_machtype) { +@@ -293,6 +316,8 @@ static void __init rb532_nand_setup(void + rb532_nand_data.chip.partitions = rb532_partition_info; + rb532_nand_data.chip.chip_delay = NAND_CHIP_DELAY; + rb532_nand_data.chip.options = NAND_NO_AUTOINCR; ++ ++ rb532_nand_data.chip.chip_fixup = &rb532_nand_fixup; + } + + diff --git a/target/linux/rb532/src/patch-cmdline.c b/target/linux/rb532/src/patch-cmdline.c new file mode 100644 index 000000000..571f848d8 --- /dev/null +++ b/target/linux/rb532/src/patch-cmdline.c @@ -0,0 +1,79 @@ +/* + * patch-cmdline.c - patch the kernel command line on rb532 + * + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <string.h> + +#define SEARCH_SPACE (16 * 1024) +#define CMDLINE_MAX 512 + +int main(int argc, char **argv) +{ + int fd, found = 0, len, ret = -1; + char *ptr, *p; + + if (argc != 3) { + fprintf(stderr, "Usage: %s <file> <cmdline>\n", argv[0]); + goto err1; + } + len = strlen(argv[2]); + if (len + 9 > CMDLINE_MAX) { + fprintf(stderr, "Command line string too long\n"); + goto err1; + } + + if (((fd = open(argv[1], O_RDWR)) < 0) || + (ptr = (char *) mmap(0, SEARCH_SPACE + CMDLINE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) { + fprintf(stderr, "Could not open kernel image"); + goto err2; + } + + for (p = ptr; p < (ptr + SEARCH_SPACE); p += 4) { + if (memcmp(p, "CMDLINE:", 8) == 0) { + found = 1; + p += 8; + break; + } + } + if (!found) { + fprintf(stderr, "Command line marker not found!\n"); + goto err3; + } + + memset(p, 0, CMDLINE_MAX - 8); + strcpy(p, argv[2]); + msync(p, CMDLINE_MAX, MS_SYNC|MS_INVALIDATE); + ret = 0; + +err3: + munmap((void *) ptr, len); +err2: + if (fd > 0) + close(fd); +err1: + return ret; +} |