Interested in learning OS-level programming
#1
Most of my knowledge is in web development, dev-ops, and a fair amount in Linux tooling. One thing I've always wanted to learn was working with OS-level programming, but I've never really had a good excuse to get into it until I got a Pinephone. I've taken a university course where I've written programs in C that do system-level calls, as well as creating some simple ARM assembly code, so I suppose I do have a little experience.

To start simple, if I want to for example create a CLI tool that toggles the flashlight on the Pinephone, what fundamentals should I learn first before going about that? I'd also like to try and make a CLI tool to interface with the modem on the Pinephone just for the learning experience.

The material for OS-level programming feels a bit impenetrable for a noob like me, so maybe you guys have some good suggestions?
  Reply
#2
The flashlight, along with many other things, is controlled by reading and writing 'files' under the /sys pseudo-filesystem. You can do that using normal shell tools like echo, tee, pipes etc. or by using a programming language's file read/write methods. In this case you're looking to write either 0 or 1 to /sys/devices/platform/led-controller/leds/white:flash/brightness - note the permissions on that file which may mean you'll need to use sudo or similar to access it.

What level do you want to access the modem at? Low level access is easiest via the serial port using AT commands. Most of the OS versions abstract that out via either ModemManager or oFono, in which case you'd access the modem through those using a dbus interface.

The other bit is how to get things into and out of your program via the cli, but that's usually address in or soon after 'Hello World.'
  Reply
#3
I would say that programming could be difficult and not able to focus while you are a student so in that case you can less y ne writing service which can provide you so many options for writing your homework in a perfect way
  Reply
#4
(08-15-2020, 11:43 AM)wibble Wrote: The flashlight, along with many other things, is controlled by reading and writing 'files' under the /sys pseudo-filesystem. You can do that using normal shell tools like echo, tee, pipes etc. or by using a programming language's file read/write methods. In this case you're looking to write either 0 or 1 to /sys/devices/platform/led-controller/leds/white:flash/brightness - note the permissions on that file which may mean you'll need to use sudo or similar to access it.
Just noticed this very informed response. I don't suppose this kind of stuff is documented anywhere? And is it OS specific? I can RTFM if I can find them.
  Reply
#5
(04-21-2021, 07:51 AM)rleasle Wrote:
(08-15-2020, 11:43 AM)wibble Wrote: The flashlight, along with many other things, is controlled by reading and writing 'files' under the /sys pseudo-filesystem. You can do that using normal shell tools like echo, tee, pipes etc. or by using a programming language's file read/write methods. In this case you're looking to write either 0 or 1 to /sys/devices/platform/led-controller/leds/white:flash/brightness - note the permissions on that file which may mean you'll need to use sudo or similar to access it.
Just noticed this very informed response. I don't suppose this kind of stuff is documented anywhere? And is it OS specific? I can RTFM if I can find them.
You can find a lot of that very helpful stuff on megous' website, very informative (scroll down to the feature/driver support matrix and click on the part that interests you). It should not depend on the OS as long as they are using a similar kernel.
  Reply
#6
Thanks for post
  Reply
#7
You can do quite a lot in the shell. Which is quite arcane, but I am glad I learned it. Comes in handy all the time. Woolidge FAQ (which is linked from #bash MoTD on libera.chat) is a very good resource here.

Personally I read 'system level OS programming' to mean something like writing kernel drivers in C. In which case there is a famous book about that. But maybe that's not what you mean.

We are lucky in that there are tons of resources available nowadays with the Internet. But you can still learn a lot studying man and Gnu Info pages. The path to true wizardry lie through spending many hours reading such tomes of ancient wisdom.

If you can expand on your interests, maybe some more specific resources can be suggested.
Cheers,
TRS-80

What is Free Software and why is it so important for society?

Protocols, not Platforms

For the most Linux-y experience on your Linux phone, try SXMO!

I am (nominally) the Armbian Maintainer for PineBook Pro (although severely lacking in time these days).
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Wrong Battery Charge Level Displayed - How to Fix acid andy 7 6,633 06-12-2023, 01:04 PM
Last Post: jakfish

Forum Jump:


Users browsing this thread: 1 Guest(s)