Spark Logic

[libmaple] SDIO

stevestrong Sun Jun 18, 2017 5:20 pm

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 STM32F4/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

Replies

stevestrong Wed Jul 05, 2017 11:53 pm

[Pito – Wed Jul 05, 2017 11:36 pm] –
Something wrong with 512-2048b buffer sizes?

I don’t know, and I cannot figure out since I don’t have no such a card.
For my cards, as well as for your other cards, it seems to work fine.

Pito wrote:Why do you not use the SdFatEX?

acronis Wed Aug 02, 2017 8:37 am

Hello.

If you #include <MapleFreeRTOS900.h> SD card (SDIO) the error appears.

#include <Arduino.h>
#include <SPI.h>
#include "SdioF4.h"

SdFatSdio sd;
File file;

In file included from C:\Users\Admin\Documents\Arduino\libraries\SdFat\src/BlockDriver.h:27:0,

from C:\Users\Admin\Documents\Arduino\libraries\SdFat\src/SdFat.h:27,

from C:\Users\Admin\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\SDIO/SdioF4.h:5,

from C:\Users\Admin\Desktop\STM32F4\RFIDRTOS\RFIDRTOS.ino:12:

C:\Users\Admin\Documents\Arduino\libraries\SdFat\src/SdCard/SdSpiCard.h:264:51: error: macro "writeData" passed 2 arguments, but takes just 1

stevestrong Wed Aug 02, 2017 8:42 am

If you are looking more carefully, you see that this is not an SDIO error, but something wrong with a macro in your sketch and SdSpiCard.h:
SdSpiCard.h:264:51: error: macro "writeData" passed 2 arguments, but takes just 1

acronis Wed Aug 02, 2017 8:47 am

Thank you.

victor_pv Wed Aug 02, 2017 1:28 pm

Steve,

Are you porting this library to the libmaple F1? I was reading the F1 to F4 porting documents from STM and says the peripheral is pretty much the same on both, except for some bugfixes (only errata I could find for SDIO in F1 is about using some serial ports and timers in the same pins, nothing big).
The base address is different, but registers etc claim to be the same.

stevestrong Wed Aug 02, 2017 1:32 pm

Hi Victor,
as I don’t own any F1 board which would support SDIO, I cannot test it so I cannot give any support on that, that’s why will not port it.
But anyone is free to do it.

victor_pv Wed Aug 02, 2017 4:46 pm

[stevestrong – Wed Aug 02, 2017 1:32 pm] –
Hi Victor,
as I don’t own any F1 board which would support SDIO, I cannot test it so I cannot give any support on that, that’s why will not port it.
But anyone is free to do it.

I have some boards that support it, so may give it a shot.
It seems to be stable now right? or are you planning changes to the code?

stevestrong Wed Aug 02, 2017 5:20 pm

No changes planned, it seems to work stable, but which does not mean that is bug-free :P
So you are good to go.

acronis Thu Aug 03, 2017 2:10 am

Hello victor_pv.

Saw Your message in the desire of porting FreeRTOS on STM32F4 microcontroller.
Do You have such plans? An example from the library works fine, but I failed to run my program with ETHERNET.
The compiler gave the error I wrote above.
Do you have the opportunity to understand and help me ?

victor_pv Thu Aug 03, 2017 3:42 am

[acronis – Thu Aug 03, 2017 2:10 am] –
Hello victor_pv.

Saw Your message in the desire of porting FreeRTOS on STM32F4 microcontroller.
Do You have such plans? An example from the library works fine, but I failed to run my program with ETHERNET.
The compiler gave the error I wrote above.
Do you have the opportunity to understand and help me ?

Have you posted that error in a separate thread? this one seems to be dedicated to the SDIO only, so I don’t want to hijack it, it will make it difficult for people to follow what’s going on.
Please send me the link to the thread where you posted about that error.

victor_pv Thu Aug 03, 2017 3:44 am

[stevestrong – Wed Aug 02, 2017 5:20 pm] –
No changes planned, it seems to work stable, but which does not mean that is bug-free :P
So you are good to go.

Steve, just compared the SDIO peripherals in the reference manual side by side between F1 and F4, they are idential to the letter except the bus they are connected to, and few cosmetic changes in some lines.

Base addresses are different, rest should be the same, so I will see if I can find a board in my pile with an sdcard and test it out.

If it is as expected, all that will change is the base address in the header file. If that’s the case even if you make major changes to the code should still work in the F1.

acronis Thu Aug 03, 2017 4:10 am

[victor_pv – Thu Aug 03, 2017 3:42 am] –

Have you posted that error in a separate thread? this one seems to be dedicated to the SDIO only, so I don’t want to hijack it, it will make it difficult for people to follow what’s going on.
Please send me the link to the thread where you posted about that error.

http://www.stm32duino.com/viewtopic.php … =60#p32263

victor_pv Thu Aug 03, 2017 4:54 pm

[acronis – Thu Aug 03, 2017 4:10 am] –
[victor_pv – Thu Aug 03, 2017 3:42 am] –

