Return to Level1Techs.com

FermiOS: An OS development for Raspi 3

project
blog
programming

#1

tumblr_p1vwba9m2u1v6qhdmo1_500

Hey L1T!

Inspired by #devember2k18 (thread) I decided to post a thread here about my current main project . Operating System development for Raspberry Pi 3 B. I am only targeting Raspi 3 B, since that what I have.

Sources

BSD 3-clause licensed git repo:

DevLogs/Updates:

This project is in very slow update phase atm because of uni and upcoming exams.

I am going to post devlogs and more on my blog and link them here. Why not post directly here? I like to keep my data for myself :wink:
Plus shameless self-promotion. :man_shrugging:

Why develop an OS?

Few reasons:

  • I wanna learn more about function of OS, and I learn best by doing
  • I am also planning to use parts of the code for another project :wink:
  • Coding in C is fun.

I tried my hand in OS dev before, but didn’t get too far. In fact FermiOS first was planned for x86 PC platform, but since I find them overly complicated (at least for the first try) I decided not to resurrect that project and start from scratch on Pi.

Old x86 attempt:

What is it going to be?

Hopefully it’s going to be a multi-task, multi-user OS inspired by POSIX, but not compliant, since I want to be free in experimenting with it.

Main points of interest to develop:

  • Multi-tasking
  • Multi-user
  • File System (possible homebrew)
  • USB Host
  • TCP/IP Stack

CLI first, but GUI should come later, too.

What is it now?

Atm it’s nothing but a dumb pre-programmed serial console.


^ Funny thing I don’t have a USB to serial cable, so I am using Arduino Uno as one.

Docs


1: AFAIK BCM2837 has same peripherals as BCM2835. The difference between them are ARM core and more clocked VideoCore.
2: You probs want ARM® Architecture Reference Manual ARMv8, for ARMv8-A architecture profile
and Arm Cortex-A53 MPCore Processor Technical Reference Manual

Year of Dev and beyond

I want to commit to a single main project (side projects may happen, but need to be extremely small ones) so I can, for once, finish one.

So in that spirit I want to give updates at least once a week on ongoing progress. It might be as simple as “This week I researched X in order to do Y”, or be a full blown blogpost devlog.

Well, hopefully this will make me accountable since (hopefully) there are eyes on me now.

tenor12412


#2

Good luck.


#3

Woohooo! Awesome project! :sunglasses:

Way over my head but I will follow this anyway.

love this by the way :grin:
grafik

I also like the name!


#4

Here’s the old one in action:


Also about the blog, when I get more free time, the first small side project might be to finish the CPU dev series. Since the actual CPU is built anyways, all I need is to write text.


#5

I really like the code in the kernel. It’s very clean and easy to read. Not very C like :stuck_out_tongue_winking_eye:

Or, perhaps, it’s very C like, and the C programmers I know are garbage :thinking:


#6

Thanks. :blush:

Did you check the dev branch? Probably worse there. It’s clean coz there’s not much functionality lol.


#7

Just the master :wink: But it’s still so cool.

OS Dev is insane. I was going to ask why you’re not using Go instead of C but I’m honestly impressed. Not going to shit up this thread with my abstract (absent) sense of humor :grin:


#8

I just checked the dev branch, there’s not too much new there. I did abandon the project coz of uni and coz I suck at sticking with projects.

I have 2 gripes with Go:

  1. GC
  2. Forced { on same line :stuck_out_tongue:

Yes the 2nd bug me enough, and it would bug me even if it was forcing { on new line. I think it’s not a job of compiler to enforce style.

As for GC, it’s self-evident :wink:

IMO C is perfect for OS dev, it let’s you express lower level things, it doesn’t make you fight the compiler (in OS dev you sometimes knowingly do “unsafe” things) and it small enough for me to keep most of the lang in the head (excluding less used libc and more obscure (aka most lol) UB).


#9

:rofl: I can relate :grin:


#10

@AdminDev you made me scroll through that code and I found a bug lol.

46    int event_get_id(char* name)
47    {
48    	for(size_t i = 0; i < EVENT_TYPES_SIZE; i++)
49    		if(event_types[i] == name)
50    			return i;
51    
52    	return -1;
53    }

line 49, that’s pointer comparison not strcmp() lol.


#11

How are you getting around the Binary blob needed to run the Broadcom chip?

Can you talk a bit about how you set up the CPU and enabled the serial peripheral,

I think this is the first time I have seen someone doing a uOS project on arm.


#12

I just use the same blob that they provided for Raspbian. As long as I don’t distribute it, it should be fine.

I haven’t set much of the CPU, yet. Again I just started. The main processing unit on Pi is VideoCore GPU actually. It reads the bin blob, then finds the kernel*.bin, Loads it up in the memory, turns on all 4 ARM cores in hypervisor exception level (ring -1 in x86) and points their IPs at kernel.

So all 4 cores start to execute same code. So I read a MSR mask 3 cores out of 4, make em go into lower power mode and loop em there. Now on 1 core I initialize simpler of 2 UARTs in polling mode and talk using it with my PC.

After this I plan to set up virtual memory, interrupts, switch to other UART (it has its own clock).

As for PC side, since I don’t have USB2Serial cable, I rigged my Arduino Uno to be one. Just programmed it using default Arduino libs to read 2 pins as serial (I assume its bitbanging that) and just repeat that over its actual serial to my PC.
Arduino Uno is working in 5V though, while Pi is 3.3V, so for Arduino -> Pi signals I made a voltage divider.

That’s about it so far.


Also what is

?

micro OS? like for microcomputers? :smiley:
Or microkernel? Coz this is gonna be monolithic coz it’s easier.


#13

uOS is my slang, yes it means micro OS but only in the terms “micro” meaning not built to be deployed to thousands of real users.

Hobby OS would be a better term.

Last question:

how did you get kernel.bin onto the pi? Is it just loaded off of a fat formatted SD card?


#14

Yeah. Oh in fact before I do all this:

I actually was planning to write a SerialBoot. because taking the SD writing, and then putting it back into Pi is annoying. So I am gonna write a bootloader that on boots gonna read a file over serial and load it up into memory, than just jump into it. :wink:


#15

I understand the desire to keep work closed until it is polished to a state you’re happy with,

But it sounds like you have a useful base platform already, opening it up now would allow people to reproduce your results and start their own experiments.

Any chances of opening it up early, and allowing some community collaboration?


#16

:thinking:

Okay, I’ll open it up, but I won’t merge pull requests since the whole point is to do it myself.

Will do this a bit later today.

engagement


#17

Engagement!


#18

Engagement!!!


#19

The repo is public now. (Updated the main post)

You can go nuts @SIGSEGV


#20

Now that’s what I call a Makefile… impressive…

Many thanks