1 From 690e7f2cad271595ff68cace1c45fb10779bde41 Mon Sep 17 00:00:00 2001
2 From: Alexey Brodkin <abrodkin@synopsys.com>
3 Date: Fri, 15 Jan 2016 00:34:01 +0300
4 Subject: [PATCH 2/2] openwrt: arc - add OWRTDTB section
6 This change allows OpenWRT to patch resulting kernel binary with
9 That allows us to re-use exactky the same vmlinux on different boards
10 given its ARC core configurations match (at least cache line sizes etc).
12 ""patch-dtb" searches for ASCII "OWRTDTB:" strign and copies external
13 .dtb right after it, keeping the string in place.
15 Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
17 arch/arc/kernel/head.S | 10 ++++++++++
18 arch/arc/kernel/setup.c | 4 +++-
19 arch/arc/kernel/vmlinux.lds.S | 13 +++++++++++++
20 3 files changed, 26 insertions(+), 1 deletion(-)
22 diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S
23 index 689dd86..51154ae 100644
24 --- a/arch/arc/kernel/head.S
25 +++ b/arch/arc/kernel/head.S
30 +; Here "patch-dtb" will embed external .dtb
31 +; Note "patch-dtb" searches for ASCII "OWRTDTB:" string
32 +; and pastes .dtb right after it, hense the string precedes
33 +; __image_dtb symbol.
34 + .section .owrt, "aw",@progbits
40 .section .init.text, "ax",@progbits
42 ;----------------------------------------------------------------
43 diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
44 index e1b8744..9481c9d 100644
45 --- a/arch/arc/kernel/setup.c
46 +++ b/arch/arc/kernel/setup.c
47 @@ -370,6 +370,8 @@ static inline int is_kernel(unsigned long addr)
51 +extern struct boot_param_header __image_dtb;
53 void __init setup_arch(char **cmdline_p)
55 #ifdef CONFIG_ARC_UBOOT_SUPPORT
56 @@ -383,7 +385,7 @@ void __init setup_arch(char **cmdline_p)
59 /* No, so try the embedded one */
60 - machine_desc = setup_machine_fdt(__dtb_start);
61 + machine_desc = setup_machine_fdt(&__image_dtb);
63 panic("Embedded DT invalid\n");
65 diff --git a/arch/arc/kernel/vmlinux.lds.S b/arch/arc/kernel/vmlinux.lds.S
66 index 894e696..ecfc284 100644
67 --- a/arch/arc/kernel/vmlinux.lds.S
68 +++ b/arch/arc/kernel/vmlinux.lds.S
69 @@ -30,6 +30,19 @@ SECTIONS
71 . = CONFIG_LINUX_LINK_BASE;
74 + * In OpenWRT we want to patch built binary embedding .dtb of choice.
75 + * This is implemented with "patch-dtb" utility which searches for
76 + * "OWRTDTB:" string in first 16k of image and if it is found
77 + * copies .dtb right after mentioned string.
79 + * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
83 + . = ALIGN(PAGE_SIZE);
86 _int_vec_base_lds = .;