diff mbox series

[7/9] powerpc/ps3: Add check for otheros image size

Message ID e0dc92ba82a993c845f8d2bf3ace7465ef5ea996.1585340156.git.geoff@infradead.org (mailing list archive)
State Superseded
Headers show
Series [1/9] powerpc/ps3: Remove duplicate error messages | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (c6624071c338732402e8c726df6a4074473eaa0e)
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Geoff Levand March 27, 2020, 8:26 p.m. UTC
The ps3's otheros flash loader has a size limit of 16 MiB for the
uncompressed image.  If that limit will be reached output the
flash image file as 'otheros-too-big.bld'.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/boot/wrapper | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Geert Uytterhoeven March 29, 2020, 2 p.m. UTC | #1
Hi Geoff,

On Fri, Mar 27, 2020 at 9:26 PM Geoff Levand <geoff@infradead.org> wrote:
> The ps3's otheros flash loader has a size limit of 16 MiB for the
> uncompressed image.  If that limit will be reached output the
> flash image file as 'otheros-too-big.bld'.
>
> Signed-off-by: Geoff Levand <geoff@infradead.org>

Thanks for your patch!

> --- a/arch/powerpc/boot/wrapper
> +++ b/arch/powerpc/boot/wrapper
> @@ -570,7 +570,16 @@ ps3)
>          count=$overlay_size bs=1
>
>      odir="$(dirname "$ofile.bin")"
> -    rm -f "$odir/otheros.bld"
> -    gzip -n --force -9 --stdout "$ofile.bin" > "$odir/otheros.bld"
> +
> +    # The ps3's flash loader has a size limit of 16 MiB for the uncompressed
> +    # image.  If a compressed image that exceeded this limit is written to
> +    # flash the loader will decompress that image until the 16 MiB limit is
> +    # reached, then enter the system reset vector of the partially decompressed
> +    # image.  No warning is issued.
> +    rm -f "$odir"/{otheros,otheros-too-big}.bld
> +    size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)
> +    bld="otheros.bld"
> +    [ $size -le 16777216 ] || bld="otheros-too-big.bld"
> +    gzip -n --force -9 --stdout "$ofile.bin" > "$odir/$bld"
>      ;;
>  esac

Why not print an error message and exit 1 instead, like is done for
other fatal errors?

Gr{oetje,eeting}s,

                        Geert
Geoff Levand March 30, 2020, 3:10 a.m. UTC | #2
Hi Geert,

On 3/29/20 7:00 AM, Geert Uytterhoeven wrote:
>> --- a/arch/powerpc/boot/wrapper
>> +++ b/arch/powerpc/boot/wrapper
>>
>>      odir="$(dirname "$ofile.bin")"
>> -    rm -f "$odir/otheros.bld"
>> -    gzip -n --force -9 --stdout "$ofile.bin" > "$odir/otheros.bld"
>> +
>> +    # The ps3's flash loader has a size limit of 16 MiB for the uncompressed
>> +    # image.  If a compressed image that exceeded this limit is written to
>> +    # flash the loader will decompress that image until the 16 MiB limit is
>> +    # reached, then enter the system reset vector of the partially decompressed
>> +    # image.  No warning is issued.
>> +    rm -f "$odir"/{otheros,otheros-too-big}.bld
>> +    size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)
>> +    bld="otheros.bld"
>> +    [ $size -le 16777216 ] || bld="otheros-too-big.bld"
>> +    gzip -n --force -9 --stdout "$ofile.bin" > "$odir/$bld"
>>      ;;
>>  esac
> 
> Why not print an error message and exit 1 instead, like is done for
> other fatal errors?

This is not really a fatal error for the entire build.  The default
make target will build both a vmlinux file and a .bld file.  The
.bld file is the one that can be programmed to the OtherOS flash
memory (bld = boot loader).  Even if the .bld file is too big, a
big vmlinux file from such a build would be completely fine for
petitboot to load.

It may be good to print an 'info' message though.  I'll post an
updated patch.

-Geoff
diff mbox series

Patch

diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index ed6266367bc0..1dfd9fd929c8 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -570,7 +570,16 @@  ps3)
         count=$overlay_size bs=1
 
     odir="$(dirname "$ofile.bin")"
-    rm -f "$odir/otheros.bld"
-    gzip -n --force -9 --stdout "$ofile.bin" > "$odir/otheros.bld"
+
+    # The ps3's flash loader has a size limit of 16 MiB for the uncompressed
+    # image.  If a compressed image that exceeded this limit is written to
+    # flash the loader will decompress that image until the 16 MiB limit is
+    # reached, then enter the system reset vector of the partially decompressed
+    # image.  No warning is issued.
+    rm -f "$odir"/{otheros,otheros-too-big}.bld
+    size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)
+    bld="otheros.bld"
+    [ $size -le 16777216 ] || bld="otheros-too-big.bld"
+    gzip -n --force -9 --stdout "$ofile.bin" > "$odir/$bld"
     ;;
 esac