blob: 4b0534eff7f10e81fef089182d666f51cbb7f7e1 [file] [log] [blame]
developerf11ee162022-04-12 11:17:45 +08001From bb0c3b0175240bf152fd7c644821a0cf9f77c37c Mon Sep 17 00:00:00 2001
2From: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
3Date: Fri, 15 Mar 2019 18:53:38 +0300
4Subject: [PATCH] arc add OWRTDTB section
5
6This change allows OpenWRT to patch resulting kernel binary with
7external .dtb.
8
9That allows us to re-use exactky the same vmlinux on different boards
10given its ARC core configurations match (at least cache line sizes etc).
11
12""patch-dtb" searches for ASCII "OWRTDTB:" strign and copies external
13.dtb right after it, keeping the string in place.
14
15Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
16Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
17Signed-off-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
18---
19 arch/arc/kernel/head.S | 10 ++++++++++
20 arch/arc/kernel/setup.c | 4 +++-
21 arch/arc/kernel/vmlinux.lds.S | 13 +++++++++++++
22 3 files changed, 26 insertions(+), 1 deletion(-)
23
24--- a/arch/arc/kernel/head.S
25+++ b/arch/arc/kernel/head.S
26@@ -61,6 +61,16 @@
27 #endif
28 .endm
29
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
35+ .ascii "OWRTDTB:"
36+ENTRY(__image_dtb)
37+ .fill 0x4000
38+END(__image_dtb)
39+
40 .section .init.text, "ax",@progbits
41
42 ;----------------------------------------------------------------
43--- a/arch/arc/kernel/setup.c
44+++ b/arch/arc/kernel/setup.c
45@@ -492,6 +492,8 @@ static inline bool uboot_arg_invalid(uns
46 /* We always pass 0 as magic from U-boot */
47 #define UBOOT_MAGIC_VALUE 0
48
49+extern struct boot_param_header __image_dtb;
50+
51 void __init handle_uboot_args(void)
52 {
53 bool use_embedded_dtb = true;
54@@ -530,7 +532,7 @@ void __init handle_uboot_args(void)
55 ignore_uboot_args:
56
57 if (use_embedded_dtb) {
58- machine_desc = setup_machine_fdt(__dtb_start);
59+ machine_desc = setup_machine_fdt(&__image_dtb);
60 if (!machine_desc)
61 panic("Embedded DT invalid\n");
62 }
63--- a/arch/arc/kernel/vmlinux.lds.S
64+++ b/arch/arc/kernel/vmlinux.lds.S
65@@ -27,6 +27,19 @@ SECTIONS
66
67 . = CONFIG_LINUX_LINK_BASE;
68
69+ /*
70+ * In OpenWRT we want to patch built binary embedding .dtb of choice.
71+ * This is implemented with "patch-dtb" utility which searches for
72+ * "OWRTDTB:" string in first 16k of image and if it is found
73+ * copies .dtb right after mentioned string.
74+ *
75+ * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
76+ */
77+ .owrt : {
78+ *(.owrt)
79+ . = ALIGN(PAGE_SIZE);
80+ }
81+
82 _int_vec_base_lds = .;
83 .vector : {
84 *(.vector)