Become a leader in the IoT community!
New DevHeads get a 320-point leaderboard boost when joining the DevHeads IoT Integration Community. In addition to learning and advising, active community leaders are rewarded with community recognition and free tech stuff. Start your Legendary Collaboration now!
Hardware driver as in?
And does userplane program won’t work?
Show me how to add custom hardware to a embedded linux or even just a linux system
say a tof sensor over i2c
just an example
Yea, this is pretty straightforward
The reason I ask is because adding a camera to a pi is enabling i2c and adding an overlay for the camera
is that it?
what if it is a custom on, without drivers?
You could make a userplane program to control the driver
what is a userplane program?
Much more easier than touching kernel side
is what I am doing, touching the kernel
is this what loading drivers is?
Linux system are divided into 2 part
Userplane
Kernel plane
Yep
Drivers mostly come into kernel plane
You load it into the kernel
Which comm does yours use?
what if the hardware I am using does not have drivers and new ones have to be built
how does that work
I2c, I enabled it in config. Then I added an overlay for the camera in the boot config
Oh wait,
Is this for the camera or the another sensor?
the issue here is not that something is not working. It’s that I want to know how it work 🙂
So basically lets consider a custom sensor without existing drivers
For this I would make a device tree definition of the hardware.
Write the driver for it.
How does this process work in linux land?
In firmware
– I build comms drivers (i2c)
– then over the comms drivers I talk to registers on the sensor
can you show me a sample implementation ? Even a trivial one?
You would have to work on top of the existing i2c drivers.
https://github.com/Embetronicx/Tutorials/blob/master/Linux%2FDevice_Driver%2FI2C-Linux-Device-Driver%2FI2C-Client-Driver%2Fdriver.c
Here is one. Dts part not included.
Depending on the hardware type you may need to recompile the kernel with the driver or have it as a loadable kernel module.
For example, hardware that is woken up at early boot need to be recompiled with the kernel.
Oh my word, this is nice!
this is luxury, so much ground work is done!
the site is also very good
learnt a lot from there
thankfully I have all of you to learn from
Zephyr followed this model somewhat.
ah so if I add a custome driver to zephyr I can transfer than knowledge to linux?
Yeah sir. Except it doesn’t map 1:1
its has a similar driver modela and dtc usage
nothing maps 1:1 in life
amazing lessons from the both of you @32bitwidesaviour @melta101 thank you.
You have only chosen one of the most complex type of driver out there if you were wanting to write your own….
For camera drivers from scratch, you would need to:
– Look at the bus subsystem o talk to the camera
– Write the interfaces to talk to the camera
– Look at the Video4Linux2 subsystem so that it can be picked up and used by most of the userspace applications
– Interface between the camera & V4L2 (this normally involves lots of IOCTLs!)
Here is the driver for the imx219 as an example
https://elixir.bootlin.com/linux/v6.12.6/source/drivers/media/i2c/imx219.c
To contrast with that, here is a simple GPIO LED driver:
0message.txt
CONTRIBUTE TO THIS THREAD