Skip to content
This repository was archived by the owner on Oct 6, 2021. It is now read-only.

Commit 169640a

Browse files
committed
Add script to generate CMSIS startup files list
Used to solved issue: stm32duino/Arduino_Core_STM32#70 Signed-off-by: Frederic.Pillon <[email protected]>
1 parent ab7b551 commit 169640a

File tree

2 files changed

+94
-13
lines changed

2 files changed

+94
-13
lines changed

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
# stm32_tools
22
Useful tools for stm32
33

4-
## genpinmap
5-
This script is able to generate the PeripheralPins.c for a specific board.
4+
## genpinmap (Moved to [Arduino_Tools](https://github.com/stm32duino/Arduino_Tools)
65

7-
After file generation, review it carefully and please report any issue
8-
[here](https://github.com/fpistm/stm32_tools/issues)
6+
## gen_cmsis_startup_file_list.sh
7+
Used to generate the stm32_def_build.h file.
8+
Launch it at the root of [Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32)
99

10-
Once generated, you should comment a line if the pin is generated
11-
several times for the same IP or if the pin should not be used
12-
(overlaid with some HW on the board, for instance)
13-
14-
USAGE: genpinmap_arduino.py \<BOARD_NAME\> \<product xml file name\>
15-
- \<BOARD_NAME\> is the name of the board as it will be named in mbed
16-
- \<product xml file name\> is the STM32 file description in Cube MX
17-
18-
!!This xml file contains non alpha characters in its name, you should call it with quotes

gen_cmsis_startup_file_list.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash -
2+
#===============================================================================
3+
#
4+
# FILE: gen_cmsis_startup_file_list.sh
5+
#
6+
# USAGE: ./gen_cmsis_startup_file_list.sh
7+
#
8+
# DESCRIPTION:
9+
#
10+
# OPTIONS: ---
11+
# REQUIREMENTS: ---
12+
# BUGS: ---
13+
# NOTES: ---
14+
# AUTHOR: Frederic.Pillon <[email protected]>
15+
# ORGANIZATION: STMicroelectronics
16+
# COPYRIGHT: Copyright (C) 2017, STMicroelectronics - All Rights Reserved
17+
# CREATED: 08/02/17 08:25
18+
# REVISION: ---
19+
#===============================================================================
20+
21+
set -o nounset # Treat unset variables as an error
22+
23+
outfile=cores/arduino/stm32/stm32_def_build.h
24+
25+
print_header() {
26+
echo "/*
27+
* <Description>
28+
*
29+
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
30+
* Author: YOUR NAME <> for STMicroelectronics.
31+
*
32+
* License type: GPLv2
33+
*
34+
* This program is free software; you can redistribute it and/or modify it
35+
* under the terms of the GNU General Public License version 2 as published by
36+
* the Free Software Foundation.
37+
*
38+
* This program is distributed in the hope that it will be useful, but
39+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
40+
* or FITNESS FOR A PARTICULAR PURPOSE.
41+
* See the GNU General Public License for more details.
42+
*
43+
* You should have received a copy of the GNU General Public License along with
44+
* this program. If not, see
45+
* <http://www.gnu.org/licenses/>.
46+
*/
47+
#ifndef _STM32_DEF_BUILD_
48+
#define _STM32_DEF_BUILD_
49+
" > $outfile
50+
}
51+
52+
print_footer() {
53+
echo "#else
54+
#error UNKNOWN CHIP
55+
#endif
56+
#endif //_STM32_DEF_BUILD_" >> $outfile
57+
}
58+
59+
print_list() {
60+
# Handle first elements
61+
local upper=`echo ${list[0]} | awk -F'[_.]' '{print toupper($2)}' | tr X x`
62+
echo "#if defined($upper)
63+
#define CMSIS_STARTUP_FILE \"${list[0]}\"" >> $outfile
64+
65+
if [ ${#list[@]} -gt 1 ]; then
66+
for i in ${list[@]:1}
67+
do
68+
upper=`echo $i | awk -F'[_.]' '{print toupper($2)}' | tr X x`
69+
echo "#elif defined($upper)
70+
#define CMSIS_STARTUP_FILE \"$i\"" >> $outfile
71+
done
72+
fi
73+
}
74+
75+
# check if we are at the right place
76+
if [ ! -f $outfile ]; then
77+
echo "Could not find $outfile!"
78+
echo "Launch $0 at the top of the Arduion STM32 core repository!"
79+
exit 1
80+
fi
81+
82+
list=(`find -name "startup_*.s" | grep gcc | awk -F/ '{print $NF}' | sort -u`)
83+
if [ ${#list[@]} -ne 0 ]; then
84+
echo "Number of startup files: ${#list[@]}"
85+
print_header
86+
print_list
87+
print_footer
88+
else
89+
echo "No startup files found!"
90+
fi

0 commit comments

Comments
 (0)