WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to get staging overlays working on v13.1  (Read 734 times)

Offline juliannojungle

  • Newbie
  • *
  • Posts: 6
How to get staging overlays working on v13.1
« on: July 06, 2022, 04:46:59 PM »
I created an overlay https://github.com/juliannojungle/gc9a01-overlay that works perfectly on Raspberry Pi OS: just save the ".dtbo" file on "/boot/overlays", add the "dtoverlay=gc9a01" line on "config.txt" and the "fb1" framebuffer is created. After that, I can use e.g. fbcp to replicate HDMI output on LCD attached to spi0.

I just can't replicate the same on TinyCore and I would like to ask for help.

The far I could get:
- My overlay depends on fbtft and I know that it's on staging directory on TinyCore's kernel source, but I don't know how to build the kernel or what I need to do to include fbtft;
- Used these steps https://gist.github.com/juliannojungle/febb80e292616c65acda65c448f14510#load-staging-modules-as-extensions to create a tcz extension from the needed modules and now I can insmod the modules and they got listed with lsmod;
- Don't know hot to load the overlay afterwards, because TinyCore doesn't include "dtoverlay" binary, so I could "sudo dtoverlay -v -d . gc9a01.dtbo".

What else can I try? How to properly load my overlay on boot, using "config.txt"?

Thanks!

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 375
Re: How to get staging overlays working on v13.1
« Reply #1 on: July 06, 2022, 05:50:48 PM »
$ tce, (p)rovides, type dtoverlay

Should give rpi-vc.tcz

If rpi-vc.tcz is there, it will give you dtoverlay and other video core files.

Offline juliannojungle

  • Newbie
  • *
  • Posts: 6
Re: How to get staging overlays working on v13.1
« Reply #2 on: July 07, 2022, 09:43:07 AM »
Thank you Greg for the great help!

I might be wrong, but it seems to be something weird with `rpi-vc.tcz` package.
I did a `tce-load -wi rpi-vc` and it installed ok. Then I did the following:

Code: [Select]
tc@box:~$ ls gc*
gc9a01.dtbo
tc@box:~$ sudo dtoverlay -v -d . gc9a01.dtbo
run_cmd: mount -t configfs none '/config/device-tree'
mount: mounting none on /config/device-tree failed: No such file or directory
* Failed to mount configfs - 2

Searched for references and found this message with some tips on how to manually mount the device-tree: http://forum.tinycorelinux.net/index.php/topic,20260.msg126105.html#msg126105

Code: [Select]
tc@box:~$ sudo mkdir -p /config/device-tree
tc@box:~$ sudo mount -t configfs none /sys/kernel/config
tc@box:~$ sudo dtoverlay -v -d . gc9a01.dtbo
DTOVERLAY[debug]: using platform 'bcm2835'
DTOVERLAY[debug]: overlay map not loaded
run_cmd: which dtoverlay-pre >/dev/null 2>&1 && dtoverlay-pre
sh: dtoverlay-pre: not found
DTOVERLAY[debug]: loading file 'gc9a01.dtbo'
DTOVERLAY[debug]: wrote 2468 bytes to '/tmp/.dtoverlays/0_gc9a01.dtbo'
DTOVERLAY[debug]: wrote 2468 bytes to '/sys/kernel/config/device-tree/overlays/0_gc9a01/dtbo'
run_cmd: which dtoverlay-post >/dev/null 2>&1 && dtoverlay-post
sh: dtoverlay-post: not found

`dtoverlay-pre` and `dtoverlay-post` where not found, but they are both present:

Code: [Select]
tc@box:~$ ls -l /usr/local/bin/dtoverlay*
lrwxrwxrwx    1 root     root            42 Jan  1 00:00 /usr/local/bin/dtoverlay -> /tmp/tcloop/rpi-vc/usr/local/bin/dtoverlay
lrwxrwxrwx    1 root     root            47 Jan  1 00:00 /usr/local/bin/dtoverlay-post -> /tmp/tcloop/rpi-vc/usr/local/bin/dtoverlay-post
lrwxrwxrwx    1 root     root            46 Jan  1 00:00 /usr/local/bin/dtoverlay-pre -> /tmp/tcloop/rpi-vc/usr/local/bin/dtoverlay-pre
tc@box:~$ ls -l /tmp/tcloop/rpi-vc/usr/local/bin/dtoverlay*
-rwxr-xr-x    1 tc       staff        23872 May 29  2021 /tmp/tcloop/rpi-vc/usr/local/bin/dtoverlay
-rwxr-xr-x    1 tc       staff          282 May 29  2021 /tmp/tcloop/rpi-vc/usr/local/bin/dtoverlay-post
-rwxr-xr-x    1 tc       staff          280 May 29  2021 /tmp/tcloop/rpi-vc/usr/local/bin/dtoverlay-pre

