Hints about the MMC/SD card library by Roland Riegel

Working libraries, libraries being ported and related hardware
STM32
Posts: 17
Joined: Sun Mar 26, 2017 12:18 pm

Hints about the MMC/SD card library by Roland Riegel

Post by STM32 » Wed Mar 29, 2017 8:06 pm

Hy guys.
Thank you very much for this wonderful forum!
I'm a new user here.
I have an Arduino project that I would like to put on the "Blue Pill" STM32.
My goal is use a "Blue Pill" instead of an Arduino in order to run this:
https://github.com/krisztian1997/3dsunbricker
Following this instructions

http://www.stm32duino.com/viewtopic.php ... =blue+pill

I added the library and the sketch in my Arduino IDE environment.
with the current release 1.8.1 of the Arduino IDE while compiling I get these error messages:

C:\Users\Ferrario\Documents\Arduino\libraries\sdrawroland\sd_raw_roland.cpp:6:24: fatal error: avr/io.h: No such file or directory

#include <avr/io.h>


By putting a remark sign before the #include <avr/io.h> into sd_raw_roland.cpp then I get these error messages:

...\Arduino\libraries\sdrawroland/sd_raw_config_roland.h:114:6: error: #error "no sd/mmc pin mapping available!"

#error "no sd/mmc pin mapping available!"


By using Arduino IDE 1.6.9 I gt only the latest error messages:

...\Arduino\libraries\sdrawroland/sd_raw_config_roland.h:114:6: error: #error "no sd/mmc pin mapping available!"

#error "no sd/mmc pin mapping available!"


So I choose to use Arduino IDE 1.6.9 for my attempts.
The STM32 environment that I made is fine cause I can compile simple examples, but when I try to compile the 3dsunbricker project it fails.
Maybe the Roland Riegel's library doesn't work out of the box with the STM32 or more simply it's necessary to specify in it the SPI's pins for the STM32F103C8 board.
Indeed while compiling Arduino IDE 1.6.9 says:

...\Arduino\libraries\sdrawroland/sd_raw_config_roland.h:114:6: error: #error "no sd/mmc pin mapping available!"

#error "no sd/mmc pin mapping available!"


By searching I found that the right pins should be these:

STM32 SD/MMC
PA4 SD_SS
PA5 SD_SCK
PA6 SD_DO (=MISO)
PA7 SD_DI (=MOSI)


I'm pretty sure they are correct because I have retrieved them from here:

http://www.stm32duino.com/viewtopic.php?t=117#p950
http://reblag.dk/wordpress/wp-content/u ... iagram.pdf

Anyway something is weird into the diagram due the fact that SPI wires on pins A4, A5, A5 and A7 are for SPI channel 1 exactly like those on pins A15, B3, B4 and B5.
I guess it's a typo.

But into sd_raw_config_roland.h it's used a different format for the customisation of SD/MMC port access, something like these:

/* defines for customisation of sd/mmc port access */
#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \

(lines from 69 onwards into sd_raw_config_roland.h)


I wonder how can I add the right ones for the "Blue Pill"?

Actually I suspect that the matter is more hard to master so in the end the right way could be pretty different.
I need to initialize either SD than MMC and the MMC/SD card library by Roland Riegel is the only I know that natively allows for both kind of card.
On Arduino I tried a modified standard SD library and a modified SdFat libray but sadly I couldn't make them work with the "Blue Pill".
However Roland Riegel's MMC/SD card library is much better of them in this scenario.
Any hint?
Thanks in advance.

STM32

User avatar
Rick Kimball
Posts: 871
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Hints about the MMC/SD card library by Roland Riegel

Post by Rick Kimball » Wed Mar 29, 2017 11:27 pm

why bother? I mean why not just buy an arduino atmega clone and just use it.
-rick

User avatar
zoomx
Posts: 421
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Hints about the MMC/SD card library by Roland Riegel

Post by zoomx » Thu Mar 30, 2017 9:10 am

You can use also an SD adapter for PC and write your backup NAND image using some utilities like Win32DiskImager. You still need to solder.

STM32
Posts: 17
Joined: Sun Mar 26, 2017 12:18 pm

Re: Hints about the MMC/SD card library by Roland Riegel

Post by STM32 » Thu Mar 30, 2017 6:55 pm

Hi Rick,
I already own an Arduino, it is a MEGA 2560.
Of course the library and the sketch are functioning but Mega 2560 is too cumbersome for my purposes.
I need something small, something like Nano.
While I was choosing I thought that the "Blue Pill" could be a sensible choice.
Anyway in the end I think that the MMC/SD card library by Roland Riegel could be useful because the SDFat was ported on STM32 but it doesn't allow for MMC.
For the Mega I changed SD and SdFat in order to support MMC cards, for the STM32 environment I'm not in the position to succeed.
For me another important point is to understand if and how it is possible to use the same syntax

/* defines for customisation of sd/mmc port access */
#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \

for the STM32 though.
I would like to make a portable device for servicing and repair, that is my goal.

STM32

STM32
Posts: 17
Joined: Sun Mar 26, 2017 12:18 pm

Re: Hints about the MMC/SD card library by Roland Riegel

Post by STM32 » Thu Mar 30, 2017 6:56 pm

Hi Zoomx,
soldering isn't totally a problem for me.
Honestly I don't understand what do you mean.
Then the whole thing isn't so simple as you described.
In order to do what you wrote it is need a computer like some laptops which have MMC/SD card reader directly connected to the PCI bus.
I know that lately Ubuntu can do things like that but it needs some piece of hardware that is too cumbersome for my purposes and it isn't standalone.
The matter is totally different using the "Blue Pill" which is small and standalone.

