#!/bin/bash

set -e
set -u

. libcampo/scripts/campo.sh dummy

getBuildDirectory
if [ "$#" -gt "0" ]; then
    buildDirectory=$1
fi

app=candis
# app=candis_writehwdata

echo "Build DIr: $buildDirectory"

cd $buildDirectory
make -j128 ${app}_bootloader.binfiles


echo -e "### calling:\n${HOME}/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI -c port=usb1 -w $buildDirectory/candis/${app}_bootloader.bin 0x08000000 -s -rst\n"

# -s: start

${HOME}/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI -c port=usb1 -w $buildDirectory/candis/${app}_bootloader.bin 0x08000000
${HOME}/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI -c port=usb1 -s


#---fin------------------------------------------------------------------------
