aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2012-02-14 17:48:04 +0000
committerJohn Crispin <john@openwrt.org>2012-02-14 17:48:04 +0000
commitcd1a204365fff2639329c28c1b986f3a4e7246d4 (patch)
tree110a78ac8772fcb23ba40e73117c18271957f642 /target/linux
parent17e17170332f0fba7a53dbb0bd7480a639cf8ef7 (diff)
downloadupstream-cd1a204365fff2639329c28c1b986f3a4e7246d4.tar.gz
upstream-cd1a204365fff2639329c28c1b986f3a4e7246d4.tar.bz2
upstream-cd1a204365fff2639329c28c1b986f3a4e7246d4.zip
Support booting the Speedport W502V using BRN-BOOT.
While the disadvantage is less available flash space, it's easy and safe to flash without opening the device. Going back to the original firmware is also possible. This patch add two firmware utilities, mkbrncmdline and mkbrnboot. mkbrncmdline patches the uncompressed kernel so the registeres a0 to a3 are initialized and the memory size is passed in. mkbrnboot takes the lzma compressed kernel and squashfs images and creates a firmware image that can be flashed using the BRN-BOOT recovery kernel, which is booted by holding both buttons when powering up the device and will listen on http://192.168.2.1. The firmware file from bin/lantiq/ to use is openwrt-lantiq-danube-ARV4525PW-BRNDTW502-brnImage The BRN-BOOT recovery kernel does size-check the image, so if it's too big to fit into flash it will complain accordingly. A second patch is needed to make the wired network interface work since there is no u-boot to pre-initialise it. Signed-off-by: Tobias Diedrich <ranma+openwrt@tdiedrich.de> SVN-Revision: 30532
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/lantiq/files-3.1/arch/mips/lantiq/xway/mach-arv45xx.c63
-rw-r--r--target/linux/lantiq/image/Makefile9
-rw-r--r--target/linux/lantiq/patches/206-owrt-brnboot.patch93
3 files changed, 158 insertions, 7 deletions
diff --git a/target/linux/lantiq/files-3.1/arch/mips/lantiq/xway/mach-arv45xx.c b/target/linux/lantiq/files-3.1/arch/mips/lantiq/xway/mach-arv45xx.c
index 78d8b5b77e..9be1a5fb93 100644
--- a/target/linux/lantiq/files-3.1/arch/mips/lantiq/xway/mach-arv45xx.c
+++ b/target/linux/lantiq/files-3.1/arch/mips/lantiq/xway/mach-arv45xx.c
@@ -78,6 +78,35 @@ static struct mtd_partition arv45xx_partitions[] =
},
};
+static struct mtd_partition arv45xx_brnboot_partitions[] =
+{
+ {
+ .name = "brn-boot",
+ .offset = 0x0,
+ .size = 0x20000,
+ },
+ {
+ .name = "config",
+ .offset = 0x20000,
+ .size = 0x30000,
+ },
+ {
+ .name = "linux",
+ .offset = 0x50000,
+ .size = 0x390000,
+ },
+ {
+ .name = "reserved", /* 12-byte signature at 0x3efff4 :/ */
+ .offset = 0x3e0000,
+ .size = 0x010000,
+ },
+ {
+ .name = "eeprom",
+ .offset = 0x3f0000,
+ .size = 0x10000,
+ },
+};
+
static struct mtd_partition arv7525_partitions[] =
{
{
@@ -136,6 +165,11 @@ static struct physmap_flash_data arv45xx_flash_data = {
.parts = arv45xx_partitions,
};
+static struct physmap_flash_data arv45xx_brnboot_flash_data = {
+ .nr_parts = ARRAY_SIZE(arv45xx_brnboot_partitions),
+ .parts = arv45xx_brnboot_partitions,
+};
+
static struct physmap_flash_data arv7525_flash_data = {
.nr_parts = ARRAY_SIZE(arv7525_partitions),
.parts = arv7525_partitions,
@@ -244,13 +278,22 @@ arv452cpw_gpio_leds[] __initdata = {
static struct gpio_led
arv4525pw_gpio_leds[] __initdata = {
- { .name = "soc:green:fxs1", .gpio = 4, .active_low = 1, .default_trigger = "default-on" },
- { .name = "soc:green:fxs2", .gpio = 5, .active_low = 1, .default_trigger = "default-on" },
- { .name = "soc:red:dsl", .gpio = 6, .active_low = 1, .default_trigger = "default-on" },
+ { .name = "soc:green:dsl", .gpio = 6, .active_low = 1, .default_trigger = "default-on" },
{ .name = "soc:green:wifi", .gpio = 8, .active_low = 1, .default_trigger = "default-on" },
{ .name = "soc:green:online", .gpio = 9, .active_low = 1, .default_trigger = "default-on" },
+ { .name = "soc:green:fxs-internet", .gpio = 5, .active_low = 1, .default_trigger = "default-on" },
+ { .name = "soc:green:fxs-festnetz", .gpio = 4, .active_low = 1, .default_trigger = "default-on" },
};
+#define ARV4525PW_PHYRESET 13
+#define ARV4525PW_RELAY 31
+
+static struct gpio arv4525pw_gpios[] __initdata = {
+ { ARV4525PW_PHYRESET, GPIOF_OUT_INIT_HIGH, "phyreset" },
+ { ARV4525PW_RELAY, GPIOF_OUT_INIT_HIGH, "relay" },
+};
+
+
static struct gpio_led
arv752dpw22_gpio_leds[] __initdata = {
{ .name = "soc:blue:power", .gpio = 3, .active_low = 1, .default_trigger = "default-on" },
@@ -521,16 +564,24 @@ MIPS_MACHINE(LANTIQ_MACH_ARV452CPW,
"ARV452CPW - Arcor A801",
arv452Cpw_init);
-
static void __init
arv4525pw_init(void)
{
-#define ARV4525PW_MADWIFI_ADDR 0xb07f0400
+#define ARV4525PW_MADWIFI_ADDR 0xb03f0400
+ if (ltq_brn_boot)
+ ltq_register_nor(&arv45xx_brnboot_flash_data);
+ else
+ ltq_register_nor(&arv45xx_flash_data);
+
ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4525pw_gpio_leds), arv4525pw_gpio_leds);
- ltq_register_nor(&arv45xx_flash_data);
+ gpio_request_array(arv4525pw_gpios, ARRAY_SIZE(arv4525pw_gpios));
+ gpio_export(ARV4525PW_RELAY, false);
+ gpio_export(ARV4525PW_PHYRESET, false);
ltq_pci_data.clock = PCI_CLOCK_INT;
ltq_register_pci(&ltq_pci_data);
ltq_register_madwifi_eep(ARV4525PW_MADWIFI_ADDR);
+ arv45xx_register_ath5k();
+ ltq_register_ath5k(arv45xx_ath5k_eeprom_data, arv45xx_ath5k_eeprom_mac);
ltq_eth_data.mii_mode = PHY_INTERFACE_MODE_MII;
arv45xx_register_ethernet();
}
diff --git a/target/linux/lantiq/image/Makefile b/target/linux/lantiq/image/Makefile
index 8c607b2151..9ccf45d188 100644
--- a/target/linux/lantiq/image/Makefile
+++ b/target/linux/lantiq/image/Makefile
@@ -23,6 +23,12 @@ define PatchKernelLzma
$(call CompressLzma,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).lzma)
endef
+define MkBrnImage
+ mkbrncmdline -i $(KDIR)/vmlinux-$(4) -o $(KDIR)/vmlinux-$(4)-brn BRN-BOOT $(6)
+ $(call CompressLzma,$(KDIR)/vmlinux-$(4)-brn,$(KDIR)/vmlinux-$(4)-brn.lzma)
+ mkbrnimg -s $(1) -m $(2) -o $(3) $(KDIR)/vmlinux-$(4)-brn.lzma $(KDIR)/root.$(5)
+endef
+
define MkImageLzma
mkimage -A mips -O linux -T kernel -a 0x80002000 -C lzma \
-e 0x80002000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
@@ -32,6 +38,7 @@ endef
define Image/Build/squashfs
cat $(KDIR)/uImage-$(2) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
$(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image)
+ $(if $(3),$(call MkBrnImage,$(3),$(4),$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(3)-brnImage,$(2),$(1),$(5)))
endef
define Image/Build/jffs2-64k
@@ -109,7 +116,7 @@ define Image/BuildKernel/Profile/ARV4525PW
endef
define Image/Build/Profile/ARV4525PW
- $(call Image/Build/$(1),$(1),ARV4525PW)
+ $(call Image/Build/$(1),$(1),ARV4525PW,BRNDTW502,0x12345678,memsize=32)
endef
define Image/BuildKernel/Profile/ARV7525PW
diff --git a/target/linux/lantiq/patches/206-owrt-brnboot.patch b/target/linux/lantiq/patches/206-owrt-brnboot.patch
new file mode 100644
index 0000000000..c21d76d1f8
--- /dev/null
+++ b/target/linux/lantiq/patches/206-owrt-brnboot.patch
@@ -0,0 +1,93 @@
+Index: linux-3.1.9/drivers/mtd/mtdpart.c
+===================================================================
+--- linux-3.1.9.orig/drivers/mtd/mtdpart.c 2012-01-29 22:55:30.295904157 +0100
++++ linux-3.1.9/drivers/mtd/mtdpart.c 2012-01-29 22:55:30.395904294 +0100
+@@ -899,6 +899,38 @@
+ return le32_to_cpu(temp) == SQUASHFS_MAGIC;
+ }
+
++static unsigned long find_brnimage_size(struct mtd_info *mtd,
++ unsigned long offset)
++{
++ unsigned long buf[4];
++ // Assume at most 2MB of kernel image
++ unsigned long end = offset + (2 << 20);
++ unsigned long ptr = offset + 0x400 - 12;
++ size_t len;
++ int ret;
++
++ while (ptr < end) {
++ long size_min = ptr - 0x400 - 12 - offset;
++ long size_max = ptr + 12 - offset;
++ ret = mtd->read(mtd, ptr, 16, &len, (void *)buf);
++ if (ret || len != 16)
++ return 0;
++
++ if (le32_to_cpu(buf[0]) < size_min ||
++ le32_to_cpu(buf[0]) > size_max) {
++ ptr += 0x400;
++ continue;
++ }
++
++ if (le32_to_cpu(buf[3]) == SQUASHFS_MAGIC)
++ return ptr + 12 - offset;
++
++ ptr += 0x400;
++ }
++
++ return 0;
++}
++
+ static int split_uimage(struct mtd_info *mtd,
+ const struct mtd_partition *part)
+ {
+@@ -916,8 +948,11 @@
+
+ split_partitions[0].size = find_uimage_size(mtd, part->offset);
+ if (!split_partitions[0].size) {
+- printk(KERN_NOTICE "no uImage found in linux partition\n");
+- return -1;
++ split_partitions[0].size = find_brnimage_size(mtd, part->offset);
++ if (!split_partitions[0].size) {
++ printk(KERN_NOTICE "no uImage or brnImage found in linux partition\n");
++ return -1;
++ }
+ }
+
+ if (!detect_squashfs_partition(mtd,
+Index: linux-3.1.9/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
+===================================================================
+--- linux-3.1.9.orig/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h 2012-01-29 22:55:30.195904014 +0100
++++ linux-3.1.9/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h 2012-01-29 22:55:30.395904294 +0100
+@@ -149,6 +149,7 @@
+
+ extern __iomem void *ltq_ebu_membase;
+ extern __iomem void *ltq_cgu_membase;
++extern long ltq_brn_boot;
+
+ /* request a non-gpio and set the PIO config */
+ extern int ltq_gpio_request(unsigned int pin, unsigned int alt0,
+Index: linux-3.1.9/arch/mips/lantiq/setup.c
+===================================================================
+--- linux-3.1.9.orig/arch/mips/lantiq/setup.c 2012-01-29 22:55:30.095903875 +0100
++++ linux-3.1.9/arch/mips/lantiq/setup.c 2012-01-29 22:59:28.686237119 +0100
+@@ -20,6 +20,8 @@
+
+ /* assume 16M as default incase uboot fails to pass proper ramsize */
+ unsigned long physical_memsize = 16L;
++/* set to 1 if the bootloader is BRN-BOOT instead of u-boot */
++unsigned long ltq_brn_boot = 0;
+
+ void __init plat_mem_setup(void)
+ {
+@@ -39,6 +41,10 @@
+ if (strict_strtoul(e, 0, &physical_memsize))
+ pr_warn("bad memsize specified\n");
+ }
++ if (!strncmp(e, "BRN-BOOT", 8)){
++ pr_info("Found BRN-BOOT instead of u-boot\n");
++ ltq_brn_boot = 1;
++ }
+ envp++;
+ }
+ physical_memsize *= 1024 * 1024;