[BPI-R2] create Kernel without appended DTB

Hi,

i’m trying to move dtb to outside kernel to get it loaded separately in uboot (like r64)

my source:

uboot output:

U-Boot> printenv
askkernel=askenv kernelinput "enter uImage-name:";
board=bpi-r2
boot0=run lskernel;run askkernel;if printenv kernelinput ;then setenv kernel ${kernelinput}; run newboot; fi
boot1=run selectmmc; run loadbootenv; run importenv; run newboot;
boot14=setenv kernel ${kernel414}; run newboot;
boot19=setenv kernel ${kernel419}; run newboot;
boot19_dt=setenv kernel ${kernel419_nodt}; setenv fdt ${fdt419}; run newboot2;
boot20=setenv kernel ${kernel420}; run newboot;
bootall=if printenv fdt ;then run loadfdt; bootm ${loadaddr} - $dtaddr ;else bootm fi
bootargs=board=bpi-r2 console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait vmalloc=496M 7
bootcmd=setenv bootdelay 3; run reloadmenu;
bootdelay=3
bootenv=uEnv.txt
bootfile=uImage_4.19.0-rc1-hdmiv5
bootmenu_0=1. Enter kernel-name to boot from SD/EMMC.=run boot0
bootmenu_1=2. Boot kernel from TFTP.=run bootnet
bootmenu_2=3. Boot from SD/EMMC 4.14.=run boot14                                                                                                   
bootmenu_3=4. Boot from SD/EMMC 4.19.=run boot19                                                                                                   
bootmenu_4=5. Boot from SD/EMMC 4.20.=run boot20                                                                                                   
bootmenu_5=6. Boot from SD/EMMC 4.19 (fdt/dto).=run boot19_dt                                                                                      
bootmenu_default=4                                                                                                                                 
bootnet=printenv; setenv bootargs ${netbootargs};tftp ${loadaddr} ${bootfile};bootm                                                                
bootopts=vmalloc=496M debug=7 initcall_debug=0                                                                                                     
bpi=bananapi                                                                                                                                       
buildargs=setenv bootargs "board=${board} console=${console} root=${root} ${bootopts} ${graphic}"                                                  
checkenv=test -e ${device} ${partition} ${bpi}/${board}/${service}/${bootenv}                                                                      
checksd=fatinfo ${device} 1:1                                                                                                                      
console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200                                                                                  
device=mmc                                                                                                                                         
dtaddr=0x83000000                                                                                                                                  
dtolist419=bpi-r2-mac.dtb                                                                                                                          
ethaddr=02:03:04:05:06:07                                                                                                                          
fdt=bpi-r2-4.19-13-main.dtb                                                                                                                        
fdt419=bpi-r2-4.19-13-main.dtb                                                                                                                     
fdtcontroladdr=ffb96fc0                                                                                                                            
fileaddr=80200000                                                                                                                                  
filesize=6f6a30                                                                                                                                    
graphic=video=1280x1024 drm.debug=0x7                                                                                                              
importenv=env import -t ${scriptaddr} ${filesize}                                                                                                  
ipaddr=192.168.0.11                                                                                                                                
kernel=uImage_4.19.13-main_nodt                                                                                                                    
kernel414=uImage_4.14.74-main                                                                                                                      
kernel419=uImage_4.19.13-main                                                                                                                      
kernel419_nodt=uImage_4.19.13-main_nodt                                                                                                            
kernel420=uImage_4.20.0-gmac                                                                                                                       
loadaddr=0x80200000                                                                                                                                
loadbootenv=if fatload ${device} ${partition} ${scriptaddr} ${bpi}/${board}/${service}/${bootenv};then run importenv;else echo "fatload (${bootenvi
loaddto=fdt addr ${dtaddr};fdt resize; setexpr fdtovaddr ${dtaddr} + F000; fatload ${device} ${partition} ${fdtovaddr} ${bpi}/${board}/${service}/}
loadfdt=fatload $device $partition $dtaddr ${bpi}/${board}/${service}/dtb/${fdt}                                                                   
loadkernel= fatload ${device} ${partition} ${loadaddr} ${bpi}/${board}/${service}/${kernel}                                                        
lskernel=ls ${device} ${partition} ${bpi}/${board}/${service};                                                                                     
lstftp=tftp ${loadaddr} ${serverip}:files.lst;setexpr listend ${loadaddr} + ${filesize};mw.b ${listend} 00 2;strings ${loadaddr};                  
netbootargs=console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait                                                                                   
netmask=255.255.255.0                                                                                                                              
newboot=run buildargs;printenv bootargs;fatload ${device} ${partition} ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm                     
newboot2=run buildargs; printenv bootargs; run loadkernel; run bootall;                                                                            
partition=1:1                                                                                                                                      
reloadmenu=run selectmmc;if run checkenv; then run loadbootenv; else echo file not found; fi;bootmenu;                                             
resetenv=env default -a;printenv;                                                                                                                  
root=/dev/mmcblk0p2 rootfstype=ext4 rootwait                                                                                                       
scriptaddr=0x83000000                                                                                                                              
selectmmc=if run checksd; then echo Boot from SD ; setenv partition 1:1;else echo Boot from eMMC; setenv partition 0:1 ; fi;                       
serverip=192.168.0.10                                                                                                                              
service=linux                                                                                                                                      
                                                                                                                                                   
