0002-openwrt-arc-add-OWRTDTB-section.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. From 142abc9f7b8860638e39cf3850cf7ba328c26b42 Mon Sep 17 00:00:00 2001
  2. From: Alexey Brodkin <[email protected]>
  3. Date: Sat, 31 Oct 2015 15:58:20 +0300
  4. Subject: [PATCH] openwrt: arc - add OWRTDTB section
  5. This change allows OpenWRT to patch resulting kernel binary with
  6. external .dtb.
  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).
  9. ""patch-dtb" searches for ASCII "OWRTDTB:" strign and copies external
  10. .dtb right after it, keeping the string in place.
  11. Signed-off-by: Alexey Brodkin <[email protected]>
  12. ---
  13. arch/arc/kernel/head.S | 10 ++++++++++
  14. arch/arc/kernel/setup.c | 4 +++-
  15. arch/arc/kernel/vmlinux.lds.S | 13 +++++++++++++
  16. 3 files changed, 26 insertions(+), 1 deletion(-)
  17. diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S
  18. index 689dd86..51154ae 100644
  19. --- a/arch/arc/kernel/head.S
  20. +++ b/arch/arc/kernel/head.S
  21. @@ -49,6 +49,16 @@
  22. 1:
  23. .endm
  24. +; Here "patch-dtb" will embed external .dtb
  25. +; Note "patch-dtb" searches for ASCII "OWRTDTB:" string
  26. +; and pastes .dtb right after it, hense the string precedes
  27. +; __image_dtb symbol.
  28. + .section .owrt, "aw",@progbits
  29. + .ascii "OWRTDTB:"
  30. +ENTRY(__image_dtb)
  31. + .fill 0x4000
  32. +END(__image_dtb)
  33. +
  34. .section .init.text, "ax",@progbits
  35. ;----------------------------------------------------------------
  36. diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
  37. index c33e77c..96fbfd0 100644
  38. --- a/arch/arc/kernel/setup.c
  39. +++ b/arch/arc/kernel/setup.c
  40. @@ -370,6 +370,8 @@ static inline int is_kernel(unsigned long addr)
  41. return 0;
  42. }
  43. +extern struct boot_param_header __image_dtb;
  44. +
  45. void __init setup_arch(char **cmdline_p)
  46. {
  47. #ifdef CONFIG_ARC_UBOOT_SUPPORT
  48. @@ -383,7 +385,7 @@ void __init setup_arch(char **cmdline_p)
  49. #endif
  50. {
  51. /* No, so try the embedded one */
  52. - machine_desc = setup_machine_fdt(__dtb_start);
  53. + machine_desc = setup_machine_fdt(&__image_dtb);
  54. if (!machine_desc)
  55. panic("Embedded DT invalid\n");
  56. diff --git a/arch/arc/kernel/vmlinux.lds.S b/arch/arc/kernel/vmlinux.lds.S
  57. index dd35bde..f309104 100644
  58. --- a/arch/arc/kernel/vmlinux.lds.S
  59. +++ b/arch/arc/kernel/vmlinux.lds.S
  60. @@ -30,6 +30,19 @@ SECTIONS
  61. . = CONFIG_LINUX_LINK_BASE;
  62. + /*
  63. + * In OpenWRT we want to patch built binary embedding .dtb of choice.
  64. + * This is implemented with "patch-dtb" utility which searches for
  65. + * "OWRTDTB:" string in first 16k of image and if it is found
  66. + * copies .dtb right after mentioned string.
  67. + *
  68. + * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
  69. + */
  70. + .owrt : {
  71. + *(.owrt)
  72. + . = ALIGN(PAGE_SIZE);
  73. + }
  74. +
  75. _int_vec_base_lds = .;
  76. .vector : {
  77. *(.vector)
  78. --
  79. 2.4.3