Looks like with `dtoverlay-pre` and `dtoverlay-post` not running, the overlay is not loading properly as the device is not completely initiated (it's a lcd screen and even though it now have image, the backlight still completely off). Maybe I'm missing something here, maybe that GPIO pin is in use by something else and it's not related to `dtoverlay-pre` and `dtoverlay-post`...

Any tips please? Thanks a lot!

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 842
Re: How to get staging overlays working on v13.1
« Reply #3 on: July 07, 2022, 01:31:51 PM »
You are likely using commands setup for raspiOS.   You will have to modify them for piCore.

By far the easiest way is to mount the boot partition.  copy your dtbo into the overlays folder, then add the appropreate dtoverlay=xxxxx to the config.txt, and then reboot your system.   You obviously also need to make sure the drivers are loaded in an extension

There are also overlays supplied with the image that might be helpful too.
https://github.com/raspberrypi/linux/blob/2a4746398db05d1d71e00c8f2cccdb85b2d3ca3c/arch/arm/boot/dts/overlays/README#L912

Many screen drivers do not support backlight controls.   Just update the gpio pin that the backlight is connected to manually.

« Last Edit: July 07, 2022, 01:36:06 PM by Paul_123 »

Offline juliannojungle

  • Newbie
  • *
  • Posts: 6
Re: How to get staging overlays working on v13.1
« Reply #4 on: July 08, 2022, 05:03:57 PM »
Wow, how did I miss that? Thanks for the heads up, Paul.

It was indeed the very first thing I tried, but since the kernel modules weren't present, it obviously wouldn't work. After I figured how to load them as tcz extensions, I tried to manually load the overlay (for tests purposes) and fell down so deep into that road that completely forgot to test the very first setup again (but now with working video modules).

I got the screen working nicely now. For future references, I created a tutorial to make the process easy to be replicated:
https://github.com/juliannojungle/gc9a01-tinycorelinux-tcz

Btw: this driver overlay does have support for backlight control, but I'll deal with it not working on TinyCore later. Right now I need to learn how to rebuild the kernel with the desired modules included to improve boot time.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 842
Re: How to get staging overlays working on v13.1
« Reply #5 on: July 08, 2022, 05:15:27 PM »
Probably need the backlight kernel module then.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10364
Re: How to get staging overlays working on v13.1
« Reply #6 on: July 08, 2022, 06:48:31 PM »
Hi juliannojungle
... Right now I need to learn how to rebuild the kernel with the desired modules included to improve boot time.
Or you could add the modules to the  .img  file.
Here are some posts that may be of use to you:
Resizing a  .img  file
http://forum.tinycorelinux.net/index.php/topic,24015.msg151428.html#msg151428
Mounting a  .img  file
http://forum.tinycorelinux.net/index.php/topic,24063.msg151721.html#msg151721
Modifying a  modules.gz  file
http://forum.tinycorelinux.net/index.php/topic,23447.msg146916.html#msg146916
A thread about remastering piCore
http://forum.tinycorelinux.net/index.php/topic,25171.0.html

Offline juliannojungle

  • Newbie
  • *
  • Posts: 6
Re: How to get staging overlays working on v13.1
« Reply #7 on: July 10, 2022, 12:22:29 PM »
@Paul_123 I just tried that without luck.
I've created another tcz with backlight.ko and it's module gets listed properly on lsmod after boot.
Tested the pin with a multimeter: As soon the Raspberry Pi gets powered on, the GPIO pin 18 (physical pin 12) is HIGH, but as soon the driver gets loaded, the pin gets LOW.
Also just confirmed that this does not happen when running Raspberry Pi OS: The pin starts HIGH and stays that way after the driver initiates. Maybe I'm still missing something?

===

@Rich that sounds pretty interesting! I'll for sure give it a try later today.

My goal is to show a custom splash screen during the boot process and after that my app takes over. Right now, the display is taking 16 seconds to show something (when the boot process is almost done). This is not desireble since the user gets 16 seconds of black screen, could misunderstand and perhaps power cycle.

Explaining the full picture: the video driver loaded only gives me fb1 ready to use, but to actually show something on the screen I need to run fbcp or something to mirror fb0 to fb1. At the moment, I'm calling "fbcp&" from "bootlocal.sh".

Is there any proper way to have image faster and let the system boot afterwards?
It would be the perfect scenario if the image could get to the screen as soon as the Raspberry gets power (like that rainbow screen that we have on HDMI/fb0). Can it be done?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 842
Re: How to get staging overlays working on v13.1
« Reply #8 on: July 10, 2022, 12:56:16 PM »
Put anything that you need at boot in an initrd, and add it to the initramfs line in the config.txt.  There is an 80character line limit , so keep the file name small, but you can load as many initrd files as you want.

The upside, is that your files/drivers are available at boot.   The downside is that the initrd is loaded into RAM, so the more files, the less ram available.

Now back to the backlight.   There is no difference between how RaspiOS and piCore handles overlays, that is a function of the kernel, which is the same.  The difference is making sure you have the appropriate drivers available.  Since you have  RaspiOS system, Take a look at all of the modules that are loaded.. 

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10364
Re: How to get staging overlays working on v13.1
« Reply #9 on: July 10, 2022, 01:36:45 PM »
Hi juliannojungle
... Is there any proper way to have image faster and let the system boot afterwards? ...
I believe the fourth link I posted (A thread about remastering piCore) deals with what you are looking to do.