git: e4bfe8e96615 - main - arm: Generate the kernel.bin file in zImage format.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Aug 2025 16:44:56 UTC
The branch main has been updated by mmel:
URL: https://cgit.FreeBSD.org/src/commit/?id=e4bfe8e96615b16687271147ee2856e6f2a0c478
commit e4bfe8e96615b16687271147ee2856e6f2a0c478
Author: Michal Meloun <mmel@FreeBSD.org>
AuthorDate: 2025-05-04 11:29:57 +0000
Commit: Michal Meloun <mmel@FreeBSD.org>
CommitDate: 2025-08-07 16:44:40 +0000
arm: Generate the kernel.bin file in zImage format.
This allows you to run the kernel using the bootz command, which can be
useful on a board where the manufacturer's u-boot does not support EFI.
The original behavior has not been changed, the zImage binary can still
be run by jumping to the beginning of the binary file.
MFC after: 2 weeks
---
sys/conf/Makefile.arm | 2 +-
sys/tools/arm_kernel_boothdr.awk | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm
index 216f012d688e..15ccb982c2a4 100644
--- a/sys/conf/Makefile.arm
+++ b/sys/conf/Makefile.arm
@@ -93,7 +93,7 @@ ${KERNEL_KO}.bin: ${FULLKERNEL}
--output-target=binary ${FULLKERNEL} ${.TARGET}.temp
@{ ${NM} ${FULLKERNEL} | \
LC_ALL=C \
- ${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v7jump && \
+ ${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v7bootz && \
cat ${.TARGET}.temp; \
} > ${.TARGET}
@rm ${.TARGET}.temp
diff --git a/sys/tools/arm_kernel_boothdr.awk b/sys/tools/arm_kernel_boothdr.awk
index e0f193f7922c..37d8c4b5af0e 100644
--- a/sys/tools/arm_kernel_boothdr.awk
+++ b/sys/tools/arm_kernel_boothdr.awk
@@ -38,6 +38,7 @@ BEGIN {
# The type of header we're writing is set using -v hdrtype= on
# the command line, ensure we got a valid value for it.
if (hdrtype != "v7jump" &&
+ hdrtype != "v7bootz" &&
hdrtype != "v8jump" &&
hdrtype != "v8booti") {
print "arm_kernel_boothdr.awk: " \
@@ -107,6 +108,35 @@ function write_v7jump() {
write_le32(hexstr_to_num("ea000000") + (gStartOff / 4) - 2)
}
+function write_v7bootz() {
+
+ # We are writing this struct...
+ #
+ # struct BootZ_header {
+ # uint32_t code0; /* Executable code */
+ # uint32_t dummy[8]; /* dummy */
+ # uint32_t magic; /* Magic number 0x016f2818*/
+ # uint32_t load_offset; /* Image load offset, LE */
+ # uint32_t image_size; /* Effective Image size, LE */
+ # };
+ #
+ # We write 'b _start' into code0. The image size is everything from
+ # the start of the loaded image to the offset given by the _end symbol.
+
+ write_v7jump() # code0
+ write_le32(0) # dummy[0]
+ write_le32(0) # dummy[1]
+ write_le32(0) # dummy[2]
+ write_le32(0) # dummy[3]
+ write_le32(0) # dummy[4]
+ write_le32(0) # dummy[5]
+ write_le32(0) # dummy[6]
+ write_le32(0) # dummy[7]
+ write_le32(hexstr_to_num("016f2818")) # magic marker
+ write_le32(0) # load_offset (0 -> auto)
+ write_le32(gEndOff) # image_size
+}
+
function write_v8jump() {
# Write the machine code for "b _start"...
@@ -186,6 +216,8 @@ END {
if (gHdrType == "v7jump") {
write_v7jump()
+ } else if (gHdrType == "v7bootz") {
+ write_v7bootz()
} else if (gHdrType == "v8jump") {
write_v8jump()
} else if (gHdrType == "v8booti") {