Skip to content

Commit

Permalink
tools/psoc6/mpy-psoc6.*: Added qspi_conf to openocd program.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Jun 27, 2023
1 parent 2250fa2 commit e6df5d1
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 83 deletions.
72 changes: 30 additions & 42 deletions tools/psoc6/mpy-psoc6.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -84,59 +84,33 @@ exit /b 0
set hex_file=%~2

echo Deploying Micropython...
openocd.exe -s openocd\scripts -c "source [find interface/kitprog3.cfg]; ; source [find target/psoc6_2m.cfg]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program %hex_file% verify reset exit;"

exit /b 0

:hw_firmware_download:

set board=%~1
curl.exe -s -L https://github.com/infineon/micropython/releases/download/v0.3.0/hello-world_%board%.hex > hello-world_%board%.hex

exit /b 0

:hw_firmware_clean

set board=%~1
del hello-world_%board%.hex

exit /b 0

:flash_erase_firmware_download:

set board=%~1
curl.exe -s -L https://github.com/infineon/micropython/releases/download/v0.3.0/device-erase_%board%.hex > device-erase_%board%.hex

exit /b 0

:flash_erase_firmware_clean

set board=%~1
del device-erase_%board%.hex
openocd.exe -s openocd\scripts -s openocd\board -c "source [find interface/kitprog3.cfg]; ; source [find target/psoc6_2m.cfg]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program %hex_file% verify reset exit;"

exit /b 0

:mpy_firmware_download:

set board=%~1
set version=%~2
set fw_name=%~1
set board=%~2
set version=%~3

if "%version%" == "latest" (
call set sub_url=latest/download
) else (
call set sub_url=download/%version%
)

echo Downloading MicroPython PSoC6 port %version% for %board% board...
curl.exe -s -L https://github.com/infineon/micropython/releases/%sub_url%/mpy-psoc6_%board%.hex > mpy-psoc6_%board%.hex
echo Downloading %fw_name% %version% for %board% board...
curl.exe -s -L https://github.com/infineon/micropython/releases/%sub_url%/%fw_name%_%board%.hex > %fw_name%_%board%.hex

exit /b 0

:mpy_firmware_clean

set board=%~1
echo Cleaning up micropython hex files...
del mpy-psoc6_%board%.hex
set fw_name=%~1
set board=%~2
echo Cleaning up %fw_name% hex files...
del %fw_name%_%board%.hex

exit /b 0

Expand All @@ -150,6 +124,18 @@ exit /b 0

exit /b 0

:openocd_board_conf_download

set board=%~1
echo Downloading openocd %board% configuration...
cd openocd
mkdir board
cd board
curl.exe -s -L https://github.com/infineon/micropython/releases/download/v0.3.0/qspi_config_%board%.cfg > qspi_config.cfg
cd ../..

exit /b 0

:openocd_uninstall_clean

echo Cleaning up openOCD installation package...
Expand Down Expand Up @@ -190,8 +176,9 @@ exit /b 0

Rem Download flashing tool and firmware
call :openocd_download_install
call :hw_firmware_download %board%
call :mpy_firmware_download %board% %mpy_firmware_version%
call :openocd_board_conf_download %board%
call :mpy_firmware_download hello-world %board% v0.3.0
call :mpy_firmware_download mpy-psoc6 %board% %mpy_firmware_version%

