2
0

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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From bb0c3b0175240bf152fd7c644821a0cf9f77c37c 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. @@ -88,6 +88,16 @@
  22. DSP_EARLY_INIT
  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. @@ -450,6 +450,8 @@ static inline bool uboot_arg_invalid(uns
  39. /* We always pass 0 as magic from U-boot */
  40. #define UBOOT_MAGIC_VALUE 0
  41. +extern struct boot_param_header __image_dtb;
  42. +
  43. void __init handle_uboot_args(void)
  44. {
  45. bool use_embedded_dtb = true;
  46. @@ -488,7 +490,7 @@ void __init handle_uboot_args(void)
  47. ignore_uboot_args:
  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. @@ -27,6 +27,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)