[HN Gopher] Learning operating system development using Linux ke... ___________________________________________________________________ Learning operating system development using Linux kernel and Raspberry Pi Author : weeber Score : 401 points Date : 2020-06-23 08:00 UTC (15 hours ago) (HTM) web link (s-matyukevich.github.io) (TXT) w3m dump (s-matyukevich.github.io) | ObsoleteNerd wrote: | The offical Raspberry Pi distro of Linux is already called | "Raspberry Pi OS": | | https://www.raspberrypi.org/downloads/raspberry-pi-os/ | shakna wrote: | Raspbian was renamed to "Raspberry Pi OS" on the 27th of May, | 2020. That's so recent you can assume that there'll be a whole | bunch of naming conflicts and/or confusion. | Yuioup wrote: | Renamed from "Raspbian". Perhaps the article was written before | the name change? | amatecha wrote: | Yeah the github repo ( | https://github.com/s-matyukevich/raspberry-pi-os ) shows it | as being created just a little under 2 years ago | johnnycab wrote: | I hope there is an official release of 64-bit version soon. | | https://www.raspberrypi.org/forums/viewtopic.php?f=117&t=275... | thomond wrote: | This project seems to go back at least 2 years while Raspbian | changed it's name very recently. | teleforce wrote: | If you are looking to learn operating system concepts using RPi | there is a new textbook by Prof. Vanderbauwhede, under ARM | textbook initiative [1]. | | I think for educational purposes it will be very interesting and | useful if someone develop from scratch a simple System V UNIX for | RPi based on Bach's description in his seminal book on "The | Design of the UNIX Operating System" [2]. The book also covers | multi processors topic as supported by modern platforms such as | RPi. | | [1]https://www.arm.com/resources/education/books/operating- | syst... | | [2]https://github.com/suvratapte/Maurice-Bach- | Notes/blob/master... | bla3 wrote: | Is the ebook of the textbook a regular PDF/epub/mobi or is it | only viewable in their viewer apps? The page doesn't say, and I | don't want to spend money on it and then realize it's not a | real download. | jakamau wrote: | I was curious about that as well. The official ARM site | doesn't list one but another distributor lists the related | ISBN as epub. | | https://www.vitalsource.com/products/operating-systems- | found... | pumanoir wrote: | The "book" you download from this website is _not_ an epub. | You must use their apps to read it. | pricci wrote: | I'm interested in that book but I can't tell if I can follow | along using a RPi Zero or I need a specific version. Can't find | a preview of the book. | pumanoir wrote: | They focus on rpi 3b | ngcc_hk wrote: | does it go through the process? | vips7L wrote: | > develop from scratch a simple System V UNIX for RPi | | A few people seem to have ported xv6 to arm. | | https://github.com/david50407/xv6-rpi | | https://github.com/houcheng/xv6-armv7/ | lewis1028282 wrote: | Might be a bit controversial but I found writing drivers for | Linux on my raspberry pi helped me understand kernels, virtual | memory etc. I used Linux Device Drivers (ldd3) which is free | online. The book was written for the 2.6 kernel but someone on | GitHub updated the code for the latest kernels. | vmladenov wrote: | This doesn't seem controversial. It's how the operating systems | class[1] was structured at University of Illinois, though the | target was a VM instead of physical hardware. It was easier to | reset things when your new scheduler module instantly crashes | the OS. | | [1]https://courses.engr.illinois.edu/cs423/sp2016/ | jabedude wrote: | Hello, could you share the link for the updated version of | LDD3? | Ristovski wrote: | I was able to find this, which appears to have been updated | for 4.x kernels, https://github.com/jgraha8/ldd3-examples- | modern | nullbuffer wrote: | Alternatively there's this: | https://github.com/martinezjavier/ldd3 | stevekemp wrote: | I've never written a driver myself, because all my hardware is | supported. But I've certainly added new PCI IDs to existing | drivers, and done that kind of low-level learning. | | I expect if I found a random piece of hardware that was close | to an existing one that adding the driver, or updating things | so that it worked on the new hardware would be possible. It's | just not a situation I've come across. | | What I found useful/educational was writing a simple linux | security module. | | 1. LSMs are essentially isolated. 2. They don't care about | hardware. 3. You can do lots of things with them. Even horrid | evils things. | | For example I put together the following module in which the | kernel calls back to userspace every single time you execute a | binary, to decide whether it should be permitted or not: | | https://github.com/skx/linux-security-modules | | (And yes, I appreciate that is almost exactly as horrid as it | sounds! So much fun to hack around with though.) | lewis1028282 wrote: | You can just write char drivers that operate a slab of kernel | memory, and implement all the syscalls like open, read, write | on that piece of memory. | Narishma wrote: | Why would it be controversial? | Frost1x wrote: | >Why would it be controversial? | | Not OP but my perspective is that much of software | development, engineering, and practices become cult like, | often without theoretical or empirical basis. | | I'm rarely surprised anymore when I see criticism of one | approach over another. Someone may think "the way" to learn | Linux kernel development isn't what OP suggested and there's | a cult of people who agree who will adamantly concur to a | fault. | mikece wrote: | In terms of teaching fundamentals of operating system theory and | systems programming, is there such a thing as an operating system | kernel written in Python or some language which is meant to be | easy to hack on for educational purposes? I wonder how useful | that would be for a CS student, taking the complexity of C, C++, | or Rust out of the picture and just running a kernel in a VM for | educational purposes. | mywittyname wrote: | An OS course taught in Python is really just a data structures | and algorithms course. When you ignore the hardware aspect, | topics like scheduling and virtual memory management are about | selecting an algorithm with the appropriate trade-offs. | | My OS course was hacking on x86 Linux in C. The C wasn't really | the difficult part. Honestly, neither was the assembly, as most | of was boilerplate: here's how you configure to registers for a | system call, here's how you trigger the interrupt for the | system call, here's how you get the return codes, etc. | | I don't think the class would have been nearly as valuable if C | were replaced with Python. At that point, so many of the | interesting details would be hand-waved away that it wouldn't | really be all that different from the other programming classes | I took. | simion314 wrote: | IMO this topic is entangled with hardware, the student needs to | do a course in hardware and how CPUs work, do some simple | assembly coding, after that C is a natural progression. If C is | too complex for some students then system programming and OS | development is not for them. For educational and getting | started I think https://www.nand2tetris.org is a good source | material, the complexity or real world stuff is missing there | so you can focus on essentials. | chillfox wrote: | I don't know of any specifically made for teaching, but there | is biscuit made in Go[0] and Lilith made in Crystal[1]. | | [0] https://pdos.csail.mit.edu/projects/biscuit.html [1] | https://github.com/ffwff/lilith | DC-3 wrote: | There's no point abstracting away the nitty-gritty. OS dev _is_ | the nitty-gritty. | Santosh83 wrote: | You could write a Java based virtual kernel designed to run | within the JVM and manage child processes I suppose, but what | is the real world utility of such a thing? | | Almost everything to do with kernels is about directly writing | to memory addresses and ports and these things can't be done | with a managed language, at least not without a significant | runtime doing all the grunt work, at which point you'll need to | understand much of the runtime's internals and at that point, | you may as well have started out with a small C/C++/Rust | kernel, plenty of which exist. | shakna wrote: | There are actually plenty of languages that can lead you down | this path, including some designed for the purpose. | | For real world learning, C is still what you want. It is one of | the easier roads through. | | However, here's a just few languages that can let you build a | kernel up quickly: | | + Forth. It is well suited for the purpose. A tiny bit of | assembly, and then just a bunch of definitions and you've built | it all from the ground up. But if you think C is too complex | for learning, then the idea of moving to a stack-based language | could get in the way. | | + Lisp. The Symbolic Lisp machines might be in the past, but | the various versions of Lisp are still flexible enough to let | you build an OS, and lots of CS students do. | | + Lua. It is only slightly higher level than C, but with fun | things like coroutines, hash tables, dynamic typing and GC. Due | to its C99 nature and the desire to keep the language | constrained, it runs on bare metal great. You don't have to | modify Lua to run it baremetal on a Pi. [0] | | [0] http://lua-users.org/lists/lua-l/2020-01/msg00157.html | cwoolfe wrote: | C is a language which is closer to hardware than Python, so | you'll find it to be the language of OS programming. In fact, | Python is written in C. I think trying to do OS programming in | Python would actually be more difficult than learning C. | | If you are a solid programmer who already knows Python, | learning C would only take 2-4 weeks. The benefit is worth the | investment. | | https://stackoverflow.com/questions/10904721/is-it-possible-... | lzlz wrote: | Actually using C or C++ is the most straightforward painless | way to learn kernel dev. C is not complex at all. What you need | to learn first is something like what nand2tetris offers, at | least the first part. Usually you will have to do some | variation of nand2tetris in the first or second year of | undergrad. | glouwbug wrote: | Correct. Try these two: | | https://github.com/DoctorWkt/acwj | | https://github.com/cfenollosa/os-tutorial | vertex-four wrote: | Depending on what, exactly, you want to hack on, building | components on top of seL4 could be a way to go. There's a large | collection of libraries built on top of it, that you can | replace as you feel like - | https://docs.sel4.systems/projects/available-user-components... | - and there's a few different options for communication between | them (seL4's IPC, shared memory, etc). | | You could easily get a stripped-down interpreter or something | running in that environment. | OldTechSucks wrote: | I want to learn about firmware development. I have been playing | with rpi gpio and arduino i2c but have no idea how to start with | firmware development. please throw at me references, i'm very | fragile but i'll take it and learn from. | [deleted] ___________________________________________________________________ (page generated 2020-06-23 23:00 UTC)