STM32GENERIC, my arduino implementation

Cores are the underlying magic that make the Arduino API possible
fpiSTM
Posts: 191
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: STM32GENERIC, my arduino implementation

Post by fpiSTM » Sat May 13, 2017 5:43 am

Hi @danieleff,

FYI, I've packaged the arm gcc toolchain 6-2017-q1-update, it's available here:
https://github.com/stm32duino/BoardMana ... TM32/tools

It's the official release from arm (except the linux 32-bits one):
https://developer.arm.com/open-source/g ... /downloads
I've only remove the documentations and all v8 directories to decrease the archive file size.
As arm do not provide the linux 32-bits version, I've built it from the source.

You could use it, if you create a package. You will find packages description in the json file.

ChrisMicro
Posts: 290
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32GENERIC, my arduino implementation

Post by ChrisMicro » Sat May 13, 2017 6:42 am

@Daniel:
we could add this header to the Winbond example.

Code: Select all

/*    Test and print statistics of the onboard SPI-flash memmory
  
  board:
    BLACK407VE 

  how to:
  1. Install library: SPIFlash by Prajwal Bhattaram (Marzogh)
    https://github.com/Marzogh/SPIFlash
  2. Upload sketch
  3. Open USB serial monitor

  Issues: Start the serial monitor in less than 5 seconds after downloading
          The USB-serial may hang due to the amount of data printed.
            
*/
Sometimes the serial hangs. I added a 5 seconds delay after Serial.begin();

ChrisMicro
Posts: 290
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32GENERIC, my arduino implementation

Post by ChrisMicro » Sun May 14, 2017 2:58 am

examples->STM board examples for users -> Black407VE -> SDIODirListWriteRead
// 1. Install SdFat-beta from https://github.com/greiman/SdFat-beta
OK.
// 2. In SdFatConfig.h, Change ENABLE_SDIO_CLASS 0 to 1
??

The current state is: the example is working
Last edited by ChrisMicro on Sun May 14, 2017 6:01 am, edited 1 time in total.

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: STM32GENERIC, my arduino implementation

Post by danieleff » Sun May 14, 2017 3:24 am

ChrisMicro wrote:examples->STM board examples for users -> Black407VE -> SDIODirListWriteRead
// 1. Install SdFat-beta from https://github.com/greiman/SdFat-beta
OK.
// 2. In SdFatConfig.h, Change ENABLE_SDIO_CLASS 0 to 1
??

The current state is: the example is not working
The exact file / line is this: https://github.com/greiman/SdFat-beta/b ... fig.h#L165

Given that this is the only SDIO implementation for Arduino, the easiets way was to use it with that absulutely minimal change. I do not want to reimplement FAT32.

By the way you can install SPIFlash from sketch / library / manage libraries.

The examples need a more standardised way to describe, that is the same in every example, standard menu naming, menu layout etc... But I do not have time for that now.

@fpiSTM: thanks! Have you thought about using github releases instead of committing them as files?

ChrisMicro
Posts: 290
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32GENERIC, my arduino implementation

Post by ChrisMicro » Sun May 14, 2017 5:58 am

Thanks for the quick answer, Daniel.
It is working now :D
Given that this is the only SDIO implementation for Arduino, the easiets way was to use it with that absulutely minimal change. I do not want to reimplement FAT32.
Of course not. But the question it, how can we include a SD-card example which is running out of the box.

I think what Roger did in the SM32F1repository is really good: including all important libraries so that the things are simply running.

Because it is not to easy to find the location where the library is stored and to change a certain line in a config file to get an example running.

Here is a summary of how to get the SD-Card running:

Code: Select all

/* 
   1. Install SdFat-beta from https://github.com/greiman/SdFat-beta
   By the way you can install SPIFlash from sketch / library / manage libraries
 
   2. In SdFatConfig.h, Change ENABLE_SDIO_CLASS 0 to 1
   If you have installed the library with the library manager in windows your will find the
   file here:
   C:\Users\..WhatEverUser..\Documents\Arduino\libraries\SdFat\src

   sdFatConfig.h:
   ..
   // Enable SDIO driver if available. 
   #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
   #define ENABLE_SDIO_CLASS 1
   #define ENABLE_SDIOEX_CLASS 1
   #else  // ENABLE_SDIO_CLASS
   #define ENABLE_SDIO_CLASS 0  // ==> !! change this to ENABLE_SDIO_CLASS 1 !!   
   #endif  // ENABLE_SDIO_CLASS
  ...
*/



