PINE64
Interested in learning OS-level programming - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120)
+--- Forum: PinePhone Software (https://forum.pine64.org/forumdisplay.php?fid=121)
+--- Thread: Interested in learning OS-level programming (/showthread.php?tid=11026)



Interested in learning OS-level programming - 8453sixtyfour - 08-12-2020

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?


RE: Interested in learning OS-level programming - wibble - 08-15-2020

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.'


RE: Interested in learning OS-level programming - Snyder52 - 04-20-2021

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


RE: Interested in learning OS-level programming - rleasle - 04-21-2021

(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.


RE: Interested in learning OS-level programming - kqlnut - 04-21-2021

(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.


RE: Interested in learning OS-level programming - harismo1 - 04-04-2022

Thanks for post


RE: Interested in learning OS-level programming - TRS-80 - 04-30-2022

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.