332-arc-add-OWRTDTB-section.patch 2.4 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. @@ -520,7 +520,7 @@ ignore_uboot_args:
  39. #endif
  40. if (use_embedded_dtb) {
  41. - machine_desc = setup_machine_fdt(__dtb_start);
  42. + machine_desc = setup_machine_fdt(&__image_dtb);
  43. if (!machine_desc)
  44. panic("Embedded DT invalid\n");
  45. }
  46. @@ -536,6 +536,8 @@ ignore_uboot_args:
  47. }
  48. }
  49. +extern struct boot_param_header __image_dtb;
  50. +
  51. void __init setup_arch(char **cmdline_p)
  52. {
  53. handle_uboot_args();
  54. --- a/arch/arc/kernel/vmlinux.lds.S
  55. +++ b/arch/arc/kernel/vmlinux.lds.S
  56. @@ -30,6 +30,19 @@ SECTIONS
  57. . = CONFIG_LINUX_LINK_BASE;
  58. + /*
  59. + * In OpenWRT we want to patch built binary embedding .dtb of choice.
  60. + * This is implemented with "patch-dtb" utility which searches for
  61. + * "OWRTDTB:" string in first 16k of image and if it is found
  62. + * copies .dtb right after mentioned string.
  63. + *
  64. + * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
  65. + */
  66. + .owrt : {
  67. + *(.owrt)
  68. + . = ALIGN(PAGE_SIZE);
  69. + }
  70. +
  71. _int_vec_base_lds = .;
  72. .vector : {
  73. *(.vector)