aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/lantiq/patches/206-owrt-brnboot.patch
blob: d10d66b1e2a1f490b7e2417261df06501920124a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Index: linux-3.1.10/drivers/mtd/mtdpart.c
===================================================================
--- linux-3.1.10.orig/drivers/mtd/mtdpart.c	2012-02-14 19:38:40.102266817 +0100
+++ linux-3.1.10/drivers/mtd/mtdpart.c	2012-02-14 19:38:40.146266819 +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.10/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
===================================================================
--- linux-3.1.10.orig/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h	2012-02-14 19:38:40.058266816 +0100
+++ linux-3.1.10/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h	2012-02-14 19:57:07.790314179 +0100
@@ -149,6 +149,7 @@
 
 extern __iomem void *ltq_ebu_membase;
 extern __iomem void *ltq_cgu_membase;
+extern unsigned 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.10/arch/mips/lantiq/setup.c
===================================================================
--- linux-3.1.10.orig/arch/mips/lantiq/setup.c	2012-02-14 19:38:40.010266814 +0100
+++ linux-3.1.10/arch/mips/lantiq/setup.c	2012-02-14 19:38:40.150266820 +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;