1#!/usr/bin/env bash 2#****************************************************************************** 3# * @attention 4# * 5# * <h2><center>© Copyright (c) 2019 STMicroelectronics. 6# * All rights reserved.</center></h2> 7# * 8# * This software component is licensed by ST under BSD 3-Clause license, 9# * the "License"; You may not use this file except in compliance with the 10# * License. You may obtain a copy of the License at: 11# * opensource.org/licenses/BSD-3-Clause 12# * 13# ****************************************************************************** 14 15echo "TFM UPDATE started" 16sn_option="" 17if [ $# -eq 1 ]; then 18sn_option="sn=$1" 19fi 20# Absolute path to this script 21SCRIPT=$(readlink -f $0) 22SCRIPTPATH=`dirname $SCRIPT` 23#copy tfm_ns_signed to the true path 24cp $SCRIPTPATH/../../build_ns/bin/tfm_ns_signed.bin image_signing/scripts 25 26# Absolute path this script 27BINPATH_SPE="$SCRIPTPATH/bin" 28BINPATH_BL2="$SCRIPTPATH/bin" 29BINPATH_NSPE="$SCRIPTPATH/image_signing/scripts" 30 31PATH="/C/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/":$PATH 32stm32programmercli="STM32_Programmer_CLI" 33# part ot be updated according to flash_layout.h 34slot0= 35slot1= 36slot2= 37slot3= 38its= 39sst= 40scratch= 41nvcounter= 42boot= 43nvmcnt= 44prov= 45unused= 46encrypted= 47#select external flash according to slot2 value 48u5=0x70000000 49l5=0x90000000 50slot_s=$slot0 51slot_ns=$slot1 52cubedir="`which STM32_Programmer_CLI`" 53cubedir="$(dirname "${cubedir}")" 54#when image are encrypted, image are not installed in place (mcuboot installs the image from download slot) 55if [ "$encrypted" == "0x1" ]; then 56slot_s=$slot2 57slot_ns=$slot3 58fi 59if [ "$slot2" == $u5 ]; then 60external_loader="-el $cubedir/ExternalLoader/MX25LM51245G_STM32U585I-IOT02A.stldr" 61fi 62if [ "$slot2" == $l5 ]; then 63external_loader="-el $cubedir/ExternalLoader/MX25LM51245G_STM32L562E-DK.stldr" 64fi 65connect_no_reset="-c port=SWD "$sn_option" mode=UR $external_loader" 66connect="-c port=SWD "$sn_option" mode=UR $external_loader" 67 68echo "Write TFM_Appli Secure" 69# part ot be updated according to flash_layout.h 70 71$stm32programmercli $connect -d $BINPATH_SPE/tfm_s_signed.bin $slot_s -v 72echo "TFM_Appli Secure Written" 73echo "Write TFM_Appli NonSecure" 74$stm32programmercli $connect -d $BINPATH_NSPE/tfm_ns_signed.bin $slot_ns -v 75echo "TFM_Appli NonSecure Written" 76echo "Write TFM_SBSFU_Boot" 77$stm32programmercli $connect -d $BINPATH_BL2/bl2.bin $boot -v 78echo "TFM_SBSFU_Boot Written" 79echo "TFM_UPDATE Done" 80