Building an OS - 3 - The FAT file system

Поділитися
Вставка
  • Опубліковано 22 сер 2024
  • 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/nan...
    Tools:
    - Bochs: bochs.sourcefor...
    - mtools: www.gnu.org/so...
    - VSCode: code.visualstu...
    - Okteta (Linux): apps.kde.org/e...
    - HxD hex editor (Windows): mh-nexus.de/en...
    Documentation:
    - FAT12 file system: wiki.osdev.org...
    - INT 13h: www.stanislavs...
    - x86 instruction reference: c9x.me/x86/

КОМЕНТАРІ • 118

  • @treytomes
    @treytomes Рік тому +8

    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
      @nanobyte-dev  Рік тому +1

      The coding part is sped up a bit. I'm glad you're enjoying it.

    • @treytomes
      @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
      @nanobyte-dev  Рік тому +2

      @@treytomes You can skip the watcom stuff... just watch 2 more videos until I return to GCC's loving arms.

  • @bro-fi4gc
    @bro-fi4gc 2 роки тому +15

    these videos are amazing, the best osdev content on youtube!
    awesome job!!

  • @manni.Net60
    @manni.Net60 Рік тому +8

    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

  • @Dani-pl1cv
    @Dani-pl1cv 3 роки тому +13

    Great series, hope to see more!

    • @nanobyte-dev
      @nanobyte-dev  3 роки тому +4

      Thank you, more is definitely coming :)

  • @adrianstephens56
    @adrianstephens56 Рік тому +3

    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.

  • @thecodingpress5970
    @thecodingpress5970 2 роки тому +51

    This is definitely the best os development content i have seen so far, where did you find out how to do all this?

    • @tedbasher3000
      @tedbasher3000 Рік тому

      most likely by studying up on file systems, assembly, c, bioses and everything else required

    • @nanobyte-dev
      @nanobyte-dev  Рік тому +18

      I started just like you, reading tutorials (10 years ago there wasn't much on UA-cam). 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
      @legacywolf443 Рік тому +1

      If you're patient enough you just need Wikipedia honestly

    • @nanobyte-dev
      @nanobyte-dev  Рік тому +5

      @@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
      @raxneff 11 місяців тому +2

      @@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, ...)

  • @radeksmola3422
    @radeksmola3422 5 місяців тому +1

    Thank you, very great article. I remember writing my own OS 25 years ago. You are master BTW ;)

  • @ashajjar
    @ashajjar Рік тому +1

    I want to take a minute to appreciate your music choice 🤩

  • @user-zb2bl2jc5x
    @user-zb2bl2jc5x Рік тому +1

    Thank you, your explanation is one of the best and it serves perfectly as a complementary to other materials

    • @nanobyte-dev
      @nanobyte-dev  Рік тому

      Unfortunately my job and my kids won't let me work during the day...

  • @thomascarlsen8097
    @thomascarlsen8097 2 роки тому +4

    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
      @nanobyte-dev  2 роки тому +2

      Thanks for the feedback. I agree that the code is a bit too sped up in the earlier videos like this one.

  • @raphodule185
    @raphodule185 3 роки тому +1

    Continu please, you are awesome 😎

  • @lens3973
    @lens3973 2 роки тому +5

    Ah, the wonderful days of bios interrupts.
    At least it saves you from spending a week writing a disk driver 🤣

    • @unixity_WasTaken
      @unixity_WasTaken Рік тому

      trust me, one time it took me a month writing a disk driver

    • @JtagSheep
      @JtagSheep Рік тому

      Interrupts are your friend... till you load the kernel :D

  • @WistrelChianti
    @WistrelChianti 2 роки тому +1

    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
      @nanobyte-dev  2 роки тому +1

      Many people start watching, but not that many finish. It happens will any series like this.

  • @yuka1367
    @yuka1367 2 роки тому

    You intro movie is very cool!

  • @Super_Music_Channel
    @Super_Music_Channel Місяць тому

    Please, make tutorial series about building an UEFI-based OS.

  • @stormz4040
    @stormz4040 3 роки тому +1

    Awesome videos!
    I just subscribed to your channel.

  • @chaitanyabhatt7915
    @chaitanyabhatt7915 Рік тому +1

    kindly dont fast forward the coding part. its the best part

  • @mikefinnerty1852
    @mikefinnerty1852 11 місяців тому

    Amazing job!

  • @jawad9757
    @jawad9757 2 роки тому +8

    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
      @nanobyte-dev  2 роки тому +3

      Thank you, I've learned from my mistake and it gets better in newer videos.

    • @jawad9757
      @jawad9757 2 роки тому

      @@nanobyte-dev awesome, thanks for taking the time to read my comment

  • @kennethlooney6769
    @kennethlooney6769 2 роки тому

    Awesome tutorial so far! Though I would stop with the speeding up the videos! 😁

  • @IlliaZhdanov
    @IlliaZhdanov Рік тому +5

    nanobyte: 'and ofc, c doesn't have boolean types'
    stdbool.h: 'what?'

    • @pebble24
      @pebble24 Рік тому

      yeah I got confused by that and googled the standard to check lol. it was introduced in C99

    • @IlliaZhdanov
      @IlliaZhdanov Рік тому

      @@pebble24 yep.

  • @Scaik
    @Scaik Рік тому +2

    i dont get it, how do i get "root dir size"?

  • @pizzainc.1465
    @pizzainc.1465 5 місяців тому +5

    I hope the file system can lose weight…

  • @mohmoh6856
    @mohmoh6856 2 роки тому

    great work i love this

  • @UltimusTheSoldier
    @UltimusTheSoldier Рік тому +1

    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.

  • @rizzyhizzy173
    @rizzyhizzy173 11 місяців тому

    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
      @jackwalker4887 9 місяців тому

      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
      @toslaw9615 8 місяців тому +1

      In the first part of the series he said which OS he uses, it's Ubuntu if I'm not mistaken.

    • @Sebwazhere
      @Sebwazhere 8 місяців тому

      @@toslaw9615 In the comments of episode 2 he said he uses Kubuntu

    • @toslaw9615
      @toslaw9615 8 місяців тому

      @@Sebwazhere it's just Ubuntu with KDE instead of GNOME.

    • @Sebwazhere
      @Sebwazhere 8 місяців тому

      @@toslaw9615 oh ok

  • @algoimer5013
    @algoimer5013 6 місяців тому

    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
      @nanobyte-dev  6 місяців тому

      In this particular video, I was using Kubuntu. In later videos, I switched to Fedora.

  • @nizambhagaskara8317
    @nizambhagaskara8317 2 роки тому

    Hi, where can I learn more about Assembly?

  • @mastergamer4335
    @mastergamer4335 2 роки тому +1

    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
      @nanobyte-dev  2 роки тому +2

      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
      @mastergamer4335 2 роки тому

      @@nanobyte-dev i understand you. And great 👍.

  • @programmieren_lernen
    @programmieren_lernen 7 місяців тому

    Even ChatGPT (Artificient Intelligence) suggested me this Video! Very good tutorial!!!

  • @Shadowblitz16
    @Shadowblitz16 Рік тому

    I get segment fault when running the fat program

    • @Shadowblitz16
      @Shadowblitz16 Рік тому +2

      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
      @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
      @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
      @ningleizhang9060 Рік тому

      @@Shadowblitz16 yes, after i replaced some code, everything is fine, thinks just somewhere typos.haha

    • @IlliaZhdanov
      @IlliaZhdanov Рік тому

      wait WHAT? i had the same issue before. And never realised that this was the solution. Thanks

  • @Teog1992
    @Teog1992 2 роки тому

    Hey , do you implement journaling for the filesystem in your series ?

    • @remsalt3882
      @remsalt3882 2 роки тому

      i think this series is over man'

    • @nanobyte-dev
      @nanobyte-dev  2 роки тому +8

      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.

  • @HEDGEBATCAT
    @HEDGEBATCAT Рік тому

    What did I do wrong? I can't get the OS to work anymore. :\

    • @nanobyte-dev
      @nanobyte-dev  Рік тому

      I'm sorry to hear that. If come to our discord channel, we can help you solve the problem.

    • @HEDGEBATCAT
      @HEDGEBATCAT Рік тому

      @@nanobyte-dev okay, thanks.

  • @user-wi4jn8pp6w
    @user-wi4jn8pp6w 11 місяців тому

    Why do we have to write fat.c in assembly ?

    • @MorePixels-ff8tv
      @MorePixels-ff8tv 2 місяці тому

      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

  • @EggerMan69
    @EggerMan69 Рік тому

    12:53

  • @majkus5224
    @majkus5224 3 роки тому

    when will be the next episode ??

    • @majkus5224
      @majkus5224 3 роки тому

      you should user input in next episode

    • @nanobyte-dev
      @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
      @majkus5224 3 роки тому

      could you say something more about user input or link a documentation or some tutorial

    • @nanobyte-dev
      @nanobyte-dev  3 роки тому

      @@majkus5224 Join me on discord, and we can talk more about it :) discord.gg/RgHc5XrCEw

  • @kuusik100
    @kuusik100 Рік тому

    Timestamp for tommorow
    13:37
    18:25

  • @mastergamer4335
    @mastergamer4335 2 роки тому

    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
      @nanobyte-dev  2 роки тому

      Personally, I disagree. I think spacing things out makes code much more readable.

    • @mastergamer4335
      @mastergamer4335 2 роки тому

      @@nanobyte-dev in some cases but for the most parti like to compress the code.

    • @nanobyte-dev
      @nanobyte-dev  2 роки тому

      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
      @mastergamer4335 2 роки тому

      @@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
      @nanobyte-dev  2 роки тому

      @@mastergamer4335 What's wrong if it feels like python? I love python.

  • @unixity_WasTaken
    @unixity_WasTaken Рік тому

    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
      @IlliaZhdanov Рік тому

      just try to strip out the unnecessary code if you have some.

    • @unixity_WasTaken
      @unixity_WasTaken Рік тому

      @@IlliaZhdanov wdym?

    • @MiraiMindz
      @MiraiMindz Рік тому

      @@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
      @unixity_WasTaken Рік тому

      @@MiraiMindz i dont know alot of asm so can you show me an example

    • @nanobyte-dev
      @nanobyte-dev  Рік тому

      You either have too much code, or strings that are too long. 512 bytes fill up fast.

  • @wazt2732
    @wazt2732 Рік тому

    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

  • @Sean-gm4ns
    @Sean-gm4ns Рік тому

    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
      @IlliaZhdanov Рік тому

      what's your code?

    • @nanobyte-dev
      @nanobyte-dev  Рік тому

      Check the github repo linked in the description, you might have a typo