This commit is contained in:
Wolfgang Hottgenroth 2020-10-10 22:28:12 +02:00
commit ca16d2a6e0
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
3 changed files with 65 additions and 0 deletions

4
openocd.cfg Normal file
View File

@ -0,0 +1,4 @@
source /usr/share/openocd/scripts/interface/stlink-v2.cfg
source /usr/share/openocd/scripts/target/stm32f1x.cfg
reset_config srst_nogate

5
readme.md Normal file
View File

@ -0,0 +1,5 @@
On Ubuntu install
* gcc-arm-none-eabi
* openocd

56
tools/insertMyCode.sh Normal file
View File

@ -0,0 +1,56 @@
#!/bin/bash
MAIN_C=./Core/Src/main.c
MAIN_C_BAK=${MAIN_C}-bak
MAKEFILE=./Makefile
MAKEFILE_BAK=${MAKEFILE}-bak
PROCESSED="Processed by $0"
checkFile () {
FILE=$1
BAK_FILE=$2
if [ ! -f $FILE ]; then
echo "no $FILE available"
exit 1
fi
if [ -f $BAK_FILE ]; then
echo "$BAK_FILE already available, delete manually"
exit 1
fi
grep -q "$PROCESSED" $FILE
if [ "$?" = "0" ]; then
echo "$FILE has already been processed"
exit 1
fi
}
checkFile $MAIN_C $MAIN_C_BAK
checkFile $MAKEFILE $MAKEFILE_BAK
cp $MAIN_C $MAIN_C_BAK
echo "// $PROCESSED" > $MAIN_C
cat $MAIN_C_BAK | \
sed -e 's,\(/\* USER CODE BEGIN Includes \*/\),\1\n#include "main2.h"\n,' | \
sed -e 's,\(/\* USER CODE BEGIN 1 \*/\),\1\n my_setup_1();\n,' | \
sed -e 's,\(/\* USER CODE BEGIN 2 \*/\),\1\n my_setup_2();\n,' | \
sed -e 's,\(/\* USER CODE BEGIN 3 \*/\),\1\n my_loop();\n,' | \
sed -e 's,\(/\* USER CODE BEGIN Error_Handler_Debug \*/\),\1\n my_errorHandler();\n,' | \
sed -e 's,\(/\* USER CODE END Error_Handler_Debug \*/\),\1\n while(1) { };\n,' >> $MAIN_C
SRC_EXT=''
for I in User/Src/*.c; do
SRC_EXT+="$I "
done
cp $MAKEFILE $MAKEFILE_BAK
echo "# $PROCESSED" > $MAKEFILE
cat $MAKEFILE_BAK | \
sed -e 's,\(C_SOURCES = \\\),\1\n'"$SRC_EXT"' \\,' | \
sed -e 's,\(C_INCLUDES = \\\),\1\n-IUser/Inc \\,' >> $MAKEFILE