Skip to contentSkip to conversation

MIPS: zboot: put appended dtb into a section

PATCH Applied Chuanhong Guo 3 participants 3 messages Oct 26, 2020 – Nov 6, 2020 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: zboot: put appended dtb into a section

This will make a separated section for dtb appear in ELF, and we can then use objcopy to patch a dtb into vmlinuz when RAW_APPENDED_DTB is set in kernel config.

command to patch a dtb:
objcopy --set-section-flags=.appended_dtb=alloc,contents \
--update-section=.appended_dtb=<target>.dtb vmlinuz

---
Note:
This should supersede this patch on linux-mips:
[2/2] mips: boot compressed: add support for vlinuz ELF DTB [0]

[0] https://patchwork.kernel.org/project/linux-mips/patch/[email protected]/

 arch/mips/boot/compressed/ld.script | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/mips/boot/compressed/ld.script +6 -3
index 2ed08fbef8e7..0ebb667274d6 100644
@@ -31,9 +31,12 @@ SECTIONS
 		CONSTRUCTORS
 		. = ALIGN(16);
 	}
-	__appended_dtb = .;
-	/* leave space for appended DTB */
-	. += 0x100000;
+
+	.appended_dtb : {
+		__appended_dtb = .;
+		/* leave space for appended DTB */
+		. += 0x100000;
+	}
 
 	_edata = .;
 	/* End of data section */
Signature · 1 line
2.26.2
#1 lore raw
Quoted 3 lines · Chuanhong Guo

This will make a separated section for dtb appear in ELF, and we can then use objcopy to patch a dtb into vmlinuz when RAW_APPENDED_DTB is set in kernel config.

Thank you Chuanhong Guo, this worked for me.

I have successfully network boot tested this change on ath79 hardware:
- kernel vmlinuz.bin
then appended DTB, and packed into a uImage (out of kernel tree)
- kernel vmlinuz
then updated ELF DTB appended_dtb section, and ELF booted

Cheers,

Signature · 1 line
  John Thomson
maintainer Applied
#2 lore raw
In reply to Chuanhong Guo
Quoted 14 lines · Chuanhong Guo

This will make a separated section for dtb appear in ELF, and we can then use objcopy to patch a dtb into vmlinuz when RAW_APPENDED_DTB is set in kernel config.

command to patch a dtb:
objcopy --set-section-flags=.appended_dtb=alloc,contents \
--update-section=.appended_dtb=<target>.dtb vmlinuz

---
Note:
This should supersede this patch on linux-mips:
[2/2] mips: boot compressed: add support for vlinuz ELF DTB [0]

Quoted 4 lines

[0] https://patchwork.kernel.org/project/linux-mips/patch/[email protected]/

 arch/mips/boot/compressed/ld.script | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]