Compare commits
12 Commits
ad02c17e0c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 04a1714237 | |||
| e616e22dd7 | |||
| bea543269e | |||
| a2256acd94 | |||
| 641a6a88af | |||
| d722738de9 | |||
| 6021c9e1e2 | |||
| cd986ff984 | |||
| d0c488645c | |||
| 4b07178f3d | |||
| 104bd65ac0 | |||
| caf5456067 |
14
.gitignore
vendored
14
.gitignore
vendored
@@ -7,11 +7,11 @@ Debug
|
|||||||
*.user.*
|
*.user.*
|
||||||
*.lss
|
*.lss
|
||||||
*.d
|
*.d
|
||||||
stm32f4-sdio.cflags
|
*.cflags
|
||||||
stm32f4-sdio.config
|
*.config
|
||||||
stm32f4-sdio.creator
|
*.creator
|
||||||
stm32f4-sdio.cxxflags
|
*.cxxflags
|
||||||
stm32f4-sdio.files
|
*.files
|
||||||
stm32f4-sdio.includes
|
*.includes
|
||||||
|
|
||||||
|
|
||||||
|
*.jdebug
|
||||||
|
|||||||
@@ -28,12 +28,10 @@ DSTATUS disk_status (
|
|||||||
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DSTATUS stat;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
case DEV_SD:
|
case DEV_SD:
|
||||||
return SDIO_status();
|
return sdio_status();
|
||||||
}
|
}
|
||||||
return STA_NOINIT;
|
return STA_NOINIT;
|
||||||
}
|
}
|
||||||
@@ -48,12 +46,9 @@ DSTATUS disk_initialize (
|
|||||||
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DSTATUS stat;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
case DEV_SD:
|
case DEV_SD:
|
||||||
return SDIO_initialize();
|
return sdio_initialize();
|
||||||
}
|
}
|
||||||
return STA_NOINIT;
|
return STA_NOINIT;
|
||||||
}
|
}
|
||||||
@@ -71,12 +66,9 @@ DRESULT disk_read (
|
|||||||
UINT count /* Number of sectors to read */
|
UINT count /* Number of sectors to read */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DRESULT res;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
case DEV_SD:
|
case DEV_SD:
|
||||||
return SDIO_disk_read(buff, sector, count);
|
return sdio_disk_read(buff, sector, count);
|
||||||
}
|
}
|
||||||
return RES_PARERR;
|
return RES_PARERR;
|
||||||
}
|
}
|
||||||
@@ -96,12 +88,9 @@ DRESULT disk_write (
|
|||||||
UINT count /* Number of sectors to write */
|
UINT count /* Number of sectors to write */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DRESULT res;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
case DEV_SD:
|
case DEV_SD:
|
||||||
return SDIO_disk_write(buff, sector, count);
|
return sdio_disk_write(buff, sector, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RES_PARERR;
|
return RES_PARERR;
|
||||||
@@ -120,12 +109,9 @@ DRESULT disk_ioctl (
|
|||||||
void *buff /* Buffer to send/receive control data */
|
void *buff /* Buffer to send/receive control data */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DRESULT res;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
case DEV_SD:
|
case DEV_SD:
|
||||||
return SDIO_disk_ioctl(cmd, buff);
|
return sdio_disk_ioctl(cmd, buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RES_PARERR;
|
return RES_PARERR;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -12,12 +12,13 @@
|
|||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
DSTATUS SDIO_status();
|
DSTATUS sdio_status();
|
||||||
DSTATUS SDIO_initialize();
|
DSTATUS sdio_initialize();
|
||||||
DRESULT SDIO_disk_read(BYTE *buff, DWORD sector, UINT count);
|
|
||||||
DRESULT SDIO_disk_write(const BYTE *buff, DWORD sector, UINT count);
|
DRESULT sdio_disk_read(BYTE *buff, DWORD sector, UINT count);
|
||||||
DRESULT SDIO_disk_ioctl(BYTE cmd, void* buff);
|
DRESULT sdio_disk_write(const BYTE *buff, DWORD sector, UINT count);
|
||||||
DWORD get_fattime();
|
DRESULT sdio_disk_ioctl(BYTE cmd, void* buff);
|
||||||
|
DWORD get_fattime();
|
||||||
|
|
||||||
|
|
||||||
//Defines for Card Status in struct _CardStatus
|
//Defines for Card Status in struct _CardStatus
|
||||||
@@ -31,9 +32,7 @@ DWORD get_fattime();
|
|||||||
#define CURRENT_STATE_PRG 7
|
#define CURRENT_STATE_PRG 7
|
||||||
#define CURRENT_STATE_DIS 8
|
#define CURRENT_STATE_DIS 8
|
||||||
|
|
||||||
|
struct sd_card_status {
|
||||||
|
|
||||||
typedef struct _CardStatus {
|
|
||||||
uint32_t reserved : 3;
|
uint32_t reserved : 3;
|
||||||
uint32_t AKE_SEQ_ERROR : 1;
|
uint32_t AKE_SEQ_ERROR : 1;
|
||||||
uint32_t reserved_2 : 1;
|
uint32_t reserved_2 : 1;
|
||||||
@@ -60,21 +59,19 @@ typedef struct _CardStatus {
|
|||||||
uint32_t BLOCK_LEN_ERROR : 1;
|
uint32_t BLOCK_LEN_ERROR : 1;
|
||||||
uint32_t ADDRESS_ERROR : 1;
|
uint32_t ADDRESS_ERROR : 1;
|
||||||
uint32_t OUT_OF_RANGE : 1;
|
uint32_t OUT_OF_RANGE : 1;
|
||||||
}CardStatus_t;
|
};
|
||||||
|
|
||||||
|
enum sdio_card_type {CARD_NONE = 0, MMC, SD_V1, SD_V2_SC, SD_V2_HC};
|
||||||
|
|
||||||
typedef enum {CARD_NONE = 0, MMC, SD_V1, SD_V2_SC, SD_V2_HC} card_type_t;
|
|
||||||
// MMC not supported
|
// MMC not supported
|
||||||
typedef struct _SDInfo {
|
struct sd_info {
|
||||||
uint16_t rca;
|
uint16_t rca;
|
||||||
card_type_t type;
|
enum sdio_card_type type;
|
||||||
uint32_t sector_count;
|
uint32_t sector_count;
|
||||||
}SDInfo_t;
|
};
|
||||||
|
|
||||||
typedef union _StatusConv {
|
union sdio_status_conv {
|
||||||
CardStatus_t statusstruct;
|
struct sd_card_status statusstruct;
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
}StatusConv_t;
|
};
|
||||||
|
|
||||||
#endif /* FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_ */
|
#endif /* FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_ */
|
||||||
|
|||||||
@@ -10,17 +10,20 @@
|
|||||||
#define HW_FLOW 0 //0
|
#define HW_FLOW 0 //0
|
||||||
//1 bit: !=4
|
//1 bit: !=4
|
||||||
//4 bit: 4
|
//4 bit: 4
|
||||||
#define BUSWIDTH 4 //4
|
#define BUSWIDTH 4 //4
|
||||||
//Initial Transfer CLK (ca. 400kHz)
|
//Initial Transfer CLK (ca. 400kHz)
|
||||||
#define INITCLK 130 //120
|
#define INITCLK 130 //120
|
||||||
//Working CLK (Maximum)
|
//Working CLK (Maximum)
|
||||||
#define WORKCLK 50 //0
|
#define WORKCLK 2 //0
|
||||||
//Data Timeout in CLK Cycles
|
//Data Timeout in CLK Cycles
|
||||||
#define DTIMEOUT 0x3000 //150
|
#define DTIMEOUT 0x8000 //150
|
||||||
//DMA Stream used for TX and RX DMA2 Stream 3 or 6 possible
|
//DMA Stream used for TX and RX DMA2 Stream 3 or 6 possible
|
||||||
// Currently not used due to possible misalignment of the data buffer.
|
|
||||||
//#define DMASTREAM DMA2_Stream6
|
|
||||||
|
|
||||||
|
#define USE_DMA 1
|
||||||
|
|
||||||
|
#define DMASTREAM DMA2_Stream6
|
||||||
|
|
||||||
|
#define DMASTREAM_NO 6
|
||||||
|
|
||||||
/* Port Definitions */
|
/* Port Definitions */
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
/ Function Configurations
|
/ Function Configurations
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define FF_FS_READONLY 1
|
#define FF_FS_READONLY 0
|
||||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||||
|
|||||||
34
main.c
34
main.c
@@ -22,10 +22,16 @@ volatile uint32_t sdio_wait;
|
|||||||
|
|
||||||
int initreq = 0xFF;
|
int initreq = 0xFF;
|
||||||
|
|
||||||
int main() {
|
//const char *write_string = "This is a write test. Okay... Writing seems to work. Let's close the file\n";
|
||||||
char buff[1024];
|
|
||||||
|
char buff[8192*6];
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
char *name;
|
char *name;
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
|
|
||||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
|
||||||
__DSB();
|
__DSB();
|
||||||
GPIOA->MODER |= OUTPUT(6) | OUTPUT(7);
|
GPIOA->MODER |= OUTPUT(6) | OUTPUT(7);
|
||||||
@@ -39,20 +45,20 @@ int main() {
|
|||||||
initreq = f_mount(&SDfs, "0:/", 1);
|
initreq = f_mount(&SDfs, "0:/", 1);
|
||||||
while(initreq);
|
while(initreq);
|
||||||
|
|
||||||
initreq = f_opendir(&root, "/");
|
for (i = 0; i < 8192*6; i++)
|
||||||
if (initreq == FR_OK) {
|
buff[i] = 'A';
|
||||||
if (!f_readdir(&root, &fno))
|
|
||||||
{
|
|
||||||
name = fno.fname;
|
|
||||||
initreq = f_open(&file, name, FA_READ);
|
|
||||||
if (initreq == FR_OK) {
|
|
||||||
f_gets(buff, sizeof(buff), &file);
|
|
||||||
printf("%s:\r\n%s\r\n",name, buff);
|
|
||||||
f_close(&file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
initreq = f_open(&file, "foo.txt", FA_OPEN_APPEND | FA_WRITE);
|
||||||
|
if (initreq == FR_OK) {
|
||||||
|
for (i = 0; i < 100; i++) {
|
||||||
|
initreq = f_write(&file, buff, 8192*6, NULL);
|
||||||
|
if (initreq) {
|
||||||
|
initreq++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
initreq = f_close(&file);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fflush(stdout);
|
//fflush(stdout);
|
||||||
|
|
||||||
while(1);
|
while(1);
|
||||||
@@ -92,7 +98,7 @@ void SysTick_Handler()
|
|||||||
sdio_wait++;
|
sdio_wait++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDIO_wait_ms(unsigned int i) {
|
void sdio_wait_ms(unsigned int i) {
|
||||||
sdio_wait = 0;
|
sdio_wait = 0;
|
||||||
while(sdio_wait<i);
|
while(sdio_wait<i);
|
||||||
|
|
||||||
|
|||||||
8
program-device.gdb
Normal file
8
program-device.gdb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
target extended-remote :2331
|
||||||
|
monitor speed 4000
|
||||||
|
monitor reset
|
||||||
|
load
|
||||||
|
monitor reset
|
||||||
|
kill
|
||||||
|
quit
|
||||||
|
|
||||||
18
program-device.sh
Executable file
18
program-device.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
JLinkGDBServer -if SWD -device STM32F407VE &
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# Check if GDB server is still running
|
||||||
|
gdbpid=`pidof JLinkGDBServer`
|
||||||
|
|
||||||
|
if [[ $gdbpid == "" ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "GDB Server not running! Check target connection."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
arm-none-eabi-gdb -x program-device.gdb stm32f4sdio.elf
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
kill $gdbpid
|
||||||
@@ -152,7 +152,7 @@ SECTIONS
|
|||||||
|
|
||||||
/* Uninitialized data section */
|
/* Uninitialized data section */
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
.bss :
|
.bss (NOLOAD):
|
||||||
{
|
{
|
||||||
/* This is used by the startup in order to initialize the .bss secion */
|
/* This is used by the startup in order to initialize the .bss secion */
|
||||||
_sbss = .; /* define a global symbol at bss start */
|
_sbss = .; /* define a global symbol at bss start */
|
||||||
@@ -167,7 +167,7 @@ SECTIONS
|
|||||||
} >RAM
|
} >RAM
|
||||||
|
|
||||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||||
._user_heap_stack :
|
._user_heap_stack (NOLOAD):
|
||||||
{
|
{
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
PROVIDE (heap_low = .); /* for _sbrk */
|
PROVIDE (heap_low = .); /* for _sbrk */
|
||||||
|
|||||||
Reference in New Issue
Block a user