OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --- a/drivers/mtd/Kconfig |
2 | +++ b/drivers/mtd/Kconfig |
||
3 | @@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME |
||
4 | depends on MTD_SPLIT_FIRMWARE |
||
5 | default "firmware" |
||
6 | |||
7 | +config MTD_UIMAGE_SPLIT |
||
8 | + bool "Enable split support for firmware partitions containing a uImage" |
||
9 | + depends on MTD_SPLIT_FIRMWARE |
||
10 | + default y |
||
11 | + |
||
12 | source "drivers/mtd/mtdsplit/Kconfig" |
||
13 | |||
14 | endmenu |
||
15 | --- a/drivers/mtd/mtdpart.c |
||
16 | +++ b/drivers/mtd/mtdpart.c |
||
17 | @@ -682,6 +682,37 @@ mtd_pad_erasesize(struct mtd_info *mtd, |
||
18 | return len; |
||
19 | } |
||
20 | |||
21 | +#define UBOOT_MAGIC 0x27051956 |
||
22 | + |
||
23 | +static void split_uimage(struct mtd_info *master, struct mtd_part *part) |
||
24 | +{ |
||
25 | + struct { |
||
26 | + __be32 magic; |
||
27 | + __be32 pad[2]; |
||
28 | + __be32 size; |
||
29 | + } hdr; |
||
30 | + size_t len; |
||
31 | + |
||
32 | + if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr)) |
||
33 | + return; |
||
34 | + |
||
35 | + if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC)) |
||
36 | + return; |
||
37 | + |
||
38 | + len = be32_to_cpu(hdr.size) + 0x40; |
||
39 | + len = mtd_pad_erasesize(master, part->offset, len); |
||
40 | + if (len + master->erasesize > part->mtd.size) |
||
41 | + return; |
||
42 | + |
||
43 | + if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW)) |
||
44 | + pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n"); |
||
45 | + else |
||
46 | + pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n"); |
||
47 | + |
||
48 | + __mtd_add_partition(master, "rootfs", part->offset + len, |
||
49 | + part->mtd.size - len, false); |
||
50 | +} |
||
51 | + |
||
52 | #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME |
||
53 | #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME |
||
54 | #else |
||
55 | @@ -690,7 +721,14 @@ mtd_pad_erasesize(struct mtd_info *mtd, |
||
56 | |||
57 | static void split_firmware(struct mtd_info *master, struct mtd_part *part) |
||
58 | { |
||
59 | - run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); |
||
60 | + int ret; |
||
61 | + |
||
62 | + ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); |
||
63 | + if (ret > 0) |
||
64 | + return; |
||
65 | + |
||
66 | + if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT)) |
||
67 | + split_uimage(master, part); |
||
68 | } |
||
69 | |||
70 | void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, |