milkv-duo / duo-buildroot-sdk

Milk-V Duo Official buildroot SDK
386 stars 168 forks source link

Missing support for RPi camera (sensor IMX219) #123

Open silentjet opened 1 month ago

silentjet commented 1 month ago

RPi camera module of the first version is rather rarely available these days, instead the most common is RPi camera module v2, which uses a different sensor - IMX219. Please add the support for this camera module.... Also it would be nice to add IMX708 as well

piotr-defendeye commented 1 month ago

Bump

Gety0 commented 1 month ago

I just today hooked it up expecting it to work right away, but: init middleware failed! ret=ffffffff. The cameras should have identical pin-outs. It seems some drivers are already out there: IMX219 driver for linux(github.com)

Gety0 commented 1 month ago

After a bit of digging i found out there are "traces" of it in Milk-v buildroot: https://github.com/milkv-duo/duo-buildroot-sdk/blob/99f93483206a0691a3b5d1afe0aa5db4816c4e6d/linux_5.10/drivers/media/i2c/imx219.c#L121

I am not too good at Milk-V embedded Linux OS but maybe we only need to add an appropriate configuration "sensor_cfg.ini" to /mnt/data/sensor_cfg.ini in order to make it work... I will tinker with this later and report if i there is more progress after creating the correct .ini... I do not know if the lane_id is the same or not, but i would not know where to look to find out... I do not know if i need to pinmux stuff to make the camera work etc. I know that in order to use I2C one has to pinmux the SDA,SCL pins. Disregarding all worries, the github link above suggests that it should be pretty much plug and play.

edit this is the file i came up with, will test later and report if it works or not:

edit2 it does not work unfortunately. i do not have an rpi to confirm if the camera is even functional, so i am going to stop here... Hope this helps someone

sensor_cfg.ini

;section for source
[source]
type = SOURCE_MIPI_2M_30FPS_10BIT
dev_num = 1

;section for sensor
[sensor]
name = OV_IMX219_MIPI_8MP_30FPS_10BIT
bus_id = 2
sns_i2c_addr = 0x10
mipi_dev = 0
lane_id = 5, 3, 4, -1, -1
pn_swap = 0, 0, 0, 0, 0
silentjet commented 1 month ago

So when we talk about different RPI cameras on a physical level (by pin designation) they are the same or compatible. What IS different is a sensor's bus configuration, because the configuration depends on the sensor hardware. Normally it shall be configured via device tree files (remember that Rpi's *.dtbo files?), but here is taken a different approach...

piotr-defendeye commented 3 weeks ago

Has anyone had any success with this?

raphaelscholle commented 1 week ago

getting new cameras working is really hard and expensive, I did glance at this repo a while, but didn't really work on anything here. Usually I'll just write a device tree overlay and make the driver work, (everything else is usually commissioned).But it looks like this is a little different.

raphaelscholle commented 1 week ago

you also forget something important .. the rpi-mipi-csi port is 3.3V logic level, the civitec one is 1.8, so a adapter should always be needed