Spark Logic

[libmaple] Black F407VET6

stevestrong Wed Apr 12, 2017 4:37 pm

The master branch of my repo contains the latest developments for F4, so I recommend to use this if somebody wants to test it with Arduino IDE or PlatformIO.
Supported board variants: generic F4 (tested), generic F4 mini (tested), disco F407 (compiles but not tested).

Some basic information about the board can be found on wiki: http://wiki.stm32duino.com/index.php?title=STM32F407

Currently working:
– GPIOs + LED toggle
– USB serial and serial 1,2,3. Evaluated USB serial speed, Tx: ~800kBps
– SPI (1,2,3) with DMA (also for SD cards using latest SdFat lib made by Greiman), extended DMA functions
– FSMC (adapted for driving 16 bit parallel LCDs) http://stm32duino.com/viewtopic.php?f=39&t=2298#p31037
– SDIO [non-HAL implementation] (for SD cards using latest SdFat lib made by Greiman) http://stm32duino.com/viewtopic.php?f=39&t=2215
– RTC – reworked, does not need any extra time library
– I2C (Wire) viewtopic.php?f=39&t=2804&p=37376#p37376
– supports W5500-based Ethernet modules (see viewtopic.php?f=13&t=503&p=32063#p32063)
– DAC, see viewtopic.php?f=39&t=1976&p=41564#p41564
– ADC, see http://stm32duino.com/viewtopic.php?f=3 … 720#p42720
– DCMI, see viewtopic.php?f=39&t=3414&p=43358#p43358
– CAN, see: http://stm32duino.com/viewtopic.php?f=3 … 239#p49235

Todo:
– port the new (faster) version of SDIO from Victor (https://github.com/rogerclarkmelbourne/ … 2/pull/474)
– check the on-board W25Q64 SPI flash, maybe add SPIflash lib to repo (where from?) https://github.com/LowPowerLab/SPIFlash
– check/add FPU (http://stm32duino.com/viewtopic.php?f=39&t=2001, http://stm32duino.com/viewtopic.php?f=3 … 048#p31040)
– add support for Seed Arch Max board
– add Ethernet lib (usable with Seeed Arch Max board)

EDIT – 2018.10.02
– added extended SPI DMA functions, see: viewtopic.php?f=15&t=3415

EDIT – 2018.09.12
– working CAN, see: http://stm32duino.com/viewtopic.php?f=3 … 239#p49235 (thanks to @michael_i!)

EDIT – 2018.03.19
– tested ADC, see: http://stm32duino.com/viewtopic.php?f=3 … 720#p42720

EDIT – 2018.02.18
– tested DAC, see: viewtopic.php?f=39&t=1976&p=41564#p41564

EDIT – 2018.01.16
– Added I2C (Wire), see: viewtopic.php?f=39&t=2804&p=37376#p37376

EDIT – 2017.07.10
– RTC lib reworked to be independent from other time libraries. Includes an example sketch to read and set the RTC time, as well as how to use the time elements.
It can be downloaded from here: viewtopic.php?f=39&t=775&p=31218#p31218

EDIT – 2017.06.18
– Implemented SDIO [non-HAL implementation] (for SD cards using latest SdFat lib made by Greiman)
viewtopic.php?f=39&t=2215

EDIT – 2017.06.02

Upload under windows currently only possible with STLink (V2).
When BOOT0=”1″(3.3V) and BOOT1=”0″(GND), the chip is recognized by Win10 as ‘STM Device in DFU mode’ (USB\VID_0483&PID_DF11).
However, there is no working DFU loader for Windows available, yet.

Comments & suggestions are welcome in this thread.
Any bug reports & PRs in Github, please.

————————————————————————————-
Hi all,

I know there is another thread on vet6 & zet6 boards, but there are at least 2 type of boards mixed, with partially different information.
And there is a lot of other information spread over other threads, like this generic implementation from danieleff.
Wiki has some basic stuff, too (thanks, Palmer!).

So, I got my black board today and I though it makes sense to open a separate thread only for the black VET6 board. The title can be edited later if needed, and the useful and tested information can (should) be added to wiki.

First of all, this is the current situation:
Both LEDs blink, but the USB device descriptor failed (VID 0x000 PID 0x0002).
On the serial port (115200Baud, 8N1) I receive after each reset: “LCD ID:ffff”
I can connect with the ST-Link probe, and I could read out the flash (I can attach here or to wiki if wanted). I assume writing would be also possible.

Now would like to start with the sw development.
The question is: how?

I know, there are a lot of alternative options (the official STM32 core, Start Otto github, Koduino, and so on).
But honestly, I like very much the existing Arduino_STM32 repo and I would like to use this for my future work.
I also know, it will be a hard way to go. But I think, with small steps I (we?) can achieve great results.

So, will the Arduino_STM32 provide the basic structure and functionality for a blinky example?
If anyone tried that already and had success, I would appreciate a short description of what and how to do.

For the beginning I intend to use the STlink upload method as the USB DFU seems not (yet?) to work.
Is there any working bootloader available for this board?

Replies

danieleff Wed Apr 12, 2017 5:30 pm

The discovery_f407 variant in the Arduino_STM32 / STM32F4 can actually blink the black F407VET on PA6 using ST Link, so I guess its a good start?

victor_pv Wed Apr 12, 2017 5:35 pm

Steve, the core is compatible with the F4, the problem is that the compatible part was based of libmaple several years ago and has not been brought up to the latest arduino API.
I have an F407 board and the led blink example works fine.
Most of the libmaple libraries are adapted. You may need to update things like stream and others. I would think a good start would be to run a diff between the F1 and the F4 cores to see what may be completely missing from the F4 side.

The SPI library files were copied from the F1 some time ago after we added the dmaSend and dmaTransfer functions, but those should not work in the F4 because the DMA controller is different, but we could rewrite those for both the F1 and F4 using the dmatubes leaflabs added to libmaple, because that API works on both F1 and F4.

Those are the things that come off my head about the F4 core.

ag123 Wed Apr 12, 2017 6:11 pm

another thing though, i’m not too certain if we could bundle and distribute those ST cube-mx HAL and standard peripheral libs sources as part of stm32_duino set of sources. but i do see them bundled e.g. with gnu arm eclipse etc

i’m finding that danieleff’s stm32generic duino implementation that’s based on hal make sense, in particular as F4 is less resource constrained vs F1 codes compiled for f4 can easilly be re-compiled say for f1, f2, f3, f4, f7, l4 etc (just that on the more resource constrained f1 / f0 etc, the binaries may turn out to be ‘fat’ and eats more sram – could be a key difference for memory hungry sketches)
http://www.stm32duino.com/viewtopic.php?f=42&t=1966

some of the codes and initializers are apparently common, however, i think when we start to dig deeper into the ‘other peripherals’ e.g. USB, SPI, I2C, DMA etc, things may start to diverge, but i’d think ST has them catered in the hal

in a way in stm32duino we are sort of creating a ‘custom hal’, and arduino sketches connects through the stm32duino arduino / maple api

or perhaps we should after all have alternatives

Pito Wed Apr 12, 2017 6:56 pm

I took my Black 407ZET6, set F4Discovery in Arduino IDE, and it compiled blink with two leds at PF9 and PF10 fine.
My Jlink connected to the 20pin Jtag header, Jflash flashed (SWD) the .bin ok (from 0x08000000).
And it blinks with 2 leds ok.
Added Serial.println() (uart1 at pins PA9, PA10), ok.
Hello World from F407!
Hello World from F407!
Hello World from F407!

ag123 Wed Apr 12, 2017 7:33 pm

oh that whetstone benchmark should be a hardware fpu benchmark, 16 double precision mflops! did you set float ABI as FP instructions hard, fpv4-sp-d16? :D

Pito Wed Apr 12, 2017 7:41 pm

I did nothing, just pushed the button :)
This one:
Compile.JPG
Compile.JPG (8.05 KiB) Viewed 5743 times

ag123 Wed Apr 12, 2017 7:43 pm

i see :D
ok i dug up the benchmark thread
http://www.stm32duino.com/viewtopic.php?t=76

some of the old records seemed to be:
Kenjutsu wrote:Just for interest sake, here are some Whetstone benchmark results for my Nucleo F411RE and Blue Pill board:

// mbed online - F411RE
// Loops: 1000, Iterations: 1, Duration: 25 sec.
// C Converted Double Precision Whetstones: 4.0 MIPS

// gcc4mbed - F411RE
// Loops: 1000, Iterations: 1, Duration: 17 sec.
// C Converted Double Precision Whetstones: 5.9 MIPS

// gcc4mbed - F103RE (Blue Pill)
// Loops: 1000, Iterations: 1, Duration: 34 sec.
// C Converted Double Precision Whetstones: 2.9 MIPS

// STM32duino Blue Pill
// Loops: 1000 Iterations: 1 Duration: 19838 millisec.
// C Converted Double Precision Whetstones: 5.04 MIPS

Pito Wed Apr 12, 2017 8:11 pm

And for big and fast CPUs here is the big math :) :
Black F407 Math Test by Pito 4/2017
x= 3444444444445555555555666666.6666677777777788888889
y= -56666666666677777777777788.888888888111111111112222

z=x+y= 3387777777778877777777888877.7777788896666677777767
3.387777777778878e+27
elapsed: 20 us

z=x-y= 3501111111112233333333444455.5555566658888900000011
3.501111111112233e+27
elapsed: 15 us

z=x*y= -1.9518518518528641975309276666666672819753092717704E+53
-1.951851851852864e+53
elapsed: 46 us

z=x/y= -60.784313725497885428683223790246606967299291272272
-6.078431372549789e+01
elapsed: 162 us

z=cos(0.7)= 0.76484218728448842625585999019186490926821055037373
7.648421872844884e-01
elapsed: 3843 us

stevestrong Wed Apr 12, 2017 8:24 pm

Guys, please, my intension was the startup, not the benchmark.
I didnt even mange to flash a blinky…
This thread should clarify startup issues, not the exponential part of a floating point value.
I will try to set the Arduino board to the only one available F4 board and then see if it works on the black F4.

Pito Wed Apr 12, 2017 8:26 pm

Steve, it must work the same way on the VET6.. Forget USB.
Your LEDs are at PA6, PA7.
Serial pins at PA9, PA10.
The biggest problem is to find the .bin.
Erase the chip and upload the blink .bin from 0x08000000..
Disconnect your flasher (Stlink?) EDIT: soft disconnect
Reset.
It must work.

stevestrong Wed Apr 12, 2017 9:03 pm

Pito, thank you, I confirm: blinky on PA6/7 and serial (USART1 on PA9/10) work indeed when board is set to F4 disco in Arduino.
And… I don’t even have to disconnect the STLink probe to work ;)

