Dear all,
I am trying to have the kernel ad5360 module available (for communicating via SPI to a bipolar multi-channel DAC).
I could not find an updated guide for compiling a kernel, so I report here my FAILED attempt, hoping that you can suggest me how to succeed.
On a side note, for compiling a custom kernel, it would be convenient to have on the Olimex repository also the linux-headers-* and the linux-source-* packages (suggested also here (https://github.com/OLIMEX/OLINUXINO/issues/99)).
I performed these steps directly on the target A64-OLinuXino-2Ge8G-IND in order to not worry with the cross-compilation stuff.
1) make a backup of your /boot/kernel.itb file (it was verrrry useful for recovering the broken system)
cp /boot/kernel.itb /boot/kernel.itb-20231116
2) get the source code
mkdir ~/kernel
cd ~/kernel
git clone --depth=1 https://github.com/OLIMEX/linux-olimex -b release-20230725-v5.10.180
The specified branch points to the latest available code in that repository as of today.
I specified --depth=1 to avoid overheating, swapping and rebooting of the A64-olinuxino (anyway the box was open and I installed a huge heat sink (https://www.adafruit.com/product/3082) (that fits perfectly inside the black metal box)).
cd linux-olimex
3) apply the current kernel configuration
cp /proc/config.gz .
gunzip config.gz
mv config .config
make oldconfig
4) select the wanted modules
make menuconfig
...look for the module and select it...
5) compile it as a Debian package
To package the new kernel as a .deb package seems the most convenient option to me. Found the command here (https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-building).
make bindeb-pkg KDEB_PKGVERSION=$(make kernelversion)-1
6) install the package with dpkg
cd ..
dpkg -i linux-image-5.10.180-olimex+_5.10.180-1_arm64.deb
7) reboot
(actually the reboot often fails for me (approx 50% of times), I have to poweroff (from the OS), then unplug and plug again)
8) hit the problem
In my case the system was stuck at the bootloader. Connecting a serial-to-USB adapter, I saw these messages:
[...]
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot/boot.scr
2274 bytes read in 2 ms (1.1 MiB/s)
## Executing script at 4fc00000
U-boot loaded from SD
Boot script loaded from mmc
Checking for /uEnv.txt...
Checking for /boot/uEnv.txt...
610 bytes read in 1 ms (595.7 KiB/s)
Loaded environment from /boot/uEnv.txt
Loading FIT image...
37739691 bytes read in 1618 ms (22.2 MiB/s)
## Loading kernel from FIT Image at 58000000 ...
Using 'config-8861' configuration
Trying 'kernel-1' kernel subimage
Description: Linux kernel 5.10.180-olimex+
Type: Kernel Image
Compression: uncompressed
Data Start: 0x580000d4
Data Size: 20051976 Bytes = 19.1 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x40080000
Entry Point: 0x40080000
Hash algo: crc32
Hash value: 62c3ae8d
Hash algo: sha1
Hash value: 4a758e3a90da6390220db741fb285add5cd708fb
Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading ramdisk from FIT Image at 58000000 ...
Using 'config-8861' configuration
Trying 'ramdisk-1' ramdisk subimage
Description: Ramdisk for kernel 5.10.180-olimex+
Type: RAMDisk Image
Compression: Unknown Compression
Data Start: 0x5931fa14
Data Size: 17536353 Bytes = 16.7 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x4fe00000
Entry Point: 0x4fe00000
Hash algo: crc32
Hash value: 6fc8f1a9
Hash algo: sha1
Hash value: 9b5bef05889c72d7e7c03a5d818834af2a634209
Verifying Hash Integrity ... crc32+ sha1+ OK
Loading ramdisk from 0x5931fa14 to 0x4fe00000
WARNING: 'compression' nodes for ramdisks are deprecated, please fix
your .its file!
## Loading fdt from FIT Image at 58000000 ...
Using 'config-8861' configuration
Trying 'fdt-3' fdt subimage
Description: unavailable
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x5a3e762c
Data Size: 28737 Bytes = 28.1 KiB
Architecture: AArch64
Load Address: 0x4fa00000
Hash algo: crc32
Hash value: 8812a397
Hash algo: sha1
Hash value: e7381def5b4518beef225212a863c0ce5e13f53e
Verifying Hash Integrity ... crc32+ sha1+ OK
Loading fdt from 0x5a3e762c to 0x4fa00000
## Loading fdt from FIT Image at 58000000 ...
Trying 'overlay-1' fdt subimage
Description: unavailable
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x5a3fcec4
Data Size: 330 Bytes = 330 Bytes
Architecture: AArch64
Load Address: 0x4fa10000
Hash algo: crc32
Hash value: 4feb8819
Hash algo: sha1
Hash value: 5a2294834f1bb2916cdbcde98423a535ef16022f
Verifying Hash Integrity ... crc32+ sha1+ OK
Loading fdt from 0x5a3fcec4 to 0x4fa10000
failed on fdt_overlay_apply(): FDT_ERR_NOTFOUND
base fdt does did not have a /__symbols__ node
make sure you've compiled with -@
Could not find a valid device tree
SCRIPT FAILED: continuing...
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Scanning disk mmc@1c0f000.blk...
** Unrecognized filesystem type **
[...]
9) restore your working system
in order to recover the system I powered it off, took out the SD memory card, plugged it to my laptop and restored the backup of the /boot/kernel.itb file.
Then it booted fine, I removed the custom kernel using apt
apt remove linux-image-5.10.180-olimex+
and reinstalled the official kernel using
apt reinstall linux-image-5.10.180-olimex
What am I doing wrong?
Where can I find the right kernel compilation guide?
Just realized that there is a guide for this at the end of the Olimage-guide document (https://github.com/OLIMEX/OLINUXINO/tree/master/DOCUMENTS/OLIMAGE)!
Comparing what I did with those instructions, seems I was missing the
DTC_FLAGS=-@
flag in my make command.
Will try and confirm here if it works.