Bare metal programming


Hi all! First post. Day job is principle engineer, 20yr, lately mostly Java and BigData Warehousing ETL in capital markets sector.

So, for hobbies I do anything but.

Recently I learnt my way around an Atmel MCU Atmega328p (of Arduino fame). Like learnt how to program it in ASM and C, with and without the Arduino IDE/Stack and eventually with the gcc-avr cross compile environment. Ending in a hand designed, hand soldered, minimal "blinky" on a PCB with a bare-metal bootloader-less chip, running custom ASM only. 0% Arduino.

Recently I found a series of YouTube videos on bare-metal in terms of modern x86_64 architecture which cover the ASM to get the CPU switched into various modes from 16bit with BIOS to 32bit protected and 64bit long mode, setting up the virtual memory maps and LSB page tables.

It got me started, towards a hobby space, learn by doing avenue to OS design and implementation, but now I'm a little stuck at a cross roads with where to go from here.

First I need to decide is I should remain in 64bit long mode and all the complications there in, or should I hand around in BIOS or 32bit mode and learn a few more basics first. Like a proper console, basic file and device IO, segmentation, multi-programming, scheduling, multi-tasking and so on. Then later move up into 64bit mode.

Then I need to decide the order to tackle things in. I doubt for example I would be getting anywhere near supporting the whole GNU LibC. I would be lucky if I could get a kernel to support stdlib!

I'm even wondering if it might be better to research and select a good book, even the Minux one Linus used and work that way.

Anyone done this?
Any tips, links, guides, books?

I suppose a good question is "What is the purpose?" and again, it would be as an exercise to understand by doing. Also I find all this low level bit-banging hardware a breath of fresh air after a day job in high level enterprise Java.

Out of interest, the closest I've come to OS design was making my own "Linux from scratch" based on the open source book and even contributed to the "Beyond Linux from scratch" book, all the way out to Open Office, KDE and Firefox compiles/installs.

It's great that you have already gained knowledge about the Atmel Atmega328p microcontroller and the modern x86_64 architecture.

Regarding your question, it is important to understand your end goal. If you're interested in OS development, you can start with a smaller goal, such as building a simple OS kernel with basic console I/O and memory management. Once you get comfortable with this, you can move on to more advanced features like the file system, device drivers, and multitasking.

Some popular:
books on OS development include Operating System Concepts, Modern Operating Systems, and Linux Kernel Development.
Platforms such as Udemy and Coursera also have several online courses dedicated to OS development.

As you mentioned, working with an open-source OS project like Minix can be a great learning experience. Participating in open-source projects can help you gain real-world experience and learn from experienced developers.

In general, the key is to start with small goals and gradually build them up.
Top Bottom