Next, I will setup a new Black_VET6 variant and make some customization.

victor_pv Thu Apr 13, 2017 3:09 am

stevestrong wrote:Guys, please, my intension was the startup, not the benchmark.
I didnt even mange to flash a blinky…
This thread should clarify startup issues, not the exponential part of a floating point value.
I will try to set the Arduino board to the only one available F4 board and then see if it works on the black F4.

ag123 Thu Apr 13, 2017 6:56 am

there is no need for a boot loader
1) set BOOT0
2) *just press reset won’t do, pull out the usb cable and reconnect again*
dmesg
[ 5955.084223] usb 3-4: new full-speed USB device number 9 using xhci_hcd
[ 5955.248859] usb 3-4: New USB device found, idVendor=0483, idProduct=df11
[ 5955.248861] usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 5955.248862] usb 3-4: Product: STM32 BOOTLOADER
[ 5955.248863] usb 3-4: Manufacturer: STMicroelectronics
[ 5955.248864] usb 3-4: SerialNumber: 338334803335

stevestrong Thu Apr 13, 2017 7:28 am

I can confirm, BOOT0 = “1” and reset will put the device in bootloader mode, as expected.
On win10 x64 machine a new USB device is detected, first as “STM32 BOOTLOADER”, then after a while it becomes “STM device in DFU mode”.

