2
votes

I'm using Atollic TrueSTUDIO for STM32 as an Eclipse Based IDE to perform Digital Signal Processing on audio signal. I'm looking for a way to plot an array (16 bits audio samples) from RAM memory. For the moment I'm using :

  • The memory View
  • The SWV real time data time line

None of this tools are powerful to analyse signal on an array, and it doesn't have to be on real time : Just ploting an array after reaching a breakpoint.

Is there an Eclipse Plugin or some other ways to do this ? I'm considering to export the RAM memory and in a file and plot it in Matlab, but it seems really inapropriate for such a simple thing.

Thanks for any advices

4

4 Answers

2
votes

In Atollic, you can easily attach gdb commands to breakpoints. Doing this, allows you to automaticly dump any variables. Additionally, you can execute an external programm once afterwards, to plot the content of the dumped variable.

To do so, goto breakpoint properties and create a new action. Select "Debugger Command Action" and use dump binary value x.bin x to dump variable x to file x.bin

You can also start a python script from the breakpoint to plot the data. Use an additonal "External Tool Action" and select your python location. Make sure to select your current Working Dictonary. Use the arguments to pass the full path of the python file. The following file will import a float array and plot it.

import struct
import numpy as np
import matplotlib.pyplot as plt
import os

def readBinaryDump(filename):
    result = []
    N=8
    with open(filename,'rb') as f:
        while(True):
            b = f.read(4*N);
            if len(b) ==0:
                break
            fn = "f"*N
            result.append(struct.unpack(fn,b))

    result = np.array(result)  
    return result.ravel()  

plt.plot(readBinaryDump("x.bin"))

Don't forget to add the actions to the current breakpoint. Now once the breakpoint is reached, the variable should be dumped and plotted automaticly.

1
votes

While it's surprising nothing could be embeded in Atollic/Eclipse, I followed the idea of writing an specific application. Here are the steps I used :

Dump Memory :

  • Debug your software
  • Stop on a BreakPoint
  • View > Memory > Export Button > Format : "Plain Text"

The file representing a sine wawe looks like this :

00 00 3E 00 7D 00 BC 00 FB 00 39 01 78 01 
B7 01 F6 01 34 02 73 02 B2 02 F0 02 2F 03 

You should read these int16 samples like this :

 1. 0x0000
 2. 0x003E
 3. 0x007D
 4. etc...

Write this Matlab script :

fileID = fopen('your_file','r');    
samples =  textscan(fileID,'%s')   
fclose(fileID);                   
samples = samples{1};              
words = strcat(samples(2:2:end,1), samples(1:2:end,1));  
values = typecast(uint16(hex2dec(words)),'int16');      
plot(values) ;                                             

The sinus wave plotted in Matlab

0
votes

While there aren't any Eclipse plugins that would do what you're asking for that I'm personally aware of, there's STM Studio whose main purpose is displaying variables in real-time. It parses your ELF file to get the available variables, so the effort to at least give it a try should be minimal.

It's available here: https://www.st.com/en/development-tools/stm-studio-stm32.html

ST-Link is required to run it.

0
votes

Write the simple app in C#. Use semi hosting to dump the memory to the text file. Open it and display.

Recently I had problem with MEMS-es and this was written in less than one hour. IMO (In My Opinion) it is easier to write program which will visualize the data instead of wasting hours or days searching for the ready made one:

enter image description here