1 From: Alexey Brodkin <abrodkin@synopsys.com>
2 Subject: openwrt: arc - add OWRTDTB section
4 This change allows OpenWRT to patch resulting kernel binary with
7 That allows us to re-use exactky the same vmlinux on different boards
8 given its ARC core configurations match (at least cache line sizes etc).
10 ""patch-dtb" searches for ASCII "OWRTDTB:" strign and copies external
11 .dtb right after it, keeping the string in place.
13 Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
15 arch/arc/kernel/head.S | 10 ++++++++++
16 arch/arc/kernel/setup.c | 4 +++-
17 arch/arc/kernel/vmlinux.lds.S | 13 +++++++++++++
18 3 files changed, 26 insertions(+), 1 deletion(-)
20 --- a/arch/arc/kernel/head.S
21 +++ b/arch/arc/kernel/head.S
26 +; Here "patch-dtb" will embed external .dtb
27 +; Note "patch-dtb" searches for ASCII "OWRTDTB:" string
28 +; and pastes .dtb right after it, hense the string precedes
29 +; __image_dtb symbol.
30 + .section .owrt, "aw",@progbits
36 .section .init.text, "ax",@progbits
38 ;----------------------------------------------------------------
39 --- a/arch/arc/kernel/setup.c
40 +++ b/arch/arc/kernel/setup.c
41 @@ -421,6 +421,8 @@ static inline int is_kernel(unsigned lon
45 +extern struct boot_param_header __image_dtb;
47 void __init setup_arch(char **cmdline_p)
49 #ifdef CONFIG_ARC_UBOOT_SUPPORT
50 @@ -434,7 +436,7 @@ void __init setup_arch(char **cmdline_p)
53 /* No, so try the embedded one */
54 - machine_desc = setup_machine_fdt(__dtb_start);
55 + machine_desc = setup_machine_fdt(&__image_dtb);
57 panic("Embedded DT invalid\n");
59 --- a/arch/arc/kernel/vmlinux.lds.S
60 +++ b/arch/arc/kernel/vmlinux.lds.S
61 @@ -30,6 +30,19 @@ SECTIONS
63 . = CONFIG_LINUX_LINK_BASE;
66 + * In OpenWRT we want to patch built binary embedding .dtb of choice.
67 + * This is implemented with "patch-dtb" utility which searches for
68 + * "OWRTDTB:" string in first 16k of image and if it is found
69 + * copies .dtb right after mentioned string.
71 + * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
75 + . = ALIGN(PAGE_SIZE);
78 _int_vec_base_lds = .;