Re: U-Boot loaded RAMDisk crashes Linux on MT7623

2021-07-19 Thread Daniel Schwierzeck
Hi Daniel,

Am Montag, den 19.07.2021, 18:34 +0100 schrieb Daniel Golle:
> Hi,
> 
> I writing in the hope that someone has a good idea about why U-boot
> is
> handing over a broken memory address for a loaded ramdisk which
> results
> in Linux crashing very early on boot on MediaTek's MT7623N SoC
> (ARMv7).
> If anyone has a good idea why this is happening, I'd be very glad, as
> this currently prevents me from updating that target in OpenWrt.
> Background:
> OpenWrt used to have the initramdisk built-into the kernel itself.
> Having it separate is nicer as then you won't need to recompile the
> kernel or even have a compiler installed in order to modify the
> ramdisk. This already works great on MT7622 and it'd be great to have
> it the same way on MT7623 (and MT7629 in future).
> 
> So when loading a uImage.FIT with RAMDisk subimage to me it looks
> like
> U-Boot is not translating the address of the ramdisk correctly, see
> logs below:
> 
> U-Boot> tftpboot 0x8800 openwrt-mediatek-mt7623-bpi_bananapi-r2-
> initramfs-recovery.itb
> Using ethernet@1b10 device
> TFTP from server 192.168.5.2; our IP address is 192.168.5.100
> Filename 'openwrt-mediatek-mt7623-bpi_bananapi-r2-initramfs-
> recovery.itb'.
> Load address: 0x8800
> Loading:
> #
>  
> #
>  
> #
>  
> #
>  
> #
>  
> #
>  
> #
>  
> #
>  
> #
>  
> #
>  
> #
>  13 MiB/s
> done
> Bytes transferred = 10492520 (a01a68 hex)
> U-Boot> bootm
> ## Loading kernel from FIT Image at 8800 ...
>Using 'config-1' configuration
>Trying 'kernel-1' kernel subimage
>  Description:  ARM OpenWrt Linux-5.10.51
>  Type: Kernel Image
>  Compression:  gzip compressed
>  Data Start:   0x88e4
>  Data Size:4944975 Bytes = 4.7 MiB
>  Architecture: ARM
>  OS:   Linux
>  Load Address: 0x80008000
>  Entry Point:  0x80008000
>  Hash algo:crc32
>  Hash value:   9da8225f
>  Hash algo:sha1
>  Hash value:   ea4e69501bed0925ecdee0bb6b3a3b489fedc38c
>Verifying Hash Integrity ... crc32+ sha1+ OK
> ## Loading ramdisk from FIT Image at 8800 ...
>Using 'config-1' configuration
>Trying 'initrd-1' ramdisk subimage
>  Description:  ARM OpenWrt bpi_bananapi-r2 initrd
>  Type: RAMDisk Image
>  Compression:  Unknown Compression
>  Data Start:   0x884b7668
>  Data Size:5511960 Bytes = 5.3 MiB
>  Architecture: ARM
>  OS:   Linux
>  Load Address: unavailable
>  Entry Point:  unavailable

you could try to explicitely set load and entry address to 0.

