332-arc-add-OWRTDTB-section.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From 34ef04f3845ed2b47d57dd9d3b795b16e1f8185a Mon Sep 17 00:00:00 2001
  2. From: Evgeniy Didin <[email protected]>
  3. Date: Fri, 15 Mar 2019 18:53:38 +0300
  4. Subject: [PATCH] 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: Eugeniy Paltsev <[email protected]>
  12. Signed-off-by: Alexey Brodkin <[email protected]>
  13. Signed-off-by: Evgeniy Didin <[email protected]>
  14. ---
  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(-)
  19. --- a/arch/arc/kernel/head.S
  20. +++ b/arch/arc/kernel/head.S
  21. @@ -59,6 +59,16 @@
  22. #endif
  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. --- a/arch/arc/kernel/setup.c
  37. +++ b/arch/arc/kernel/setup.c
  38. @@ -434,6 +434,8 @@ static inline bool uboot_arg_invalid(uns
  39. #define UBOOT_TAG_CMDLINE 1
  40. #define UBOOT_TAG_DTB 2
  41. +extern struct boot_param_header __image_dtb;
  42. +
  43. void __init handle_uboot_args(void)
  44. {
  45. bool use_embedded_dtb = true;
  46. @@ -469,7 +471,7 @@ ignore_uboot_args:
  47. #endif
  48. if (use_embedded_dtb) {
  49. - machine_desc = setup_machine_fdt(__dtb_start);
  50. + machine_desc = setup_machine_fdt(&__image_dtb);
  51. if (!machine_desc)
  52. panic("Embedded DT invalid\n");
  53. }
  54. --- a/arch/arc/kernel/vmlinux.lds.S
  55. +++ b/arch/arc/kernel/vmlinux.lds.S
  56. @@ -29,6 +29,19 @@ SECTIONS
  57. */
  58. . = CONFIG_LINUX_LINK_BASE;
  59. + /*
  60. + * In OpenWRT we want to patch built binary embedding .dtb of choice.
  61. + * This is implemented with "patch-dtb" utility which searches for
  62. + * "OWRTDTB:" string in first 16k of image and if it is found
  63. + * copies .dtb right after mentioned string.
  64. + *
  65. + * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
  66. + */
  67. + .owrt : {
  68. + *(.owrt)
  69. + . = ALIGN(PAGE_SIZE);
  70. + }
  71. +
  72. _int_vec_base_lds = .;
  73. .vector : {