Skip to content

Commit ee44e03

Browse files
jaenrig-ifxactions-user
authored andcommitted
tools/psoc6/mpy-psoc6.cmd: Added device-erase function.
Signed-off-by: enriquezgarc <[email protected]>
1 parent f6cf09c commit ee44e03

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

tools/psoc6/mpy-psoc6.cmd

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ setlocal
44
if "%1"=="quick-start" goto cmd_quick_start
55
if "%1"=="device-setup" goto cmd_device_setup
66
if "%1"=="firmware-deploy" goto cmd_firmware_deploy
7+
if "%1"=="device-erase" goto cmd_device_erase
78
if "%1"=="help" goto help
89

910
goto help
@@ -22,6 +23,10 @@ exit /b 0
2223
call :mpy_firmware_deploy %2 %3
2324
exit /b 0
2425

26+
:cmd_device_erase
27+
call :mpy_device_erase %2 %3
28+
exit /b 0
29+
2530

2631
rem ~~~~~~~~~~~~~~~~
2732
rem Script functions
@@ -60,6 +65,15 @@ rem ~~~~~~~~~~~~~~~~
6065
echo board PSoC6 prototyping kit name
6166
echo hex_file MicroPython PSoC6 firmware .hex file
6267
echo:
68+
echo device-erase Erase the external memory of the device.
69+
echo Use this command to erase the external memory if available
70+
echo for the selected board.
71+
echo Requires openocd available on the system path.
72+
echo usage: mpy-psoc6.cmd device-erase [board [[\q]]
73+
echo:
74+
echo board PSoC6 prototyping kit name
75+
echo \q Quiet. Do not prompt any user confirmation request
76+
echo:
6377

6478
exit /b 0
6579

@@ -88,6 +102,20 @@ exit /b 0
88102

89103
exit /b 0
90104

105+
:flash_erase_firmware_download:
106+
107+
set board=%~1
108+
curl.exe -s -L https://github.com/infineon/micropython/releases/download/v0.3.0/device-erase_%board%.hex > device-erase_%board%.hex
109+
110+
exit /b 0
111+
112+
:flash_erase_firmware_clean
113+
114+
set board=%~1
115+
del device-erase_%board%.hex
116+
117+
exit /b 0
118+
91119
:mpy_firmware_download:
92120

93121
set board=%~1
@@ -190,6 +218,58 @@ exit /b 0
190218

191219
exit /b 0
192220

221+
:mpy_device_erase
222+
223+
setlocal enabledelayedexpansion
224+
225+
Rem Board selection
226+
set board=%~1
227+
set board_list[0]=CY8CPROTO-062-4343W
228+
if [%board%]==[] (
229+
echo:
230+
echo Supported MicroPython PSoC6 boards
231+
echo +---------+-----------------------------------+
232+
echo ^| ID ^| Board ^|
233+
echo +---------+-----------------------------------+
234+
echo ^| 0 ^| CY8CPROTO-062-4343W (default^) ^|
235+
echo +---------+-----------------------------------+
236+
echo:
237+
echo No user selection required. Only one choice.
238+
set /a board_index=0
239+
echo:
240+
Rem set /p/( "board_index=Please type the desired board ID. " --> Uncomment and remove preselection above when more options are available
241+
call set board=%%board_list[!board_index!]%%
242+
)
243+
echo MicroPython PSoC6 Board :: %board%
244+
245+
Rem Download flashing tool and firmware
246+
call :openocd_download_install
247+
call :flash_erase_firmware_download %board%
248+
249+
if not [%~2]==[\q] (
250+
echo:
251+
echo Please CONNECT THE BOARD and PRESS ANY KEY to start the firmware deployment...
252+
pause >nul
253+
echo:
254+
)
255+
256+
Rem Deploy on board
257+
call :mpy_firmware_deploy %board% device-erase_%board%.hex
258+
echo Device firmware deployment completed.
259+
260+
call :openocd_uninstall_clean
261+
call :flash_erase_firmware_clean %board%
262+
263+
if not [%~2]==[\q] (
264+
echo:
265+
echo Press any key to continue...
266+
pause >nul
267+
echo:
268+
)
269+
270+
exit /b 0
271+
272+
193273
:arduino_lab_download_and_launch
194274

195275
echo Downloading Arduino Lab for Micropython...

0 commit comments

Comments
 (0)