Dev/OPi/OPiZeroPlus/From Scratch: Difference between revisions
(Created page with "== ARM trusted firmware == You can generate it following the instructions from the file board/sunxi/README.sunxi64 from u-boot sources (see below) or get it directly [http://d...") |
(→Use) |
||
Line 45: | Line 45: | ||
=== Use === | === Use === | ||
* Linux Kernel | * Linux Kernel | ||
Compilation result is in arch/arm64/boot/Image | Compilation result is in arch/arm64/boot/Image | ||
* Device tree | * Device tree | ||
Use the sun50i-h5-orangepi-zero-plus-ed3l.dtb (found in arch/arm64/boot/dts/allwinner/) | Use the sun50i-h5-orangepi-zero-plus-ed3l.dtb (found in arch/arm64/boot/dts/allwinner/) |
Latest revision as of 19:02, 27 July 2022
ARM trusted firmware
You can generate it following the instructions from the file board/sunxi/README.sunxi64 from u-boot sources (see below) or get it directly from here.
git clone https://github.com/ARM-software/arm-trusted-firmware.git cd arm-trusted-firmware make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_a64 DEBUG=1 bl31
Result is in build/sun50i_a64/debug/bl31.bin
U-boot
Grab the sources
This is the repository from megous (linux-sunxi.org Wiki)
git clone https://megous.com/git/u-boot/ cd u-boot/ git checkout
Compile
Note: fix the path (or use the right path) to your bl31.bin firmware
make CROSS_COMPILE=aarch64-linux-gnu- orangepi_zero_plus_defconfig export BL31=/path/to/arm-trusted-firmware/bl31.bin ##../arm-trusted-firmware/build/sun50i_a64/debug/bl31.bin make -j8 CROSS_COMPILE=aarch64-linux-gnu-
Note: you can customize your u-boot configuration by using a make menuconfig, or get my config_uboot_ed3l_*** and save the file as ".config" in u-boot sources directory and then make oldconfig.
Use
Erase the first Mo of the SD card while keeping the partition table:
dd if=/dev/zero of=${card} bs=1k count=1023 seek=1
Copy uboot image (SPL + ATF + second stage) to the SD card:
dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1k seek=8
Linux Kernel
Grab the sources
- Kernel from kernel.org
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
I'll need to document the differences or provide the patches between vanilla kernel and mine.
- Configuration file : config_5.19.0_***-ed3l
Compile
mkdir -p Build/{linux,results} cd linux cp config_5.19.0_2022-07-26-ed3l ../opizeroplus/Build/linux/.config make ARCH=arm64 -j8 O=../opizeroplus/Build/linux/ oldconfig cd ../opizeroplus/Build/linux/ make ARCH=arm64 -j8 CROSS_COMPILE=aarch64-linux-gnu- make ARCH=arm64 -j8 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=../results/Mods
Use
- Linux Kernel
Compilation result is in arch/arm64/boot/Image
- Device tree
Use the sun50i-h5-orangepi-zero-plus-ed3l.dtb (found in arch/arm64/boot/dts/allwinner/)
- Modules
If the compilation has been performed using the above command lines you should have a directory "Build/Mods/lib/modules/***" (*** = name of the kernel you just compiled)
You must copy the whole directory (not only the content) on the SD card, in the partition holding the root filesystem (rootfs), in the /lib/modules/ directory without changing the name.
SD Card creation
Original information from linux-sunxi wiki
SD card architecture
start | sector | size | usage |
---|---|---|---|
0KB | 0 | 8KB | Unused, available for an MBR or (limited) GPT partition table |
8KB | 16 | 32KB | Initial SPL loader |
40KB | 80 | - | U-Boot |
Typically partitions start at XXXMB (which is the default setting of most partitioning tools), but there is no hard requirement for this, so U-Boot can grow bigger than 984KB, if needed.
Cleaning
Erase the first Mo of the SD card while keeping the partition table:
dd if=/dev/zero of=${card} bs=1k count=1023 seek=1
(Use count=1024 and remove "seek" option to also erase the partition table)
Bootloader
Copy (dd) uboot images (u-boot-sunxi-with-spl.bin) to the SD card. Refer to "U-boot/Use" section above.
First partition
The first partition must start at +XXXMo, and be a few Mo (50 Mo should be OK) and be formated using ext2/3/4
Place the files "Image-5.19.0-ed3l", "sun50i-h5-orangepi-zero-plus-ed3l.dtb" and "boot.scr" on the first partition.
- The file "boot.scr" is generated using mkimage from "boot.cmd" with the following command :
mkimage -C none -A arm -T script -d boot.cmd boot.scr
An example "boot.cmd" file can be found in boot_devuan_ceres_***.tar.bz2
A short one can look like this :
setenv kernel_image "Image-5.19.0-ed3l" setenv fdtfile "sun50i-h5-orangepi-zero-plus-ed3l.dtb" setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait quiet" load ${devtype} ${devnum} ${fdt_addr_r} ${fdtfile} load ${devtype} ${devnum} ${kernel_addr_r} ${kernel_image} booti ${kernel_addr_r} - ${fdt_addr_r}
Second partition
The second partition must be formated using ext4 and starts right after the first one. It can take all the remaining size unless you have other specific needs.
This partition holds the root filesystem (rootfs).
Rootfs
This board uses an ARM64 processor, thus the root filesystem should be built using "aarch64-linux-gnu-" cross-toolchain or use the arm64 architecture for Devuan or other Debian based distribution.
Refer to the rootfs creation page for more information. You should find a base Devuan rootfs here : rootfs_devuan_ceres_arm64_***.tar.bz2.