Info:
At the time of writing, Yocto dunfell was used. Pl use the latest versions wherever applicable. Build was done in Ubuntu 20.04
STEPS:
Install the necessary tools
sudo apt install build-essential chrpath diffstat gawk libncurses5-dev python3-distutils texinfo wget git-core diffstat unzip texinfo gcc-multilib socat libsdl1.2-dev xterm
Checkout the necessary repo to have the basic poky setup
mkdir rpi4
cd ~/rpi4
git clone -b dunfell http://git.yoctoproject.org/git/poky
cd poky
git clone -b dunfell git://git.yoctoproject.org/meta-raspberrypi
Checkout the add on layer so that you can add any additional recipe
git clone git@github.com:ArivuAlamari/meta-rpi4linux-addon.git
Add the layers at ~/rpi4/poky/build/temp/bblayers.conf as below
BBLAYERS ?= " \
/home/your_home/rpi4/poky/meta \
/home/your_home/rpi4/poky/meta-poky \
/home/your_home/rpi4/poky/meta-yocto-bsp \
/home/your_home/rpi4/poky/meta-raspberrypi \
/home/your_home/rpi4/poky/meta-rpi4linux-addon \
"
Update the machine name and build controllers in ~/rpi4/poky/build/temp/local.conf
MACHINE ??= "raspberrypi4-64"
BB_NUMBER_THREADS = "4"
PARALLEL_MAKE = "-j 4"
Build the SW
cd ~/rpi4/poky/
source oe-init-build-env
bitbake rpi4linux-image
The build takes from 45 min up to 4hrs based on your system speed. It will also takes up to 30Gb. Final results will be stores at
cd ~/rpi4/poky/build/tmp/deploy/images/raspberrypi4-64
SD Card Preparation:
Normally dmesg should tell you the card is sdb or sdc where the microSD is mounted. If it is not sdc, please change the drive name below as it mounts in your system.
Format the SD card as below
fdisk /dev/sdc
# delete all partitions pre exist in the card
#create 2 primary partions
#change partition 1 to FAT32 type
#change partition 2 to ext4 type
# don't forget to write the changes
# make the filesystem and format
sudo mkfs.vfat /dev/sdc1
sudo mkfs.ext4 /dev/sdc2
# create the partion names as below
sudo fatlabel /dev/sdc1 BOOT
sudo e2label /dev/sdc2 ROOT
Copy the relevant filed to the partitions
#mount the partions
sudo mount /dev/sdc1 /media/BOOT
sudo mount /dev/sdc2 /media/ROOT
# delete any pre existing files
cd /media/BOOT
rm -rf *
cd /media/ROOT
rm -rf *
cd ~/rpi4/poky/build/tmp/deploy/images/raspberrypi4-64/
# copy DTB
sudo cp bcm2711-rpi-4-b.dtb /media/BOOT/
# copy the Linux Image
sudo cp Image /media/BOOT/kernel_rpilinux.img
#copy boot files
cd bootfiles
sudo cp * /media/BOOT/
#copy filesystem
cd /media/ROOT/
sudo tar -xvjf ~/rpi4/poky/build/tmp/deploy/images/raspberrypi4-64/rpi4linux-image-raspberrypi4-64.tar.bz2
Update Config Files:
Update boot config as
sudo vi /media/BOOT/config.txt
kernel=kernel_rpilinux.img
arm_64bit=1
enable_uart=1
Update boot command as
sudo vi /media/BOOT/cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=ttyS0 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
fstab file needs to be updated as follows
sudo vi /media/ROOT/etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblo0p2 / ext4 defaults,noatime 0 1
Alternatively, you could copy the sample files with above changes to the respective locations as below
sudo cp ~/rpi4/poky/meta-rpi4linux-addon/sample/fstab.sample /media/ROOT/etc/fstab
sudo cp ~/rpi4/poky/meta-rpi4linux-addon/sample/config.txt.sample /media/BOOT/config.txt
sudo cp ~/rpi4/poky/meta-rpi4linux-addon/sample/cmdline.txt.sample /media/BOOT/cmdline.txt
Finally unmount the SD card
cd ~
sudo umount /media/BOOT
sudo umount /media/ROOT
Testing
if everything goes well, you will get the boot prompt
username : root
password :
# no password required. Set the password once you successfully login
コメント