Have you posted that error in a separate thread? this one seems to be dedicated to the SDIO only, so I don’t want to hijack it, it will make it difficult for people to follow what’s going on.
Please send me the link to the thread where you posted about that error.

http://www.stm32duino.com/viewtopic.php … =60#p32263

Can you post a link to the version of sdfat that you are using? or better yet, can you post here the line that the error is referencing to?

victor_pv Thu Aug 03, 2017 5:00 pm

[acronis – Wed Aug 02, 2017 8:37 am] –
Hello.

If you #include <MapleFreeRTOS900.h> SD card (SDIO) the error appears.

#include <Arduino.h>
#include <SPI.h>
#include "SdioF4.h"

SdFatSdio sd;
File file;

In file included from C:\Users\Admin\Documents\Arduino\libraries\SdFat\src/BlockDriver.h:27:0,

from C:\Users\Admin\Documents\Arduino\libraries\SdFat\src/SdFat.h:27,

from C:\Users\Admin\Documents\Arduino\hardware\Arduino_STM32-master\STM32F4\libraries\SDIO/SdioF4.h:5,

from C:\Users\Admin\Desktop\STM32F4\RFIDRTOS\RFIDRTOS.ino:12:

C:\Users\Admin\Documents\Arduino\libraries\SdFat\src/SdCard/SdSpiCard.h:264:51: error: macro "writeData" passed 2 arguments, but takes just 1

acronis Fri Aug 04, 2017 2:42 am

Hm….
Today I tried again to make a clean project for example rtos_blink.
Connect two libraries immediately you receive this error.
If you leave any one library, then everything is fine.

Library https://github.com/stevstrong/Adafruit_ … 6bit_STM32

But together the two give an error.

Use cost STM32F407VET6 BLACK and https://github.com/stevstrong/Arduino_STM32/

#include <MapleFreeRTOS900.h>

#include <Adafruit_TFTLCD_16bit_STM32.h> // https://github.com/stevstrong/Adafruit_TFTLCD_16bit_STM32
#include <SPI.h>
#include "SdioF4.h" //http://stm32duino.com/viewtopic.php?f=39&t=2215

static void vLEDFlashTask(void *pvParameters) {
for (;;) {
vTaskDelay(1000);
digitalWrite(BOARD_LED_PIN, HIGH);
vTaskDelay(50);
digitalWrite(BOARD_LED_PIN, LOW);
}
}

void setup() {
// initialize the digital pin as an output:
pinMode(BOARD_LED_PIN, OUTPUT);

xTaskCreate(vLEDFlashTask,
"Task1",
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY + 2,
NULL);
vTaskStartScheduler();
}

void loop() {
// Insert background code here
}

acronis Fri Aug 04, 2017 2:55 am

It turned out that the problem is in the order of connection of libraries

In this order works


#include <SPI.h>
#include “SdioF4.h”
#include <Adafruit_TFTLCD_16bit_STM32.h> // Hardware-specific library

In this order it gives an error

C:\Users\Admin\Documents\Arduino\libraries\SdFat\src/SdCard/SdSpiCard.h:264:51: error: macro “writeData” passed 2 arguments, but takes just 1

bool writeData(uint8_t token, const uint8_t* src);



#include <Adafruit_TFTLCD_16bit_STM32.h> // Hardware-specific library
#include <SPI.h>
#include “SdioF4.h”

Library FreeRTOS does not affect this error.
Code and without connection FreeRTOS gives an error if you connect the libraries in the wrong order.

Why is this happening ?

victor_pv Fri Aug 04, 2017 3:20 am

At the moment I am not using that core neither the Arduino IDE so I can’t test myself.
I have had very strange things happen to with the Arduino IDE, apparently due to a bug in the software since changing to a newer version would solve it.
Sometimes it messes up with different versions of the library if you have different libraries with the same name for different cores, like one for the AVR arduinos, and one for the STM32.

A while back I stopped using the Arduino IDE and started using Eclipse, and I don’t plan to go back.

Unless Steve can duplicate the same issue and give some advice, my only advice is to make sure you have downloaded the latest version of his F4 core, and to try a different version of the Arduino IDE.

acronis Fri Aug 04, 2017 3:28 am

I understand You.

I use the last version of the IDE and the latest versions of the libraries.

And Eclipse use the same library or is there ?

stevestrong Fri Aug 04, 2017 7:14 am

Why do you use <SPI.h>?
I see no reason for that. SDIO does not use SPI, and 16 bit lib is also not using SPI.
Arduino IDE is fine.
Btw, I think the problem is in the SdFat lib, it compiles the SPI related files and functions although only SDIO is needed.

acronis Fri Aug 04, 2017 7:36 am

Removed the SPI library.Error remained. If swap – then everything is fine

Error:

#include <Adafruit_TFTLCD_16bit_STM32.h> // Hardware-specific library
#include “SdioF4.h”

Ok:

#include “SdioF4.h”
#include <Adafruit_TFTLCD_16bit_STM32.h> // Hardware-specific library

Sign in to reply