Environment size: 3920/4092 bytes

=====================================================================
                                                                                                          
U-Boot> run loadkernel                                                                                                                             
7301680 bytes read in 469 ms (14.8 MiB/s)                                                                                                          
U-Boot> run loadfdt                                                                                                                                
27836 bytes read in 10 ms (2.7 MiB/s)                                                                                                              
U-Boot> bootm ${loadaddr} - $dtaddr                                                                                                                
## Booting kernel from Legacy Image at 80200000 ...                                                                                                
   Image Name:   Linux Kernel 4.19.13-main_nodt                                                                                                    
   Image Type:   ARM Linux Kernel Image (uncompressed)                                                                                             
   Data Size:    7301616 Bytes = 7 MiB                                                                                                             
   Load Address: 80008000                                                                                                                          
   Entry Point:  80008000                                                                                                                          
   Verifying Checksum ... OK                                                                                                                       
## Flattened Device Tree blob at 83000000                                                                                                          
   Booting using the fdt blob at 0x83000000                                                                                                        
   Loading Kernel Image ... OK                                                                                                                     
   Loading Device Tree to ffb8c000, end ffb95cbb ... OK                                                                                            
                                                                                                                                                   
Starting kernel ...        

and nothing happens…

simply i compile like the kernel with appended dtb, but without this option and modified mkimage (no append of dtb via cat)

i only copy the build dtb to dtb-folder on BPI-root

any idea why kernel does not boot? have checked that ARM_APPENDED_DTB is set to [=n]…so kernel should not look into its binary to find dtb and use address passed by uboot

can anybody explain this to me?

kernelci.org uses below way to load kernel and dtb seprately for your reference…

image

only zImage (without mkimage) and using bootz…i try that

U-Boot> setenv kernel bpi-r2-zimage-4.19.13-main_nodt
U-Boot> run loadkernel
7301616 bytes read in 455 ms (15.3 MiB/s)
U-Boot> run loadfdt
27836 bytes read in 11 ms (2.4 MiB/s)
U-Boot> bootz ${loadaddr} - $dtaddr
Unknown command 'bootz' - try 'help'

mhm…bootz is not compiled in my uboot…need to rebuild this

mhm…looks same like with uimage

BPI-R2> setenv kernel bpi-r2-zimage-4.19.13-main_nodt
BPI-R2> run loadkernel
7301616 bytes read in 453 ms (15.4 MiB/s)
BPI-R2> run loadfdt
27836 bytes read in 10 ms (2.7 MiB/s)
BPI-R2> bootz ${loadaddr} - $dtaddr
Kernel image @ 0x80200000 [ 0x000000 - 0x6f69f0 ]
## Flattened Device Tree blob at 83000000
   Booting using the fdt blob at 0x83000000
   Loading Device Tree to ffb8c000, end ffb95cbb ... OK

Starting kernel ...

and then stops… kernel does look at wrong place for dtb, my bootargs are set right by menuentry

config.tar.gz (28,5 KB)

[14:41:31]$ grep -i 'dtb' .config
# CONFIG_ARM_APPENDED_DTB is not set

do i need any option to get dtb from outside of kernel-image (have not found any in r64-defconfig)? also made clean and mrproper

dt seems to be loaded correctly

BPI-R2> setenv fdt bpi-r2-4.19-13-main.dtb
BPI-R2> run loadfdt
27836 bytes read in 10 ms (2.7 MiB/s)
BPI-R2> fdt addr $dtaddr
BPI-R2> fdt list / model
model = "Bananapi BPI-R2"

tried also adding debug to bootargs

BPI-R2> printenv bootargs                                                                                                                       
bootargs=console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait ip=dhcp                                                                           
BPI-R2> setenv bootargs ${bootargs} debug                                                                                                       
BPI-R2> printenv bootargs                                                                                                                       
bootargs=console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait ip=dhcp debug                                                                     
BPI-R2> printenv kernel                                                                                                                         
kernel=bpi-r2-zimage-4.19.13-main_nodt                                                                                                          
BPI-R2> run loadkernel
7301616 bytes read in 447 ms (15.6 MiB/s)                                                                                                       
BPI-R2> bootz ${loadaddr} - $dtaddr

also stops after starting kernel…

i tried also with the memory-addresses

0x82000000 for kernel (loaddress)
0x83f00000 for dtb (dtaddr)

same effect

the trick is

setenv fdt_high 0xffffffff

with this, kernel gets booted:

root@bpi-r2:~# uname -r
4.19.13-bpi-r2-main_nodt

Maybe my fdt-address is to high: https://unix.stackexchange.com/questions/257508/fdt-relocated-by-u-boot-cannot-be-accessed-by-linux-in-highmem