[Raspberrypi 3b+] U-boot loaded kernel and devicetree with workable UART

好文分享

Raspberry 3b+ UART information:

3b+ and 3b basic are the same, only the CPU upgraded. 3b+ has two UART options, one is mini-UART and the other is PL011.

PL011 and mini-UART

There are some differences between PL011 UARTs and mini-UART.

The mini-UART has smaller FIFOs. Combined with the lack of flow control, this makes it more prone to losing characters at higher baudrates. It is also generally less capable than a PL011, mainly due to its baud rate link to the CPU clock speed.

The particular deficiencies of the mini UART compared to a PL011 are:

  • No break detection
  • No framing errors detection
  • No parity bit
  • No receive timeout interrupt

Primary and Secondary UART

I use mini-UART today, all the UART settings in this article is for mini-UART.

if set enable_uart=1 and your device has bluetooth, then ttyAMA0 goes to bt, and ttyS0 to gpio 14/15

Reference:


Raspberry Pi: Cross-compile the kernel

https://www.raspberrypi.com/documentation/computers/linux_kernel.html

Toolchain install

Compile the 64-bit Kernel

cd linux
KERNEL=kernel8
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs

Install kernel

you can use Raspberry Pi Imager to create a workable SD card first and follow the article to finish install kernel.

https://www.raspberrypi.com/documentation/computers/linux_kernel.html#configure-the-kernel

U-boot

mkdir uboot
cd uboot
git clone https://source.denx.de/u-boot/u-boot.git
cd u-boot
git checkout v2021.07
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rpi_3_b_plus_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

edit config.txt

add:

#Run in 64-bit mode
arm_64bit=1
kernel=u-boot.bin

#u-boot uart message
uart_2ndstage=1
enable_uart=1

Boot to U-boot

Add those setting above in boot/config.txt and copy the u-boot.bin you built to /boot (first partition on the SD card)

Kernel image

Copy raspberrypi(Your RaspberryPi code base)/linux/arch/arm/boot/Image to
1.SD card /boot
or
2.tftpboot folder

Load kernel from SD Card

U-Boot>setenv console ‘console=tty1 console=ttyS0,115200 8250.nr_uarts=1’
U-Boot>setenv bootcmd ‘fatload mmc 0 0x80000 Image;fatload mmc 0 0x2600000 bcm2710-rpi-3-b-plus.dtb; booti 0x80000 – 0x2600000’
U-Boot>setenv bootargs ‘console=${console} root=/dev/mmcblk0p2 rootwait’
U-Boot>saveenv
U-Boot>boot

Load kernel from TFTP server

U-Boot>setenv serverip 10.12.1.68
U-Boot>setenv netmask 255.255.255.0
U-Boot>setenv ipaddr 10.12.1.182
U-Boot>setenv gatewayip 10.12.1.1
U-Boot>setenv bootcmd_tftp ‘tftp 0x80000 Image; tftp 0x2600000 bcm2710-rpi-3-b-plus.dtb; booti 0x80000 – 0x2600000’
U-Boot>setenv bootcmd ‘run bootcmd_tftp’
U-Boot>saveenv
U-Boot>boot

Boot from TFTP & SD card File system

U-Boot>setenv console ‘console=tty1 console=ttyS0,115200 8250.nr_uarts=1’
U-Boot>mmcsdargs ‘setenv bootargs console=${console} root=/dev/mmcblk0p2 ip=dhcp rw rootwait’
U-Boot>setenv mmcsdboot ‘run mmcsdargs; run bootcmd_tftp’
U-Boot>saveenv
U-Boot>run mmcsdboot
U-Boot>boot

Boot from TFTP & NFS Rootfs

U-Boot>setenv console ‘console=tty1 console=ttyS0,115200 8250.nr_uarts=1’
U-Boot>setenv mmcnfsargs ‘setenv bootargs console=${console} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp rw rootwait’
U-Boot>setenv mmcnfsboot ‘run mmcnfsargs; run bootcmd_tftp’
U-Boot>setenv bootcmd ‘run mmcnfsboot’
U-Boot>saveenv
U-Boot>boot

Booting message from console.

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料