Odroid-C2: Difference between revisions

From Alpine Linux
No edit summary
No edit summary
Line 23: Line 23:


==Required environement and toolchain==
==Required environement and toolchain==
Using GNU/Linux is recommended and this guide and here are the required dependencies:
Using GNU/Linux is recommended and this guide and here are the required dependencies, for Debian (as example) :
Example on debian :
<pre>
<pre>
apt install bc bison flex make gcc gcc-aarch64-linux-gnu libncurses-dev git
apt install bc bison flex make gcc gcc-aarch64-linux-gnu libncurses-dev git
</pre>
</pre>
Environement variables
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.
<pre>
<pre>
export ARCH=arm64
export ARCH=arm64
Line 35: Line 34:


==Build u-boot from source==
==Build u-boot from source==
We need to build uboot from source as the u-boot provided does not autoboot without UART connected.
<pre>
<pre>
git clone --depth 1 https://source.denx.de/u-boot/u-boot.git -b v2022.01 u-boot-denx.de
git clone --depth 1 https://source.denx.de/u-boot/u-boot.git -b v2022.01 u-boot-denx.de
Line 41: Line 41:
make mrproper && make odroid-c2_defconfig
make mrproper && make odroid-c2_defconfig
</pre>
</pre>
Change boot options:
TODO : remove lines
< # CONFIG_AUTOBOOT_KEYED is not set
< # CONFIG_AUTOBOOT_USE_MENUKEY is not set


Patch default configuration:
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.
<pre>
<pre>
sed -i -e 's/.*CONFIG_SD_BOOT.*/CONFIG_SD_BOOT=y/' .config
sed -i -e 's/.*CONFIG_SD_BOOT.*/CONFIG_SD_BOOT=y/' .config
echo "CONFIG_AUTOBOOT_KEYED=y" >> .config
sed -i -e 's/.*CONFIG_AUTOBOOT_KEYED .*/CONFIG_AUTOBOOT_KEYED=y/' .config
echo "CONFIG_AUTOBOOT_FLUSH_STDIN=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_PROMPT="Press quickly 'Enter' twice to stop autoboot: %d\n"" >> .config
Line 57: Line 54:
echo "CONFIG_AUTOBOOT_KEYED_CTRLC=y" >> .config
echo "CONFIG_AUTOBOOT_KEYED_CTRLC=y" >> .config
</pre>
</pre>
Build time:
 
Then, it's time to build :
<pre>
<pre>
time make -j$(nproc)
time make -j$(nproc)
</pre>
</pre>


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''




Line 70: Line 70:
make mrproper && make defconfig
make mrproper && make defconfig
</pre>
</pre>
We need to adapt the default arm64 generated by defconfig
We need to adapt the default arm64 generated by defconfig. This configuration is required for Alpine/Linux and not enabled by default.
<pre>
<pre>
sed -i -e 's/.*CONFIG_SQUASHFS_XZ.*/CONFIG_SQUASHFS_XZ=y/' .config
sed -i -e 's/.*CONFIG_SQUASHFS_XZ.*/CONFIG_SQUASHFS_XZ=y/' .config
Line 80: Line 80:
</pre>
</pre>


Build the kernel:
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>
<pre>
time make -j$(nproc) Image dtbs modules
time make -j$(nproc) Image dtbs modules

Revision as of 19:45, 22 March 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 libncurses-dev git

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.154.y linux-stable
cd linux-stable
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

The, build your kernel, associated modules and the DTB (Device Tree Blob) from the source :

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

Work in progress


Booting

Work in progress


Troubleshooting

Work in progress