ChrisMicro
Posts: 290
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32GENERIC, my arduino implementation

Post by ChrisMicro » Sun May 14, 2017 7:40 am

I just realized that if I use I2S and the SD-card on the BlackF407VE, the I2S stops working.
What could be the reason? Is the SD-Card using SPI3?

Code: Select all

#include "Arduino.h"
#include "SDIO.h"
#include "STM32SdFatSdio.h"
#include "I2S.h"

I2SClass I2S(SPI3, PC12 /*DIN*/ , PA4 /*LRC*/, PC10 /*SCLK*/);

STM32SdFatSdio SD;

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: STM32GENERIC, my arduino implementation

Post by danieleff » Sun May 14, 2017 8:43 am

ChrisMicro wrote:I just realized that if I use I2S and the SD-card on the BlackF407VE, the I2S stops working.
What could be the reason? Is the SD-Card using SPI3?

Code: Select all

#include "Arduino.h"
#include "SDIO.h"
#include "STM32SdFatSdio.h"
#include "I2S.h"

I2SClass I2S(SPI3, PC12 /*DIN*/ , PA4 /*LRC*/, PC10 /*SCLK*/);

STM32SdFatSdio SD;
SDIO uses PC8, PC9, PC10, PC11, PC12, PD2

For I2S, you can for example use SPI2, PC3, PB12, PB10
Or SPI3, PB5, PA4, PB3

The best to find out the pins is to open up CubeMX, and enable SDIO (4 bit), and you will see which pins is it on.
Enable I2S2 (uses SPI2, which is why SPI2==I2S2), and see which pins it gives. ctrl+click on a green pin to see alternatives.

How will the user know these? Yeah...

Putting the libraries into the repository: I don't really want to deal with that. Rather change the original library so the user only has to download that (preferably in arduino library manager). But before that, it needs to be ironed out in viewtopic.php?f=51&t=2036 . Somebody will need to fork SdFat-beta, add the STM32SdFatSdio, figure out #defines so it does not break code for every other chip, publish it, test with multiple people, pull request back, finish. The example is really to show that it works by hacking it, and is an intermediate solution.

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: STM32GENERIC, my arduino implementation

Post by Pito » Sun May 14, 2017 11:37 am

The SDIO is NOT the same as SPI, the interface is different.
The current SDIO by Victor is still under development, so it has no sense to mess with it today, unless you want to test/debug it.
Pukao Hats Cleaning Services Ltd.

ChrisMicro
Posts: 290
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32GENERIC, my arduino implementation

Post by ChrisMicro » Sun May 14, 2017 8:30 pm

Daniel wrote:
The best to find out the pins is to open up CubeMX, and enable SDIO (4 bit), and you will see which pins is it on.
Thanx :D

Pito wrote:
The SDIO is NOT the same as SPI, the interface is different.
The current SDIO by Victor is still under development, so it has no sense to mess with it today, unless you want to test/debug it.
As far as I can see from the BlackF407 schematic the SDIO is fixed to the pins Daniel mentioned above.

SPI2 and its pins seem to be free on the board so I tried

Code: Select all

I2SClass I2S(SPI2, PC3 /*DIN*/ , PB12 /*LRC*/, PB10 /*SCLK*/);
Now it is working: I can read one second of a wav file into a RAM-buffer and play it over I2S. :D

... probably DMA I2S would be good ....

Daniel wrote:
The best to find out the pins is to open up CubeMX, and enable SDIO (4 bit), and you will see which pins is it on.
Enable I2S2 (uses SPI2, which is why SPI2==I2S2), and see which pins it gives. ctrl+click on a green pin to see alternatives.

How will the user know these? Yeah...
In humble opinion flexibility leads to mountains of errors. ;)

:mrgreen: To many choices are the source of all evil. :mrgreen:
Arduino means reduction of choices and giving the people what they need.

So standard I2S for a STM32GENERIC Black F407VE Arduino shall be fixed to SPI2.

Shall it :?:

fpiSTM
Posts: 191
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: STM32GENERIC, my arduino implementation

Post by fpiSTM » Sun May 14, 2017 9:28 pm

danieleff wrote:@fpiSTM: thanks! Have you thought about using github releases instead of committing them as files?
Currently not, as it's os dependant.
You ask this for dev purpose I think? Clone a repo or extract an archive is quiet the same things to do.

Post Reply