User Tools

Site Tools



en:bpi-r3:uboot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:bpi-r3:uboot [2022/10/10 07:11] – [building] franken:bpi-r3:uboot [2024/04/07 09:39] (current) – [writing emmc] frank
Line 1: Line 1:
 ====== U-Boot ====== ====== U-Boot ======
 +
 +[[https://u-boot.readthedocs.io/en/latest/develop/release_cycle.html#current-status|Release cycle]]
  
 Mtk uboot: https://github.com/mtk-openwrt/u-boot Mtk uboot: https://github.com/mtk-openwrt/u-boot
Line 23: Line 25:
   sudo dd if=build/mt7986/release/fip.bin of=/dev/sdb4   sudo dd if=build/mt7986/release/fip.bin of=/dev/sdb4
  
-ATF branch contains gpt file for flashing first and script to create basic image with bootchain+ATF branch contains gpt file (gpt_sdmmc_100m6g.img) for flashing first and script to create basic image with bootchain 
 + 
 +  ./build.sh createimg
 ===== booting kernel ===== ===== booting kernel =====
  
Line 65: Line 69:
   BPI-R3> run newboot   BPI-R3> run newboot
  
-  #using spi dt-overlay+  #using dt-overlay config
   BPI-R3> setenv bootconf "#conf-sd-nor" #conf-sd-nor=sd base dts + nor dt overlay   BPI-R3> setenv bootconf "#conf-sd-nor" #conf-sd-nor=sd base dts + nor dt overlay
  
Line 82: Line 86:
 Bootup with sdcard (put spi-nand bl2 + fip with emmc-and usb-support as files on card) and flash them like described [[#nand_flash|here]] then boot from spi (sw2 to boot from spi-nand + change sw6 to have access to emmc) and then [[#writing_emmc|flash emmc]]. Finally change sw2 back to boot from emmc and sw1 has to be changed too. Bootup with sdcard (put spi-nand bl2 + fip with emmc-and usb-support as files on card) and flash them like described [[#nand_flash|here]] then boot from spi (sw2 to boot from spi-nand + change sw6 to have access to emmc) and then [[#writing_emmc|flash emmc]]. Finally change sw2 back to boot from emmc and sw1 has to be changed too.
 ===== nand flash ===== ===== nand flash =====
 +
 +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nand.dtso
  
 <code> <code>
Line 133: Line 139:
 </code> </code>
  
 +===== nor flash =====
 +
 +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso
 +
 +<code>
 +MT7986> sf probe
 +SF: Detected w25q256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
 +MT7986> sf erase 0 0x180000
 +SF: 1572864 bytes @ 0x0 Erased: OK
 +MT7986> fatload usb 0:1 ${loadaddr} 2023.04/bpi-r3_nor_bl2.img
 +202160 bytes read in 21 ms (9.2 MiB/s)
 +MT7986> sf write ${loadaddr} 0 0x40000
 +device 0 offset 0x0, size 0x40000
 +SF: 262144 bytes @ 0x0 Written: OK
 +MT7986> fatload usb 0:1 ${loadaddr} 2023.04/bpi-r3_nor_fip.bin
 +255509 bytes read in 25 ms (9.7 MiB/s)
 +MT7986> sf write ${loadaddr} 0x100000 0x80000
 +device 0 offset 0x100000, size 0x80000
 +SF: 524288 bytes @ 0x100000 Written: OK
 +</code>
 +
 +if you get this error on bootup
 +
 +  NOTICE:  BL31: Built : 20:24:28, Apr  5 2023                                    
 +  No valid device tree binary found at 0000000041e92f20                           
 +  initcall sequence 0000000041e621a8 failed at call 0000000041e57800 (err=-2)     
 +  ### ERROR ### Please RESET the board ###
 +
 +you need to compress bl31
 +
 +  xz -f -e -k -9 -C crc32 u-boot.bin
 +
 +and use the resulting u-boot.bin.xz as BL33
 +
 +==== kernel/initrd ====
 +
 +currently untested...
 +
 +<code>
 +label = "recovery"; //initrd max 10MB
 +reg = <0x180000 0xa80000>;
 +
 +label = "fit"; //kernel max 20MB
 +reg = <0xc00000 0x1400000>;
 +</code>
 +
 +<code>
 +MT7986> sf probe
 +SF: Detected w25q256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
 +MT7986> sf erase 0x180000 0xa80000
 +SF: 11010048 bytes @ 0x180000 Erased: OK
 +MT7986> fatload usb 0:1 ${loadaddr} rootfs_bpi-r3.cpio.zst
 +9501203 bytes read in 798 ms (11.4 MiB/s)
 +MT7986> sf write ${loadaddr} 0x180000 ${filesize}
 +device 0 offset 0x180000, size 0x90fa13
 +SF: 9501203 bytes @ 0x180000 Written: OK
 +MT7986> sf erase 0xc00000 0x1400000
 +SF: 20971520 bytes @ 0xc00000 Erased: OK
 +MT7986> fatload usb 0:1 ${loadaddr} bpi-r3-6.1.itb
 +8424540 bytes read in 708 ms (11.3 MiB/s)
 +MT7986> sf write ${loadaddr} 0xc00000 ${filesize}                               
 +device 0 offset 0xc00000, size 0x808c5c                                         
 +SF: 8424540 bytes @ 0xc00000 Written: OK
 +</code>
 +
 +loading it:
 +
 +<code>
 +MT7986> setenv useinitrd 'setenv root "/dev/ram0 rw";setenv bootopts "${bootopts} initrd=${rdaddr},20M";'
 +MT7986> sf read ${rdaddr} 0x180000 0xa80000
 +device 0 offset 0x180000, size 0xa80000
 +SF: 11010048 bytes @ 0x180000 Read: OK
 +MT7986> sf read ${kaddr} 0xc00000 0x1400000
 +device 0 offset 0xc00000, size 0x1400000
 +SF: 20971520 bytes @ 0xc00000 Read: OK
 +MT7986> setenv bootnor 'run useinitrd;run setbootconf; run buildargs; bootm ${kaddr}${bootconf};'
 +MT7986> run bootnor
 +</code>
 ===== usb ===== ===== usb =====
  
Line 174: Line 258:
 </code> </code>
 ===== writing emmc ===== ===== writing emmc =====
 +
 +:!: newest atf for mediatek needs gpt with fip partition so it must be created first (maybe copy first 1M from sdcard to emmc).
  
 get emmc/gpt information: get emmc/gpt information:
Line 321: Line 407:
  
 now flash bl2 to boot0 block and fip to fip partition now flash bl2 to boot0 block and fip to fip partition
 +
 +short way using my environment:
 +<code>
 +MT7986> setenv bl2file 2023.04/bpi-r3_emmc_bl2.img                                                                                                                                          
 +MT7986> setenv fipfile 2023.04/bpi-r3_emmc_fip.bin                                                                                                                                          
 +MT7986> run wremmc                                                                                                                                                                          
 +bl2file=2023.04/bpi-r3_emmc_bl2.img                                                                                                                                                         
 +195976 bytes read in 20 ms (9.3 MiB/s)                                                                                                                                                      
 +                                                                                                                                                                                            
 +MMC erase: dev # 0, block # 0, count 1024 ... 1024 blocks erased: OK                                                                                                                        
 +                                                                                                                                                                                            
 +MMC write: dev # 0, block # 0, count 1024 ... 1024 blocks written: OK                                                                                                                       
 +fipfile=2023.04/bpi-r3_emmc_fip.bin                                                                                                                                                         
 +645001 bytes read in 58 ms (10.6 MiB/s)                                                                                                                                                     
 +                                                                                                                                                                                            
 +MMC erase: dev # 0, block # 13312, count 4096 ... 4096 blocks erased: OK                                                                                                                    
 +                                                                                                                                                                                            
 +MMC write: dev # 0, block # 13312, count 4096 ... 4096 blocks written: OK
 +</code>
 +manual way:
 +<hidden>
 <code> <code>
 BPI-R3> mmc dev 0 BPI-R3> mmc dev 0
Line 347: Line 454:
 BPI-R3> BPI-R3>
 </code> </code>
 +</hidden>
  
 If boot from emmc does not work,maybe bootbus needs to be changed to 0: If boot from emmc does not work,maybe bootbus needs to be changed to 0:
  
   mmc bootbus 0 0 0 0   mmc bootbus 0 0 0 0
 +
 +
 +instead of writing the gpt image file you can bootup a linux with initrd
 +
 +you get all files here: https://drive.google.com/drive/folders/1ZsJ2jsOieg_6HM4LHWUimROX5p5Kx7vo?usp=share_link
 +
 +  BPI-R3> run useusb
 +  BPI-R3> setenv initrd rootfs.cpio.zst                                                                                                                                      
 +  BPI-R3> setenv fit bpi-r3.itb
 +  BPI-R3> run newboot
 +
 +and create gpt like i do it for [[https://github.com/frank-w/u-boot/blob/mtk-atf/build.sh#L114|sdcard]], original gpt uses same values for partitions and use a partition named gpt (0..33) instead of bl2 (34..8191)
 +
 +<code>
 +sudo sgdisk -o ${LDEV}
 +#sudo sgdisk -a 1 -n 1:34:8191 -A 1:set:2 -t 1:8300 -c 1:"bl2" ${LDEV} #sdcard only
 +sudo sgdisk -a 1 -n 1:0:33 -A 1:set:2 -t 1:8300 -c 1:"gpt" ${LDEV} #emmc only
 +sudo sgdisk -a 1 -n 2:8192:9215 -t 2:8300 -c 2:"u-boot-env" ${LDEV}
 +sudo sgdisk -a 1 -n 3:9216:13311 -t 3:8300 -c 3:"factory" ${LDEV}
 +sudo sgdisk -a 1 -n 4:13312:17407 -t 4:8300 -c 4:"fip" ${LDEV}
 +sudo sgdisk -a 1024 -n 5:17408:${bootend} -t 5:8300 -c 5:"boot" ${LDEV}
 +sudo sgdisk -a 1024 -n 6:${rootstart}:${rootend} -t 6:8300 -c 6:"rootfs" ${LDEV}
 +</code>
 ===== chainload uboot ===== ===== chainload uboot =====
  
en/bpi-r3/uboot.1665378681.txt.gz · Last modified: 2023/06/08 17:06 (external edit)