On the default installation of ubuntu, the only way to add overlays is with grub. The default ubuntu is configured to load the devicetree overlays with grub. So if we want to add overlays, we need to change the grub.
To add a new entry on the grub we need to go to /etc/grub.d/40_custom
and there we put the entry we want. The best way is to copy the same information that is in /boot/grub/grub.cfg regarding to the OS, like:
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-90836834-7e07-48ca-b0f9-29880429770d' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 90836834-7e07-48ca-b0f9-29880429770d
echo 'Loading Linux 5.19.0-1015-allwinner ...'
linux /boot/vmlinuz-5.19.0-1015-allwinner root=/dev/mmcblk0p1 ro quiet splash
echo 'Loading device tree blob...'
devicetree /boot/dtb
}
My modified version would be:
menuentry 'UbuntuWithOverlays' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'ubuntu-custom-overlay'' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root 90836834-7e07-48ca-b0f9-29880429770d
echo 'Loading Linux 5.17.0-1003-allwinner ...'
linux /boot/vmlinuz-5.17.0-1003-allwinner root=LABEL=cloudimg-rootfs ro quiet splash
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-5.17.0-1003-allwinner
echo 'Loading device tree blob...'
devicetree /boot/overlay/my_overlay.dtb
}
- To make that entry the default in grub you need to add
GRUB_DEFAULT="ubuntu-custom-overlay"
to/etc/default/grub
.
After some testing I realized that there can be only one command of devicetree, it is not supported the overlays, the comfiguration is cleaned in every devicetree command. But you can get the original devicetree, modify and put it in the command, that works.
Dont forget to do update-grub
after.