STM32

victor_pv
Posts: 1267
Joined: Mon Apr 27, 2015 12:12 pm

Re: Hints about the MMC/SD card library by Roland Riegel

Post by victor_pv » Thu Mar 30, 2017 9:46 pm

STM32 wrote:Hi Rick,
I already own an Arduino, it is a MEGA 2560.
Of course the library and the sketch are functioning but Mega 2560 is too cumbersome for my purposes.
I need something small, something like Nano.
While I was choosing I thought that the "Blue Pill" could be a sensible choice.
Anyway in the end I think that the MMC/SD card library by Roland Riegel could be useful because the SDFat was ported on STM32 but it doesn't allow for MMC.
For the Mega I changed SD and SdFat in order to support MMC cards, for the STM32 environment I'm not in the position to succeed.
For me another important point is to understand if and how it is possible to use the same syntax

/* defines for customisation of sd/mmc port access */
#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \

for the STM32 though.
I would like to make a portable device for servicing and repair, that is my goal.

STM32
The SdFat library from Bill Greyman is already ported to our core and works fine.
The code you linked to in the first post doens't seem to use the SPI library for the Arduino, but rather writes directly to the SPI peripheral registers.
The best way I think would probably be to try to port that to using the SPI library functions, then it can be ported to stm32, teensy, or anything else much more easily.

User avatar
Rick Kimball
Posts: 871
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Hints about the MMC/SD card library by Roland Riegel

Post by Rick Kimball » Thu Mar 30, 2017 11:20 pm

STM32 wrote:Hi Rick,
I already own an Arduino, it is a MEGA 2560.
Of course the library and the sketch are functioning but Mega 2560 is too cumbersome for my purposes.
I need something small, something like Nano.
My point was the cost of a Nano is like $3. The time it would take to make the code function on the bluepill seems non-trivial. My question is why not just buy a $3 nano and be done with it? If your end goal is to get into using the bluepill, then fine. If your end goal is just to play games then it seems a waste of time porting everything.
-rick

stevestrong
Posts: 1169
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Hints about the MMC/SD card library by Roland Riegel

Post by stevestrong » Fri Mar 31, 2017 7:32 am

Rick Kimball wrote:My point was the cost of a Nano is like $3. The time it would take to make the code function on the bluepill seems non-trivial. My question is why not just buy a $3 nano and be done with it? If your end goal is to get into using the bluepill, then fine. If your end goal is just to play games then it seems a waste of time porting everything.
+1

User avatar
zoomx
Posts: 421
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Hints about the MMC/SD card library by Roland Riegel

Post by zoomx » Fri Mar 31, 2017 9:02 am

STM32 wrote:Hi Zoomx,
soldering isn't totally a problem for me.
Honestly I don't understand what do you mean.
Then the whole thing isn't so simple as you described.
In order to do what you wrote it is need a computer like some laptops which have MMC/SD card reader directly connected to the PCI bus.
I know that lately Ubuntu can do things like that but it needs some piece of hardware that is too cumbersome for my purposes and it isn't standalone.
The matter is totally different using the "Blue Pill" which is small and standalone.

STM32
Unbrick require to flash a NAND backup, it is the first requirement in the github repository. So, I believe, you still need a PC. You can modify a simple USB/SD adapter, not a PCI Card Reader.
Here is described howto make a NAND dump but you can flash NAND backup too!
https://gbatemp.net/threads/tutorial-no ... xl.414498/

STM32
Posts: 17
Joined: Sun Mar 26, 2017 12:18 pm

Re: Hints about the MMC/SD card library by Roland Riegel

Post by STM32 » Fri Mar 31, 2017 7:31 pm

Thank you guys, you're opening up my mind.

@victor_pv

I agree but natively SdFat doesn't support MMC so I can't use it.
What I wanted to know was if it was possible to implement on STM32 such a thing, not so much lead that library into STM32.
I mean manage MMC/MMC+/eMMC on the "Blue Pill" as same Arduino can do.
Now I understand it isn't so easy.
The better chance would be change the SdFat Beta in order to unlock MMC.
I know that works on the Arduino side (I tested it myself on Uno and Mega), so I'll put more effort on it.
My starting doubt was about the syntax I wrote and if there were such a thing even for STM32.
Since nobody wrote about it I understand it doesn't exists into the STM32 side.

@Rick

Like already I wrote from my side isn't a matter of costs but rather to be able to do that thing with different hardware than Arduino, better if new ones aren't cumbersome.
I wanted to see if there were any known way to manage MMC with the "Blue Pill".
I thought it would be useful to add that capability.
I know that Arduino can do the job and due STM32 doesn't (untill now), I have a single way to go.

@stevestrong

+1
Me too now that I've got your answers.

@zoomx

I get it now.
Actually mine was just as example, I didn't intend to replicate the project on the "Blue Pill", but rather to have a way to natively manage the MMC cards on it.
I shown the sketch in order to make sense at the whole context of the Roland Riegel's library which is in the position to manage both MMC or SD cards.
Anyway it seems to me that lately Ubuntu can do the job when running on hardware that allows direct connected to PCI bus for the reader.
Raspberry Pi too does it for sure.
In a such scenario it would be enough a simple adapter that allows to bring outside the necessary signals in order to connect them on the device where you want to work.

STM32

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest