xistor 910619de4c fix missing semicolon 1 yıl önce
..
Makefile 426205e2a3 Added makefiles for LLVM Clang 5 yıl önce
Makefile.clang 9c5c2813a0 Update QEMU command in all README and Makefile 2 yıl önce
Makefile.gcc 9c5c2813a0 Update QEMU command in all README and Makefile 2 yıl önce
OLVASSEL.md 9c5c2813a0 Update QEMU command in all README and Makefile 2 yıl önce
README.md 47022f22d7 Fixed typos 2 yıl önce
delays.c 910619de4c fix missing semicolon 1 yıl önce
delays.h 7ace64ba9f Initial commit 6 yıl önce
fat.c a9a9d5234a Update fat.c 2 yıl önce
fat.h 7c337daa89 change access to unaligned data to use individual "char" 6 yıl önce
gpio.h 7ace64ba9f Initial commit 6 yıl önce
kernel8.img 8ce0f75b47 Recompiled with latest gcc 4 yıl önce
link.ld 7ace64ba9f Initial commit 6 yıl önce
main.c 7ace64ba9f Initial commit 6 yıl önce
mbox.c 214885df63 compute the mailbox cmd only once 6 yıl önce
mbox.h 7ace64ba9f Initial commit 6 yıl önce
sd.c 0c0b9a5b21 Fixed newline 6 yıl önce
sd.h 7ace64ba9f Initial commit 6 yıl önce
start.S ea4691947c Improve comments wrt stack setup 3 yıl önce
uart.c 8a80ab88b9 Clearified mbox call in uart per issue #49 6 yıl önce
uart.h 7ace64ba9f Initial commit 6 yıl önce

README.md

Tutorial 0D - Read File

We learned how to read and parse the root directory. In this tutorial we'll get one file from the root directory, and walk through the cluster chain to load it entirely into memory.

$ qemu-system-aarch64 -M raspi3b -drive file=test.dd,if=sd,format=raw -serial stdio
        ... output removed for clarity ...
FAT File LICENC~1BRO starts at cluster: 00000192
FAT Bytes per Sector: 00000200
FAT Sectors per Cluster: 00000004
FAT Number of FAT: 00000002
FAT Sectors per FAT: 00000014
FAT Reserved Sectors Count: 00000004
FAT First data sector: 00000054
        ... output removed for clarity ...
00085020: 43 6F 70 79  72 69 67 68  74 20 28 63  29 20 32 30  Copyright (c) 20
00085030: 30 36 2C 20  42 72 6F 61  64 63 6F 6D  20 43 6F 72  06, Broadcom Cor
00085040: 70 6F 72 61  74 69 6F 6E  2E 0A 43 6F  70 79 72 69  poration..Copyri
00085050: 67 68 74 20  28 63 29 20  32 30 31 35  2C 20 52 61  ght (c) 2015, Ra
00085060: 73 70 62 65  72 72 79 20  50 69 20 28  54 72 61 64  spberry Pi (Trad
00085070: 69 6E 67 29  20 4C 74 64  0A 41 6C 6C  20 72 69 67  ing) Ltd.All rig
        ... output removed for clearity ...

Fat.h, fat.c

This is also easy and pretty well documented. We locate the directory entry for our file, and get the starting cluster number. Then we load each cluster into memory as we walk the cluster chain.

fat_getpartition() load and check the boot record of the first MBR partition.

fat_getcluster(fn) return the starting cluster for the given filename.

fat_readfile(clu) reads a file into memory, returns pointer to the first byte.

Main

Once we initialize EMMC to read sectors, we load the boot record of the first partition. If the BPB describes a valid FAT partition, we find the starting cluster for the file 'LICENCE.broadcom'. If that not found, we'll look for 'kernel8.img'. If any of these found, we load it and dump it's first 512 bytes.