summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Glaser <tg@mirbsd.org>2011-01-07 19:56:23 +0000
committerWaldemar Brodkorb <wbx@openadk.org>2011-01-07 23:30:22 +0100
commit5ab78079fc70b8edbef2f04f852ad7bc3ccb2377 (patch)
tree4e71b7b6cbc1caf90d71a4e6d59d78cd6859821f
parentc5f31c89138e4bf5f7c2634f770e6b280a9cd334 (diff)
provide squashfs for bcm47xx including cfgfs partition
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
-rw-r--r--mk/image.mk10
-rw-r--r--target/linux/patches/2.6.36/brcm.patch87
-rw-r--r--target/mipsel/Makefile22
3 files changed, 100 insertions, 19 deletions
diff --git a/mk/image.mk b/mk/image.mk
index 9b74348fe..6b0eff483 100644
--- a/mk/image.mk
+++ b/mk/image.mk
@@ -96,12 +96,16 @@ ${BUILD_DIR}/${INITRAMFS_PIGGYBACK}: ${TARGET_DIR}
sed "s#\(.*\)#:0:0::::::\1#" | sort | \
${TOOLS_DIR}/cpio -o -C512 -Hnewc -P >$@ 2>/dev/null
-${BIN_DIR}/${ROOTFSSQUASHFS}: ${TARGET_DIR}
+${BUILD_DIR}/root.squashfs: ${TARGET_DIR}
${STAGING_HOST_DIR}/bin/mksquashfs ${TARGET_DIR} \
${BUILD_DIR}/root.squashfs \
-nopad -noappend -root-owned $(MAKE_TRACE)
- cat ${BUILD_DIR}/${TARGET_KERNEL} ${BUILD_DIR}/root.squashfs > \
- ${BUILD_DIR}/${ROOTFSSQUASHFS}
+
+ifeq (,${CUSTOM_ROOTFSSQUASHFS_BUILD})
+${BIN_DIR}/${ROOTFSSQUASHFS}: ${BUILD_DIR}/root.squashfs
+ cat ${BUILD_DIR}/${TARGET_KERNEL} ${BUILD_DIR}/root.squashfs \
+ >${BUILD_DIR}/${ROOTFSSQUASHFS}
+endif
createinitramfs:
@-rm $(LINUX_DIR)/usr/initramfs_data.cpio* $(MAKE_TRACE)
diff --git a/target/linux/patches/2.6.36/brcm.patch b/target/linux/patches/2.6.36/brcm.patch
index 44db7d0d5..10a9a4947 100644
--- a/target/linux/patches/2.6.36/brcm.patch
+++ b/target/linux/patches/2.6.36/brcm.patch
@@ -1,4 +1,3 @@
-diff -Nur linux-2.6.36.orig/arch/mips/bcm47xx/Makefile linux-2.6.36/arch/mips/bcm47xx/Makefile
--- linux-2.6.36.orig/arch/mips/bcm47xx/Makefile 2010-10-20 22:30:22.000000000 +0200
+++ linux-2.6.36/arch/mips/bcm47xx/Makefile 2010-12-22 16:39:15.000000000 +0100
@@ -3,4 +3,4 @@
@@ -7,16 +6,16 @@ diff -Nur linux-2.6.36.orig/arch/mips/bcm47xx/Makefile linux-2.6.36/arch/mips/bc
-obj-y := gpio.o irq.o nvram.o prom.o serial.o setup.o time.o wgt634u.o
+obj-y := gpio.o irq.o nvram.o prom.o serial.o setup.o time.o platform.o
-diff -Nur linux-2.6.36.orig/arch/mips/bcm47xx/platform.c linux-2.6.36/arch/mips/bcm47xx/platform.c
---- linux-2.6.36.orig/arch/mips/bcm47xx/platform.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.36/arch/mips/bcm47xx/platform.c 2010-12-22 16:57:43.000000000 +0100
-@@ -0,0 +1,81 @@
+--- /dev/null Fri Jan 7 17:21:57 2011
++++ linux-2.6.36/arch/mips/bcm47xx/platform.c Fri Jan 7 17:21:42 2011
+@@ -0,0 +1,147 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
-+ * Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org>
++ * Copyright (C) 2010, 2011 Waldemar Brodkorb <wbx@openadk.org>
++ * Copyright © 2007, 2011 Thorsten Glaser <tg@freewrt.org>
+ */
+
+#include <linux/platform_device.h>
@@ -28,19 +27,35 @@ diff -Nur linux-2.6.36.orig/arch/mips/bcm47xx/platform.c linux-2.6.36/arch/mips/
+#include <asm/mach-bcm47xx/nvram.h>
+
+#define NVRAM_FLASH_SIZE 0x10000
++#define CFGFS_FLASH_SIZE (64 * 1024)
+
+static struct mtd_partition bcm47xx_partitions[] = {
++#define SLOT_CFE 0
+ {
+ .name = "cfe",
+ .offset = 0,
+ .size = 0x40000, /* 256k */
+ .mask_flags = MTD_WRITEABLE /* force read-only */
+ },
++#define SLOT_LINUX 1
+ {
+ .name = "linux",
+ .offset = 0,
+ .size = 0,
+ },
++#define SLOT_ROOTFS 2
++ {
++ .name = "rootfs",
++ .offset = 0,
++ .size = 0,
++ },
++#define SLOT_CFGFS 3
++ {
++ .name = "cfgfs",
++ .offset = 0,
++ .size = 0,
++ },
++#define SLOT_NVRAM 4
+ {
+ .name = "nvram",
+ .offset = 0,
@@ -69,18 +84,67 @@ diff -Nur linux-2.6.36.orig/arch/mips/bcm47xx/platform.c linux-2.6.36/arch/mips/
+ &bcm47xx_flash,
+};
+
++struct bcm47xx_trx_header {
++#define BCM47XX_TRX_MAGIC 0x30524448
++ u32 magic;
++ u32 len;
++ u32 crc32;
++ u32 flag_version;
++ u32 offsets[3];
++};
++
++#define UPTODOWN(slot, psize) do { \
++ posn -= psize; left -= psize; \
++ bcm47xx_partitions[slot].offset = posn; \
++ bcm47xx_partitions[slot].size = psize; \
++} while (/* CONSTCOND */ 0)
++
+static int __init bcm47xx_register_devices(void)
+{
+ u32 flash_size;
++ size_t left, posn;
+ struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
++ struct bcm47xx_trx_header *trx_hdr;
++
++ trx_hdr = (void *)KSEG1ADDR(mcore->flash_window + 0x40000);
+
+ /* devices might have 2, 4 or 8 MB flash size */
++#ifdef BCM47XX_OVERRIDE_FLASHSIZE
++ flash_size = BCM47XX_OVERRIDE_FLASHSIZE;
++ mcore->flash_window_size = flash_size;
++#define BCM47XX_OVERRODE_FLASHSIZE " (overridden)"
++#else
+ flash_size = mcore->flash_window_size;
-+ printk(KERN_INFO "FLASH SIZE: %x\n", flash_size);
-+ bcm47xx_partitions[1].offset = 0x40000;
-+ bcm47xx_partitions[1].size = flash_size - NVRAM_FLASH_SIZE - 0x40000;
-+ bcm47xx_partitions[2].offset = flash_size - NVRAM_FLASH_SIZE;
-+ bcm47xx_partitions[2].size = NVRAM_FLASH_SIZE;
++#define BCM47XX_OVERRODE_FLASHSIZE ""
++#endif
++ printk(KERN_INFO "FLASH SIZE%s: %x\n", BCM47XX_OVERRODE_FLASHSIZE,
++ flash_size);
++
++ left = flash_size - 0x40000;
++ posn = flash_size;
++ UPTODOWN(SLOT_NVRAM, NVRAM_FLASH_SIZE);
++ UPTODOWN(SLOT_CFGFS, CFGFS_FLASH_SIZE);
++ bcm47xx_partitions[SLOT_LINUX].offset = 0x40000;
++ bcm47xx_partitions[SLOT_LINUX].size = left;
++
++ if (trx_hdr->magic == BCM47XX_TRX_MAGIC) {
++ bcm47xx_partitions[SLOT_ROOTFS].offset =
++ bcm47xx_partitions[SLOT_LINUX].offset +
++ trx_hdr->offsets[1];
++ bcm47xx_partitions[SLOT_ROOTFS].size =
++ bcm47xx_partitions[SLOT_LINUX].size -
++ trx_hdr->offsets[1];
++ } else
++ printk("bcm47xx/platform: no TRX header found\n");
++
++ printk(KERN_INFO "=== Flash map dump ===\n");
++ for (posn = 0; posn < bcm47xx_flash_data.nr_parts; ++posn)
++ printk(KERN_INFO " #%u %08X @%08X '%s'\n",
++ (unsigned int)posn,
++ (unsigned int)bcm47xx_partitions[posn].size,
++ (unsigned int)bcm47xx_partitions[posn].offset,
++ bcm47xx_partitions[posn].name);
++ printk(KERN_INFO "=== Hope this works, have a nice day\n");
+
+ bcm47xx_flash_data.width = mcore->flash_buswidth;
+ bcm47xx_flash_resource.start = mcore->flash_window;
@@ -92,7 +156,6 @@ diff -Nur linux-2.6.36.orig/arch/mips/bcm47xx/platform.c linux-2.6.36/arch/mips/
+}
+
+device_initcall(bcm47xx_register_devices);
-diff -Nur linux-2.6.36.orig/drivers/ssb/driver_mipscore.c linux-2.6.36/drivers/ssb/driver_mipscore.c
--- linux-2.6.36.orig/drivers/ssb/driver_mipscore.c 2010-10-20 22:30:22.000000000 +0200
+++ linux-2.6.36/drivers/ssb/driver_mipscore.c 2010-12-22 16:38:53.000000000 +0100
@@ -193,7 +193,7 @@
diff --git a/target/mipsel/Makefile b/target/mipsel/Makefile
index d0aa6e5c9..8e1748a1f 100644
--- a/target/mipsel/Makefile
+++ b/target/mipsel/Makefile
@@ -5,6 +5,11 @@ include $(TOPDIR)/rules.mk
include $(TOPDIR)/mk/kernel.mk
include $(TOPDIR)/mk/modules.mk
include $(TOPDIR)/mk/kernel-build.mk
+
+ifeq (${ADK_TARGET_SYSTEM_LINKSYS_WRT54G},y)
+CUSTOM_ROOTFSSQUASHFS_BUILD=1
+endif
+
include $(TOPDIR)/mk/image.mk
KERNEL:=$(LINUX_DIR)/vmlinux
@@ -21,9 +26,18 @@ tools-compile: $(TOOLS_BUILD_DIR)
ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_WRT54G),y)
kernel-install: tools-compile
- $(TARGET_CROSS)objcopy $(OSTRIP) -S $(LINUX_DIR)/vmlinux \
- $(LINUX_DIR)/vmlinux.stripped
- @gzip -c9 $(LINUX_DIR)/vmlinux.stripped > $(BUILD_DIR)/$(TARGET_KERNEL)
+ ${TARGET_CROSS}objcopy ${OSTRIP} -S ${LINUX_DIR}/vmlinub.elf \
+ ${BUILD_DIR}/${TARGET_KERNEL}
+
+${BUILD_DIR}/${ROOTFSSQUASHFS}: ${BUILD_DIR}/root.squashfs
+ ${TARGET_CROSS}objcopy -O binary ${BUILD_DIR}/${TARGET_KERNEL} \
+ ${BUILD_DIR}/${TARGET_KERNEL}.bin
+ gzip -n9 <${BUILD_DIR}/${TARGET_KERNEL}.bin \
+ >${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
+ printf '\0' >>${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
+ PATH='${TARGET_PATH}' trx -o $@~ ${BUILD_DIR}/${TARGET_KERNEL}.bin.gz \
+ -a 1024 ${BUILD_DIR}/root.squashfs
+ PATH='${TARGET_PATH}' addpattern -4 -p W54G -v v4.20.6 -g -i $@~ -o $@
endif
ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_AG241),y)
@@ -49,7 +63,7 @@ imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSUSERTARBALL)
@echo "If you just want to update, use adkupdate."
endif
ifeq ($(ADK_TARGET_FS),squashfs)
-imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSSQUASHFS)
+imageinstall: kernel-install ${BUILD_DIR}/${ROOTFSSQUASHFS}
@if [ $$(stat -f %z ${BUILD_DIR}/${ROOTFSSQUASHFS}) -gt 3801088 ];then \
echo 'Image is too big!'; \
else \