Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: mistakenot... on January 21, 2024, 07:20:22 AM
-
Hi,
I have a Pi Zero W V1.1 and a ZeroCam NoIR.
I believe the ZerCam uses the 5Mpixel OV5647 camera as used in the official RPi V1 camera. With that in mind the end of my config.txt looks like this (the rest is as supplied in piCore 14.1):
[all]
dtoverlay=ov5647
start_x=1
gpu_mem=128
Actually I've tried various things in config.txt including removing the ov5647 overlay which didn't seem necessary in other forum posts.
I have libcamera.tcz and libcamera-apps.tcz installed and have added the following as per libcarea.tcz.info
tc@box:~$ sudo chown tc:staff /dev/media*
tc@box:~$ sudo chown tc:staff /dev/dma_heap/*
tc@box:~$ ls -l /dev/media*
crw------- 1 tc staff 242, 0 Jan 1 1970 /dev/media0
crw------- 1 tc staff 242, 1 Jan 1 1970 /dev/media1
crw------- 1 tc staff 242, 2 Jan 1 1970 /dev/media2
I get the following with libcamera-hello:
tc@box:~$ libcamera-hello -n
[0:04:00.730156000] [1669] INFO Camera camera_manager.cpp:293 libcamera v0.0.1+1-f4201e96
ERROR: *** no cameras available ***
I don't know that the ZeroCam works with other OSes, soon as I can get my hands on another sd card I'll test that. Meanwhile...any clues?
Cheers
-
I suggest you should start with Raspberry Pi OS, and get it working, with your camera.
And then you should try to get all info how to get it working, like what kernel modules was loaded and so on.
And what config.txt contains.
Then you could try to implement the same concept to picore.
-
Found an SD card. Brilliant. Good news is that the camera works with the latest raspberry pi lite os.
Here's the output of libcamera-hello on the Raspberry Pi OS:
pi@test:~ $ libcamera-hello -n
[0:38:34.309563252] [1281] INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e
[0:38:34.580764632] [1286] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:38:34.603822834] [1286] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media1
[0:38:34.606098854] [1286] INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
Mode selection for 1296:972:12:P
SGBRG10_CSI2P,640x480/0 - Score: 3296
SGBRG10_CSI2P,1296x972/0 - Score: 1000
SGBRG10_CSI2P,1920x1080/0 - Score: 1349.67
SGBRG10_CSI2P,2592x1944/0 - Score: 1567
Stream configuration adjusted
[0:38:34.638816142] [1281] INFO Camera camera.cpp:1183 configuring streams: (0) 1296x972-YUV420 (1) 1296x972-SGBRG10_CSI2P
[0:38:34.643148180] [1286] INFO RPI vc4.cpp:608 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
And here's the config.txt:
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Additional overlays and parameters are documented
# /boot/firmware/overlays/README
# Automatically load overlays for detected cameras
camera_auto_detect=1
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Automatically load initramfs files, if found
auto_initramfs=1
# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1
# Disable compensation for displays with overscan
disable_overscan=1
# Run as fast as firmware / board allows
arm_boost=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[all]
So I've added the following (and only the following - everything else as default) to the bottom of my config.txt since it seemed relevant
camera_auto_detect=1
dtoverlay=vc4-kms-v3d
But no improvement, output of libcamera-hello in piCore is still as per the original post.
I also notice that libcamera is v0.1.0 in rpios and 0.0.1 in piCore.
-
More to add.
In rpiOS the ov5647 module is loaded, in piCore it is not. I manually add the module with modprobe but the result is unchanged.
I notice the debug output from the working libcamera-hello on RPiOS mentions i2c and furthermore I see these i2c modules loaded with lsmod:
i2c_mux_pinctrl 3610 0
i2c_mux 6207 1 i2c_mux_pinctrl
If I try to load modules by those names in piCore I get a not found in modules.dep error and I don't see those modules where I would expect them.
If I download and untar http://tinycorelinux.net/14.x/armv6/releases/RPi/src/kernel/modules-6.1.68-piCore.tar.xz I see the following:
ls -R modules-6.1.68-piCore/lib/modules/6.1.68-piCore/kernel/drivers/i2c/
modules-6.1.68-piCore/lib/modules/6.1.68-piCore/kernel/drivers/i2c/:
algos busses i2c-dev.ko i2c-mux.ko muxes
modules-6.1.68-piCore/lib/modules/6.1.68-piCore/kernel/drivers/i2c/algos:
i2c-algo-bit.ko
modules-6.1.68-piCore/lib/modules/6.1.68-piCore/kernel/drivers/i2c/busses:
i2c-bcm2708.ko i2c-gpio.ko i2c-tiny-usb.ko
i2c-bcm2835.ko i2c-robotfuzz-osif.ko
modules-6.1.68-piCore/lib/modules/6.1.68-piCore/kernel/drivers/i2c/muxes:
i2c-mux-gpmux.ko i2c-mux-pca954x.ko i2c-mux-pinctrl.ko
But if I list the modules on the installed piCore system I cannot see the i2c-mux stuff:
ls -R /lib/modules/6.1.68-piCore/kernel/drivers/i2c/
/lib/modules/6.1.68-piCore/kernel/drivers/i2c/:
algos/ busses/ i2c-dev.ko.gz
/lib/modules/6.1.68-piCore/kernel/drivers/i2c/algos:
i2c-algo-bit.ko.gz
/lib/modules/6.1.68-piCore/kernel/drivers/i2c/busses:
i2c-bcm2708.ko.gz i2c-bcm2835.ko.gz i2c-gpio.ko.gz
Is there a reason why I should not expect the modules in an installed system to be the complete set as per the modules in the source?
Incidentally, is any way to find out exactly what happens when using the camera_auto_detect=1 option in config.txt (I realise this is a more general RPi question rather than a tinyCore one but Google hasn't sorted me out)? I presume a script runs to identify the camera and work out which overlays to load but how? What is it and can I see the source?
Thanks
-
Hi mistakenot...
If you wish to package any of the kernel modules into an
extension yourself, you should be able to use this example
as a guide:
https://forum.tinycorelinux.net/index.php/topic,20195.msg154211.html#msg154211
-
First thank you for testing your camera on the working environment(raspios), so we know that camera is supported on the hardware and so on.
With your question regarding the config.txt file you can read about it on this place.
https://www.raspberrypi.com/documentation/computers/config_txt.html#camera_auto_detect (https://www.raspberrypi.com/documentation/computers/config_txt.html#camera_auto_detect)
# Automatically load overlays for detected cameras
camera_auto_detect=1
And if you scroll in your file you can also see that this has already being set.
And reading about camera in this url location they talking about camera firmware, you may looking in the dmesg log to see maybe some more info when the module is loading in in the kernel, of course in raspios.
So try to execute.
sudo dmesg
Or maybe if that return to many lines you may try to grep on some keywords like camera and so on.
sudo dmesg | grep camera
And when we also talking about the device tree, that are set via config.txt file, and some options are also set via kernel command line via the boot code, so you can also take that info, stored in proc.
So you can take this info via this command.
cat /proc/cmdline
-
I've made some progress.
I extracted some relevant i2c modules from modules-6.1.68-piCore.tar.xz and added them:
sudo depmod
sudo modprobe i2c-mux
sudo modprobe i2c-mux-pinctrl
And it works!
My bottom of my config.txt file looks like this at the moment:
dtoverlay=i2c-mux
dtoverlay=ov5647
dtoverlay=vc4-kms-v3d
But maybe it will now work with camera_auto_detect=1? More experiments, back in a bit...
-
Working after these commands
tc@box:~$ sudo cp /mnt/mmcblk0p2/tce/lib/modules/6.1.68-piCore/kernel/drivers/i2c/i2c-mux.ko /lib/modules/6.1.68-piCore/kernel/drivers/i2c/
tc@box:~$ sudo mkdir /lib/modules/6.1.68-piCore/kernel/drivers/i2c/muxes
tc@box:~$ sudo cp /mnt/mmcblk0p2/tce/lib/modules/6.1.68-piCore/kernel/drivers/i2c/muxes/i2c-mux-pinctrl.ko /lib/modules/6.1.68-piCore/kernel/drivers/i2c/muxes/
tc@box:~$ sudo depmod
tc@box:~$ sudo modprobe i2c-mux
tc@box:~$ sudo modprobe i2c-mux-pinctrl
tc@box:~$ sudo chown tc:staff /dev/media*
tc@box:~$ sudo chown tc:staff /dev/dma_heap/*
tc@box:~$ libcamera-hello
Made DRM preview window
[0:02:42.322427000] [1772] INFO Camera camera_manager.cpp:293 libcamera v0.0.1+1-f4201e96
[0:02:42.550616000] [1773] INFO RPI raspberrypi.cpp:1377 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media0
[0:02:42.558512000] [1772] INFO Camera camera.cpp:1026 configuring streams: (0) 1296x972-YUV420
[0:02:42.564587000] [1773] INFO RPI raspberrypi.cpp:764 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
and this config.txt:
camera_auto_detect=1
dtoverlay=vc4-kms-v3d
Thanks for the help so far gang. Now to get those modules into an extension...
-
Last issue I hope:
As per comments in http://tinycorelinux.net/14.x/armv6/tcz/libcamera.tcz.info by juanito
Comments: camera support library
----------
for the moment, after loading:
sudo chown tc:staff /dev/media*
sudo chown tc:staff /dev/dma_heap/*
can optionally use gst-plugins-base
I set the ownership and it works. But I want that to happen at boot time. If I put the chown commands in bootlocal.sh it doesn't work. How do I set ownership of devices automatically at boot?
Cheers
-
Hi mistakenot...
... If I put the chown commands in bootlocal.sh it doesn't work. ...
Maybe the devices don't exist yet?
Here is an example of how to test for that:
https://forum.tinycorelinux.net/index.php/topic,26667.msg171934.html#msg171934
Do you have libcamera.tcz listed in your onboot.lst file.
It probably creates those devices.
-
Comments: camera support library
----------
for the moment, after loading:
sudo chown tc:staff /dev/media*
sudo chown tc:staff /dev/dma_heap/*
can optionally use gst-plugins-base
I thought this had been fixed in the piCore udev rules - perhaps only in piCore64?
-
dma-heap is in 99-com rules
media is in 50-udev-default-rules
https://github.com/tinycorelinux/Core-scripts/blob/d5b60ea6b708e3b4ec2ac4b1a961ec7dce667395/etc/udev/rules.d/50-udev-default.rules#L49
but media only sets the guid bit. It does not change the file mode, so perhaps the newer kernel is only setting the file mode to 600
-
Maybe the devices don't exist yet?
Spot on Rich. I added this dirty fix to make bootlocal.sh wait for the devices to appear:
while [ ! -c /dev/media3 ]
do
sleep .5
done
The very slight delay of about 2 to 3 seconds is acceptable for my purpose.
Thanks ;D
-
Hi mistakenot...
There's nothing wrong with your fix. You can however
push that delay into the background if you wish.
Place this in a separate file, /opt/FixCam.sh for example:
#!/bin/sh
while [ ! -c /dev/media3 ]
do
sleep .5
done
sudo chown tc:staff /dev/media*
sudo chown tc:staff /dev/dma_heap/*
Then call it from bootlocal.sh like this:
/opt/FixCam.sh &
That will run in the background while bootlocal continues
and your desktop loads.