Building an OS - 3 - The FAT file system
Ғылым және технология
We continue writing our bootloader, and we learn to read a file from a FAT disk.
Part 2: • Building an OS - 2 - R...
Part 1: • Building an OS - 1 - H...
Source code: github.com/nanobyte-dev/nanob...
Tools:
- Bochs: bochs.sourceforge.net/
- mtools: www.gnu.org/software/mtools/
- VSCode: code.visualstudio.com/
- Okteta (Linux): apps.kde.org/en/okteta
- HxD hex editor (Windows): mh-nexus.de/en/hxd/
Documentation:
- FAT12 file system: wiki.osdev.org/FAT
- INT 13h: www.stanislavs.org/helppc/int...
- x86 instruction reference: c9x.me/x86/
Пікірлер: 116
these videos are amazing, the best osdev content on youtube! awesome job!!
This is incredible, thank you :) I just wanted to see some of how an OS is built in practise, as in university it was all quite abstract. I will not ever build one myself, unless for the fun of it. But my curiosity is being sparked perfectly by this
Great series, hope to see more!
@nanobyte-dev
3 жыл бұрын
Thank you, more is definitely coming :)
Thank you, your explanation is one of the best and it serves perfectly as a complementary to other materials
@nanobyte-dev
Жыл бұрын
Unfortunately my job and my kids won't let me work during the day...
This has been so far a most enjoyable series. Thank you. I'll be interested to see how far you take it, and whether you delve into real-time. I'm a retired software engineer who has written bare metal OSs (no file systems!) for embedded instrumentation starting with a 6502 microprocessor in the 1980s. I also wrote an OS for an 80186-based WiFi product in about 1995 (well, it was 802.11 frequency hopping, before the WiFi term was coined) - this was an example in how *not* to write a real-time OS/application because I became unnecessarily mired in locks/semaphores protecting unnecessary critical regions. Eventually I pursuaded my bosses to let me re-engineer it, and the company was almost immediately sold off. Not sure what that says about life, the universe and everything.
@andrewdoherty737
9 ай бұрын
42!
You actually move faster than I can type. I type pretty fast. I actually find this refreshing compared to other channels that I have to pump up to double-speed to keep up with me. Also, thanks for going beyond the bootloader section of teaching OS development. Not many video series' make it that far.
@nanobyte-dev
Жыл бұрын
The coding part is sped up a bit. I'm glad you're enjoying it.
@treytomes
Жыл бұрын
@@nanobyte-dev I actually built the i686-gcc environment first before starting the series. Then I got stuck on the video on setting up the Watcom compiler. I just didn't feel ready to setup yet another compiler on my system. That's what I get for going out of order.
@nanobyte-dev
Жыл бұрын
@@treytomes You can skip the watcom stuff... just watch 2 more videos until I return to GCC's loving arms.
I want to take a minute to appreciate your music choice 🤩
Thank you, very great article. I remember writing my own OS 25 years ago. You are master BTW ;)
@tayoyuva2203
2 ай бұрын
That's interesting!
This is definitely the best os development content i have seen so far, where did you find out how to do all this?
@tedbasher3000
11 ай бұрын
most likely by studying up on file systems, assembly, c, bioses and everything else required
@nanobyte-dev
11 ай бұрын
I started just like you, reading tutorials (10 years ago there wasn't much on KZread). Then I went to university, got a job, got good at programming, and now I show others how to do it. There are plenty of resources on OS development if you know where to look. And if something isn't well documented, I can check the sources of open source kernels like linux, bsd etc.
@legacywolf443
10 ай бұрын
If you're patient enough you just need Wikipedia honestly
@nanobyte-dev
10 ай бұрын
@@legacywolf443 Wikipedia helps, but it lacks a lot of information. But there are plenty of resources available online. Some can be pretty hard to read (like manuals, datasheets), so reading source code from Linux or BSD can help a lot.
@raxneff
10 ай бұрын
@@nanobyte-dev Well, but how to you find the right stuff in the source code? Me, being a computer science student myself, finds it very hard to even get an oversight about the code structure of Linux (or other open source projects, Darwin, Minix, FreeBSD, ...)
Continu please, you are awesome 😎
I think I have lost track. It could be that code part is going really fast and I am not totally sure why we do the things we do. I felt the same in episode 2. Maybe it would benefit to keep reminding us why we do the things we are doing to not loose track. Otherwise, I Imagine that it takes a lot of time what you are doing and I gratefully thank you to put in the effort and creating such helpful videos. Cheers.
@nanobyte-dev
Жыл бұрын
Thanks for the feedback. I agree that the code is a bit too sped up in the earlier videos like this one.
Awesome videos! I just subscribed to your channel.
Amazing job!
You intro movie is very cool!
great work i love this
Ah, the wonderful days of bios interrupts. At least it saves you from spending a week writing a disk driver 🤣
@unixity_WasTaken
Жыл бұрын
trust me, one time it took me a month writing a disk driver
@JtagSheep
10 ай бұрын
Interrupts are your friend... till you load the kernel :D
I love how the number of comments is dropping off the further in we get :D Just about hanging in there on the understanding of these.
@nanobyte-dev
2 жыл бұрын
Many people start watching, but not that many finish. It happens will any series like this.
Awesome tutorial so far! Though I would stop with the speeding up the videos! 😁
Hi, where can I learn more about Assembly?
i dont get it, how do i get "root dir size"?
Apologies for the late and somewhat unrelated comment, but which OS and theme are you using for these videos? I really like the clean and simplistic look.
@jackwalker4887
8 ай бұрын
Judging by the icon in the top left corner of the screen this would be Linux with the KDE desktop and I reckon he could be using the Breeze Dark theme?
@toslaw9615
7 ай бұрын
In the first part of the series he said which OS he uses, it's Ubuntu if I'm not mistaken.
@Sebwazhere
6 ай бұрын
@@toslaw9615 In the comments of episode 2 he said he uses Kubuntu
@toslaw9615
6 ай бұрын
@@Sebwazhere it's just Ubuntu with KDE instead of GNOME.
@Sebwazhere
6 ай бұрын
@@toslaw9615 oh ok
kindly dont fast forward the coding part. its the best part
nanobyte: 'and ofc, c doesn't have boolean types' stdbool.h: 'what?'
@pebble24
11 ай бұрын
yeah I got confused by that and googled the standard to check lol. it was introduced in C99
@IlliaZhdanov
11 ай бұрын
@@pebble24 yep.
Hey , do you implement journaling for the filesystem in your series ?
@remsalt3882
2 жыл бұрын
i think this series is over man'
@nanobyte-dev
2 жыл бұрын
It's not, I promise. It just takes a lot of time to finish a video. I've been trying to keep a monthly schedule, but with kids it's hard to keep to it. I'm currently editing part 9, hoping to release it in maybe 2-3 weeks.
I think there's a mistake. in 6:32 the table shows 1 sectors per cluster, but in 9:51 you wrote that we have 2 sectors per cluster.
@UltimusTheSoldier
9 ай бұрын
@ncurses.h nice catch!
this is an awesome series and i'm learning a huge amount, however it would be helpful to not speed up the code-writing phase as much, I personally find it quite difficult to keep up.
@nanobyte-dev
2 жыл бұрын
Thank you, I've learned from my mistake and it gets better in newer videos.
@jawad9757
2 жыл бұрын
@@nanobyte-dev awesome, thanks for taking the time to read my comment
On a Mac, whenever I try to run your code I get: gcc -g -o -v build/tools tools/fat/fat.c ld: file cannot be mmap()ed, errno=22 path=build/tools in 'build/tools' clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [build/tools/fat] Error 1 Any tips?
@nanobyte-dev
4 ай бұрын
In this particular video, I was using Kubuntu. In later videos, I switched to Fedora.
Even ChatGPT (Artificient Intelligence) suggested me this Video! Very good tutorial!!!
Why do we have to write fat.c in assembly ?
@MorePixels-ff8tv
Ай бұрын
fat.c is just writing the complicated assembly code into c so you can understand it and then you type the assembly code because its easier
when will be the next episode ??
@majkus5224
3 жыл бұрын
you should user input in next episode
@nanobyte-dev
3 жыл бұрын
Next episode is in work, and I'm hoping to finish it within the next 2-3 weeks, these take a lot of time to do. It will be about writing code in C. User input is not actually that hard in real mode, you can find this information online. Look for int16 ah=00 bios interrupt. My focus is to get to 64bit protected mode and cover all the basics, after which we will write some drivers for keyboard, storage, maybe even graphics.
@majkus5224
3 жыл бұрын
could you say something more about user input or link a documentation or some tutorial
@nanobyte-dev
3 жыл бұрын
@@majkus5224 Join me on discord, and we can talk more about it :) discord.gg/RgHc5XrCEw
I get segment fault when running the fat program
@Shadowblitz16
Жыл бұрын
I fixed it. if you have this problem make sure your doing ok = ok && (fread(bufferOut , g_BootSector.BytesPerSector, count, disk ) == count); instead of ok = ok && (fread(bufferOut , g_BootSector.BytesPerSector, count, SEEK_SET) == count); XD
@ningleizhang9060
Жыл бұрын
@@Shadowblitz16 i got the same problem, after use disk instead of seek_set the segment fault is gone. but readSectors will return false do you fix this ?
@Shadowblitz16
Жыл бұрын
@@ningleizhang9060 I would recommend going to his github on this video's commit and comparing your code to his. It is most likely a typo somewhere on your end. I make typos all the time and have to compare my code to his. although if you can't even compile his version it could be a issue with one of the libraries, I had to update my gcc and binutils versions in one of the later videos I followed because they caused a segfault
@ningleizhang9060
Жыл бұрын
@@Shadowblitz16 yes, after i replaced some code, everything is fine, thinks just somewhere typos.haha
@IlliaZhdanov
11 ай бұрын
wait WHAT? i had the same issue before. And never realised that this was the solution. Thanks
What did I do wrong? I can't get the OS to work anymore. :\
@nanobyte-dev
11 ай бұрын
I'm sorry to hear that. If come to our discord channel, we can help you solve the problem.
@HEDGEBATCAT
11 ай бұрын
@@nanobyte-dev okay, thanks.
This is a very good series but i find it both difficult and irritating that the coding is spead up. I personally like when the person in the video explains what things does and when it is coded live and you do not have a voice over. but this is a good series and a good channel so i just wanted to give you a tip that you could better if you 1. code live(not recording and then make a voice over) and explain what things does. 2. dont speed it up.
@nanobyte-dev
Жыл бұрын
I understand that, but for me, I script my videos because I can explain things better by not trying to explain at the same time that I'm coding. I also want to reduce how long the videos are, because if I didn't speed anything up the videos would be 1-2h long. In any case, at least in newer videos, I speed up a lot less aggressively and do my best to keep it easy to follow.
@mastergamer4335
Жыл бұрын
@@nanobyte-dev i understand you. And great 👍.
12:53
I hope the file system can lose weight…
@notmanciv5016
Ай бұрын
😭
Timestamp for tommorow 13:37 18:25
Why do people like do have a bunch of spaces in a for loop? like 18:31 i would write that for loop like this: for(uint32_t i=0;i
@nanobyte-dev
Жыл бұрын
Personally, I disagree. I think spacing things out makes code much more readable.
@mastergamer4335
Жыл бұрын
@@nanobyte-dev in some cases but for the most parti like to compress the code.
@nanobyte-dev
Жыл бұрын
If it helps you read and understand it better, sure, I have no problem with that. Me, and in my experience most other people, prefer using lots of spaces. A long time ago, screens were really small and you couldn't fit a lot of code which is why old code tends to be more compressed.
@mastergamer4335
Жыл бұрын
@@nanobyte-dev yeah it does. When i add a bunch of spacing the everything it starts to feel like python or something lol.
@nanobyte-dev
Жыл бұрын
@@mastergamer4335 What's wrong if it feels like python? I love python.
i get the error src/bootloader/boot.asm:228: error: TIMES value -129 is negative make: *** [Makefile:23: build/bootloader.bin] Error 1, and this is the code: times 510-($-$$) db 0 can you help?
@IlliaZhdanov
11 ай бұрын
just try to strip out the unnecessary code if you have some.
@unixity_WasTaken
11 ай бұрын
@@IlliaZhdanov wdym?
@MiraiMindz
11 ай бұрын
@@unixity_WasTaken This is mainly because your code is getting 129 bits beyond the 512 range, thus making it out of bound and creating this "negative times value", remove some unecessary instructions, use lower registers and lower the number of variables or the size of them, for instance, using AL instead of AX could make your code smaller ONLY if you are insterested in the lower bits of AX, and shrinking any variables can make a HUGE impact on the size too.
@unixity_WasTaken
11 ай бұрын
@@MiraiMindz i dont know alot of asm so can you show me an example
@nanobyte-dev
11 ай бұрын
You either have too much code, or strings that are too long. 512 bytes fill up fast.
When i use the ./build/tools/fat build/main_floppy.img TEST TXT this gives me "Could Not read FAT!" all the time, it doesn't matter if the file doesn't exist, it always puts that or when I put ./build/tools/fat build/main_floppy.img "TEST TXT" I get a syntax error that generates Fat.c, please help
@unixity_WasTaken
Жыл бұрын
can you send the code?
im still on 19:37, but I always got: [1] 3873 segmentation fault ./build/tools/fat build/main_floppy.img "TEST TXT" idk why
@IlliaZhdanov
11 ай бұрын
what's your code?
@nanobyte-dev
11 ай бұрын
Check the github repo linked in the description, you might have a typo