Skip to content

dwelch67/black_pill_too

Repository files navigation

STM32F407VGT6 breakout board baremetal examples.

So if you google

stm32 blue pill

you find an inexpensive cortex-m3 based board.  You google STM32 black
pill you find a similar one.  (This repo has ABSOLUTELY NOTHING to
do with either one of those boards, nor anything maple or arduino)

Well there is also a black board you find if you search for

STM32F407VGT6 board

on ebay or amazon.  I have been burned a few times on ebay now
with empty shipments and no way to recover, amazon two to three times
the price for the same board but already in the states your choice.

This one says diymroe (diymore mispelled) on the top and DIY MORE
on the bottom.  Website is bogus or doesnt work anymore.  Found
the schematic on google searches and dumb luck.

On the other end of the board away from the usb connector, one corner
has another button and says diymroe, not that corner, but the other
has silkscreen that says BOOT0BOOT1.  Those last to sets of pins
on that reset button edge of the board are BOOT0 and BOOT1 and a
ground.  See the black_ebay_board.png file to see the board that I am
talking about.  I have marked the BOOT0 pin(s) in blue and the BOOT1
in red.

If you plug a two pin jumber across the BOOT1 pin(s), the ones I marked
in red, to short BOOT1 to ground (ground being on the outer edge of the
board BTW) and plug the board into your computer using a usb cable
then you should see something like this with dmesg

[431754.721749] usb 2-1.7.2: New USB device found, idVendor=0483, idProduct=df11
[431754.721752] usb 2-1.7.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[431754.721755] usb 2-1.7.2: Product: STM32  BOOTLOADER
[431754.721756] usb 2-1.7.2: Manufacturer: STMicroelectronics
[431754.721758] usb 2-1.7.2: SerialNumber: 333333333333

apt-get install dfu-util

then you can do something like this

dfu-util -a 0 -s 0x08000000 -D blinker00.bin

Then move the jumper one set of pins over from the end, BOOT0 and GND
I have marked as blue in the picture, and press reset, that will then
run our program in flash.

This implies that BOOT0 and BOOT1 float high when not shorted to ground.

If you have a jumper on both BOOT0 and BOOT1 it also boots into your
application flash.  So if you leave the BOOT1 in place and then put a
momentary pushbutton on BOOT0 you can hold it and press reset to run
the application, press reset without BOOT0 and run the bootloader no
more moving jumpers.

Documents you will need

On the st.com website search for STM32F407VGT6, get the datasheet (currently
shown as DS8626) and the reference manual as a minimum (currently shown
as RM0090.  You can get the programming manual, and maybe it has some
different information but the proper manuals are at ARMs website with
respect to the cortex-m4 core, we know it is a cortex-m4 because we
looked at the st documentation for this chip.

We go to infocenter.arm.com then on the left we see cortex-m series
processors (this as with all websites are subject to change), expand
that.  See Cortex-M4, expand that see different revisions r0p1 for
example is the most recent I see.  So expand that and see ARM
Cortex-M4 Processor Technical Reference Manual.  Click on that go to the
bottom and get the pdf version.  You might have to sacrifice an email
address.

Now the ARM TRM (technical reference manual) tells us this processor
core conforms to the ARMV7-M architecture so we go back to the left side
of that page, expand ARM Architecture.  Expand Reference Manuals, expand
ARMv7-M Reference Manual.  Select ARMv7-M Architectural Reference
Manual and download the pdf version.  Might have to give up an email
address.  This is the ARM ARM (Architectural Reference Manual) at
least for this architecture version.  Used to be only one ARM ARM
now there are many.

ARM makes IP/cores not chips, ST makes this chip, the processor is
at the center but much of the logic around it is from ST or other ip
vendors ST purchased ip from.  When you use a different cortex-m4 be
it from ST or from some other company (ti, NXP, Atmel, etc) the
cortex-m4 inside may be the same (or may vary a little) but the rest
of the chip is from the chip vendor, it can vary widely, even from
one ST chip to another, you will find particularly with ST but also
with others, that they may have a few different uart peripherals and
a few different timers and a few different gpio peripherals and when
they go to make a new chip they may mix and match the peripherals from
their existing choices, or may make a new one or modify one.  You may
find a uart in this chip that matches a uart in another ST chip maybe
not at the same base address but otherwise identical but this and that
chip may have different GPIO logic.  Short answer, dont go around
asking how do I do something with an ARM Cortex-M4 you ask how do
I do something with an ST STM32F407VGT6, MOST of your code has to
do with the non ARM portions of the chip, thus most questions you will
have have to do with the non ARM logic in the chip.

As mentioned I have included a picture of the board I have, and have
a schematic here that so far matches as well.

Although a moving target see the TOOLCHAIN file for notes on getting
a toolchain with which to build these examples.  The root directory
contains a working blinker00.bin file.

Start with the blinker examples.

For the uart examples and others that use the uart, you need a
uart solution.  There are many.  Search for

ftdi breakout

on amazon or ebay or adafruit or sparkfun.  See the FTDI_breakout.jpg
picture, these are a couple of bucks each on ebay.  Make sure you
set the jumper/switch to 3.3v.  And TX <-> RX

PA9  USART1_TX to FTDI breakout RX
PA10 USART1_RX to FTDI breakout TX

There are a myriad of solutions and they dont have to be FTDI they just
need to be a uart solution at 3.3V TTL levels NOT RS232!!!  And not
5V and not 1.8V.

I buy bundles of female to female jumper wires, ebay you can get 40 for
under $2 shipped.  YMMV sparkfun, adafruit, etc have them too.  If you
get a female breakout board then you may need a male/female jumper wire
I prefer to stick with one kind where possible.

Learn how to use a dumb terminal program like minicom

Even though there is a warning here is my /etc/minicom/minirc.usb0:

# Machine-generated file - use "minicom -s" to change parameters.
pu port             /dev/ttyUSB0
pu minit            
pu mhangup          
pu rtscts           No 
pu sound            No 

Cut and (create and) paste this to minirc.usb1 and usb2 and usb3...
changing the tthUSB0 to ttyUSB1 and so on.  Saves a lot of time with
their menu system.

sudo apt-get install minicom lrzsz

May need the zmodem and xmodem at some point not necessarily for this
repo but for other things.

Once you have one of these setup plug in the usb uart board/cable

Looking for the last line

[499317.633302] usb 2-1.7.4: FTDI USB Serial Device converter now attached to ttyUSB0

which tells me

minicom usb0

with the rc files I created above.  And there you go, defaults to 115200 8N1
so ready to go.


chipinfo example shows this is a cortex-m4 r0p1.  no cache.  single but
no double precision float.  has both stacks (not that we care the other
stack is not worth the trouble)

About

STM32F407VGT6 breakout board baremetal examples.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages