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!

Step 1 of 5

CREATE YOUR PROFILE *Required

Change Email
OR
Step 2 of 5

WHAT BRINGS YOU TO DEVHEADS? *Choose 1 or more

Collaboration & Work 🤝
Learn & Grow 📚
Contribute Experience & Expertise 🔧
Step 3 of 5

WHAT'S YOUR INTEREST OR EXPERTISE? *Choose 1 or more

Hardware & Design 💡
Embedded Software 💻
Edge Networking
Step 4 of 5

Personalize your profile

Step 5 of 5

Read & agree to our COMMUNITY RULES

  1. We want this server to be a welcoming space! Treat everyone with respect. Absolutely no harassment, witch hunting, sexism, racism, or hate speech will be tolerated.
  2. If you see something against the rules or something that makes you feel unsafe, let staff know by messaging @admin in the "support-tickets" tab in the Live DevChat menu.
  3. No age-restricted, obscene or NSFW content. This includes text, images, or links featuring nudity, sex, hard violence, or other graphically disturbing content.
  4. No spam. This includes DMing fellow members.
  5. You must be over the age of 18 years old to participate in our community.
  6. Our community uses Answer Overflow to index content on the web. By posting in this channel your messages will be indexed on the worldwide web to help others find answers.
  7. You agree to our Terms of Service (https://www.devheads.io/terms-of-service/) and Privacy Policy (https://www.devheads.io/privacy-policy)
By clicking "Finish", you have read and agreed to the our Terms of Service and Privacy Policy.

can you show me a rudimentary hardware driver in linux?

@melta101 or @32bitwidesaviour can either of you show me a rudimentary hardware driver in linux? How much of it is config and how much of it is code?

  1. melta101#0000

    Hardware driver as in?

  2. melta101#0000

    And does userplane program won’t work?

  3. ZacckOsiemo#0000

    Show me how to add custom hardware to a embedded linux or even just a linux system

  4. ZacckOsiemo#0000

    say a tof sensor over i2c

  5. ZacckOsiemo#0000

    just an example

  6. melta101#0000

    Yea, this is pretty straightforward

  7. ZacckOsiemo#0000

    The reason I ask is because adding a camera to a pi is enabling i2c and adding an overlay for the camera

  8. ZacckOsiemo#0000

    is that it?

  9. ZacckOsiemo#0000

    what if it is a custom on, without drivers?

  10. melta101#0000

    You could make a userplane program to control the driver

  11. ZacckOsiemo#0000

    what is a userplane program?

  12. melta101#0000

    Much more easier than touching kernel side

  13. ZacckOsiemo#0000

    is what I am doing, touching the kernel

  14. ZacckOsiemo#0000

    is this what loading drivers is?

  15. melta101#0000

    Linux system are divided into 2 part
    Userplane
    Kernel plane

  16. melta101#0000

    Yep
    Drivers mostly come into kernel plane

  17. melta101#0000

    You load it into the kernel

  18. melta101#0000

    Which comm does yours use?

  19. ZacckOsiemo#0000

    what if the hardware I am using does not have drivers and new ones have to be built

  20. ZacckOsiemo#0000

    how does that work

  21. ZacckOsiemo#0000

    I2c, I enabled it in config. Then I added an overlay for the camera in the boot config

  22. melta101#0000

    Oh wait,
    Is this for the camera or the another sensor?

  23. ZacckOsiemo#0000

    the issue here is not that something is not working. It’s that I want to know how it work 🙂

  24. ZacckOsiemo#0000

    So basically lets consider a custom sensor without existing drivers

  25. 32bitSaviour#0000

    For this I would make a device tree definition of the hardware.
    Write the driver for it.

  26. ZacckOsiemo#0000

    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?

  27. 32bitSaviour#0000

    You would have to work on top of the existing i2c drivers.

  28. 32bitSaviour#0000
  29. 32bitSaviour#0000

    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.

  30. ZacckOsiemo#0000

    Oh my word, this is nice!

  31. ZacckOsiemo#0000

    this is luxury, so much ground work is done!

  32. melta101#0000

    the site is also very good

  33. melta101#0000

    learnt a lot from there

  34. ZacckOsiemo#0000

    thankfully I have all of you to learn from

  35. 32bitSaviour#0000

    Zephyr followed this model somewhat.

  36. ZacckOsiemo#0000

    ah so if I add a custome driver to zephyr I can transfer than knowledge to linux?

  37. 32bitSaviour#0000

    Yeah sir. Except it doesn’t map 1:1

  38. melta101#0000

    its has a similar driver modela and dtc usage

  39. ZacckOsiemo#0000

    nothing maps 1:1 in life

  40. ZacckOsiemo#0000

    amazing lessons from the both of you @32bitwidesaviour @melta101 thank you.

  41. Ming#0000

    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

Browse other questions tagged 

Leaderboard

RANKED BY XP

All time
  • 1.
    Avatar
    @Nayel115
    1620 XP
  • 2.
    Avatar
    @UcGee
    650 XP
  • 3.
    Avatar
    @melta101
    600 XP
  • 4.
    Avatar
    @lifegochi
    250 XP
  • 5.
    Avatar
    @Youuce
    180 XP
  • 6.
    Avatar
    @hemalchevli
    170 XP