Flash Firmware
The concept for firmware flashing in the Testframework is to connect your programmer to the PC. The PC program will do a command line call to trigger an external tool for firmware flashing. Triggering the flashing process will be done with a function call in your test script.
Tip: Before you start, take a look at how you can flash a firmware to the device via the command line.
Setup
The command line call for the external flashing tool have to be setuped in the project settings.
Go to Settings
–> Project Settings
. In the new window, select the Tab Flash Options
.

Here you can enter a command and its parameter. The working directory for the command is the project folder.
For more details what to enter here, see Examples below.
Integrate it into your Test
Before download the firmware to your device, you may have to initialize your device. Maybe you have to bring it into a bootloader mode or just to enable the power. It is therefore advisable to write a separate routine for the firmware download in the test script. This could look like this, for example:
from testframework import *
async def DownloadFirmware():
enableExternalSupply()
abortTestOnFailure(True)
await sleep(1.5)
res = await executeCommand(1)
report.checkBool("Download firmware to the device", res == 0)
await sleep(0.5)
abortTestOnFailure(False)
disableExternalSupply()
The flashFirmware
command is async and will return if the called command has finished.
The return value will be true
if the command returned without errors (return code 0) and false
otherwise.
Tip: In most cases it makes no sense to run the test if downloading of the firmware was unsucesfully.
So it makes sense to enable the abortTestOnFailure
option here.