Any advice for programming stm32

I am trying to program an nucleo f401re board. The chip is (stm32f401ret6u). I am looking to use an eternal programmer (stlink v2). I am having trouble connecting to the programmer. Do you have any advice?

It looks like there is a frequent issue connecting… and reading. I believe the full memory in hex is 80000. I am guessing, For some reason this is a successful read.

Maybe jumping around the question but is there a particular reason for not using the onboard ST-Link on the Nucleo board? It is almost exactly the same as the external programmer without the headache of having potentially incorrect connections.

2 Likes

@JMerkle is planning a class on a related board and may have input on this.

1 Like

There is a reason bobbycounts. As it stands i am looking to debug boards that are 32 Arduino boot loaders. Right now most Arduino programmers and the Arduino IDE can not access the 32 bit Arduino boards. I believe this is only temporary. The Arduino platform is form of hardware extrapolation, (kind of like a ha l(hardware abstraction layer)). The nucleo board is relatively simple, So my objective is put the Arduino boot-loader on and a custom Arduino program the nucleo board. I then want to have the I want to have hardware break points, access to the hardware register and decent processor simulator. I think i can only get through stmcubeide.
I then want to do the same thing with big tree tech(btt) Octopus board. (I have version 1.1) I want to load the Arduino boot loader and the marlin firmware on the btt Octopus board. ( GitHub - bigtreetech/BIGTREETECH-OCTOPUS-V1.0: This is Octopus open source material )
image

The problem i see is that Arduino is form of abstraction so if i have specific problem i can not narrow it down to specific line and specific assembly instruction. I do think some of these processors can do specified in the datasheet, but I need more control to develop the initial firmware. I also want Arduino to help distribute my code and to allow people to help analyze it when the problems are able to defined in arduino c.
So i can see that i need to buy “NUCLEO-F103RB” JMerkle class and “nucleo-stm302R8” to use the book Programming with stm32 Donald Norris (ISBN 978-1-260-03131-7) (along with openocd book (ISBN 9789888381166).

I think I’m understand where you are coming from. From your screenshot of ST-Link Utility, it seems that you most likely have the wire hooked up correctly. The probe will not be able to read the CPUID if the connections are not correct. You can try to lower the connect speed to under 1MHz to see if that helps. Sometimes using higher speeds will flying lead will cause connection issues.

It is somewhat possible to debug code and set hardware breakpoints for Arduino using openocd and gdb. You can load the .elf file generated by Arduino into gdb and set breakpoints at functions, inspect memory, and single step through the code. The compiler will need to have debug symbols enabled, so you may need to add the -g switch to gcc if not already enabled.

1 Like

On my Nucleo-F103RB page, http://merkles.com/MediaWiki/index.php/NUCLEO-F103RB
Near the bottom, in the " Arduino IDE Support" section, I have the following two links:

http://www.emcu.eu/2017/03/13/how-to-use-stm32-and-arduino-ide/

Not sure which one I used in the past, but the concept is the same as adding ESP32 support to Arduino. These add STM32 support to Arduino, by adding Arduino libraries to produce STM32 functions for Arduino calls… (If that makes sense)

1 Like

Did you make the cable for the ST-link or was that provided by ST-Micro. Is that an IDC connector? Sometimes they need to be pressed down on the ribbon cable for a good connection.

1 Like

I created the cable and did a test for connectivity.