>  Hash algo:crc32
>  Hash value:   01e5fbf0
>  Hash algo:sha1
>  Hash value:   6ceb78df26920d97dee505ddeb0318e0c1522ba0
>Verifying Hash Integrity ... crc32+ sha1+ OK
> WARNING: 'compression' nodes for ramdisks are deprecated, please fix
> your .its file!
> ## Loading fdt from FIT Image at 8800 ...
>Using 'config-1' configuration
>Trying 'fdt-1' fdt subimage
>  Description:  ARM OpenWrt bpi_bananapi-r2 device tree blob
>  Type: Flat Device Tree
>  Compression:  uncompressed
>  Data Start:   0x889f9288
>  Data Size:33453 Bytes = 32.7 KiB
>  Architecture: ARM
>  Hash algo:crc32
>  Hash value:   a2599155
>  Hash algo:sha1
>  Hash value:   59c64737be8bda92b33417dfadca87e9c4662be2
>Verifying Hash Integrity ... crc32+ sha1+ OK
>Booting using the fdt blob at 0x889f9288
>Uncompressing Kernel Image
>Loading Ramdisk to ff4b9000, end ff9fab18 ... OK
>^^
>Using Device Tree in place at 889f9288, end 88a04534
> 
> Starting kernel ...
> 
> [0.00] Booting Linux on physical CPU 0x0
> [0.00] Linux version 5.10.51 (daniel@box) (arm-openwrt-linux-
> muslgnueabi-gcc (OpenWrt GCC 8.4.0 r17073+11-8bb4437c01) 8.4.0, GNU
> ld (GNU Binutils) 2.34) #0 SMP PREEMPT Mon Jul 19 12:26:15 2021
> [0.00] CPU: ARMv7 Processor [410fc073] revision 3 (ARMv7),
> cr=10c5387d
> [0.00] CPU: div instructions available: patching division
> code
> [0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing
> instruction cache
> [

Re: U-Boot loaded RAMDisk crashes Linux on MT7623

2021-07-19 Thread Daniel Golle
Hi again,

On Mon, Jul 19, 2021 at 06:34:38PM +0100, Daniel Golle wrote:
> ...
>Loading Ramdisk to ff4b9000, end ff9fab18 ... OK
>^^
>Using Device Tree in place at 889f9288, end 88a04534
> 
> Starting kernel ...
> ...
> [0.00] Zone ranges:
> [0.00]   Normal   [mem 0x8000-0xafff]
> [0.00]   HighMem  [mem 0xb000-0xefff]
> [0.00] Movable zone start for each node
> [0.00] Early memory node ranges
> [0.00]   node   0: [mem 0x8000-0xefff]
> [0.00] Initmem setup node 0 [mem 
> 0x8000-0xefff]
> [0.00] 8<--- cut here ---
> [0.00] Unable to handle kernel paging request at virtual address 
> 3f9fab0c
> 
> ^^
> ...

I've found the answer myself, thanks to another patch posted to this
list, solving the same problem for another board:
[RFC 1/1] board: sifive: unmatched: use zero copy for initrd

So just like there, setting initrd_high (in this case to 0xafff)
solved the problem.

Sorry for the noise :)


U-Boot loaded RAMDisk crashes Linux on MT7623

2021-07-19 Thread Daniel Golle
Hi,

I writing in the hope that someone has a good idea about why U-boot is
handing over a broken memory address for a loaded ramdisk which results
in Linux crashing very early on boot on MediaTek's MT7623N SoC (ARMv7).
If anyone has a good idea why this is happening, I'd be very glad, as
this currently prevents me from updating that target in OpenWrt.
Background:
OpenWrt used to have the initramdisk built-into the kernel itself.
Having it separate is nicer as then you won't need to recompile the
kernel or even have a compiler installed in order to modify the
ramdisk. This already works great on MT7622 and it'd be great to have
it the same way on MT7623 (and MT7629 in future).

So when loading a uImage.FIT with RAMDisk subimage to me it looks like
U-Boot is not translating the address of the ramdisk correctly, see
logs below:

U-Boot> tftpboot 0x8800 
openwrt-mediatek-mt7623-bpi_bananapi-r2-initramfs-recovery.itb
Using ethernet@1b10 device
TFTP from server 192.168.5.2; our IP address is 192.168.5.100
Filename 'openwrt-mediatek-mt7623-bpi_bananapi-r2-initramfs-recovery.itb'.
Load address: 0x8800
Loading: #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 #
 13 MiB/s
done
Bytes transferred = 10492520 (a01a68 hex)
U-Boot> bootm
## Loading kernel from FIT Image at 8800 ...
   Using 'config-1' configuration
   Trying 'kernel-1' kernel subimage
 Description:  ARM OpenWrt Linux-5.10.51
 Type: Kernel Image
 Compression:  gzip compressed
 Data Start:   0x88e4
 Data Size:4944975 Bytes = 4.7 MiB
 Architecture: ARM
 OS:   Linux
 Load Address: 0x80008000
 Entry Point:  0x80008000
 Hash algo:crc32
 Hash value:   9da8225f
 Hash algo:sha1
 Hash value:   ea4e69501bed0925ecdee0bb6b3a3b489fedc38c
   Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading ramdisk from FIT Image at 8800 ...
   Using 'config-1' configuration
   Trying 'initrd-1' ramdisk subimage
 Description:  ARM OpenWrt bpi_bananapi-r2 initrd
 Type: RAMDisk Image
 Compression:  Unknown Compression
 Data Start:   0x884b7668
 Data Size:5511960 Bytes = 5.3 MiB
 Architecture: ARM
 OS:   Linux
 Load Address: unavailable
 Entry Point:  unavailable
 Hash algo:crc32
 Hash value:   01e5fbf0
 Hash algo:sha1
 Hash value:   6ceb78df26920d97dee505ddeb0318e0c1522ba0
   Verifying Hash Integrity ... crc32+ sha1+ OK
WARNING: 'compression' nodes for ramdisks are deprecated, please fix your .its 
file!
## Loading fdt from FIT Image at 8800 ...
   Using 'config-1' configuration
   Trying 'fdt-1' fdt subimage
 Description:  ARM OpenWrt bpi_bananapi-r2 device tree blob
 Type: Flat Device Tree
 Compression:  uncompressed
 Data Start:   0x889f9288
 Data Size:33453 Bytes = 32.7 KiB
 Architecture: ARM
 Hash algo:crc32
 Hash value:   a2599155
 Hash algo:sha1
 Hash value:   59c64737be8bda92b33417dfadca87e9c4662be2
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Booting using the fdt blob at 0x889f9288
   Uncompressing Kernel Image
   Loading Ramdisk to ff4b9000, end ff9fab18 ... OK
   ^^
   Using Device Tree in place at 889f9288, end 88a04534

Starting kernel ...

[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 5.10.51 (daniel@box) 
(arm-openwrt-linux-muslgnueabi-gcc (OpenWrt GCC 8.4.0 r17073+11-8bb4437c01) 
8.4.0, GNU ld (GNU Binutils) 2.34) #0 SMP PREEMPT Mon Jul 19 12:26:15 2021
[0.00] CPU: ARMv7 Processor [410fc073] revision 3 (ARMv7), cr=10c5387d
[0.00] CPU: div instructions available: patching division code
[0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing 
instruction cache
[0.00] OF: fdt: Machine model: Bananapi BPI-R2
[0.00] earlycon: uart8250 at MMIO32 0x11004000 (options '')
[0.00] printk: bootconsole [uart8250] enabled
[0.00] Memory policy: Data cache writealloc
[0.00] Zone ranges:
[0.00]   Normal   [mem 0x8000-0xafff]
[0.00]   HighMem  [mem 0xb000-0xefff]
[