Odroid-C2: Difference between revisions

From Alpine Linux
m (Kernel assembly)
m (DVFS for s905)
Line 80: Line 80:
echo CONFIG_BLK_DEV_RAM_SIZE=4096 >> .config
echo CONFIG_BLK_DEV_RAM_SIZE=4096 >> .config
</pre>
</pre>
If you want to enable DVFS for the s905 amlogic cpu :
<pre>
git apply --ignore-space-change --ignore-whitespace - << EOF
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index 201596247..027df3756 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -348,7 +348,8 @@ &saradc {
};
&scpi_clocks {
-      status = "disabled";
+      /* Works only with new blobs that have limited DVFS table */
+      status = "okay";
};
/* SD */
EOF
</pe>


The, build your kernel, associated modules and the [https://elinux.org/Device_Tree_Reference#What_Is_Device_Tree DTB] (Device Tree Blob) from the source :
The, build your kernel, associated modules and the [https://elinux.org/Device_Tree_Reference#What_Is_Device_Tree DTB] (Device Tree Blob) from the source :
Line 95: Line 115:
rm -rf installed-modules
rm -rf installed-modules
</pre>
</pre>


==Assembly==
==Assembly==

Revision as of 19:49, 5 April 2022

This material needs wiki syntax or style improvements ...

Please feel free to help us clean it up.

(Parts of this page are WIP, still incomplete and some might be incorrect.)

Introduction

The Odroid-C2 single board computer is not very well supported by Alpine/Linux. However the "Generic ARM (aarch64)" build contains almost everything we need !


What do we need ?

  • kernel : provided kernel by the Alpine team does not boot
  • u-boot : provided u-boot does not autoboot without serial
  • system files : everything is okay


On the hardware side:

  • Odroid-C2
  • Official PSU or just a micro-SD cable (notes : the barrel plug (inner(positive) diameter 0.8mm and outer(negative) diameter 2.5mm) is recommended, without the J1 jumper)
  • micro-SD (or eMMC)
  • USB to TTL (official or CP2102 chipset or an old rpi)


Required environement and toolchain

Using GNU/Linux is recommended and this guide and here are the required dependencies, for Debian (as example) :

apt install bc bison flex make gcc gcc-aarch64-linux-gnu libssl-dev libncurses-dev git squashfs-tools

We need to set specific environment variables IF you are not using an arm64 machine. Usually, you should be running on a x64 architecture (Intel or AMD I guess), so you would like to cross-compile.

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu

Build u-boot from source

We need to build uboot from source as the u-boot provided does not autoboot without UART connected.

git clone --depth 1 https://source.denx.de/u-boot/u-boot.git -b v2022.01 u-boot-denx.de
cd u-boot-denx.de
export ARCH=arm64 && export CROSS_COMPILE=aarch64-linux-gnu-
make mrproper && make odroid-c2_defconfig

We used the specific deconfig for the Odroid-C2 but, as mentionned before : we want to autoboot with or without UART connection. You can still access the SPL prompt by pressing the 'Enter' key twice before the two seconds countdown.

sed -i -e 's/.*CONFIG_SD_BOOT.*/CONFIG_SD_BOOT=y/' .config
sed -i -e 's/.*CONFIG_AUTOBOOT_KEYED .*/CONFIG_AUTOBOOT_KEYED=y/' .config
echo "CONFIG_AUTOBOOT_FLUSH_STDIN=y" >> .config
echo "CONFIG_AUTOBOOT_PROMPT="Press quickly 'Enter' twice to stop autoboot: %d\n"" >> .config
echo "# CONFIG_AUTOBOOT_ENCRYPTION is not set" >> .config
echo "CONFIG_AUTOBOOT_DELAY_STR=""" >> .config
echo "CONFIG_AUTOBOOT_STOP_STR="\xd\xd"" >> .config
echo "CONFIG_AUTOBOOT_KEYED_CTRLC=y" >> .config

Then, it's time to build :

time make -j$(nproc)

Amlogic doesn’t provide sources for the firmware and for tools needed to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor. Work in progress


Build the latest LTS kernel from source

git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git -b linux-5.15.y linux-stable
cd linux-stable
export ARCH=arm64 && export CROSS_COMPILE=aarch64-linux-gnu-
make mrproper && make defconfig

We need to adapt the default arm64 generated by defconfig. This configuration is required for Alpine/Linux and not enabled by default.

sed -i -e 's/.*CONFIG_SQUASHFS_XZ.*/CONFIG_SQUASHFS_XZ=y/' .config
sed -i -e 's/.*CONFIG_UEVENT_HELPER.*/CONFIG_UEVENT_HELPER=y/' .config
sed -i -e 's/.*CONFIG_BLK_DEV_RAM.*/CONFIG_BLK_DEV_RAM=y/' .config
echo CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\" >> .config
echo CONFIG_BLK_DEV_RAM_COUNT=16 >> .config
echo CONFIG_BLK_DEV_RAM_SIZE=4096 >> .config

If you want to enable DVFS for the s905 amlogic cpu :

git apply --ignore-space-change --ignore-whitespace - << EOF
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index 201596247..027df3756 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -348,7 +348,8 @@ &saradc {
 };

 &scpi_clocks {
-       status = "disabled";
+       /* Works only with new blobs that have limited DVFS table */
+       status = "okay";
 };

 /* SD */
EOF
</pe>

The, build your kernel, associated modules and the [https://elinux.org/Device_Tree_Reference#What_Is_Device_Tree DTB] (Device Tree Blob) from the source :
<pre>
time make -j$(nproc) Image dtbs modules

Create modloop:

rm -rf installed-modules && mkdir installed-modules
INSTALL_MOD_PATH=installed-modules make modules_install
find installed-modules -type l -delete
rm -f modloop
mksquashfs installed-modules/lib/ modloop -b 1048576 -comp xz -Xdict-size 100% -all-root
rm -rf installed-modules

Assembly

Kernel part:

DST="/mnt/mmcblk0p1"
gzip -c arch/arm64/boot/Image > ${DST}/vmlinuz
cp .config ${DST}/config
cp modloop ${DST}/modloop
cp System.map ${DST}/System.map

System part: Work in progress


Booting

Work in progress


Troubleshooting

Work in progress