if not [%~3]==[\q] (
echo:
Expand All @@ -206,8 +193,8 @@ exit /b 0
echo Device firmware deployment completed.

call :openocd_uninstall_clean
call :hw_firmware_clean %board%
call :mpy_firmware_clean %board%
call :mpy_firmware_clean hello-world %board%
call :mpy_firmware_clean mpy-psoc6 %board%

if not [%~3]==[\q] (
echo:
Expand Down Expand Up @@ -244,7 +231,8 @@ exit /b 0

Rem Download flashing tool and firmware
call :openocd_download_install
call :flash_erase_firmware_download %board%
call :openocd_board_conf_download %board%
call :mpy_firmware_download device-erase %board% v0.3.0

if not [%~2]==[\q] (
echo:
Expand All @@ -258,7 +246,7 @@ exit /b 0
echo Device firmware deployment completed.

call :openocd_uninstall_clean
call :flash_erase_firmware_clean %board%
call :mpy_firmware_clean device-erase %board%

if not [%~2]==[\q] (
echo:
Expand Down
71 changes: 30 additions & 41 deletions tools/psoc6/mpy-psoc6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,54 +50,30 @@ function mpy_firmware_deploy {
board=$1
hex_file=$2

echo Deploying Micropython...
openocd -s openocd\scripts -c "source [find interface/kitprog3.cfg]; ; source [find target/psoc6_2m.cfg]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program ${hex_file} verify reset exit;"
}

function hw_firmware_download {
# hello-world flashing workaround to overcome factory board flashing error.
# This flashing step will be removed when the root cause fix is available.
board=$1

curl -s -L https://github.com/infineon/micropython/releases/download/v0.3.0/hello-world_${board}.hex > hello-world_${board}.hex
}

function hw_firmware_clean {
board=$1

rm hello-world_${board}.hex
}

function flash_erase_firmware_download {
board=$1

curl -s -L https://github.com/infineon/micropython/releases/download/v0.3.0/device-erase_${board}.hex > device-erase_${board}.hex
}

function flash_erase_firmware_clean {
board=$1

rm device-erase_${board}.hex
echo Deploying firmware...
openocd -s openocd\scripts -s openocd/board -c "source [find interface/kitprog3.cfg]; ; source [find target/psoc6_2m.cfg]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program ${hex_file} verify reset exit;"
}

function mpy_firmware_download {
board=$1
version=$2
fw_name=$1
board=$2
version=$3

echo Downloading MicroPython PSoC6 port ${version} for ${board} board...
echo Downloading ${fw_name} ${version} for ${board} board...
if [ "$version" = "latest" ]; then
sub_url="latest/download"
else
sub_url="download/${version}"
fi
curl -s -L https://github.com/infineon/micropython/releases/${sub_url}/mpy-psoc6_${board}.hex > mpy-psoc6_${board}.hex
curl -s -L https://github.com/infineon/micropython/releases/${sub_url}/${fw_name}_${board}.hex > ${fw_name}_${board}.hex
}

function mpy_firmware_clean {
board=$1
fw_name=$1
board=$2

echo Cleaning up micropython hex files...
rm mpy-psoc6_${board}.hex
echo Cleaning up ${fw_name} hex files...
rm ${fw_name}_${board}.hex
}

function openocd_download_install {
Expand All @@ -109,6 +85,17 @@ function openocd_download_install {
./openocd/udev_rules/install_rules.sh
}

function openocd_board_conf_download {
board=$1

echo Downloading openocd ${board} configuration...
cd openocd
mkdir board
cd board
curl -s -L https://github.com/infineon/micropython/releases/download/v0.3.0/qspi_config_${board}.cfg > qspi_config.cfg
cd ../..
}

function openocd_uninstall_clean {
echo Cleaning up openOCD installation package...
rm openocd.tar.gz
Expand Down Expand Up @@ -178,8 +165,9 @@ function mpy_device_setup {

# Download flashing tool and firmware
openocd_download_install
hw_firmware_download ${board}
mpy_firmware_download ${board} ${mpy_firmware_version}
openocd_board_conf_download ${board}
mpy_firmware_download hello-world ${board} v0.3.0
mpy_firmware_download mpy-psoc6 ${board} ${mpy_firmware_version}

wait_and_request_board_connect $3

Expand All @@ -189,8 +177,8 @@ function mpy_device_setup {
echo Device firmware deployment completed.

openocd_uninstall_clean
hw_firmware_clean ${board}
mpy_firmware_clean ${board}
mpy_firmware_clean hello-world ${board}
mpy_firmware_clean mpy-psoc6 ${board}

wait_user_termination $3
}
Expand All @@ -200,15 +188,16 @@ function mpy_device_erase {

# Download flashing tool and firmware
openocd_download_install
flash_erase_firmware_download ${board}
openocd_board_conf_download ${board}
mpy_firmware_download device-erase ${board} v0.3.0

wait_and_request_board_connect $2

# Deploy on board
mpy_firmware_deploy ${board} device-erase_${board}.hex

openocd_uninstall_clean
flash_erase_firmware_clean ${board}
mpy_firmware_clean device-erase ${board}

wait_user_termination $2
}
Expand Down

0 comments on commit e6df5d1

Please sign in to comment.