STM32F4 Discovery, SPI and microSD #560
Replies: 14 comments
-
Posted at 2014-08-07 by @gfwilliams Hi, Things have moved on a bit since that last post, but you'll still have to compile your own Espruino Binary... You'll have to:
and then the filesystem should work. Also, if you want something that 'just works', is cheaper than buying all that, and also helps to pay for all the time I spend on improving and supporting Espruino, you can always buy an Espruino board ;) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-07 by roy.emmerich Thanks for the help @gordon. Super snappy response :)
I would love to support you but at the moment I am in the process of evaluating Espruino for much larger things. I'm starting my own company and have spent a lot of time looking for a hardware platform to base it on. So if things work out between Espruino and myself, you and I should talk some more about future collaboration ;) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-07 by @gfwilliams Looks good - definitely if you're putting it into a product, doing your own compile with SD card support built in (and whatever else) probably makes a lot of sense anyway. One thing though: I was told (I'm not sure if it's true) that the licence for the Discovery boards forbids them to be used in anything commercial - I believe one of the reasons the board itself is so cheap is that ST basically sells it at cost. That means that you may have to look at another system anyway - or maybe MikroElektronika makes their own F4 board... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-07 by roy.emmerich
This is just the prototyping platform. The final product will have a different backplane board with more mikroBUS sockets and will have a processor board something like the MINI-M4 for STM32. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-08 by roy.emmerich Okay @gordon I went through the process and everything goes fine until I connect to the board in the webIDE. I get the following message in the console:
I swear I didn't delete the log function :) Running something simple like I put a simple text file on the SD card (
Any tips? This is exactly what I did to get to this point:
The relevant sections of my
and the
I then just ran the command I must say I can't figure out how to use Running the following command:
I end up with the following error:
So instead I use the
Everything flashes fine and I can remove the jumpers and restart the board. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-08 by @gfwilliams Yes, that all seems good - stm32loader needs a serial connection to the chip, which you won't have. The short-hand to use st-flash to flash the board is just The error you're getting is almost certainly because you haven't erased the chip first, so it's still got the 'old' code you saved in it. As it says in http://www.espruino.com/Other+Boards, just hold down Button1 while booting (which will stop Espruino automatically loading the saved program). Then type 'save()' to save a correct (but Empty) JavaScript program back into flash. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-08 by roy.emmerich Sweet! So that solved the This is what I did:
Any ideas @gordon? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-08 by @gfwilliams All I could suggest is that you make sure you reformat the SD card in FAT32, and make sure that the connections you gave really are the right ones for where you've plugged in the SD card shield. Maybe try and stick a scope on the data pins and see if they really are working when you try and access the card. People definitely have had it working on the F4 though, so I'd imagine it's something relatively simple. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-08 by roy.emmerich Unfortunately still not working. So I did the following:
and captured this image where channel 2 (blue) is PB15 (DI):
So it seems it is at least addressing the correct pins. Pinout differences: My observations:
Any tips @gordon? Once again many thanks. Roy |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-09 by Frida Have you tryed to put CS to GND, before you talk to the card. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-09 by roy.emmerich Thanks for the suggestion @frida. Unfortunately it still gives the same error:
This is what I saw in my two attempts, this time monitoring the CS and DI pins. First attempt I started by executing the following command to set the CS pin low:
I then followed this up with the file read command:
and saw the following on the scope: Second attempt This time I just ran the file read command and saw the following on the scope: Conclusion From this it seems the chip select pin is being set correctly. Any other ideas? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-10 by roy.emmerich Well what do you know, it is working! :) Wandering in the wilderness Since my last post I delved right down into the SD specification to try and figure out what should be happening. I found a few particularly helpful posts and documents that I'd like to share here for others having similar problems:
and it even got me ferreting through the C code ;) Thanks to reference #2 above I found out what should be happening with the card detect (CD) pin when the card is put into the slot. Everything was in order. Still no joy! For some reason I decided to use another set of pins and see what happened. This is the current standing of the SD definition block in
I connected her up, ran my command and this is what I got:
followed by a write just to make sure it really was working:
So I'm not quite sure what is wrong with the other set of pins but at least it is now working and I have learnt a bunch of stuff I never thought I'd have to! Thanks again for all your help @gordon. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-10 by roy.emmerich Just to properly complete this ticket I thought I would add some scope images of what things look like when everything is working. Read
produces: Write
produces: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-11 by @gfwilliams Glad you got it sorted... I wonder what the issue was - whether it was a pin conflict, or some problem with SPI on those pins... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-08-07 by roy.emmerich
I am trying to get my head around connecting up a microSD card using SPI and wouldn't mind a bit of guidance, especially since I am new to Espruino.
Some background:
I am using the following hardware
which pretty much looks like this:
I have the microSD click board (bottom left in the image above) in the mikroBUS port 1 on the Discovery shield which translates to the following pinout:
mikroBUS port 1:
SD card pin -----------> STM32F4 Pin
2 (CS) -------------------> B12 (CS)
3 (DI) -------------------> B15 (SPI2 MOSI)
5 (SCK) -----------------> B13 (SPI2 SCK)
7 (DO) ------------------> B14 (SPI2 MISO)
Goal:
Is obviously to read from and write to the SD card.
I found the following conversation on the Espruino forum where @gordon alludes how to go about using SPI to get this working but I am still a bit lost.
I see that the filesystem module is only supported on boards with a SD card slot
@gordon says in his comment above to, "just stick with normal SPI"
Getting the SPI setup seems very straight forward:
SPI setup comments:
Once the SPI is taken care of how does one deal with reading and writing files with normal SPI?
Any help greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions