cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Programming a STM32 F405 flight controller - Mateksys F405-Te - Can't upload code from STM32CubeIDE

UnregisteredUser
Associate II

Hello ๐Ÿ™‚

For my university project, I need to build a drone. I've never done anything like this before and could use a bit of a jumpstart.

I have a Mateksys F405-TE flight controller that I'm supposed to use to control the drone.

To test it, I created a project in CubeIDE and tried to control the LEDs on the board. During debugging, I encountered the error message "Could not connect to J-Link" or "No ST-Link detected..."

I had worked with an original STM F4 board and an extension board before, and it just worked.

What would be easier and more preferable for me in this project is if I could model the controller in Simulink and then generate the code.

I know there are support packages for STM32 in Matlab. Therefore, I also created a model to control the LEDs. The build was successful, but it did not find a "Target Device" or something similar.

Now I am completely clueless about how to approach this. Does anyone have any ideas?

10 REPLIES 10
TDK
Guru

ST boards work because they have an on-board ST-Link programmer/debugger. That flight controller does not and is only connected by USB.

You'll need a programmer such as https://www.st.com/en/development-tools/stlink-v3minie.html and will need to find the appropriate SWD pads to connect it to, if they're even exposed, which it doesn't look like they are.

You can also program over USB if you boot into the bootloader, but you cannot debug through this interface and I don't recommend using it for development.

 

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

University? Do they teach something there? Are there teachers or instructors?

 

I was just asking...

I pretty much don't have any experience in this field, so it's not easy for me to get started.

It appears that the board has a USB connector that supports firmware update ("DFU") using the STM32CubeProgrammer utility.  See: http://www.mateksys.com/?p=6905

You would build your firmware using the Cube IDE tools, create the compiled binary output then use STM32CubeProgrammer to program that binary to the microcontroller's flash memory. 

Pavel A.
Evangelist III

Well, DFU interface lets you download the firmware, the CubeProgrammer should do this. But to debug you need the debugger (SWD) interface for ST-Link or J-link. Frankly, I don't see anything marked "SWD" on Matek STM32F4 boards photos. Is there a  connector for ST-LINK or J-Link on your board? CubeIDE cannot download firmware over DFU (USB) interface, only over ST-Link, J-Link or other debugger adapter. If there is no SWD on the board, use CubeProgrammer or other DFU capable software.

UnregisteredUser
Associate II

Thank you very much!

The board does not seem to have any ST-Link or J-Link. I'll will try with CubeProgrammer. I have seen that it is possible to load firmware to the board with CubeProgrammer, but I didn't know you could load your own code to the board. 

There are firmware available for the flight controller, like Betaflight, INAV or Ardupilot. On their websites .hex files were available that you can load to the board and use their graphical interface to configure the controller. They also have their firmware open source on GitHub. So I was wondering how they have accomplished this. 

So I will use CubeIDE to write code, then compile to .hex file and then use CubeProgrammer to put it on the flight controller!

UnregisteredUser
Associate II

Thank you very much! I will try your ideas!

The debug pins for SWD PA13/PA14 are exposed as LED's, you can get an ST-LINK / J-LINK via those, but then you'd need to suppress in your code

https://github.com/ArduPilot/ardupilot/blob/e4a27943f5b692ad331c09840960f0c408169599/libraries/AP_HAL_ChibiOS/hwdef/MatekF405-TE/hwdef.dat#L25

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

It will be much faster to first learn a development on a proper Nucleo or Discovery board with a debugger and only then move to undebuggable amateur creations...