The purpose of this article is to introduce a new way to program/erase an EFR32/EFM32 device with batch file. In development stage, comparing with the general way to program device with GUI based Simplicity Commander or Flash programmer, the method bring out here can improve work efficiency.
In general, there are 4 tools for programming purpose.
The new method proposed here is based on type 4. We prepare a batch file to run the whole programming procedure.
The Simplicity Commander tool is located at following folder by default. "C:\SiliconLabs\SimplicityStudio\v4\developer\adapter_packs\commander".
If the path of installation is different, just change it accordingly in the batch file. If you prefer to program ".S37" file, just replace the ".hex" with ".S37" in the batch file.
Create a flash.bat file for flash program.
@echo off cd "%~dp0" set filename= for /f "delims=" %%i in ('dir /b /a-d *.hex') do (set filename=%filename%%%i) echo %filename% cd "C:\SiliconLabs\SimplicityStudio\v4\developer\adapter_packs\commander" commander flash "%~dp0%filename%" pause
Create a erase.bat file for flash erase.
@echo off cd "C:\SiliconLabs\SimplicityStudio\v4\developer\adapter_packs\commander" commander device pageerase --region @mainflash pause
Put the flash.bat file in the same directory that the hex file is located at.
Here takes "C:\Users\ersu\SimplicityStudio\v4_workspace\dutycycle\GNU ARM v7.2.1 – Default" as an example. The directory should contain only one hex file in the folder. Just double click the flash.bat in Simplicity Studio IDE perspective, then it can program the hex file into the flash of the target device. If the program failed, you could check the J-Link connection with Simplicity Commander GUI tools. Keep in mind, it cannot program if the J-Link is in debug status, need to exit debug mode first (disconnect the target).
It can be found in Simplicity Studio.
The output of flash program operation as shown below:
The erase.bat file can be put anywhere since it doesn’t need a hex file.
The output of erase operation as shown below
The advantage is simple and fast, especially in scenarios that multi boards need to be programmed simultaneously. You only need double click the batch file and the erase or program operation started automatically.
The disadvantage is that you need to copy the batch file to the folder that the hex located at for each project.