mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/fatfs: switched to git mirror for downloading FatFs code instead of authors webserver, added Makefile.dep for fatfs, cleanup code for using rtc
This commit is contained in:
parent
e0f60ba10a
commit
938fe26757
@ -8,10 +8,6 @@ OLD_USEPKG := $(sort $(USEPKG))
|
||||
# pull dependencies from drivers
|
||||
include $(RIOTBASE)/drivers/Makefile.dep
|
||||
|
||||
ifneq (,$(filter fatfs_diskio_sdcard_spi,$(USEMODULE)))
|
||||
USEMODULE += sdcard_spi
|
||||
endif
|
||||
|
||||
ifneq (,$(filter csma_sender,$(USEMODULE)))
|
||||
USEMODULE += random
|
||||
USEMODULE += xtimer
|
||||
|
@ -1,58 +1,13 @@
|
||||
PKG_NAME = fatfs
|
||||
PKG_URL = elm-chan.org/fsw/ff/arc
|
||||
PKG_VERSION = ff12b
|
||||
PKG_EXT = zip
|
||||
PKG_FILE = $(PKG_NAME)-$(PKG_VERSION).$(PKG_EXT)
|
||||
PKG_BUILDDIR = $(PKGDIRBASE)/$(PKG_NAME)
|
||||
MODULE_MAKEFILE := $(CURDIR)/Makefile.module
|
||||
PKG_NAME=fatfs
|
||||
PKG_URL=https://github.com/MichelRottleuthner/FatFs_for_RIOT.git
|
||||
PKG_VERSION=61fd6ae3815170bf7bf6121f33f1ef68c2b11599
|
||||
PKG_LICENSE=BSD-1-Clause
|
||||
MODULE_MAKEFILE := $(CURDIR)/Makefile.fatfs
|
||||
|
||||
ifneq ($(RIOTBASE),)
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
endif
|
||||
.PHONY: all
|
||||
|
||||
.PHONY: all clean patch
|
||||
|
||||
all: $(PKG_BUILDDIR)/.patched
|
||||
|
||||
ffconf_patches += $(CURDIR)/patches/enable_use_lable.patch
|
||||
ffconf_patches += $(CURDIR)/patches/set_code_page_to_ascii.patch
|
||||
ffconf_patches += $(CURDIR)/patches/enable_use_mkfs.patch
|
||||
ffconf_patches += $(CURDIR)/patches/enable_fs_tiny.patch
|
||||
|
||||
#if periph_rtc is available use it. Otherwise use static timestamps
|
||||
ifeq (, $(filter $(periph_rtc), $(FEATURES_PROVIDED)))
|
||||
ffconf_patches += $(CURDIR)/patches/disable_rtc.patch
|
||||
FEATURES_REQUIRED += periph_rtc
|
||||
endif
|
||||
|
||||
$(PKG_BUILDDIR)/.patched: $(PKG_BUILDDIR)/.prepared
|
||||
@$(foreach p, $(ffconf_patches), patch $(PKG_BUILDDIR)/ffconf.h < $(p);)
|
||||
@patch $(PKG_BUILDDIR)/integer.h < $(CURDIR)/patches/remove_int_type.patch
|
||||
@patch $(PKG_BUILDDIR)/ff.c < $(CURDIR)/patches/fix_for_guards.patch
|
||||
@touch $@
|
||||
|
||||
$(PKG_BUILDDIR)/.prepared: $(PKG_BUILDDIR)/.extracted
|
||||
@mv $(PKG_BUILDDIR)/src/* $(PKG_BUILDDIR)/
|
||||
@rm -rf $(PKG_BUILDDIR)/src
|
||||
@rm -rf $(PKG_BUILDDIR)/doc
|
||||
|
||||
#this file is only a dummy that should be replaced by a compatible implementation
|
||||
@rm $(PKG_BUILDDIR)/diskio.c
|
||||
all: git-download
|
||||
@cp $(MODULE_MAKEFILE) $(PKG_BUILDDIR)/Makefile
|
||||
@touch $@
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)
|
||||
|
||||
$(PKG_BUILDDIR)/.extracted: $(PKG_BUILDDIR)/$(PKG_FILE)
|
||||
@mkdir -p $(@D)
|
||||
@cd $(@D) && $(UNZIP_HERE) $(<)
|
||||
@touch $@
|
||||
|
||||
$(PKG_BUILDDIR)/$(PKG_FILE):
|
||||
@mkdir -p $(@D)
|
||||
@$(DOWNLOAD_TO_FILE) $@ $(PKG_URL)/$(PKG_VERSION).$(PKG_EXT)
|
||||
|
||||
clean::
|
||||
#delete all files except the downloaded zip file
|
||||
@ls -A $(PKG_BUILDDIR)/ | grep -v $(PKG_FILE) | xargs -I % rm -rf $(PKG_BUILDDIR)/%
|
||||
|
||||
distclean::
|
||||
@rm -rf $(PKG_BUILDDIR)
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
16
pkg/fatfs/Makefile.dep
Normal file
16
pkg/fatfs/Makefile.dep
Normal file
@ -0,0 +1,16 @@
|
||||
ifneq (,$(filter fatfs_diskio_sdcard_spi,$(USEMODULE)))
|
||||
USEMODULE += sdcard_spi
|
||||
endif
|
||||
|
||||
ifneq (,$(filter fatfs,$(USEPKG)))
|
||||
USEMODULE += fatfs_diskio_common
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/boards/$(BOARD)/Makefile.features
|
||||
|
||||
#if periph_rtc is available use it. Otherwise use static timestamps
|
||||
ifneq (, $(filter periph_rtc, $(FEATURES_PROVIDED)))
|
||||
export CFLAGS+= -DFATFS_FFCONF_OPT_FS_NORTC=0
|
||||
else
|
||||
export CFLAGS+= -DFATFS_FFCONF_OPT_FS_NORTC=1
|
||||
endif
|
@ -1 +1,3 @@
|
||||
MODULE=fatfs
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -1,7 +1,9 @@
|
||||
INCLUDES += -I$(PKGDIRBASE)
|
||||
INCLUDES += -I$(RIOTPKG)/fatfs/fatfs_diskio/include
|
||||
INCLUDES += -I$(RIOTPKG)/fatfs/fatfs_diskio/common/include
|
||||
DIRS += $(PKGDIRBASE)/fatfs
|
||||
|
||||
DIRS += $(RIOTBASE)/pkg/fatfs/fatfs_diskio/common
|
||||
|
||||
ifneq (,$(filter fatfs_diskio_native,$(USEMODULE)))
|
||||
DIRS += $(RIOTBASE)/pkg/fatfs/fatfs_diskio/native
|
||||
endif
|
||||
|
@ -1,2 +1,3 @@
|
||||
MODULE = fatfs_diskio
|
||||
MODULE = fatfs_diskio_common
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -21,13 +21,11 @@
|
||||
|
||||
#include "fatfs/diskio.h" /* FatFs lower layer API */
|
||||
#include "fatfs_diskio_common.h"
|
||||
#include "time.h"
|
||||
#include "stdint.h"
|
||||
|
||||
#ifdef FATFS_RTC_AVAILABLE
|
||||
#define FATFS_DISKIO_FATTIME_YEAR_OFFS 25
|
||||
#define FATFS_DISKIO_FATTIME_MON_OFFS 21
|
||||
#define FATFS_DISKIO_FATTIME_DAY_OFFS 16
|
||||
#define FATFS_DISKIO_FATTIME_HH_OFFS 11
|
||||
#define FATFS_DISKIO_FATTIME_MM_OFFS 5
|
||||
#if FATFS_FFCONF_OPT_FS_NORTC == 0
|
||||
#include "periph/rtc.h"
|
||||
|
||||
DWORD get_fattime(void)
|
||||
{
|
@ -24,24 +24,18 @@ extern "C" {
|
||||
|
||||
#include "fatfs/diskio.h" /* FatFs lower layer API */
|
||||
|
||||
#define CTRL_SYNC 0 /* Complete pending write process
|
||||
(needed when _FS_READONLY == 0) */
|
||||
#define RTC_YEAR_OFFSET (1900)
|
||||
#define FATFS_YEAR_OFFSET (1980)
|
||||
|
||||
#define GET_SECTOR_COUNT 1 /* (needed when _USE_MKFS == 1) */
|
||||
#define FIXED_BLOCK_SIZE (512)
|
||||
|
||||
#define GET_SECTOR_SIZE 2 /* (needed when _MAX_SS > 512 ) */
|
||||
#define FATFS_DISKIO_DSTASTUS_OK (0)
|
||||
|
||||
#define GET_BLOCK_SIZE 3 /* erase block size (needed when _USE_MKFS == 1) */
|
||||
|
||||
#define CTRL_TRIM 4 /* Inform device about no longer needed data blocks
|
||||
(needed when _USE_TRIM == 1) */
|
||||
|
||||
#define RTC_YEAR_OFFSET 1900
|
||||
#define FATFS_YEAR_OFFSET 1980
|
||||
|
||||
#define FIXED_BLOCK_SIZE 512
|
||||
|
||||
#define FATFS_DISKIO_DSTASTUS_OK 0
|
||||
#define FATFS_DISKIO_FATTIME_YEAR_OFFS (25)
|
||||
#define FATFS_DISKIO_FATTIME_MON_OFFS (21)
|
||||
#define FATFS_DISKIO_FATTIME_DAY_OFFS (16)
|
||||
#define FATFS_DISKIO_FATTIME_HH_OFFS (11)
|
||||
#define FATFS_DISKIO_FATTIME_MM_OFFS (5)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -2,10 +2,4 @@ MODULE = fatfs_diskio_sdcard_spi
|
||||
|
||||
USEMODULE += sdcard_spi
|
||||
|
||||
#if periph_rtc is available use it. Otherwise use static timestamps
|
||||
ifneq (, $(filter $(periph_rtc), $(FEATURES_PROVIDED)))
|
||||
CFLAGS += -DFATFS_RTC_AVAILABLE
|
||||
USEMODULE += periph_rtc
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -18,9 +18,10 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef FATFS_RTC_AVAILABLE
|
||||
#if FATFS_FFCONF_OPT_FS_NORTC == 0
|
||||
#include "periph/rtc.h"
|
||||
#endif
|
||||
#include "fatfs_diskio_common.h"
|
||||
#include "fatfs/ff.h"
|
||||
#include "shell.h"
|
||||
#include <string.h>
|
||||
@ -29,7 +30,6 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define TEST_FATFS_RTC_YEAR_OFFSET 1900
|
||||
#define TEST_FATFS_READ_BUFFER_SIZE 64
|
||||
#define TEST_FATFS_MAX_LBL_SIZE 64
|
||||
#define TEST_FATFS_MAX_VOL_STR_LEN 8
|
||||
@ -350,7 +350,7 @@ static const shell_command_t shell_commands[] = {
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#ifdef FATFS_RTC_AVAILABLE
|
||||
#if FATFS_FFCONF_OPT_FS_NORTC == 0
|
||||
/* the rtc is used in diskio.c for timestamps of files */
|
||||
puts("Initializing the RTC driver");
|
||||
rtc_poweron();
|
||||
@ -366,7 +366,7 @@ int main(void)
|
||||
|
||||
printf("Setting RTC to %04d-%02d-%02d %02d:%02d:%02d\n",
|
||||
time.tm_year + RTC_YEAR_OFFSET,
|
||||
time.tm_mon + RTC_MON_OFFSET,
|
||||
time.tm_mon + TEST_FATFS_RTC_MON_OFFSET,
|
||||
time.tm_mday,
|
||||
time.tm_hour,
|
||||
time.tm_min,
|
||||
|
Loading…
Reference in New Issue
Block a user