Root/target/linux/lantiq/patches/206-owrt-brnboot.patch

1Index: linux-3.1.10/drivers/mtd/mtdpart.c
2===================================================================
3--- linux-3.1.10.orig/drivers/mtd/mtdpart.c 2012-02-14 19:38:40.102266817 +0100
4+++ linux-3.1.10/drivers/mtd/mtdpart.c 2012-02-14 19:38:40.146266819 +0100
5@@ -899,6 +899,38 @@
6     return le32_to_cpu(temp) == SQUASHFS_MAGIC;
7 }
8 
9+static unsigned long find_brnimage_size(struct mtd_info *mtd,
10+ unsigned long offset)
11+{
12+ unsigned long buf[4];
13+ // Assume at most 2MB of kernel image
14+ unsigned long end = offset + (2 << 20);
15+ unsigned long ptr = offset + 0x400 - 12;
16+ size_t len;
17+ int ret;
18+
19+ while (ptr < end) {
20+ long size_min = ptr - 0x400 - 12 - offset;
21+ long size_max = ptr + 12 - offset;
22+ ret = mtd->read(mtd, ptr, 16, &len, (void *)buf);
23+ if (ret || len != 16)
24+ return 0;
25+
26+ if (le32_to_cpu(buf[0]) < size_min ||
27+ le32_to_cpu(buf[0]) > size_max) {
28+ ptr += 0x400;
29+ continue;
30+ }
31+
32+ if (le32_to_cpu(buf[3]) == SQUASHFS_MAGIC)
33+ return ptr + 12 - offset;
34+
35+ ptr += 0x400;
36+ }
37+
38+ return 0;
39+}
40+
41 static int split_uimage(struct mtd_info *mtd,
42             const struct mtd_partition *part)
43 {
44@@ -916,8 +948,11 @@
45 
46     split_partitions[0].size = find_uimage_size(mtd, part->offset);
47     if (!split_partitions[0].size) {
48- printk(KERN_NOTICE "no uImage found in linux partition\n");
49- return -1;
50+ split_partitions[0].size = find_brnimage_size(mtd, part->offset);
51+ if (!split_partitions[0].size) {
52+ printk(KERN_NOTICE "no uImage or brnImage found in linux partition\n");
53+ return -1;
54+ }
55     }
56 
57     if (!detect_squashfs_partition(mtd,
58Index: linux-3.1.10/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
59===================================================================
60--- linux-3.1.10.orig/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h 2012-02-14 19:38:40.058266816 +0100
61+++ linux-3.1.10/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h 2012-02-14 19:57:07.790314179 +0100
62@@ -149,6 +149,7 @@
63 
64 extern __iomem void *ltq_ebu_membase;
65 extern __iomem void *ltq_cgu_membase;
66+extern unsigned long ltq_brn_boot;
67 
68 /* request a non-gpio and set the PIO config */
69 extern int ltq_gpio_request(unsigned int pin, unsigned int alt0,
70Index: linux-3.1.10/arch/mips/lantiq/setup.c
71===================================================================
72--- linux-3.1.10.orig/arch/mips/lantiq/setup.c 2012-02-14 19:38:40.010266814 +0100
73+++ linux-3.1.10/arch/mips/lantiq/setup.c 2012-02-14 19:38:40.150266820 +0100
74@@ -20,6 +20,8 @@
75 
76 /* assume 16M as default incase uboot fails to pass proper ramsize */
77 unsigned long physical_memsize = 16L;
78+/* set to 1 if the bootloader is BRN-BOOT instead of u-boot */
79+unsigned long ltq_brn_boot = 0;
80 
81 void __init plat_mem_setup(void)
82 {
83@@ -39,6 +41,10 @@
84             if (strict_strtoul(e, 0, &physical_memsize))
85                 pr_warn("bad memsize specified\n");
86         }
87+ if (!strncmp(e, "BRN-BOOT", 8)){
88+ pr_info("Found BRN-BOOT instead of u-boot\n");
89+ ltq_brn_boot = 1;
90+ }
91         envp++;
92     }
93     physical_memsize *= 1024 * 1024;
94

Archive Download this file



interactive