cancel
Showing results for 
Search instead for 
Did you mean: 

How to flash the compiled code to stm32l431cb

PD S.1
Associate II

Hi Experts,

I am planning to use stm32l431cb - as it is sufficient controller with 48 pin for my use case. Basically I am trying to find out, how to flash my code into stm32l431cb controller.

I referred to

a. https://www.st.com/resource/en/datasheet/stm32l431cb.pdf - data sheet

b. https://www.st.com/resource/en/reference_manual/dm00151940-stm32l41xxx42xxx43xxx44xxx45xxx46xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf - User manual

and could not get any clear information.

Referred to AN2606 (https://www.st.com/resource/en/application_note/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf) and this (page 32) says USART1/USART2/USART3/ (and various others like I2C, SPI etc) are supported.

Have any one used these USART for stm32l431cb? What is the procedure you followed? How do you put stm32l431cb into boot mode - I saw PH3 - BOOT0 pin - should we make it high (or low) during reset? Is there any thing else is needed? What tool is used on PC to dump the code? Any writeup/ document describing these things?

Any pointers on this - would help me.

With best regards,

Phani.

6 REPLIES 6
KnarfB
Principal III

The integrated bootloader using UART etc.. is not needed if you use a SWD debug probe like ST-LINK. Using SWD is preferrable for bringing-up a new design and during development if you intend to debug or trace (via SWO) the code in the lab. Pull BOOT0 low for that. Check Getting started with STM32L4 Series and STM32L4+ Series hardware development as reference.

The UART... bootloader (system memory boot) comes in handy for in-the-field upgrades or initial production flashing without using a SWD debug probe, called IAP (in application programming). The firmware should already be well debugged before considering this approach. Needs BOOT0 pulled high, or you can implement a jump to to system memory under certain circumstances in your firmware.

What toolchain/IDE are you using? STM32CubeIDE comes with gcc toolchain so all gcc related commands apply like arm-none-eabi-objdump, arm-none-eabi-readelf, ...

hth

KnarfB

Javier1
Principal

I use the st-link and SW pins so i can use the stm debugging options (like the discovery/nucleo boards do)

Are you using a stm dev board or your own design?

we dont need to firmware by ourselves, lets talk

Normally BOOT0 should be pulled low for operation out of FLASH. To execute the ROM loader pull BOOT0 High at reset. Should also enter if FLASH is blank.

The STM32 UART Protocol is described in various documents, should be the Flash Loader Demonstrator for older parts, and there are open source examples. It's not that complex a protocol.

The thing to watch for would be other noisy devices attached to the other UART and interfaces the loader is checking for connectivity. A GNSS receiver spitting out NMEA sentences at startup will get the System Loader's attention more quickly than an end user.

You might want to swap the RX/TX pins around and use the USART level ability to remedy that for your own interfaces.

Providing access to SWDIO/SWCLK/NRST and SWO perhaps, is the sure-fire way of guaranteeing you can access, program and debug your design.

I use the 32-pin L432KB/KC devices.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
PD S.1
Associate II

Thanks a lot guys :folded_hands::folded_hands::folded_hands:. Now I have some idea on how to progress and again some questions :)

  1. I am doing my own design - I am not using any dev board
  2. I think with BOOT0 pin (pulled high during reset) - I should be able to program the controller. Any way will update you guys once I complete the experiment (currently my PCB fabrication is in progress).
  3. I don't want to use SWDIO etc. lines for JTAG based flashing/ debugging (I do not have so many pins - these pins are already used) - so only option for me is to use USART3 for flashing the code as well debug as well (by means of print's)
  4. Any of you know any reference schematic for stm32l431cb - but some how I could not find any. This would have given some pointers for my next questions.
  5. Should I have to use 32KHz crystal as LSE (between PC14 and PC15)? Also should I have to use 8MHz crystal as HSE (between PH0 and PH1). I was thinking of using internal crystal if available - just to reduce the BOM

As always, your suggestions/ comments would be great help to me.

Thanks in advance.

With best regards,

Phani.

Hi Phani,

for reference schematics see "Getting started with STM32L4 Series and STM32L4+ Series hardware development" document.

> was thinking of using internal crystal

Thats fine unless you need more precision clocks, e.g. for the RTC. The above document has a chapter on clocks. Check also "AN2867 Application note Oscillator design guide for STM8AF/AL/S, STM32 MCUs and MPUs".

Finallay there are STM32L432KC and STM32L433 Nucleo boards which you may study or use for prototyping.

hth

KnarfB

To add to what Knarf already said - all ST boards have schematics and other design documentation available. You can study them all. And yes, read the AN4555.