Skip to content

Commit

Permalink
updates fatfs lib to a newer version, modified start.s and stub.ld files
Browse files Browse the repository at this point in the history
to fix a sd usage problem, added support to read the config file from a
folder called arm9loaderhax added support for creating the log file in
this folder, added some more debug output
  • Loading branch information
Hartie95 committed Feb 26, 2016
1 parent 9ac1780 commit 24f9d19
Show file tree
Hide file tree
Showing 39 changed files with 10,061 additions and 9,559 deletions.
4 changes: 2 additions & 2 deletions bootloader/Makefile
Expand Up @@ -18,9 +18,9 @@ include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
export TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := source source/fatfs source/inih
SOURCES := source source/fatfs source/inih source/fatfs/sdmmc
DATA := data
INCLUDES := include source/fatfs source/inih
INCLUDES := include source/fatfs source/inih source/fatfs/sdmmc

#---------------------------------------------------------------------------------
# Setup some defines
Expand Down
4 changes: 2 additions & 2 deletions bootloader/bootloaderloader/Makefile
Expand Up @@ -18,9 +18,9 @@ include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
export TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := source source/fatfs source/inih
SOURCES := source source/fatfs source/fatfs/sdmmc
DATA := data
INCLUDES := include source/fatfs source/inih
INCLUDES := include source/fatfs source/fatfs/sdmmc

#---------------------------------------------------------------------------------
# Setup some defines
Expand Down
17 changes: 0 additions & 17 deletions bootloader/bootloaderloader/source/delay.s

This file was deleted.

21 changes: 21 additions & 0 deletions bootloader/bootloaderloader/source/fatfs/00readme.txt
@@ -0,0 +1,21 @@
FatFs Module Source Files R0.11


FILES

00readme.txt This file.
history.txt Revision history.
ffconf.h Configuration file for FatFs module.
ff.h Common include file for FatFs and application module.
ff.c FatFs module.
diskio.h Common include file for FatFs and disk I/O module.
diskio.c An example of glue function to attach existing disk I/O module to FatFs.
integer.h Integer type definitions for FatFs.
option Optional external functions.


Low level disk I/O module is not included in this archive because the FatFs
module is only a generic file system layer and not depend on any specific
storage device. You have to provide a low level disk I/O module that written
to control the target storage device.

88 changes: 43 additions & 45 deletions bootloader/bootloaderloader/source/fatfs/diskio.c
@@ -1,44 +1,41 @@
/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
/*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be */
/* attached to the FatFs via a glue function rather than modifying it. */
/* This is an example of glue functions to attach various exsisting */
/* storage control module to the FatFs module with a defined API. */
/* storage control modules to the FatFs module with a defined API. */
/*-----------------------------------------------------------------------*/

#include "diskio.h" /* FatFs lower layer API */
#include "../sdmmc.h"

/* Definitions of physical drive number for each media */
#define ATA 0
#define MMC 1
#define USB 2
#include "diskio.h" /* FatFs lower layer API */
#include "sdmmc/sdmmc.h"


/*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
/* Get Drive Status */
/*-----------------------------------------------------------------------*/

DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber (0..) */
DSTATUS disk_status (
__attribute__((unused))
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
sdmmc_sdcard_init();
return RES_OK;
return RES_OK;
}



/*-----------------------------------------------------------------------*/
/* Get Disk Status */
/* Inidialize a Drive */
/*-----------------------------------------------------------------------*/

