Skip to contentSkip to conversation

docs: Correct FW_JUMP_FDT_ADDR calculation example

PATCH Superseded Gabriel Somlo 3 participants 11 messages Mar 24, 2023 – Mar 30, 2023

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

---
 docs/firmware/fw_jump.md | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
docs/firmware/fw_jump.md +8 -8
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:
   You can use the following method.
 
   ```
-  ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-  {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-  | (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\
-  increase FW_JUMP_FDT_ADDR
+  ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '
+  /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' |
+  (( `tail -1` > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
+  echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
 
-  ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-  awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-  | (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\
-  increase FW_JUMP_FDT_ADDR
+  ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n '
+  /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' |
+  (( `tail -1` > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
+  echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
   ```
 
 *FW_JUMP* Example
Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

Quoted 10 lines · Gabriel Somlo

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

Looks like you forgot my r-b. Here it is again

Thanks,
drew

Quoted 35 lines
---
 docs/firmware/fw_jump.md | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
docs/firmware/fw_jump.md +8 -8
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:
   You can use the following method.
 
   ```
-  ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-  {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-  | (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\
-  increase FW_JUMP_FDT_ADDR
+  ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '
+  /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' |
+  (( `tail -1` > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
+  echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
 
-  ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-  awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-  | (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\
-  increase FW_JUMP_FDT_ADDR
+  ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n '
+  /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' |
+  (( `tail -1` > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
+  echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
   ```
 
 *FW_JUMP* Example
Signature · 1 line
2.39.2
#2 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

Quoted 7 lines · Andrew Jones
Quoted 6 lines · Gabriel Somlo

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

Quoted 8 lines
Quoted 4 lines

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

Looks like you forgot my r-b. Here it is again

Sorry, and thanks. It's in v4 :)

--Gabriel

Quoted 38 lines

Thanks,
drew

Quoted 35 lines
---
 docs/firmware/fw_jump.md | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
docs/firmware/fw_jump.md +8 -8
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:
   You can use the following method.
 
   ```
-  ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-  {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-  | (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\
-  increase FW_JUMP_FDT_ADDR
+  ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '
+  /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' |
+  (( `tail -1` > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
+  echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
 
-  ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-  awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-  | (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\
-  increase FW_JUMP_FDT_ADDR
+  ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n '
+  /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' |
+  (( `tail -1` > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
+  echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
   ```
 
 *FW_JUMP* Example
Signature · 1 line
2.39.2
#3 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

In reply to Gabriel Somlo

? 2023-03-24???? 08:07 -0400?Gabriel Somlo???

Quoted 21 lines

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

---
?docs/firmware/fw_jump.md | 16 ++++++++--------
?1 file changed, 8 insertions(+), 8 deletions(-)

docs/firmware/fw_jump.md +0 -0
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:

?? You can use the following method.
?

Quoted 8 lines

?? ```
-? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-? {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

FW_JUMP_FDT_ADDR and FW_JUMP_ADDR should be variables in the shell, and references need to use $ as the starting char.

Quoted 9 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
?
-? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-? awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

Same as above

Regards,
Xiang W

Quoted 8 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR ?? ```
?
?*FW_JUMP* Example

Signature · 1 line
2.39.2
#4 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

Quoted 24 lines · Xiang W

? 2023-03-24???? 08:07 -0400?Gabriel Somlo???

Quoted 23 lines

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

---
?docs/firmware/fw_jump.md | 16 ++++++++--------
?1 file changed, 8 insertions(+), 8 deletions(-)

docs/firmware/fw_jump.md +0 -0
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:

?? You can use the following method.
?
?? ```
-? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\

Quoted 8 lines
Quoted 6 lines

-? {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

FW_JUMP_FDT_ADDR and FW_JUMP_ADDR should be variables in the shell, and references need to use $ as the starting char.

AFAIK, "ARITHMETIC EVALUATION" rules in bash allow shell variables to be referenced without the "parameter expansion syntax" (i.e., $FOO), when they are within an expression (e.g., "(( FOO + BAR ))").

Thanks,
--Gabriel

Quoted 22 lines
Quoted 9 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
?
-? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-? awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

Same as above

Regards,
Xiang W

Quoted 8 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR ?? ```
?
?*FW_JUMP* Example

