[libmaple] Generic F407VE mini (vcc-gnd version)

stevestrong
Tue Nov 07, 2017 10:55 pm
A really small and powerful board, with some extra hardware and lots of pins.
http://wiki.stm32duino.com/index.php?ti … 7VET6_Mini
The main difference compared to the generic black F4 board is that the mini board has a 25MHz crystal.
And the LED is on PB9 instead of PA6/7.

Important:
In order to get the board run, value 25 (instead of 8) must be entered here: https://github.com/stevstrong/Arduino_S … cF4.c#L370
In Arduino IDE the Generic F407 series menu has to be selected.
Maybe we should add an additional selection item in Arduino menu the crystal frequency?

I just quickly tested LED blink (PB9), SPI 1 and 3 and all work.

UPDATE 20.11.3017
– added Wire lib to communicate with the on-board 24c08 Eeprom. (see: viewtopic.php?f=39&t=2804&p=37376#p37376)


RogerClark
Tue Nov 07, 2017 11:44 pm
Steve

I think we’d be better off with a new variant for this, or perhaps setup the build to allow this to be switched by a define from boards.txt

I think having to select the crystal freq each time, would be a pain. (though the IDE does remember the last setting)


stevestrong
Wed Nov 08, 2017 1:28 pm
Ok, I will make a new entry in boards.txt for this, and define a new extra flag for the crystal frequency.

RogerClark
Wed Nov 08, 2017 8:44 pm
thanks

Manny
Wed Nov 08, 2017 11:24 pm
No wonder I was having trouble running this board.

stevestrong
Sun Nov 12, 2017 2:34 pm
I finally managed to adapt boards.txt and platform.txt, included a new define CRYSTAL_FREQ.

With the same occasion I have reworked both txt files, moved the common parts from boards to platform.
This changes requested to change some of the F4 files, so I did that and some cleanup, too.
https://github.com/stevstrong/Arduino_S … db35b57fd2
https://github.com/stevstrong/Arduino_S … 888095d986
https://github.com/stevstrong/Arduino_S … 5a94811edf
https://github.com/stevstrong/Arduino_S … f84c4bb5cc

I have built all F4 targets, error-free.
Only the generic F4 series (black and mini) boards were tested, both work as expected.


RogerClark
Sun Nov 12, 2017 6:59 pm
can you make a PR

Nutsy
Mon Nov 13, 2017 11:36 pm
Ohh thanks for this :D ive been looking at these boards lately… Now i know theres some support going towards it. might be able to get them working :D

stevestrong
Sun Nov 19, 2017 8:43 am
I have a problem with this board, the I2C 1 interface seems to get locked to BUSY state (SR2 bit 1) right after setting at least one of the PB6/7 pins to GPIO_AF_OUTPUT_OD.
I tried the software reset (SWRST), it clear the BUSY bit for the moment, but it gets set again after I release the SWRST bit.
I also tried the bus reset, no effect either, BUSY is set no matter what I try.

OTOH, software Wire implementation works, so the slave is definitively not blocking the bus.

Does anyone have a binary for this board with working I2C1 interface build with GENERIC or STM32duino core? i would like to investigate the signals at enable phase after reset.

I read several posts on internet and tried to implement every hint, but none of them helped.
I am trying to get desperate, it may be the interface faulty?


RogerClark
Sun Nov 19, 2017 9:26 am
Steve,

Can you try STM’s official core ? That would rule out a hardware fault in the silicon


stevestrong
Sun Nov 19, 2017 9:43 am
Well, I don’t know whether the official ST core has support for this board, this has 25MHz crystal.
I only found the Disco 407G the closest target supported.

EDIT
I checked the I2C part of ST official core , it does exactly the same as I do in the init phase.
Hmm.
It is really strange that the pins go low at once when I set the mode to GPIO_AF_OUTPUT_OD, and BUSY gets set.
Although I enable the I2C clock after the GPIOs are initialized, as recommended here: https://community.st.com/thread/43558-i … ent-168570


RogerClark
Sun Nov 19, 2017 7:17 pm
ummm

Sounds like a question for one of STMs own forums :-(


stevestrong
Sun Nov 19, 2017 11:37 pm
OK, so it seems that it was me (as always :? )
I forgot to set the AF mode register correspondingly.
Funny, as soon as I set it right, it started to work… :mrgreen:

RogerClark
Mon Nov 20, 2017 12:24 am
(LOL)

Such is programming


stevestrong
Mon Nov 20, 2017 10:08 pm
I finally managed to bring Wire lib on F4 mini to work, the new files are checked in with this commit: https://github.com/stevstrong/Arduino_S … 8d427d03f2
(Roger, don’t ask me to prepare a PR, because I know now that I am not able to make a clean PR… :( .
Hopefully you can merge the files from the patch.)
The i2c.cpp and header files had to be amended, too.
I introduced a new parameter for Softwire: SOFT_HSPEED, which generates ~1MHz clock.

Additionally, I moved the “digitalPinTo..(pin)” defines from variant header files to gpio.h, because they are common for all variants.

EDIT
All (scanning) examples were tested and they work.
I attach an example file to handle the on-board Eeprom.


RogerClark
Mon Nov 20, 2017 10:18 pm
[stevestrong – Mon Nov 20, 2017 10:08 pm] –
I finally managed to bring Wire lib on F4 to work, the new files are checked in with this commit: https://github.com/stevstrong/Arduino_S … 8d427d03f2
(Roger, don’t ask me to prepare a PR, because I know now that I am not able to make a clean PR… :( .
Hopefully you can merge the files from the patch.)
The i2c.cpp and header files had to be amended, too.
I introduced a new parameter for Softwire: SOFT_HSPEED, which generates ~1MHz clock.

Additionally, I moved the “digitalPinTo..(pin)” defines from variant header files to gpio.h, because they are common for all variants.

Thanks Steve

OK.

I’ll try to manually merge this when I get time.


RogerClark
Mon Nov 20, 2017 10:20 pm
Steve

Actually, if there is anything that needs to be manually merged, can you just raise and issue so I don’t forget

I just raised and issue for this change


michael_l
Sun Jan 21, 2018 4:30 pm
Is this the correct place to report errors with Steve’s repo?

I just downloaded Steve’s libmaple master branch and tried simple led blink sketch with F407VE mini board. Didn’t work so tried debugging with the new Atollic IDE and here’s the result:

bug.PNG
bug.PNG (22.68 KiB) Viewed 437 times

Manny
Sun Jan 21, 2018 7:46 pm
[michael_l – Sun Jan 21, 2018 4:30 pm] –
Is this the correct place to report errors with Steve’s repo?

I just downloaded Steve’s libmaple master branch and tried simple led blink sketch with F407VE mini board. Didn’t work so tried debugging with the new Atollic IDE and here’s the result:

Got blink to work but not serial USB…did you chose the the right board?


michael_l
Sun Jan 21, 2018 7:52 pm
[Manny – Sun Jan 21, 2018 7:46 pm] –

[michael_l – Sun Jan 21, 2018 4:30 pm] –
Is this the correct place to report errors with Steve’s repo?

I just downloaded Steve’s libmaple master branch and tried simple led blink sketch with F407VE mini board. Didn’t work so tried debugging with the new Atollic IDE and here’s the result:

Got blink to work but not serial USB…did you chose the the right board?

Yes, I chose the right board (mini) and serial USB from the Arduino menu. The wiki suggests to check pull-up for the usb pin if it doesn’t enumerate. As we know It should be 1.5k. Have to check that next I guess.


Manny
Sun Jan 21, 2018 8:53 pm
[michael_l – Sun Jan 21, 2018 7:52 pm] –

[Manny – Sun Jan 21, 2018 7:46 pm] –

[michael_l – Sun Jan 21, 2018 4:30 pm] –
Is this the correct place to report errors with Steve’s repo?

I just downloaded Steve’s libmaple master branch and tried simple led blink sketch with F407VE mini board. Didn’t work so tried debugging with the new Atollic IDE and here’s the result:

Got blink to work but not serial USB…did you chose the the right board?

Yes, I chose the right board (mini) and serial USB from the Arduino menu. The wiki suggests to check pull-up for the usb pin if it doesn’t enumerate. As we know It should be 1.5k. Have to check that next I guess.

I used st-link to upload the blink sketch using Steve core.
USB works fine with STM32Generic core, I just want to compare the Dhrystone benchmark between the both.


stevestrong
Sun Jan 21, 2018 10:34 pm
Sorry, it seems that something went wrong by my previous commit, although I have tested it before.
Could you try this version: https://github.com/stevstrong/Arduino_S … 8d427d03f2
Meanwhile I will check to see what is wrong there.

michael_l
Mon Jan 22, 2018 2:39 pm
[stevestrong – Sun Jan 21, 2018 10:34 pm] –
Sorry, it seems that something went wrong by my previous commit, although I have tested it before.
Could you try this version: https://github.com/stevstrong/Arduino_S … 8d427d03f2
Meanwhile I will check to see what is wrong there.

Thanks, no problems. I’ll try that later in the evening.


stevestrong
Mon Jan 22, 2018 3:20 pm
@Manny,
I don’t know how you could compare the Dhrystone benchmark, because in the libmaple (Roger’s and my) version for F4 the FPU is not yet implemented. I have it on the “todo” list, but did not have yet the required time (also lacking motivation, I have no projects which involves FPU).

michael_l
Mon Jan 22, 2018 4:33 pm
[michael_l – Mon Jan 22, 2018 2:39 pm] –

[stevestrong – Sun Jan 21, 2018 10:34 pm] –
Sorry, it seems that something went wrong by my previous commit, although I have tested it before.
Could you try this version: https://github.com/stevstrong/Arduino_S … 8d427d03f2
Meanwhile I will check to see what is wrong there.

Thanks, no problems. I’ll try that later in the evening.

Thanks, that commit seems to work!

Could I just copy FreeRTOS from F1 folder and change the freertosconfig.h, would that work ?

Also can I get the on-board sd card working ?

Thanks!


stevestrong
Mon Jan 22, 2018 4:54 pm
[michael_l – Mon Jan 22, 2018 4:33 pm] –
Could I just copy FreeRTOS from F1 folder and change the freertosconfig.h, would that work ?

Honestly, I don’t know, I’ve never tested FreeRTOS, nor any other OS.
Would be a good exercise for someone willing to test. :)

[michael_l – Mon Jan 22, 2018 4:33 pm] –
Also can I get the on-board sd card working ?

SDIO should work as it is listed to be supported here: http://stm32duino.com/viewtopic.php?f=39&t=1976


Manny
Mon Jan 22, 2018 5:37 pm
[stevestrong – Mon Jan 22, 2018 3:20 pm] –
@Manny,
I don’t know how you could compare the Dhrystone benchmark, because in the libmaple (Roger’s and my) version for F4 the FPU is not yet implemented. I have it on the “todo” list, but did not have yet the required time (also lacking motivation, I have no projects which involves FPU).

True but this is what I’m getting with STM32Generic …something definitely wrong there, got better numbers with a STMF103. :lol:
Microseconds for one run through Dhrystone: 15.16
Dhrystones per Second: 65958.27
VAX MIPS rating = 37.54


Manny
Mon Jan 22, 2018 6:10 pm
[stevestrong – Sun Jan 21, 2018 10:34 pm] –
Sorry, it seems that something went wrong by my previous commit, although I have tested it before.
Could you try this version: https://github.com/stevstrong/Arduino_S … 8d427d03f2
Meanwhile I will check to see what is wrong there.

I have a com port with that commit but nothing gets printed?

Image
tiny image host


Manny
Mon Jan 22, 2018 6:43 pm
Sorry for spamming this thread, found my FTDI breakout and was able to see the benchmark results .. -O3 flag…more like it.

Dhrystone Benchmark, Version 2.1 (Language: C)
Execution starts, 8000000 runs through Dhrystone

Execution ends
Microseconds for one run through Dhrystone: 1.78
Dhrystones per Second: 562824.91
VAX MIPS rating = 320.33


efftek
Mon Jan 22, 2018 7:34 pm
Hi,

I recently bought this board too. Although I can program it using my ST-Link, I cant getthe USB to work. If I have BOOT0 off, I get unknown device warning. Setting BOOT0 to on and the board is recognised but I get STM Serial (COM17), This device cannot start (code 10)

usb.jpg
usb.jpg (117.58 KiB) Viewed 343 times

Pito
Mon Jan 22, 2018 7:40 pm
@efftek: does the usb connector power the board actually? (sometimes the microsocket’s pins are not soldered properly).
Also the resistor dividers around boot switches have got values which are not the best choice.. I would replace the 10k pulldowns with something like 47k-100k..

..version for F4 the FPU is not yet implemented.
Quite a long reading on the FPU (407) viewtopic.php?f=39&t=2001&hilit=pito+fpu


michael_l
Mon Jan 22, 2018 8:13 pm
I just tried microSD card on the blue mini board. I got following errors with 2 GB microSD with demosketch (STM32SdioDemo):

######################################################
Demo sketch of STM32F4 SDIO (DMA) implementation.
######################################################
SdFatSdio begin() failed
Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X20,0X0


Pito
Mon Jan 22, 2018 8:35 pm
Does the SPI interface work with the sdcard?

michael_l
Mon Jan 22, 2018 8:56 pm
[Pito – Mon Jan 22, 2018 8:35 pm] –
Does the SPI interface work with the sdcard?

I haven’t tried yet. But as said the card works okay. I should have one microsd module lying around somewhere… This board is new so I’ll have to check which pins are meant for SPI1


Pito
Mon Jan 22, 2018 9:01 pm
Insert your sdcard in the socket on your 407 mini board and try an SdFat SPI demo. Set the sdcard’s chipselect/cardselect in the sketch properly.
CS (or card select) is pin2 on the socket -> PC11.

michael_l
Mon Jan 22, 2018 9:14 pm
[Pito – Mon Jan 22, 2018 9:01 pm] –
Insert your sdcard in the socket on your 407 mini board and try an SdFat SPI demo. Set the sdcard’s chipselect properly.
CS is pin2 on the socket -> PC11.

Thanks for the help! I loaded SdInfo.ino and set the chipselect to PC11 . But still same error:

SdFat version: 1.0.5

Assuming the SD is the only SPI device.
Edit DISABLE_CHIP_SELECT to disable another device.

Assuming the SD chip select pin is: 43
Edit SD_CHIP_SELECT to change the SD chip select pin.

type any character to start
error: cardBegin failed
SD errorCode: 0X20,0X0


stevestrong
Mon Jan 22, 2018 9:16 pm
Because the SPI pins do not overlay the SDIO pins, the SD cards on F4 boards are only accessible via SDIO (or software SPI but that is not implemented).
Please check my posts regarding the SDIO development, and test that version with the timely corresponding repo version.

I do currently a global check on the F4 software, it it terrible…
It seems that even the NVIC structure is not corresponding to the Cortex-M4 spec.
Then RCC misses a couple of peripherals, ADC registers are not correct, BKP domain is different, and so on, so there is a lot of stuff to double-check again.
I am just wondering why it is working (at least was working before i tried to correct things and messed up) :shock:

Please give me a couple of days to finish my overview.


michael_l
Mon Jan 22, 2018 9:24 pm
No problems, and thanks for your work. I can test when you are ready.

If someone has 100% working binary for this mini board I’d be happy to try it and verify my board is okay and reads sd cards correctly.


Manny
Mon Jan 22, 2018 10:13 pm
[michael_l – Mon Jan 22, 2018 9:24 pm] –
No problems, and thanks for your work. I can test when you are ready.

If someone has 100% working binary for this mini board I’d be happy to try it and verify my board is okay and reads sd cards correctly.

SDIO benchmark using STM32Generic

File size 5 MB
Buffer size 32768 bytes
Starting write test, please wait.

write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
947.63,1367323,14610,34453
1224.07,1383979,14703,26644

Starting read test, please wait.

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
2344.98,40740,11263,13972
2341.67,40895,13546,13995

Done
Type any character to start


stevestrong
Tue Jan 23, 2018 9:59 am
My repo should be functional again.
I had no time yet to test SDIO, but the rest of peripherals should work ok.

Manny
Tue Jan 23, 2018 8:33 pm
[stevestrong – Tue Jan 23, 2018 9:59 am] –
My repo should be functional again.
I had no time yet to test SDIO, but the rest of peripherals should work ok.

Thanks for that . I’m still not getting any output using serial USB.


stevestrong
Wed Jan 24, 2018 12:10 am
I just updated again my repo master branch, deleted all local files, cloned everything new from Github, compiled and I had working USB serial.

This is my blinky sketch:
#include <Arduino.h>

#define BOARD_LED2_PIN PA7 // on black F4

uint16_t counter;

// the setup function runs once when you press reset or power the board
void setup()
{
Serial.begin(115200);
while (!Serial);
delay(1000);
Serial.println("STM32F4 blinky...");

pinMode(LED_BUILTIN, OUTPUT);
pinMode(BOARD_LED2_PIN, OUTPUT);
counter = 0;
}

// the loop function runs over and over again forever
void loop() {
Serial.println(counter);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(BOARD_LED2_PIN, HIGH);
delay(250); // wait for a second
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(BOARD_LED2_PIN, LOW);
delay(250); // wait for a second
counter ++;
}


michael_l
Wed Jan 24, 2018 5:30 am
Thanks for the update. USB serial is working for me with your latest update but . As for SDIO I suspect some problem on my board because I tried huaweiwx’s stm32generic and yours and it does not work either way. PC card reader recognizes the cars successfully

stevestrong
Wed Jan 24, 2018 2:24 pm
I admit, I tested the SDIO only with the black F4 board, but not with the (blue) F4 mini.
So it may happen that the hardware SDIO connection is different on this small board, I have to check that.

EDIT
I have checked the schematics, the only difference is that the mini F4 board has and additional line to pin 10 (!) marked as SW1 of the micro SD slot, connected to PA8.
Honestly, I don’t know what exactly this pins is good for. Maybe detect whether a card has been pushed in the slot?


michael_l
Wed Jan 24, 2018 7:17 pm
[stevestrong – Wed Jan 24, 2018 2:24 pm] –
I admit, I tested the SDIO only with the black F4 board, but not with the (blue) F4 mini.
So it may happen that the hardware SDIO connection is different on this small board, I have to check that.

EDIT
I have checked the schematics, the only difference is that the mini F4 board has and additional line to pin 10 (!) marked as SW1 of the micro SD slot, connected to PA8.
Honestly, I don’t know what exactly this pins is good for. Maybe detect whether a card has been pushed in the slot?

Bought a new card 4GB SDHC, inserted straight from the package with this message:

SdFatSdio begin() failed
Invalid format, reformat SD.


Manny
Wed Jan 24, 2018 8:21 pm
[stevestrong – Wed Jan 24, 2018 12:10 am] –
I just updated again my repo master branch, deleted all local files, cloned everything new from Github, compiled and I had working USB serial.

I recommend you to first delete all local files before you download and extract files from the new ZIP of my repo.

Does you PC recognizes the USB as COM port? If not, you maybe need to install the official ST drivers.

Spot on …Installed STM’s virtual comport driver and now getting serial USB 8-) The few libraries with SPI like Adafruit_ILI9341_STM will not compile using the Blue mini board…I’ll leave that for another day.


Pito
Wed Jan 24, 2018 9:34 pm
SW1 – Card Detect switch.

stevestrong
Wed Jan 24, 2018 10:28 pm
SDIO test using my latest core + SdFat repo + example sketch, for a 2GB, class 4, cheap china card (not freshly formatted), file size 8MB:
######################################################
Demo sketch of STM32F4 SDIO (DMA) implementation.
######################################################

init time: 8 ms

Card type: SD2

Manufacturer ID: 27
OEM ID: PH
Product: SD02G
Version: 3.0
Serial number: 97bdbf7c
Manufacturing date: 8/2011

cardSize: 1969.23 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: 80ff8000

Volume is FAT16
blocksPerCluster: 64
clusterCount: 60086
freeClusters: 59559
freeSpace: 1951.63 MB (MB = 1,000,000 bytes)
fatStartBlock: 138
fatCount: 2
blocksPerFat: 235
rootDirStart: 608
dataStartBlock: 640

FreeStack: 61415
######################################################

Type any character to start
Test started - please wait, it may take up to 3 minutes

size, write, read
bytes, KB/sec, KB/sec
512, 190.70, 869.03
1024, 361.40, 1059.98
2048, 660.10, 2102.07
4096, 1133.33, 4088.29
8192, 1559.48, 5832.81
16384, 2007.64, 7714.63
32768, 2215.97, 8030.57

totalMicros 129325797
yieldMicros 96894938
yieldCalls 87623
yieldMaxUsec 152016
kHzSdClk 24000
Done


michael_l
Thu Jan 25, 2018 10:47 am
Thanks Steve for the updates. Finally my board detects SD card correctly !

All the time I had used SdFat repo from greiman and added the correct define. So I suspect something may have gone wrong there. Now I checked out your SdFat repo with latest STM32 code and *boom* it works. I’m smiling :)

######################################################
Demo sketch of STM32F4 SDIO (DMA) implementation.
######################################################

init time: 8 ms

Card type: SDHC

Manufacturer ID: 74
OEM ID: J`
Product: USD
Version: 1.0
Serial number: ffed8041
Manufacturing date: 5/2010

cardSize: 4025.48 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true
OCR: c0ff8000

Volume is FAT32
blocksPerCluster: 64
clusterCount: 122592
freeClusters: 122591
freeSpace: 4017.06 MB (MB = 1,000,000 bytes)
fatStartBlock: 14468
fatCount: 2
blocksPerFat: 958
rootDirStart: 2
dataStartBlock: 16384

FreeStack: 61415
######################################################

Type any character to start
Test started - please wait, it may take up to 3 minutes

size, write, read
bytes, KB/sec, KB/sec
512, 186.33, 1288.61
1024, 366.88, 2439.33
2048, 753.58, 3998.89
4096, 1473.68, 6188.57
8192, 2750.75, 8051.64
16384, 4812.20, 9550.56
32768, 5132.90, 10442.53

totalMicros 107262334
yieldMicros 85513135
yieldCalls 114269
yieldMaxUsec 74701
kHzSdClk 24000
Done

Type any character to start


efftek
Sat Mar 03, 2018 7:37 pm
[Pito – Mon Jan 22, 2018 7:40 pm] –
@efftek: does the usb connector power the board actually? (sometimes the microsocket’s pins are not soldered properly).
Also the resistor dividers around boot switches have got values which are not the best choice.. I would replace the 10k pulldowns with something like 47k-100k

Hi Pito, sorry, been busy with builders and legal problems so haven’t done much for last few weeks. In reply, the usb turns on the power light, but the code loaded into the board – blink- doesn’t run. If I power the board from the st-link connections, it does.

Looking at the bottom of the board, not all the resistors etc are labelled. I did read about wrong value of usb pull-up resistor which the schematic lists as R8 and this is one of the unmarked ones. Also the 10k resistors you mention are also unmarked. Can anyone indicate which these are?

EE7D118F-0095-477E-B83F-7D6A89B5FDBF.jpeg
EE7D118F-0095-477E-B83F-7D6A89B5FDBF.jpeg (185.13 KiB) Viewed 325 times

efftek
Tue Mar 06, 2018 1:43 pm
Update on above.

Once I replaced the hardware files with SteveStrongs github ones and reloaded the sketch via my st-link, everything is suddenly fine!

Yay….


mrburnette
Tue Mar 06, 2018 4:22 pm
[efftek – Tue Mar 06, 2018 1:43 pm] –
Update on above.

Once I replaced the hardware files with SteveStrongs github ones and reloaded the sketch via my st-link, everything is suddenly fine!

Yay….

We are starting to have several “flavors” of cores in github branches. I see a dilemma coming with trying to support all this stuff… having to ask “which core” before answering and then trying to reconcile why one branch works and one branch does not work.

Ray


Leave a Reply

Your email address will not be published. Required fields are marked *