Comments on: Simple Linux character device driver https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/ Programming, electronics and diy projects Thu, 04 May 2023 03:29:45 +0000 hourly 1 https://wordpress.org/?v=6.5.3 By: Arun https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1562 Thu, 04 May 2023 03:29:45 +0000 http://olegkutkov.me/?p=359#comment-1562 In reply to Fabian.

true, I also faced same issue with linux 6.1.2

]]>
By: Tom https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1402 Thu, 15 Dec 2022 05:42:03 +0000 http://olegkutkov.me/?p=359#comment-1402 Hi Oleg!

This is the best tutorial I have come across, thanks a ton!

I really liked rest of the articles as well. You have a knack for simplifying the complexity, keep up the good work.

I come from the bare metal side, taking first steps in embedded linux. Your example code works well on x86. I was trying to attempt it on a A7 cpu, changed the ARCH to arm-linux-gnueabihf in the makefile but it still complains.

Would be great if you could give some pointer on how and what to change for ARM based devices. Maybe add to the above article or write a new one whenever you can.

Thanks again

]]>
By: Oleg Kutkov https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1387 Mon, 14 Nov 2022 21:21:48 +0000 http://olegkutkov.me/?p=359#comment-1387 In reply to Enrico Maria De Angelis.

In most cases, yes. But this is just a tutorial about how to write chardev driver, not a production code. In the real world, apps buffer and buffer size might be dynamically declared somewhere else in a larger driver structure.

]]>
By: Why piping cat into head -c 5 for a chardev results in many more calls to the driver's read than just calling head -c 5 on the chardev? - JTuto Mercure https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1386 Sun, 13 Nov 2022 17:10:34 +0000 http://olegkutkov.me/?p=359#comment-1386 […] inspiration from this blog post, I’m playing around with linux device drivers (which I’m studying from […]

]]>
By: Enrico Maria De Angelis https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1385 Sun, 13 Nov 2022 16:32:03 +0000 http://olegkutkov.me/?p=359#comment-1385 Also, the variable ncopied seems to suggest “number of bytes copied”, whereas it is the number of bytes not copied yet, so a better name would be notCopied?

]]>
By: Enrico Maria De Angelis https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1384 Sun, 13 Nov 2022 16:07:55 +0000 http://olegkutkov.me/?p=359#comment-1384 By const I guess I mean a macro (sorry, coming from the C++ side of things, not much used to C-style arrays).

]]>
By: Enrico Maria De Angelis https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1383 Sun, 13 Nov 2022 16:04:42 +0000 http://olegkutkov.me/?p=359#comment-1383 When declaring databuf, maxdatalen is always 30. Would it make sense to define it as const, for the purpose of declaring databuf without relying on the VLA extension, and then declare another variable to be inizialized to maxdatalen and be used in its place afterwards?

]]>
By: What is the modern way of creating devices files in /dev/? - TechTalk7 https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1382 Sat, 12 Nov 2022 23:22:05 +0000 http://olegkutkov.me/?p=359#comment-1382 […] and device_create C functions, rather than mknod shell function, to create device files. Here‘s another one, blog post written in early […]

]]>
By: Brian Carcich https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1351 Fri, 15 Jul 2022 19:27:09 +0000 http://olegkutkov.me/?p=359#comment-1351 @Oleg Kutkov: Thank you for this! It was slow going to get my slow brain to the knee of the device driver learning curve, and your example has helped a lot.

The off-by-one error is still there, but since the buffer length is 30, in practice it will not matter because that buffer will actually include the next two bytes (i.e. to 32). Not that I am excusing the error, just sayin’

]]>
By: Oleg Kutkov https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/#comment-1093 Fri, 26 Nov 2021 20:08:09 +0000 http://olegkutkov.me/?p=359#comment-1093 In reply to Fabian.

Hello.
Thank you for the information. Something may be changed in the Linux kernel. I’ll check.

]]>