Signature · 1 line
2.39.2
#5 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

? 2023-03-29???? 23:13 -0400?Gabriel L. Somlo???

Quoted 34 lines · Xiang W
Quoted 24 lines

? 2023-03-24???? 08:07 -0400?Gabriel Somlo???

Quoted 23 lines

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

---
?docs/firmware/fw_jump.md | 16 ++++++++--------
?1 file changed, 8 insertions(+), 8 deletions(-)

docs/firmware/fw_jump.md +0 -0
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:

?? You can use the following method.
?
?? ```
-? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\

Quoted 8 lines
Quoted 6 lines

-? {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

FW_JUMP_FDT_ADDR and FW_JUMP_ADDR should be variables in the shell, and references need to use $ as the starting char.

Quoted 3 lines

AFAIK, "ARITHMETIC EVALUATION" rules in bash allow shell variables to be referenced without the "parameter expansion syntax" (i.e., $FOO), when they are within an expression (e.g., "(( FOO + BAR ))").

It is better to use POSIX shell, if want to use BASH it is better to add some text description

Quoted 28 lines

Regards,
Xiang W
Thanks,
--Gabriel
?

Quoted 22 lines
Quoted 9 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
?
-? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-? awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

Same as above

Regards,
Xiang W

Quoted 8 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR ?? ```
?
?*FW_JUMP* Example

Signature · 1 line
2.39.2
#6 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

? 2023-03-30???? 16:13 +0800?Xiang W???

Quoted 35 lines

? 2023-03-29???? 23:13 -0400?Gabriel L. Somlo???

Quoted 34 lines · Xiang W
Quoted 32 lines

? 2023-03-24???? 08:07 -0400?Gabriel Somlo???

Quoted 21 lines

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

---
?docs/firmware/fw_jump.md | 16 ++++++++--------
?1 file changed, 8 insertions(+), 8 deletions(-)

docs/firmware/fw_jump.md +0 -0
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:

?? You can use the following method.
?

Quoted 8 lines

?? ```
-? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-? {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

FW_JUMP_FDT_ADDR and FW_JUMP_ADDR should be variables in the shell, and references need to use $ as the starting char.

Quoted 6 lines
Quoted 3 lines

AFAIK, "ARITHMETIC EVALUATION" rules in bash allow shell variables to be referenced without the "parameter expansion syntax" (i.e., $FOO), when they are within an expression (e.g., "(( FOO + BAR ))").

It is better to use POSIX shell, if want to use BASH it is better to add some text description

Sorry!!! This is POSIX grammar!!!

Regards,
Xiang W

Quoted 28 lines
Quoted 28 lines

Regards,
Xiang W
Thanks,
--Gabriel
?

Quoted 22 lines
Quoted 9 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
?
-? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-? awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

Same as above

Regards,
Xiang W

Quoted 8 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR ?? ```
?
?*FW_JUMP* Example

Signature · 1 line
2.39.2
#7 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

Quoted 36 lines · Xiang W

? 2023-03-30???? 16:13 +0800?Xiang W???

Quoted 35 lines

? 2023-03-29???? 23:13 -0400?Gabriel L. Somlo???

Quoted 34 lines · Xiang W
Quoted 32 lines

? 2023-03-24???? 08:07 -0400?Gabriel Somlo???

Quoted 21 lines

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

---
?docs/firmware/fw_jump.md | 16 ++++++++--------
?1 file changed, 8 insertions(+), 8 deletions(-)

docs/firmware/fw_jump.md +0 -0
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:

?? You can use the following method.
?

Quoted 8 lines

