Skip to content

Commit

Permalink
Remove placeholder MEMCARD.MCR creation, fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
dangiu committed Jun 9, 2022
1 parent 65948f7 commit 2681a1e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion inc/lfs_disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define LFS_BLOCK_SIZE 4096

#define MEMCARD_FILE_NAME "memcard.mcr" // name of memcard file inside system
#define MEMCARD_FILE_CONTENT_SIZE 131072 // size of memcard file content in bytes (128KB)

/* LittleFS filesystem configuration */
extern const struct lfs_config LFS_CFG;
Expand Down
2 changes: 1 addition & 1 deletion src/lfs_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ const struct lfs_config LFS_CFG = {
.block_cycles = 500,
};

__attribute__((section(".lfs"))) const uint8_t LFS_SPACE[LFS_BLOCK_COUNT * LFS_BLOCK_SIZE]; // space allocated to LFS
__attribute__((section(".lfs"))) const uint8_t LFS_SPACE[LFS_BLOCK_COUNT * LFS_BLOCK_SIZE]; // space allocated to LFS
7 changes: 4 additions & 3 deletions src/ram_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ff.h"
#include "lfs.h"
#include "lfs_disk.h"
#include "memory_card.h"

#define WORK_BUFF_SIZE 1024

Expand Down Expand Up @@ -106,9 +107,9 @@ uint32_t RAM_disk_import_lfs_memcard() {

/* Check stored memory card size */
if(LFS_ERR_OK == lfs_mount(&lfs, &LFS_CFG)) {
if(LFS_ERR_OK == lfs_file_open(&lfs, &memcard_lfs, MEMCARD_FILE_NAME, LFS_O_RDWR | LFS_O_CREAT)) {
if(LFS_ERR_OK == lfs_file_open(&lfs, &memcard_lfs, MEMCARD_FILE_NAME, LFS_O_RDWR)) {
lfs_soff_t memcard_lfs_size = lfs_file_size(&lfs, &memcard_lfs);
if(memcard_lfs_size <= MEMCARD_FILE_CONTENT_SIZE) {
if(memcard_lfs_size <= MC_SIZE) {

/* Mirror stored memory card to virtual disk (only if size is correct) */
if(FR_OK == f_open(&memcard_fat, MEMCARD_FILE_NAME, FA_CREATE_NEW | FA_WRITE)) {
Expand Down Expand Up @@ -164,7 +165,7 @@ uint32_t RAM_disk_export_lfs_memcard() {

/* Check virtual disk memory card size */
FSIZE_t fat_memcard_size = f_size(&memcard_fat);
if(fat_memcard_size <= MEMCARD_FILE_CONTENT_SIZE) {
if(fat_memcard_size <= MC_SIZE) {
if(LFS_ERR_OK == lfs_mount(&lfs, &LFS_CFG)) {
/* Prepare LFS memory card */
lfs_remove(&lfs, MEMCARD_FILE_NAME); // remove old memory card file
Expand Down

0 comments on commit 2681a1e

Please sign in to comment.