However, I think this mode is not practical, since the user has to change the BOOT0 jumper by each upload.

The STLink is more practical, I don’t even have to remove the connection wires after uploading new software. The STLink probe re-flashes the device on the fly (tried with the STM32 ST-Link Utility).

Pito Thu Apr 13, 2017 7:46 am

I had to install libusbK (zadig) in order to see the device (Win7 64b) with dfu-util 0.9.
I have to unplug and reinsert the usb plug in order to flash again. It flashes about 5kB/sec.
I have to reinstall Boot jumper to run the code. Maybe there is a dfu command to run the code.
It works here on Black ZET6, but it seems the st-link/j-link is a better alternative.

ag123 Thu Apr 13, 2017 8:04 am

i’d think for users without a separate st-link dongle, dfu is possibly a good substitute, as for boot0 an easy way is to plug a 2 way (3 connector) switch in place i.e. select 0 or 1

i think the stock dfu-util v0.7 works just as well, just that i’ve compiled my dfu-util from source
http://dfu-util.sourceforge.net/

and i’d think we could port the bootloader as well, that’d make it simpler to install a sketch. but it would be less ‘urgent’ as there is an existing solution

Pito Thu Apr 13, 2017 8:12 am

I think there are tasks with higher priority – as for example SPI and others.. I tried to compile a sketch with Sdfat with no success (SPI compile errors).

stevestrong Thu Apr 13, 2017 8:15 am

Pito wrote:I think there are tasks with higher priority – as for example SPI and others.. I tried to compile a sketch with Sdfat with no success (SPI compile errors).

Pito Thu Apr 13, 2017 8:22 am

Btw SdFat supports SDIO with Teensy..

Sign in to reply