I'm trying to send data and retrieve the output from my stm32f4-DISCO. I'm using a python based code and specifically stm_ai_runner. The code is rather simpler but I can't access the board because even runner.summary() doesn't work. My board is flashed with the network :
And this is what my code looks like :
And the terminal :
I thank you in advance,
Solved! Go to Solution.
the tensorflow messages that you are seeing are because you don't have a NVIDIA graphics card on your machine. To get rid of those messages you can perform:
pip install tensorflow-cpu==2.9.0
of course the version of tensorflow-cpu must correspond to the version of tensorflow you have on the machine.
Also Tensorflow requires AVX2 enabled CPU, if you have an old machine with AVX2 not supported, tensorflow won't work
If the actual issue is in runner.summary(), the only thing I can think of is that the terminal is still opened and taking the COM port, on windows you can have only one process at a time accessing a COM port.
Firstly thank for your response.
I do not think that the problem come from the warnings, but I did as you asked and install tensorflow-cpu and my CPU is AVX2 enabled.
The problem must come from the fact that my code can't access via the Port COM 6 but I do not have any terminal still opened when lauching the code. Maybe he's trying to connect to COM 4 ?
you can use the "mode" command to see all the available ports.
Normally it scans all the ports until there is one responding as the target will answer.
you can specify explicitly the com port to use by passing serial:COM6:115200 instead of serial
from stm_ai_runner import AiRunner
runner = AiRunner()
runner.connect returns true if the connection is sucessfull.
You can also hit the reset button on the board before to launch the python code
Thank for your quick response !
I added a bit of code to check if runner.connect() return true or false :
runner = AiRunner() if runner.connect('serial:COM6:115200'): print("True") else: print("False") runner.summary() # display the network/run-time information inputs = tf.fill([1,90,3,1], 0) outputs, _ = runner.invoke(inputs) # invoke the model
And it return false.
There is some news, I changed my keras model into a tflite model and visibly He now tries to connect. When I do what you said about specify explicitly the COM port like so :
runner = AiRunner() runner.connect('serial:COM6:115200') runner.summary() # display the network/run-time information inputs = tf.fill([1,96,96,1], 0) outputs, _ = runner.invoke(inputs) # invoke the model
I get this error message :
And when I try to just put :
I get this error :
So it seems to try to connect but doesn't seem to success...
Even when I change the port- default value in "serial_hw_drv.py" like so :
# default values port_ = 'COM6' baud_ = int(115200)
I get the same error, do you know why ?
What about the stm32ai validate command on the target ? does it completes the validation ?
~/STM32Cube/Repository/Packs/STMicroelectronics/X-CUBE-AI/7.2.0/Utilities/windows/stm32ai validate -m model.tflite --target stm32
The command create a report file and seems te work. Except that the accuracy is "n.a" and most importantly if I unplug my board it's working, so I think it's more of a "validate on host".
Avout the python code, the problem must be from the board because when I try with another board (I used a H747) it worked as intented.
Maybe the problem is that the stm32f4-DISCO don't have a virtual port COM so I use a FTDI as a Serial Port COM. Do I need to do some kin of manipulation to work via the FTDI ?
Are you using the latest AIRunner version associated with X-Cube-AI 7.2.0 ?
The Python and C code are linked together (stm32ai CLI, C code, and AIRunner should be aligned). One side will wait for specific messages from the other side and if messages are not aligned then the communication will not be possible.
Then I would suggest you to unplug all COM ports devices from your computer (even disabling the Intel default one if you're on Windows laptop), then try also killing all instances of Python you can have in the Task Manager (if instances are still using COM port then the communication will fail) and try again the procedure.
If the problem is still here, you can try rebooting your computer knowing that Windows can have strange behavior with COM ports pluging/unpluging multiple times
Hope this can help you,