Skip to content

Commit 95591db

Browse files
committed
Update readme and improve makefile
1 parent 5c03d45 commit 95591db

File tree

3 files changed

+67
-23
lines changed

3 files changed

+67
-23
lines changed

Makefile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# KallistiOS ##version##
2+
#
3+
# libfatfs Makefile
4+
# (C) 2025 Ruslan Rostovtsev
5+
#
6+
7+
.PHONY: all
8+
9+
# Default target
10+
all:
11+
$(MAKE) -C fatfs
12+
13+
# Pass all targets to fatfs/Makefile
14+
%:
15+
$(MAKE) -C fatfs $@

README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,30 @@ cp -R include fatfs /opt/toolchains/dc/kos/addons
1515
make
1616
```
1717

18+
### Build Options
19+
You can customize the build with the following options:
20+
- `DEBUG=1` - Enable debug output (disabled by default)
21+
- `DMA_BUF=0` - Disable DMA buffer (enabled by default)
22+
- `SD_CHECK_CRC=1` - Enable CRC checking for SD cards (disabled by default)
23+
24+
Examples:
25+
```console
26+
# Build with defaults
27+
make
28+
29+
# Build with CRC checking for SD cards
30+
make SD_CHECK_CRC=1
31+
32+
# Build without DMA buffer
33+
make DMA_BUF=0
34+
```
35+
1836
## Usage
1937
- Add `#include <fatfs.h>` in your C source file.
2038
- Add `-lfatfs` in your `Makefile` on the line which builds your program, e.g.:
2139
- `kos-cc -o $(TARGET) $(OBJS) -lfatfs`
2240
- Simply call `fs_fat_mount_sd()` to mount a FAT partition to `/sd` and/or call `fs_fat_mount_ide()` to mount a FAT partition to `/ide`.
2341
- Additionally, you can use other block devices by calling `fs_fat_mount()` with the appropriate parameters for the target device -- see `fatfs.h` for more information.
24-
- To reduce memory usage you can disable DMA buffer, look in `Makefile`.
2542

2643
## Links
2744
- DreamShell: https://github.com/DC-SWAT/DreamShell

fatfs/Makefile

+34-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
# KallistiOS ##version##
2-
#
3-
# libfatfs Makefile
4-
# (C) 2025 Ruslan Rostovtsev
5-
#
6-
7-
TARGET = libfatfs.a
8-
OBJS = src/option/ccsbcs.o \
9-
src/option/syscall.o \
10-
src/ff.o \
11-
src/dc.o \
12-
src/dc_bdev.o
13-
14-
KOS_CFLAGS += -W -Wextra -pedantic -Isrc -I../include
15-
16-
# Uncomment to enable debug output.
17-
# KOS_CFLAGS += -DFATFS_DEBUG=1
18-
19-
# Comment out to reduce memory usage.
20-
KOS_CFLAGS += -DFATFS_USE_DMA_BUF=1
21-
22-
include $(KOS_BASE)/addons/Makefile.prefab
1+
# KallistiOS ##version##
2+
#
3+
# libfatfs Makefile
4+
# (C) 2025 Ruslan Rostovtsev
5+
#
6+
7+
TARGET = libfatfs.a
8+
OBJS = src/option/ccsbcs.o \
9+
src/option/syscall.o \
10+
src/ff.o \
11+
src/dc.o \
12+
src/dc_bdev.o
13+
14+
KOS_CFLAGS += -W -Wextra -pedantic -Isrc -I../include
15+
16+
# Enable debug output if DEBUG=1
17+
ifdef DEBUG
18+
KOS_CFLAGS += -DFATFS_DEBUG=1
19+
endif
20+
21+
# Enable DMA buffer unless DMA_BUF=0
22+
ifndef DMA_BUF
23+
DMA_BUF = 1
24+
endif
25+
ifeq ($(DMA_BUF), 1)
26+
KOS_CFLAGS += -DFATFS_USE_DMA_BUF=1
27+
endif
28+
29+
# Enable CRC checking for SD cards if SD_CHECK_CRC=1
30+
ifdef SD_CHECK_CRC
31+
KOS_CFLAGS += -DFATFS_SD_CHECK_CRC=1
32+
endif
33+
34+
include $(KOS_BASE)/addons/Makefile.prefab

0 commit comments

Comments
 (0)