STM32: Difference between revisions

From Braindump
Jump to navigation Jump to search
No edit summary
 
(30 intermediate revisions by the same user not shown)
Line 1: Line 1:
https://stm32-base.org/
https://stm32world.com/wiki/STM32_Memory_Map
https://github.com/stm32duino/Arduino_Core_STM32
https://github.com/stm32duino/Arduino_Core_STM32


https://uraltone.com/stm32f401ccu6-kehitysalusta-usb-c.html
https://uraltone.com/stm32f401ccu6-kehitysalusta-usb-c.html
https://opencircuit.fi/product/st-link-v2-stm8-stm32-programmer


https://github.com/stlink-org/stlink
https://github.com/stlink-org/stlink


'''STM32 F1'''
https://kleinembedded.com/stm32-without-cubeide-part-1-the-bare-necessities/


[https://estore.st.com/en/stm32f103c8t6-cpn.html STM32F103C8T6]
==== STM32 F1 ====
[https://estore.st.com/en/stm32f103c8t6-cpn.html STM32F103C8T6] Used in the Bluepill ([https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html#sample-buy $2.7946 / 10k])


Bluepill
Cortex-M3 ARM @72 MHz, 20 Kb RAM and 64Kb Flash. 3.3V, some of its pins are 5V tolerant.


Cortex-M3 ARM @72 MHz, 20 Kb RAM and 64Kb Flash. 3.3V, some of its pins are 5V tolerant.
https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html
 
https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html


STMicrelectronics RM0008 STM32F10xxx [https://www.st.com/content/ccc/resource/technical/document/reference_manual/59/b9/ba/7f/11/af/43/d5/CD00171190.pdf/files/CD00171190.pdf/jcr:content/translations/en.CD00171190.pdf Reference Manual]
STMicrelectronics RM0008 STM32F10xxx [https://www.st.com/content/ccc/resource/technical/document/reference_manual/59/b9/ba/7f/11/af/43/d5/CD00171190.pdf/files/CD00171190.pdf/jcr:content/translations/en.CD00171190.pdf Reference Manual]
Line 21: Line 26:
The Generic STM32F103 [http://reblag.dk/wordpress/wp-content/uploads/2016/07/The-Generic-STM32F103-Pinout-Diagram.pdf Pinout Diagram], Rasmus Friis Kjeldsen
The Generic STM32F103 [http://reblag.dk/wordpress/wp-content/uploads/2016/07/The-Generic-STM32F103-Pinout-Diagram.pdf Pinout Diagram], Rasmus Friis Kjeldsen


'''STM32 F4'''


[https://estore.st.com/en/stm32f401ccu6-cpn.html STM32F401CCU6]


Blackpill
https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill
 
Based on Maple Mini from Leaflabs, does not have USB-to-Serial chip
 
==== STM32 F4 ====
[https://estore.st.com/en/stm32f401ccu6-cpn.html STM32F401CCU6] Used in the [https://stm32-base.org/boards/STM32F401CCU6-WeAct-Black-Pill-V1.2 WeAct Blackpill V1.2] ([https://www.st.com/en/microcontrollers-microprocessors/stm32f401cc.html#sample-buy $2.2469 / 10k])


[[File:St32-pinout.png|thumb]]Cortex-M4 @84 Mhz,with DSP, FPU 64 Kb of RAM and 256Kb flash
[[File:St32-pinout.png|thumb]]Cortex-M4 @84 Mhz,with DSP, FPU 64 Kb of RAM and 256Kb flash
[[File:Blackpill Pin tolerance.png|thumb]]


https://www.st.com/en/embedded-software/stsw-stm32065.html
https://www.st.com/en/embedded-software/stsw-stm32065.html
Line 33: Line 42:
https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/ST-Microelectronics/FreeRTOS-for-STM32F4xx-Cortex-M4F-IAR#ConfigAndUsage
https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/ST-Microelectronics/FreeRTOS-for-STM32F4xx-Cortex-M4F-IAR#ConfigAndUsage


'''STM32 N6'''


https://estore.st.com/en/nucleo-n657x0-q-cpn.html
5V Tolerance: http://www.emcu.eu/000/STM32_5VtolerantIO.pdf
 
==== STM32 H5 ====
[https://www.st.com/en/microcontrollers-microprocessors/stm32h533re.html stm32h533ret6] ([https://www.st.com/en/microcontrollers-microprocessors/stm32h533re.html#sample-buy 2.6679 / 10k])
 
Cortex-M33 @250 MHz, 512-Kbyte Flash, 272-Kbyte RAM


Cortex-M55
https://www.st.com/en/evaluation-tools/nucleo-h533re.html


[https://www.st.com/resource/en/user_manual/um3121-stm32h5-nucleo64-board-mb1814-stmicroelectronics.pdf um3121-stm32h5-nucleo64-board-mb1814-stmicroelectronics.pdf]


https://github.com/STMicroelectronics/STM32CubeH5
==== STM32 N6 ====
https://estore.st.com/en/nucleo-n657x0-q-cpn.html


'''Fake'''
Cortex-M55


==== Fake ====
Is my bluepill a fake one? did I blow it up or does it miss some bootloader? In run mode the blink program runs.
Is my bluepill a fake one? did I blow it up or does it miss some bootloader? In run mode the blink program runs.


Line 53: Line 71:
http://web.archive.org/web/20240214091007/https://www.e-tinkers.com/2020/01/getting-started-with-stm32-and-things-you-need-to-be-aware-of/
http://web.archive.org/web/20240214091007/https://www.e-tinkers.com/2020/01/getting-started-with-stm32-and-things-you-need-to-be-aware-of/


==== Bluepill ====
==== Bootloader ====
https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill
https://github.com/rogerclarkmelbourne/STM32duino-bootloader
 
https://github.com/STMicroelectronics/stm32-mw-openbl


https://www.youtube.com/watch?v=Myon8H111PQ
https://www.youtube.com/watch?v=Myon8H111PQ


https://www.youtube.com/watch?v=L670v-Oghs4
https://www.youtube.com/watch?v=L670v-Oghs4
Based on Maple Mini from Leaflabs, does not have USB-to-Serial chip
{| class="wikitable"
{| class="wikitable"
|Programmer
|Programmer
Line 89: Line 107:
https://deepbluembedded.com/stm32-boot-modes-stm32-boot0-boot1-pins/
https://deepbluembedded.com/stm32-boot-modes-stm32-boot0-boot1-pins/


==== ST-Link ====
https://estore.st.com/en/st-link-v2-cpn.html
clone: https://www.partco.fi/en/measurement/debugging/20140-stlinkv2.html
https://www.st.com/resource/en/user_manual/um1075-stlinkv2-incircuit-debuggerprogrammer-for-stm8-and-stm32-stmicroelectronics.pdf


'''ST Link'''
The ST-Link/V2 is based on a STM32F103C8 it has an ERNI 4-pin SWIM connector and a 20 pin flat ribbon for JTAG/SWD serial wire debugging


https://estore.st.com/en/st-link-v2-cpn.html
JTAG: TCK, TMS, TDI, TDO
 
SWD: VCC, GND, RESET, SWCLK, SWDIO, SWO
 
For STM8, use the SWIM single wire interface module
 
For STM32, use the 20-pin interface. Connect the SWD pins VPP, GND, CLK, DIO
 
 
https://stm32-base.org/guides/connecting-your-debugger.html#official-st-linkv2
 
https://waterpigs.co.uk/articles/black-blue-pill-stm32-st-link-connection/
 
==== STM H5 Firmware and Examples ====
https://github.com/STMicroelectronics/STM32CubeH5
 
==== Update STlink firmware ====
STM32_Programmer
..\Drivers\FirmwareUpgrade\STLinkUpgrade.jar
 
==== RDP with Trustzone ====
[[File:RDP 0.5 with Trustzone.png|thumb]]
L5 only, not on H5
 
https://www.st.com/content/st_com/en/support/learning/stm32-education/stm32-moocs/stm32u5-rdp.html
 
https://www.youtube.com/watch?v=B3l6iuA7U8Q&list=PLnMKNibPkDnEkeKd_fytwc_9x2Ht2gRUn&index=2
 
Option byte settings
STM32_Programmer_CLI.exe -c port=SWD mode=UR -ob displ
STM32_Programmer_CLI.exe -c port=SWD mode=UR -ob TZEN=B4
 
STM32_Programmer_CLI.exe -c port=SWD mode=UR -ob SECWM1_STRT=0x0 SECWM1_END=0x1F SECWM2_STRT=0x1 SECWM2_END=0x0
[[File:GTZC.png|thumb]]
Flash the binaries
STM32_Programmer_CLI.exe -c port=SWD mode=UR -d "STM32CubeH5\Projects\NUCLEO-H533RE\Examples\GTZC\GTZC_TZSC_MPCBB_TrustZone\STM32CubeIDE\NonSecure\Debug\GTZC_TZSC_MPCBB_TrustZone_NonSecure.elf"
 
STM32_Programmer_CLI.exe -c port=SWD mode=UR -d "STM32CubeH5\Projects\NUCLEO-H533RE\Examples\GTZC\GTZC_TZSC_MPCBB_TrustZone\STM32CubeIDE\Secure\Debug\GTZC_TZSC_MPCBB_TrustZone_Secure.elf"
Read FLASH_NSSR register
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -r32 0x40022020 4
 
Provision OEM1KEY and OEM2KEY key
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -lockRDP1 0x01234567 0x89ABCDEF
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -lockRDP2 0xFEDCBA98 0x76543210
 
RDP level 2
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -ob RDP=0xCC
 
Get authentication ID
 
RDP2 to RDP1 regression
STM32_Programmer_CLI.exe -c port=SWD mode=UR -unlockRDP2 0xFEDCBA98 0x76543210
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -ob displ
 
Revert to RDP 0.5
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -unlockRDP1 0xFEDCBA98 0x76543210
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug –ob RDP=0x55
 
Flash the non secure again
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug –d GPIO_IOToggle_TrustZone_NonSecure.elf
 
from RDP 0.5 to RDP1
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -ob RDP=0xDC
 
revert to RDP 0
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -unlockRDP1 0x01234567 0x89ABCDEF
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -ob RDP=0xAA
 
Read FLASH_NSSR register
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -r32 0x40022020 4
 
Erase OEM1KEY and OEM2KEY
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -lockRDP1 0xFFFFFFFF 0xFFFFFFFF
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -lockRDP2 0xFFFFFFFF 0xFFFFFFFF
==== RUST ====
https://jonathanklimt.de/electronics/programming/embedded-rust/rust-on-stm32-2/
 
https://docs.rs/stm32f1xx-hal/latest/stm32f1xx_hal/index.html
 
https://github.com/stm32-rs/stm32f1xx-hal/tree/master
 
rustup update
rustup target install thumbv7m-none-eabi
cargo install cargo-flash
cargo init rusty-blink


clone: https://www.partco.fi/en/measurement/debugging/20140-stlinkv2.html
openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg


'''Arduino'''
cargo flash --release --chip stm32f103c8


==== Arduino ====
https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json


https://www.phippselectronics.com/blue-pill-programming-via-usb/
https://www.phippselectronics.com/blue-pill-programming-via-usb/
https://github.com/stm32duino/Arduino_Core_STM32/wiki/HAL-configuration


https://github.com/Serasidis/STM32_HID_Bootloader/releases
https://github.com/Serasidis/STM32_HID_Bootloader/releases
Line 106: Line 217:
  stm32flash.exe -g 0x8000000 -b 115200 -w hid_generic_pc13.bin COM2
  stm32flash.exe -g 0x8000000 -b 115200 -w hid_generic_pc13.bin COM2


 
==== IAR Workbench ====
'''IAR Workbench'''
[[File:IAR STM32F401CC.png|thumb]]
[[File:IAR STM32F401CC.png|thumb]]

Latest revision as of 14:22, 2 January 2025

https://stm32-base.org/

https://stm32world.com/wiki/STM32_Memory_Map

https://github.com/stm32duino/Arduino_Core_STM32

https://uraltone.com/stm32f401ccu6-kehitysalusta-usb-c.html

https://github.com/stlink-org/stlink

https://kleinembedded.com/stm32-without-cubeide-part-1-the-bare-necessities/

STM32 F1

STM32F103C8T6 Used in the Bluepill ($2.7946 / 10k)

Cortex-M3 ARM @72 MHz, 20 Kb RAM and 64Kb Flash. 3.3V, some of its pins are 5V tolerant.

https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html

https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html

STMicrelectronics RM0008 STM32F10xxx Reference Manual

STMicrelectronics AN2834 Application Note: How to get the best ADC accuracy in STM32 microcontrollers

The Generic STM32F103 Pinout Diagram, Rasmus Friis Kjeldsen


https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill

Based on Maple Mini from Leaflabs, does not have USB-to-Serial chip

STM32 F4

STM32F401CCU6 Used in the WeAct Blackpill V1.2 ($2.2469 / 10k)

St32-pinout.png

Cortex-M4 @84 Mhz,with DSP, FPU 64 Kb of RAM and 256Kb flash

Blackpill Pin tolerance.png

https://www.st.com/en/embedded-software/stsw-stm32065.html

https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/ST-Microelectronics/FreeRTOS-for-STM32F4xx-Cortex-M4F-IAR#ConfigAndUsage


5V Tolerance: http://www.emcu.eu/000/STM32_5VtolerantIO.pdf

STM32 H5

stm32h533ret6 (2.6679 / 10k)

Cortex-M33 @250 MHz, 512-Kbyte Flash, 272-Kbyte RAM

https://www.st.com/en/evaluation-tools/nucleo-h533re.html

um3121-stm32h5-nucleo64-board-mb1814-stmicroelectronics.pdf

https://github.com/STMicroelectronics/STM32CubeH5

STM32 N6

https://estore.st.com/en/nucleo-n657x0-q-cpn.html

Cortex-M55

Fake

Is my bluepill a fake one? did I blow it up or does it miss some bootloader? In run mode the blink program runs.

Fake unlicensed Gigadevice and other clones exist

https://mecrisp-stellaris-folkdoc.sourceforge.io/bluepill-diags-v1.640.html

https://www.e-tinkers.com/2020/01/getting-started-with-stm32-and-things-you-need-to-be-aware-of/

http://web.archive.org/web/20240214091007/https://www.e-tinkers.com/2020/01/getting-started-with-stm32-and-things-you-need-to-be-aware-of/

Bootloader

https://github.com/rogerclarkmelbourne/STM32duino-bootloader

https://github.com/STMicroelectronics/stm32-mw-openbl

https://www.youtube.com/watch?v=Myon8H111PQ

https://www.youtube.com/watch?v=L670v-Oghs4

Programmer Bluepill
RxD A9
TxD A10
5V 5V
GND GND

115200baud, 8E1 (even parity) ... Failed to detect F7 ... apparently the stm32 reads one byte to detect the baud speed.


USB D+ pin has 10kOhm insted of 1.5kOhm

boot0 set to 1 to enable programmer mode

boot1 set to 0 is system memory and set to 1 is embedded sram

https://deepbluembedded.com/stm32-boot-modes-stm32-boot0-boot1-pins/

ST-Link

https://estore.st.com/en/st-link-v2-cpn.html

clone: https://www.partco.fi/en/measurement/debugging/20140-stlinkv2.html

https://www.st.com/resource/en/user_manual/um1075-stlinkv2-incircuit-debuggerprogrammer-for-stm8-and-stm32-stmicroelectronics.pdf

The ST-Link/V2 is based on a STM32F103C8 it has an ERNI 4-pin SWIM connector and a 20 pin flat ribbon for JTAG/SWD serial wire debugging

JTAG: TCK, TMS, TDI, TDO

SWD: VCC, GND, RESET, SWCLK, SWDIO, SWO

For STM8, use the SWIM single wire interface module

For STM32, use the 20-pin interface. Connect the SWD pins VPP, GND, CLK, DIO


https://stm32-base.org/guides/connecting-your-debugger.html#official-st-linkv2

https://waterpigs.co.uk/articles/black-blue-pill-stm32-st-link-connection/

STM H5 Firmware and Examples

https://github.com/STMicroelectronics/STM32CubeH5

Update STlink firmware

STM32_Programmer
..\Drivers\FirmwareUpgrade\STLinkUpgrade.jar

RDP with Trustzone

RDP 0.5 with Trustzone.png

L5 only, not on H5

https://www.st.com/content/st_com/en/support/learning/stm32-education/stm32-moocs/stm32u5-rdp.html

https://www.youtube.com/watch?v=B3l6iuA7U8Q&list=PLnMKNibPkDnEkeKd_fytwc_9x2Ht2gRUn&index=2

Option byte settings

STM32_Programmer_CLI.exe -c port=SWD mode=UR -ob displ
STM32_Programmer_CLI.exe -c port=SWD mode=UR -ob TZEN=B4
STM32_Programmer_CLI.exe -c port=SWD mode=UR -ob SECWM1_STRT=0x0 SECWM1_END=0x1F SECWM2_STRT=0x1 SECWM2_END=0x0
GTZC.png

Flash the binaries

STM32_Programmer_CLI.exe -c port=SWD mode=UR -d "STM32CubeH5\Projects\NUCLEO-H533RE\Examples\GTZC\GTZC_TZSC_MPCBB_TrustZone\STM32CubeIDE\NonSecure\Debug\GTZC_TZSC_MPCBB_TrustZone_NonSecure.elf"
STM32_Programmer_CLI.exe -c port=SWD mode=UR -d "STM32CubeH5\Projects\NUCLEO-H533RE\Examples\GTZC\GTZC_TZSC_MPCBB_TrustZone\STM32CubeIDE\Secure\Debug\GTZC_TZSC_MPCBB_TrustZone_Secure.elf"

Read FLASH_NSSR register

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -r32 0x40022020 4

Provision OEM1KEY and OEM2KEY key

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -lockRDP1 0x01234567 0x89ABCDEF
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -lockRDP2 0xFEDCBA98 0x76543210

RDP level 2

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -ob RDP=0xCC

Get authentication ID

RDP2 to RDP1 regression

STM32_Programmer_CLI.exe -c port=SWD mode=UR -unlockRDP2 0xFEDCBA98 0x76543210
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -ob displ 

Revert to RDP 0.5

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -unlockRDP1 0xFEDCBA98 0x76543210
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug –ob RDP=0x55

Flash the non secure again

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug –d GPIO_IOToggle_TrustZone_NonSecure.elf

from RDP 0.5 to RDP1

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -ob RDP=0xDC

revert to RDP 0

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -unlockRDP1 0x01234567 0x89ABCDEF
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -ob RDP=0xAA

Read FLASH_NSSR register

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -r32 0x40022020 4

Erase OEM1KEY and OEM2KEY

STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -lockRDP1 0xFFFFFFFF 0xFFFFFFFF
STM32_Programmer_CLI.exe -c port=SWD mode=hotplug -lockRDP2 0xFFFFFFFF 0xFFFFFFFF

RUST

https://jonathanklimt.de/electronics/programming/embedded-rust/rust-on-stm32-2/

https://docs.rs/stm32f1xx-hal/latest/stm32f1xx_hal/index.html

https://github.com/stm32-rs/stm32f1xx-hal/tree/master

rustup update
rustup target install thumbv7m-none-eabi
cargo install cargo-flash
cargo init rusty-blink
openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg
cargo flash --release --chip stm32f103c8

Arduino

https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json

https://www.phippselectronics.com/blue-pill-programming-via-usb/

https://github.com/stm32duino/Arduino_Core_STM32/wiki/HAL-configuration

https://github.com/Serasidis/STM32_HID_Bootloader/releases

stm32flash.exe -g 0x8000000 -b 115200 -w hid_generic_pc13.bin COM2

IAR Workbench

IAR STM32F401CC.png