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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. From 690e7f2cad271595ff68cace1c45fb10779bde41 Mon Sep 17 00:00:00 2001
  2. From: Alexey Brodkin <abrodkin@synopsys.com>
  3. Date: Fri, 15 Jan 2016 00:34:01 +0300
  4. Subject: [PATCH 2/2] 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 <abrodkin@synopsys.com>
  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. --- a/arch/arc/kernel/head.S
  18. +++ b/arch/arc/kernel/head.S
  19. @@ -59,6 +59,16 @@
  20. #endif
  21. .endm
  22. +; Here "patch-dtb" will embed external .dtb
  23. +; Note "patch-dtb" searches for ASCII "OWRTDTB:" string
  24. +; and pastes .dtb right after it, hense the string precedes
  25. +; __image_dtb symbol.
  26. + .section .owrt, "aw",@progbits
  27. + .ascii "OWRTDTB:"
  28. +ENTRY(__image_dtb)
  29. + .fill 0x4000
  30. +END(__image_dtb)
  31. +
  32. .section .init.text, "ax",@progbits
  33. ;----------------------------------------------------------------
  34. --- a/arch/arc/kernel/setup.c
  35. +++ b/arch/arc/kernel/setup.c
  36. @@ -366,6 +366,8 @@ static inline int is_kernel(unsigned lon
  37. return 0;
  38. }
  39. +extern struct boot_param_header __image_dtb;
  40. +
  41. void __init setup_arch(char **cmdline_p)
  42. {
  43. #ifdef CONFIG_ARC_UBOOT_SUPPORT
  44. @@ -379,7 +381,7 @@ void __init setup_arch(char **cmdline_p)
  45. #endif
  46. {
  47. /* No, so try the embedded one */
  48. - machine_desc = setup_machine_fdt(__dtb_start);
  49. + machine_desc = setup_machine_fdt(&__image_dtb);
  50. if (!machine_desc)
  51. panic("Embedded DT invalid\n");
  52. --- a/arch/arc/kernel/vmlinux.lds.S
  53. +++ b/arch/arc/kernel/vmlinux.lds.S
  54. @@ -30,6 +30,19 @@ SECTIONS
  55. . = CONFIG_LINUX_LINK_BASE;
  56. + /*
  57. + * In OpenWRT we want to patch built binary embedding .dtb of choice.
  58. + * This is implemented with "patch-dtb" utility which searches for
  59. + * "OWRTDTB:" string in first 16k of image and if it is found
  60. + * copies .dtb right after mentioned string.
  61. + *
  62. + * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it.
  63. + */
  64. + .owrt : {
  65. + *(.owrt)
  66. + . = ALIGN(PAGE_SIZE);
  67. + }
  68. +
  69. _int_vec_base_lds = .;
  70. .vector : {
  71. *(.vector)