User:Minou/Arm64/BeaglePlay
From Gentoo Wiki
< User:Minou | Arm64
Jump to:navigation
Jump to:search
This was fully tested and worked as expected. I tested it with an ACER HDMI portable monitor bought from Costco I plan to create a smaller one that doesn't use a desktop, just a simple app. The idea is to create a cheap CAN tool. It would connect on a small LCD. I will provide all details on my github repositories
Build u-boot
Here it is assumed that the directory travail already exists We create a beagleplay directory The following is based on the script build_u-boot.sh from Robert Nelson
user $
cd $HOME/travail/arm64
user $
mkdir beagleplay
user $
cd beagleplay
user $
chmod a+x build_u-boot.sh
FILE
build_u-boot.sh
change CC64=aarch64-linux-gnu- to CC64=aarch64-unknown-linux-gnu-
In the line to compile trusted-firmware-a add ENABLE_PIE=0
It will fail compiling on gentoo unless that is done
make -C ./trusted-firmware-a/ -j4 CROSS_COMPILE=$CC64 CFLAGS= LDFLAGS= ARCH=aarch64 PLAT=k3 SPD=opteed $TFA_EXTRA_ARGS
TARGET_BOARD=${TFA_BOARD} ENABLE_PIE=0 all
user $
./build_u-boot.sh
The generated files can be found on the directory public:
bl31.bin tee-pager_v2.bin tiboot3.bin tispl.bin u-boot.img
Download pre-built u-boot
If the compiled files don't work we can try the pre-built ones
user $
git clone https://openbeagle.org/beagleboard/boot-firmware.git
The files are on the beagleplay directory Those files are tiboot3.bin tispl.bin and u-booot.img
Linux Kernel
We will cross compile the kernel It takes too long in chroot and we need a kernel to boot the image We should be able to recompile later once we have a working image
user $
cd $HOME/travail/arm64
user $
mkdir kernel
user $
cd kernel
user $
git clone https://github.com/SuzieLinux/Linux-Files.git
user $
mv Linux-Files/getKernel.sh ./
user $
./getKernel.sh
user $
mkdir deploy
user $
mkdir deploy/tmp
Compile kernel
user $
export CC=aarch64-unknown-linux-gnu-
user $
cd linux-6.12-ti-arm64-r13
user $
make ARCH=arm64 CROSS_COMPILE=${CC} distclean
user $
make ARCH=arm64 CROSS_COMPILE=${CC} bb.org_defconfig
If you want to modify the default .config use menuconfig
You may want to adjust the number of cores to use
If you use too many cores you won't be able to do anything else
user $
make -j8 ARCH=arm64 CROSS_COMPILE=${CC} menuconfig
user $
make -j8 ARCH=arm64 CROSS_COMPILE=${CC} Image modules
user $
make -j8 ARCH=arm64 CROSS_COMPILE=${CC} dtbs
If it compiles correctly we copy the files on the deploy directory
user $
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- modules_install INSTALL_MOD_PATH=../deploy/tmp
user $
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- dtbs_install INSTALL_DTBS_PATH=../deploy/tmp
user $
cp arch/arm64/boot/Image ../deploy/cp
Create micro SD boot disk
To save time we use the official Beagleplay SD image to start with Changed sdd to whatever your micro SD is. Use a 64GB micro SD or larger
root #
dd if=beagleplay-debian-12.7-xfce-arm64-2024-09-04-12gb.img of=/dev/sdd status=progress iflag=direct oflag=direct bs=4M
Use gparted to expand the ext4 partition Unplug the micro SD and plug it back Mount the ext4 partition on /mnt The fat partition is already mounted on the /run/media/__user__/BOOT Backup the debian image Here I replaced my user name with __user__, on your system it would be your user name On Debian or Ubuntu it would be on a slightly different directory.
root #
mount /dev/sdd3 /mnt
root #
mkdir /usr/src/arm64/beagleplay_debian_rootfs
root #
mkdir /usr/src/arm64/beagleplay_debian_boot
root #
mv /mnt/* /usr/src/arm64/beagleplay_debian_rootfs
root #
mv /run/media/__user__/BOOT/* /usr/src/arm64/beagleplay_debian_boot
root #
sync
Copy rootfs files
root #
cd /mnt
root #
tar xvf /usr/src/arm64/rootfs-arm64-20250129.tar.gz --strip-components 1
root #
sync
root #
cp -Rp /usr/src/arm64/beagleplay_debian_rootfs/opt/source /mnt/opt
root #
cp -Rp /usr/src/arm64/beagleplay_debian_rootfs/opt/ti-zephyr-firmware /mnt/opt
root #
cp -Rp $HOME/travail/arm64/kernel/deploy/tmp/lib/modules /mnt/lib
In order to boot on the micro SD a config file has to be created. It is slightly different than on the emmc where it is not on the root of the fat partition but on a directory called firmware
FILE
/run/media/__user__/BOOT/extlinux/extlinux.conf
timeout 50
default microSD (default)
label microSD (debug)
kernel /Image
append console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02800000 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net
fdtdir /
#initrd /initrd.img
label microSD (default)
kernel /Image
append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0
fdtdir /
#fdtoverlays /overlays/<file>.dtbo
#initrd /initrd.img
FILE
/mnt/etc/fstab
# /etc/fstab: static file system information.
#
# <fs> <mountpoint> <type> <opts> <dump> <pass>
/dev/mmcblk1p1 /boot vfat user,uid=1000,gid=1000,defaults 0 2
/dev/mmcblk1p2 none swap sw 0 0
/dev/mmcblk1p3 / ext4 noatime,errors=remount-ro 0 1
We need to copy misc files to the BOOT partition. I am not sure if the ti directory is required, I just duplicated what is done in the debian image
user $
mkdir /run/media/__user__/BOOT/ti
user $
cp -p $HOME/travail/arm64/kernel/deploy/tmp/ti/k3-am625-* /run/media/__user__/BOOT/ti
user $
cp -p $HOME/travail/arm64/kernel/deploy/tmp/ti/k3-am625-* /run/media/__user__/BOOT
user $
cp -p $HOME/travail/arm64/kernel/deploy/Image /run/media/__user__/BOOT
user $
cp -p $HOME/travail/arm64/beagleplay/public/tiboot3.bin /run/media/__user__/BOOT
user $
cp -p $HOME/travail/arm64/beagleplay/public/tispl.bin /run/media/__user__/BOOT
user $
cp -p $HOME/travail/arm64/beagleplay/public/u-boot.img /run/media/__user__/BOOT
chroot in micro SD
root #
arch-chroot /mnt
root #
env-update
root #
export PS1="(chroot) $PS1"
root #
source /etc/profile
root #
emerge --sync
update system
Don't forget to Create a root password as well as a user and user password Just in case the original rootfs is a few days or weeks old it would be a good idea to do a system update Any updates should be done with chroot if you have a powerful computer. Doing it on the target will take a long time. Updates can take a long time as well in chroot but not as much
root #
emerge -avuDN @world
root #
exit
Create image files
Before creating the image it is necessary to remove the distfile which may take a lot of room On this image the size is close to 30G out of 64G Removing them reduce the size by around 4.7G You then umount the micro SD card and using gparted you reduce the size
root #
dd if=/dev/sdd of=beagleplay-gentoo-mate-20250303.img status=progress iflag=direct
You could also do like is done on ArchLinux, to just compress each directory
user $
cd /run/media/__user__/BOOT
user $
tar cvfz $HOME/temp/beagleplay-gentoo-boot.tar.gz *
user $
cd ~
root #
cd /mnt
root #
tar cfvz /usr/src/arm64/BeaglePlayRootfs.tar.gz *
The size of this file is around 11.9G. To create a new image use a partition like this and decompress the directories one them
Disque /dev/sdd : 59,48 GiB, 63864569856 octets, 124735488 secteurs Modèle de disque : MassStorageClass Unités : secteur de 1 × 512 = 512 octets Taille de secteur (logique / physique) : 512 octets / 512 octets taille d'E/S (minimale / optimale) : 512 octets / 512 octets Type d'étiquette de disque : dos Identifiant de disque : 0x17da849f
Périphérique Amorçage Début Fin Secteurs Taille Id Type /dev/sdd1 * 2048 526335 524288 256M c W95 FAT32 (LBA) /dev/sdd2 526336 4720639 4194304 2G 82 partition d'échange Linux / Solaris /dev/sdd3 4720640 124735487 120014848 57,2G 83 Linux