Recent Changes - Search:

Menu?

PmWiki

pmwiki.org

edit SideBar

DevelopmentOnSTM32F407GDiscoveryBoard

Useful Links

Acronyms

  • PLL - Phase Locked Loop
  • HSI - High Speed Internal
  • HSE - High Speed External

How To Debug

To debug a program running on the board. First run st-util in a terminal.

    $ st-util

Some output is generated ending with something like

    INFO gdb-server.c: Listening at *:4242...

I'm assuming that the port st-util is listening to will be the same on all OSes, but just in case it is not, the value in my system is 4242. Make a note of that in your system in case it's different.

Now in another terminal run

    $ arm-none-eabi-gdb xx.elf

Where xx.elf is the name of the program that is currently burned into the STM32F board.

You will get a gdb console

    (gdb)

Now enter

    (gdb) target remote localhost:4242

Replace 4242 above with whatever output you get from running st-util, in case it's different.

You are now directly debugging the code which is running on your STM32F board.

You can set things like breakpoints

    (gdb) b waveplayer.c:41

This sets a breakpoint in the file waveplayer.c at the line number 41.

You can display and watch variables

    (gdb) display osc->freq

This will display the value of the variable osc->freq and update it anytime it changes. Assuming your code has a variable called osc->freq.

Dev log - 29th March, 2018

Learned today why some code has SysInit() being called in main and some does not. Apparently the file system_stm32f4xx.c is not the same for all projects. There is a tool - http://www.st.com/en/development-tools/stsw-stm32091.html . I'm reading a lot of references to this clock configuration tool, which is apparently an Excel spreadsheet with Macros in it. You can use it to configure the clocks on your STM32F board and this configuration tool will supposedly generate system_stm32f4xx.c for you. Since I'm unable to find the configuration tool and I don't have Excel anyway, I'm going to dive into this system_stm32f4xx.c file and try and understand what it is, and how it functions.

Dev log - 30th March, 2018

Found this - https://opensafetydemo.sourceforge.io/doc/V1.1.0/html/d4/d04/system__stm32f4xx_8c.html explaining the functioning of the system_stm32f4xx.c file, functions defined within it and other variables and macros. https://stm32f4-discovery.net/2015/01/properly-set-clock-speed-stm32f4xx-devices/

Dev log - 31st March, 2018

Found the clock configuration tool here - http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stsw-stm32091.html . Its all the way at the bottom of the page, you have to sign/up register to download it. Unfortunately this code generator does not work with the latest version of LibreOffice. But it might be of use to those who have M$ Office installed.

The difference between SPI_I2S_SendData used here - https://github.com/theisro/stm32sawwave/blob/master/main.c#L44 and Audio_MAL_Play used here - https://github.com/theisro/soundpipe-stm32f4/blob/master/src/waveplayer.c#L125 is the former is a lower level function. You pass it the direct integer value that should play at that instant. Audio_MAL_Play allows the passing of a buffer to be played.

This is my first time in dealing with programming directly at the hardware level. I'm used to programs on Operating Systems where you typically define a int main(int argc, char* argv[]) and that becomes the entry point to software that you are writing. But programming with the STM32F, you are directly interacting with the hardware without an OS in the middle to mediate things for you.

So this is my understanding of the files involved.

stm32_flash.ld - some kind of a linker script that figures out where to put your code in memory on the device. I also realize I have been using the wrong one for the soundpipe examples here - https://github.com/theisro/soundpipe-stm32f4/blob/master/src/stm32_flash.ld#L6 Its a linker script for a STM32F207IG device. But for some reason it compiles fine for the STM32F407G device.

The next is the startup_stm32f4xx.s which has a bunch of low level assembly code. This seems to setup interrupts, set the stack pointer (this is where all your variables in your code are stored) in the right place. And this finally calls main in your program.

system_stm32f4xx.c I'm not sure where in the whole startup process this is called, but I have noticed some programs call SystemInit() explicitly and others that do not. But this file basically deals with clock configuration. Basically I don't understand it, there seem to be all kinds of clocks and different ways of setting the system clock. But here you set the core tick of your system clock. If its 1ms, 10ms etc. How exactly all this is calculated is beyond me for the moment. More as I get clarity.

Edit - History - Print - Recent Changes - Search
Page last modified on March 31, 2018, at 12:34 PM