?? ```
-? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-? {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

FW_JUMP_FDT_ADDR and FW_JUMP_ADDR should be variables in the shell, and references need to use $ as the starting char.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

AFAIK, "ARITHMETIC EVALUATION" rules in bash allow shell variables to be referenced without the "parameter expansion syntax" (i.e., $FOO), when they are within an expression (e.g., "(( FOO + BAR ))").

It is better to use POSIX shell, if want to use BASH it is better to add some text description

Sorry!!! This is POSIX grammar!!!

((..)) is undefined for POSIX, only $((..)) is defined, but do we care? This is just an example in a document, not a script expected to run as part of the build on multiple platforms. Maybe we could change the sentence above to point out Bash though,

ensure *FW_JUMP_FDT_ADDR* is set high enough to avoid overwriting the kernel.
- You can use the following method.
+ Using Bash, you can use the following method:

```

Thanks,
drew

Quoted 32 lines

Regards,
Xiang W

Quoted 28 lines
Quoted 28 lines

Regards,
Xiang W
Thanks,
--Gabriel
?

Quoted 22 lines
Quoted 9 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
?
-? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-? awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

Same as above

Regards,
Xiang W

Quoted 8 lines

+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR ?? ```
?
?*FW_JUMP* Example

Signature · 1 line
2.39.2
#8 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

Quoted 60 lines · Andrew Jones

T+cdxBr0t+JJwe at errol.ini.cmu.edu>
<[email protected]> <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <[email protected]>

Quoted 36 lines · Xiang W

? 2023-03-30???? 16:13 +0800?Xiang W???

Quoted 35 lines

? 2023-03-29???? 23:13 -0400?Gabriel L. Somlo???

Quoted 34 lines · Xiang W
Quoted 32 lines

? 2023-03-24???? 08:07 -0400?Gabriel Somlo???

Quoted 21 lines

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

---
?docs/firmware/fw_jump.md | 16 ++++++++--------
?1 file changed, 8 insertions(+), 8 deletions(-)

docs/firmware/fw_jump.md +0 -0
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:

?? You can use the following method.
?

Quoted 8 lines

?? ```
-? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-? {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

FW_JUMP_FDT_ADDR and FW_JUMP_ADDR should be variables in the shell, and references need to use $ as the starting char.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

AFAIK, "ARITHMETIC EVALUATION" rules in bash allow shell variables to be referenced without the "parameter expansion syntax" (i.e., $FOO), when they are within an expression (e.g., "(( FOO + BAR ))").

It is better to use POSIX shell, if want to use BASH it is better to add some text description

Sorry!!! This is POSIX grammar!!!

((..)) is undefined for POSIX, only $((..)) is defined, but do we care? This is just an example in a document, not a script expected to run as part of the build on multiple platforms. Maybe we could change the sentence above to point out Bash though,

ensure *FW_JUMP_FDT_ADDR* is set high enough to avoid overwriting the kernel.

Review

Quoted 4 lines
(quoted diff) +1 -1
-  You can use the following method.
+  Using Bash, you can use the following method:
 
   ```

Or, we can make more use of [posix] awk and make everything posix compatible

${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -P -v maxsize=$((FW_JUMP_FDT_ADDR - FW_JUMP_ADDR)) ' /^ +[0-9]+ / {
addr="0x"$3; size="0x"$5; size+=addr;
}
END {

  if (size > maxsize) {
    print "fdt overlaps kernel, increase FW_JUMP_FDT_ADDR";

}
}'

Thanks,
drew

#9 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

Quoted 75 lines · Andrew Jones
Quoted 60 lines · Andrew Jones

T+cdxBr0t+JJwe at errol.ini.cmu.edu>
<[email protected]> <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <[email protected]>

Quoted 36 lines · Xiang W

? 2023-03-30???? 16:13 +0800?Xiang W???

Quoted 35 lines

? 2023-03-29???? 23:13 -0400?Gabriel L. Somlo???

Quoted 34 lines · Xiang W
Quoted 32 lines

? 2023-03-24???? 08:07 -0400?Gabriel Somlo???

Quoted 21 lines

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

---
?docs/firmware/fw_jump.md | 16 ++++++++--------
?1 file changed, 8 insertions(+), 8 deletions(-)

docs/firmware/fw_jump.md +0 -0
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:

?? You can use the following method.
?

Quoted 8 lines

?? ```
-? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-? {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&

FW_JUMP_FDT_ADDR and FW_JUMP_ADDR should be variables in the shell, and references need to use $ as the starting char.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

AFAIK, "ARITHMETIC EVALUATION" rules in bash allow shell variables to be referenced without the "parameter expansion syntax" (i.e., $FOO), when they are within an expression (e.g., "(( FOO + BAR ))").

It is better to use POSIX shell, if want to use BASH it is better to add some text description

Sorry!!! This is POSIX grammar!!!

((..)) is undefined for POSIX, only $((..)) is defined, but do we care? This is just an example in a document, not a script expected to run as part of the build on multiple platforms. Maybe we could change the sentence above to point out Bash though,

ensure *FW_JUMP_FDT_ADDR* is set high enough to avoid overwriting the kernel.

Review

Quoted 4 lines
(quoted diff) +1 -1
-  You can use the following method.
+  Using Bash, you can use the following method:
 
   ```

Or, we can make more use of [posix] awk and make everything posix compatible

${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -P -v maxsize=$((FW_JUMP_FDT_ADDR - FW_JUMP_ADDR)) ' /^ +[0-9]+ / {
addr="0x"$3; size="0x"$5; size+=addr;
}
END {

Quoted 4 lines
  if (size > maxsize) {
    print "fdt overlaps kernel, increase FW_JUMP_FDT_ADDR";

}
}'

If it's all the same to you all, I'd prefer we mentioned bash (or zsh, which also works) and avoided using the (IMHO much harder to read) syntax above just to satisfy posix...

I'll send out another version where bash and zsh are namedropped in the "following method" line... :)

Thanks,
--Gabriel

Quoted 2 lines

Thanks,
drew

#10 lore raw

PATCH v3 1/1 docs: Correct FW_JUMP_FDT_ADDR calculation example

In reply to Gabriel Somlo

? 2023-03-24???? 08:07 -0400?Gabriel Somlo???

Quoted 10 lines

When using PLATFORM=generic defaults, the kernel is loaded at FW_JUMP_ADDR, and the FDT is loaded at `FW_JUMP_FDT_ADDR.

Therefore, the maximum kernel size before FW_JUMP_FDT_ADDR must be increased is $(( FW_JUMP_FDT_ADDR - FW_JUMP_ADDR )).

The example calculation assumes rv64, and is wrong to boot (off by 0x200000). Fix it and update it for the general case.

LGTM

Quoted 36 lines

---
?docs/firmware/fw_jump.md | 16 ++++++++--------
?1 file changed, 8 insertions(+), 8 deletions(-)

docs/firmware/fw_jump.md +0 -0
index 956897e..ed3a43e 100644
@@ -46,15 +46,15 @@ follows:

?? You can use the following method.
?
?? ```
-? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\
-? {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' \
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
?
-? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \
-? awk -n '/^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}'\
-? | (( tail -1 > 0x2200000 )) && echo fdt overlaps kernel,\
-? increase FW_JUMP_FDT_ADDR
+? ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | awk -n ' +? /^ +[0-9]+ / {addr="0x"$3; size="0x"$5; printf "0x""%x\n",addr+size}' | +? (( tail -1 > (FW_JUMP_FDT_ADDR - FW_JUMP_ADDR) )) &&
+? echo fdt overlaps kernel, increase FW_JUMP_FDT_ADDR
?? ```
?
?*FW_JUMP* Example

Signature · 1 line
2.39.2