Error running stm32flash with QProcess (qt)
Open source flash program for STM32 using the ST serial bootloader
Brought to you by:
tormod
Hi, i'm trying to run stm32flash with qt process, but it gives "device not specified" error.
but running the same command on terminal, it works.
i'm using version 0.7.
QProcess *loadFirmware = new QProcess();
loadFirmware->start("stm32flash", QStringList() << "-b 9600 -w /run/media/sdb1/LandingBuilds/bool_cnt/Control.bin /dev/ttyUSB0");
loadFirmware->waitForFinished(-1);
qDebug() << loadFirmware->readAllStandardError();
qDebug() << loadFirmware->readAllStandardOutput();
Anonymous
Yes, wrapping it in bash script shouldn't change much (although the sleep could change things if is was a timing-sensitive issue). bash will wait for its subprocess stm32flash to finish. But whatever Qt keeps doing it will interfere with the launched process and the subprocesses the same way. I would think waitForFinished() should make the process keep running in peace. With the minimal example there is not even an event loop running. Is your embedded host at its limits? Would stm32flash directly from the command line also fail if you have other busy processes on the host?
stm32flash never failed from the command line. my host is not at limit (3/6% cpu)
You can try something like:
strace -o /tmp/trace.log -f -tt ./testqprocess fw.bin
and attach the log.
here it is
Is this from the minimal test program?
If you can reproduce the issue with a simple program, there is no reason to analyze it with a complex one.
Last edit: Tormod Volden 2023-02-14
it's the .sh file with gpio and sleep command
Then compare it with running stm32flash directly
strace -o /tmp/trace2.log -f -tt stm32flash -w fw.bin /dev/ttyUSB0
i don't see any difference, except the reply of stm32 micro
trace2.log (stm32flash directly):
The NACK is because it was not power-cycled or reset since last run, so the INIT command won't be recognized. stm32flash is clever enough to deal with this and it continues.
trace.log (via QProcess and bash script):
In this case I believe it was power-cycled so it replies ACK but too late.
So maybe it is not related to QProcess or not, but to you power-cycling or resetting the device differently in the two cases.
Please use the minimal test program, and make sure resetting or power-cycling has been done exactly the same way in both cases.
Hi, after a lot of tests, now it works. i've added a sleep of 2 seconds after set reset pin to high