-
Notifications
You must be signed in to change notification settings - Fork 1
/
import.sh
executable file
·55 lines (40 loc) · 1.26 KB
/
import.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
SRC=$(readlink -f ${BASH_SOURCE[0]})
SCRIPT_DIR=$(dirname "${SRC}")
cd $SCRIPT_DIR
cd ..
# Save current directory
CUR_DIR=$(pwd)
CubeMxProjectDir=$1
echo "Project directory: $CUR_DIR"
echo "Importing CubeMx project: $CubeMxProjectDir"
pushd $CubeMxProjectDir > /dev/null
BOARD=$(find ./ -name "*.ld" -execdir echo {} ';')
BOARD=$(echo ${BOARD:0:11})
BOARD_FAMILY=$(find ./Drivers -type d -iname "*HAL_Driver" -execdir echo {} ';')
BOARD_FAMILY=$(echo ${BOARD_FAMILY:0:9})
echo "Board: $BOARD"
echo "Board family: $BOARD_FAMILY"
mv ./Core/Inc/main.h ./main.h
mv ./Core/Src/main.c ./main.c
for file in *.s; do
mv -- "$file" "${file%.s}.S" 2>/dev/null
done
mkdir $CUR_DIR/src/$BOARD > /dev/null
mkdir $CUR_DIR/CubeMx
mkdir $CUR_DIR/CubeMx/$BOARD
mkdir $CUR_DIR/src/$BOARD
cp -v ./*.S $CUR_DIR/src/$BOARD
cp -rv ./Core $CUR_DIR/CubeMx/$BOARD/
cp -rv ./Drivers $CUR_DIR/CubeMx/$BOARD/
mv ./main.h ./Core/Inc/main.h
mv ./main.c ./Core/Src/main.c
echo "Running template script..."
python3 $SCRIPT_DIR/import.py $BOARD_FAMILY
cp -rv ./STM32F103C6Tx_FLASH.ld $CUR_DIR/CubeMx/$BOARD/${BOARD}TX_FLASH.ld
mv ./peripherals.h $CUR_DIR/src/$BOARD
mv ./peripherals.cpp $CUR_DIR/src/$BOARD
mv ./pins.h $CUR_DIR/src/$BOARD
mv ./hal_driver.h $CUR_DIR/src/$BOARD
echo "Done."
exit 0