Spark Logic

[libmaple] SDIO

8051 DIP-40 Pinout

Hi all,

I finally managed to bring the SDIO files in an acceptable form to be published.

It works with 24MHz clock and 4bits wide bus, and tested only for the generic F407VET6 board.

I have committed 2 files to libmaple core directory, and 2 files to a new SDIO lib under STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /libraries.

Usage:
– get the master branch from my repo
– get the SdFat lib from https://github.com/greiman/SdFat
– insert into line 164 of SdFatConfig:

#elif defined(__STM32F4__)
#define ENABLE_SDIO_CLASS 1

Replies20

Sun Jun 18, 2017 9:31 pm

Thanks

When I have enough time, I will pull you F4 changes

Mon Jun 19, 2017 8:24 am

Hello. Will this work on version 1.8.2 or 1.8.3 ?

Mon Jun 19, 2017 8:26 am

I tested it with 1.6.12 – I kept this version based on “never change a running system”- but I assume it should work with the latest versions as well.
If not, please post here any problems.

Mon Jun 19, 2017 8:29 am

OK.
Thank YOU very much for YOUR work !

Mon Jun 19, 2017 9:13 am

[RogerClark – Sun Jun 18, 2017 9:31 pm] –
Thanks

When I have enough time, I will pull you F4 changes

I have to first merge the latest commits from your master to my branch, I hope I manage it today in the evening.
I’ll let you know.

Mon Jun 19, 2017 10:37 am

[stevestrong – Mon Jun 19, 2017 9:13 am] –
[RogerClark – Sun Jun 18, 2017 9:31 pm] –
Thanks

When I have enough time, I will pull you F4 changes

I have to first merge the latest commits from your master to my branch, I hope I manage it today in the evening.
I’ll let you know.

OK

I think it may be OK without doing this.

But don’t rush, I have so many other things I need to do.

Mon Jun 19, 2017 5:50 pm

I have tested the reading/writing/CRC calculating sketch from Daniel (test file of 102.4MB), and this is the result:
Use a freshly formatted SD for best performance.
Type any character to start
#################################################
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 24063 msecs
*************************************************
Running CRC calculations...
File in CRC:  22BCDBEC
File out CRC: 22BCDBEC
*************************************************
Done in 70620 msecs

Type any character to start
#################################################
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 34167 msecs
*************************************************
Running CRC calculations...
File in CRC:  22BCDBEC
File out CRC: 22BCDBEC
*************************************************
Done in 70937 msecs

Type any character to start
#################################################
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 37755 msecs
*************************************************
Running CRC calculations...
File in CRC:  22BCDBEC
File out CRC: 22BCDBEC
*************************************************
Done in 70910 msecs

Type any character to start
#################################################
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 36741 msecs
*************************************************
Running CRC calculations...
File in CRC:  22BCDBEC
File out CRC: 22BCDBEC
*************************************************
Done in 70734 msecs

Type any character to start

Wed Jun 21, 2017 5:03 am

100MB F407
I get with my:
Use a freshly formatted SD for best performance.
Type any character to start

*************************************************
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 61039 msecs
*************************************************
Running CRC calculations...
File in CRC: DE9D6BE7
File out CRC: DE9D6BE7
*************************************************
Done in 71259 msecsType any character to start

*************************************************
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 60230 msecs
*************************************************
Running CRC calculations...
File in CRC: DE9D6BE7
File out CRC: DE9D6BE7
*************************************************
Done in 71251 msecsType any character to start

*************************************************
Opening the read file..
Opening the write file..
Reading and Writing..

Wed Jun 21, 2017 6:49 am

OK, so you could reproduce my issue.
For libmaple core, the first read and write takes a lot less time (34231 msecs) than the following read writes (58237 msecs).
Your core seems not to show this issue.

Hmmm.

Wed Jun 21, 2017 7:11 am

That differences are because of the Write Latencies..
The Sdcard is not a ramdisk, it lives its own life. When the Arm (or accelerated 80518051Microcontrollers and processors…mand language, interpreter written in macro-11 through any of the sub-systems(8031/2, 8051 /52), adc, dac, controlled power supplies, relay card types and STT’s, interfaces to iee…View in hardware catalog ) inside the Sdcard decides to do some housekeeping, your write time will be longer.

Wed Jun 21, 2017 7:02 pm

When I activated the debug output I saw that the first run involves much less block reads than the following ones, which are again all comparable.

So it is not due different write latencies.

Thu Jun 22, 2017 4:39 pm