DSTATUS disk_status (
BYTE pdrv /* Physical drive nmuber (0..) */
DSTATUS disk_initialize (
__attribute__((unused))
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
return RES_OK; // Stubbed
sdmmc_sdcard_init();
return RES_OK;
}


Expand All @@ -48,19 +45,18 @@ DSTATUS disk_status (
/*-----------------------------------------------------------------------*/

DRESULT disk_read (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address (LBA) */
UINT count /* Number of sectors to read (1..128) */
__attribute__((unused))
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to read */
)
{
switch(pdrv){
case 0:
if (sdmmc_sdcard_readsectors(sector,count,buff))
return RES_PARERR;
break;
}
return RES_OK;
if (sdmmc_sdcard_readsectors(sector, count, buff)) {
return RES_PARERR;
}

return RES_OK;
}


Expand All @@ -71,35 +67,37 @@ DRESULT disk_read (

#if _USE_WRITE
DRESULT disk_write (
BYTE pdrv, /* Physical drive nmuber (0..) */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address (LBA) */
UINT count /* Number of sectors to write (1..128) */
__attribute__((unused))
BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to write */
)
{
switch(pdrv){
case 0:
if (sdmmc_sdcard_writesectors(sector,count,buff))
return RES_PARERR;
break;
}
return RES_OK;
if (sdmmc_sdcard_writesectors(sector, count, (BYTE *)buff)) {
return RES_PARERR;
}

return RES_OK;
}
#endif



/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/

#if _USE_IOCTL
DRESULT disk_ioctl (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
void *buff /* Buffer to send/receive control data */
__attribute__((unused))
BYTE pdrv, /* Physical drive nmuber (0..) */
__attribute__((unused))
BYTE cmd, /* Control code */
__attribute__((unused))
void *buff /* Buffer to send/receive control data */
)
{
return RES_OK;
//return RES_PARERR; // Stubbed
return RES_PARERR;
}
#endif
62 changes: 31 additions & 31 deletions bootloader/bootloaderloader/source/fatfs/diskio.h
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------/
/ Low level disk interface modlue include file (C)ChaN, 2013 /
/ Low level disk interface modlue include file (C)ChaN, 2014 /
/-----------------------------------------------------------------------*/

#ifndef _DISKIO_DEFINED
Expand All @@ -9,22 +9,22 @@
extern "C" {
#endif

#define _USE_WRITE 1 /* 1: Enable disk_write function */
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
#define _USE_WRITE 1 /* 1: Enable disk_write function */
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */

#include "integer.h"


/* Status of Disk Functions */
typedef BYTE DSTATUS;
typedef BYTE DSTATUS;

/* Results of Disk Functions */
typedef enum {
RES_OK = 0, /* 0: Successful */
RES_ERROR, /* 1: R/W Error */
RES_WRPRT, /* 2: Write Protected */
RES_NOTRDY, /* 3: Not Ready */
RES_PARERR /* 4: Invalid Parameter */
RES_OK = 0, /* 0: Successful */
RES_ERROR, /* 1: R/W Error */
RES_WRPRT, /* 2: Write Protected */
RES_NOTRDY, /* 3: Not Ready */
RES_PARERR /* 4: Invalid Parameter */
} DRESULT;


Expand All @@ -41,37 +41,37 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);

/* Disk Status Bits (DSTATUS) */

#define STA_NOINIT 0x01 /* Drive not initialized */
#define STA_NODISK 0x02 /* No medium in the drive */
#define STA_PROTECT 0x04 /* Write protected */
#define STA_NOINIT 0x01 /* Drive not initialized */
#define STA_NODISK 0x02 /* No medium in the drive */
#define STA_PROTECT 0x04 /* Write protected */


/* Command code for disk_ioctrl fucntion */

/* Generic command (used by FatFs) */
#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
/* Generic command (Used by FatFs) */
#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */

/* Generic command (not used by FatFs) */
#define CTRL_POWER 5 /* Get/Set power status */
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
#define CTRL_EJECT 7 /* Eject media */
#define CTRL_FORMAT 8 /* Create physical format on the media */
/* Generic command (Not used by FatFs) */
#define CTRL_POWER 5 /* Get/Set power status */
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
#define CTRL_EJECT 7 /* Eject media */
#define CTRL_FORMAT 8 /* Create physical format on the media */

/* MMC/SDC specific ioctl command */
#define MMC_GET_TYPE 10 /* Get card type */
#define MMC_GET_CSD 11 /* Get CSD */
#define MMC_GET_CID 12 /* Get CID */
#define MMC_GET_OCR 13 /* Get OCR */
#define MMC_GET_SDSTAT 14 /* Get SD status */
#define MMC_GET_TYPE 10 /* Get card type */
#define MMC_GET_CSD 11 /* Get CSD */
#define MMC_GET_CID 12 /* Get CID */
#define MMC_GET_OCR 13 /* Get OCR */
#define MMC_GET_SDSTAT 14 /* Get SD status */

/* ATA/CF specific ioctl command */
#define ATA_GET_REV 20 /* Get F/W revision */
#define ATA_GET_MODEL 21 /* Get model name */
#define ATA_GET_SN 22 /* Get serial number */
#define ATA_GET_REV 20 /* Get F/W revision */
#define ATA_GET_MODEL 21 /* Get model name */
#define ATA_GET_SN 22 /* Get serial number */

#ifdef __cplusplus
}
Expand Down

0 comments on commit 24f9d19

Please sign in to comment.