1
0

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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From: Alexey Brodkin <abrodkin@synopsys.com>
  2. Subject: openwrt: arc - add OWRTDTB section
  3. This change allows OpenWRT to patch resulting kernel binary with
  4. external .dtb.
  5. That allows us to re-use exactky the same vmlinux on different boards
  6. given its ARC core configurations match (at least cache line sizes etc).
  7. ""patch-dtb" searches for ASCII "OWRTDTB:" strign and copies external
  8. .dtb right after it, keeping the string in place.
  9. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
  10. ---
  11. arch/arc/kernel/head.S | 10 ++++++++++
  12. arch/arc/kernel/setup.c | 4 +++-
  13. arch/arc/kernel/vmlinux.lds.S | 13 +++++++++++++
  14. 3 files changed, 26 insertions(+), 1 deletion(-)
  15. --- a/arch/arc/kernel/head.S
  16. +++ b/arch/arc/kernel/head.S
  17. @@ -49,6 +49,16 @@
  18. 1:
  19. .endm
  20. +; Here "patch-dtb" will embed external .dtb
  21. +; Note "patch-dtb" searches for ASCII "OWRTDTB:" string
  22. +; and pastes .dtb right after it, hense the string precedes
  23. +; __image_dtb symbol.
  24. + .section .owrt, "aw",@progbits
  25. + .ascii "OWRTDTB:"
  26. +ENTRY(__image_dtb)
  27. + .fill 0x4000
  28. +END(__image_dtb)
  29. +
  30. .section .init.text, "ax",@progbits
  31. ;----------------------------------------------------------------
  32. --- a/arch/arc/kernel/setup.c
  33. +++ b/arch/arc/kernel/setup.c
  34. @@ -388,6 +388,8 @@ static inline int is_kernel(unsigned lon
  35. return 0;
  36. }
  37. +extern struct boot_param_header __image_dtb;
  38. +
  39. void __init setup_arch(char **cmdline_p)
  40. {
  41. #ifdef CONFIG_ARC_UBOOT_SUPPORT
  42. @@ -401,7 +403,7 @@ void __init setup_arch(char **cmdline_p)
  43. #endif
  44. {
  45. /* No, so try the embedded one */
  46. - machine_desc = setup_machine_fdt(__dtb_start);
  47. + machine_desc = setup_machine_fdt(&__image_dtb);
  48. if (!machine_desc)
  49. panic("Embedded DT invalid\n");
  50. --- a/arch/arc/kernel/vmlinux.lds.S
  51. +++ b/arch/arc/kernel/vmlinux.lds.S
  52. @@ -30,6 +30,19 @@ SECTIONS
  53. . = CONFIG_LINUX_LINK_BASE;
  54. + /*
  55. + * In OpenWRT we want to patch built binary embedding .dtb of choice.
  56. + * This is implemented with "patch-dtb" utility which searches for
  57. + * "OWRTDTB:" string in first 16k of image and if it is found
  58. + * copies .dtb right after mentioned string.
  59. + *
  60. + * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
  61. + */
  62. + .owrt : {
  63. + *(.owrt)
  64. + . = ALIGN(PAGE_SIZE);
  65. + }
  66. +
  67. _int_vec_base_lds = .;
  68. .vector : {
  69. *(.vector)