[danieleff – Wed Jun 21, 2017 5:03 am] –
100MB F407
I get with my:
Use a freshly formatted SD for best performance.
Type any character to start

*************************************************
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 61039 msecs
*************************************************
Running CRC calculations...
File in CRC: DE9D6BE7
File out CRC: DE9D6BE7
*************************************************
Done in 71259 msecsType any character to start

*************************************************
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 60230 msecs
*************************************************
Running CRC calculations...
File in CRC: DE9D6BE7
File out CRC: DE9D6BE7
*************************************************
Done in 71251 msecsType any character to start

*************************************************
Opening the read file..
Opening the write file..
Reading and Writing..

Thu Jun 22, 2017 5:49 pm

Vitor,
this is SDIO, not SPI.
And higher frequencies than 37MHz for SDIO (tested by Pito) do not work reliable anymore. This is a HW limitation of the F4 chip.

Fri Jun 23, 2017 2:20 pm

[stevestrong – Thu Jun 22, 2017 5:49 pm] –
Vitor,
this is SDIO, not SPI.
And higher frequencies than 37MHz for SDIO (tested by Pito) do not work reliable anymore. This is a HW limitation of the F4 chip.
		while ( i-- ) { // do 8 byte copies, is much faster than single byte copy
*dst++ = *src++; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++;
*dst++ = *src++; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++;
}

Fri Jun 23, 2017 3:37 pm

[vitor_boss – Fri Jun 23, 2017 2:20 pm] –
Isn’t possible to work with full register(32bits) on those lines?

Not in this case.
The byte-wise copying is performed when the passed buffer address is not word (uint32_t) aligned.

Fri Jun 30, 2017 7:28 am

#include <SPI.h>
#include <Arduino.h>
#include "SdioF4.h"
SdFile myFile;
SdFat sd;

void setup(void) {
Serial.begin(115200);
//while ( !Serial.isConnected() ) ;

if (!myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END))
{
sd.errorHalt("Error open file !");
}
else
{
myFile.print("TEST");
myFile.close();
}
}

void loop(void)
{
//
}

Fri Jun 30, 2017 7:56 am

This is an example sketch to test STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog SDIO.

You still have to insert into line 164 of SdFatConfig:

#elif defined(__STM32F4__)
#define ENABLE_SDIO_CLASS 1

Fri Jun 30, 2017 8:28 am

(7.03 KiB) Downloaded 174 times

Fri Jun 30, 2017 9:14 am

It worked.
Thank you

Sat Jul 01, 2017 2:59 pm

i7 jessie 8.8, official arduino 1.8.3 64bit, latest generic_f4, directory SDIO exists :D
using the demo code, it says
"/home/stephen/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w  -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_f407v -DVECT_TAB_BASE -DERROR_LED_PORT=GPIOA -DERROR_LED_PIN=7 -w -x c++ -E -CC -mcpu=cortex-m4 -DF_CPU=168000000L -DARDUINO=10803 -DARDUINO_STM32GenericF407VET6 -DARDUINO_ARCH_STM32F4  -mthumb -DSTM32_HIGH_DENSITY -DSTM32F4 -DBOARD_generic_f407v -DUSB_NC  -mthumb -D__STM32F4__ "-I/home/stephen/sketchbook/hardware/ss-Arduino_STM32/STM32F4/system/libmaple" "-I/home/stephen/sketchbook/hardware/ss-Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4" "-I/home/stephen/sketchbook/hardware/ss-Arduino_STM32/STM32F4/cores/maple" "-I/home/stephen/sketchbook/hardware/ss-Arduino_STM32/STM32F4/variants/generic_f407v" "-I/home/stephen/sketchbook/hardware/ss-Arduino_STM32/STM32F4/libraries/SDIO" "-I/home/stephen/sketchbook/libraries/SdFat/src" "-I/home/stephen/sketchbook/hardware/ss-Arduino_STM32/STM32F4/libraries/SPI/src" "/home/stephen/sketchbook/hardware/ss-Arduino_STM32/STM32F4/libraries/SDIO/SdioF4.cpp" -o "/tmp/arduino_build_711891/preproc/ctags_target_for_gcc_minus_e.cpp"
/home/stephen/sketchbook/hardware/ss-Arduino_STM32/STM32F4/libraries/SDIO/SdioF4.cpp:22:27: fatal error: libmaple\sdio.h: No such file or directory
#include <libmaple\sdio.h>

Post a reply

Optional · up to 10 MiB