@@ -23,29 +23,30 @@ LLoutInc_path=$Core_path/cores/arduino/stm32/LL
23
23
CMSIS_Startupfile=$Core_path /cores/arduino/stm32/stm32_def_build.h
24
24
25
25
# Variables
26
- series=(` ls -d $HALDrivers_path /STM32* / | sed -e " s#$HALDrivers_path /STM32##g" | sed -e " s#xx_HAL_Driver/##g" ` )
26
+ series=($( find $HALDrivers_path -maxdepth 1 -type d -name " STM32*" | sed -e " s#$HALDrivers_path /STM32##g" -e " s#xx_HAL_Driver##g" ) )
27
+
27
28
all_LL_file=stm32yyxx_ll.h
28
29
29
30
# Create the file
30
31
print_C_header () {
31
32
if [[ $1 = * " template" * ]]; then
32
- echo " #if 0" > $1
33
+ echo " #if 0" > " $1 "
33
34
else
34
- touch $1
35
+ touch " $1 "
35
36
fi
36
37
}
37
38
38
39
# Add some pragma to ll header files to avoid several warnings
39
40
# which will be corrected along Cube update
40
41
print_LL_header () {
41
- upper=` echo $1 | awk ' {print toupper($1)}' | sed -e " s/\./_/g" `
42
+ upper=$( echo " $1 " | awk ' {print toupper($1)}' | sed -e " s/\./_/g" )
42
43
echo " #ifndef _${upper} _
43
44
#define _${upper} _
44
45
/* LL raised several warnings, ignore them */
45
46
#pragma GCC diagnostic push
46
47
#pragma GCC diagnostic ignored \" -Wunused-parameter\"
47
48
#pragma GCC diagnostic ignored \" -Wstrict-aliasing\"
48
- " > $LLoutInc_path /$1
49
+ " > $LLoutInc_path /" $1 "
49
50
}
50
51
51
52
print_CMSIS_Startup_header () {
@@ -68,17 +69,19 @@ echo "#else
68
69
print_CMSIS_Startup_list () {
69
70
# Handle first elements
70
71
# File name
71
- local f=` echo ${list[0]} | awk -F/ ' {print $NF}' `
72
- local upper=` echo $f | awk -F' [_.]' ' {print toupper($2)}' | tr X x`
72
+ local f
73
+ local upper
74
+ f=$( echo " ${list[0]} " | awk -F/ ' {print $NF}' )
75
+ upper=$( echo " $f " | awk -F' [_.]' ' {print toupper($2)}' | tr X x)
73
76
echo " #if defined($upper )
74
77
#define CMSIS_STARTUP_FILE \" $f \" " >> $CMSIS_Startupfile
75
78
76
79
if [ ${# list[@]} -gt 1 ]; then
77
- for fp in ${list[@]: 1}
80
+ for fp in " ${list[@]: 1} "
78
81
do
79
82
# File name
80
- f=` echo $fp | awk -F/ ' {print $NF}' `
81
- upper=` echo $f | awk -F' [_.]' ' {print toupper($2)}' | tr X x`
83
+ f=$( echo " $fp " | awk -F/ ' {print $NF}' )
84
+ upper=$( echo " $f " | awk -F' [_.]' ' {print toupper($2)}' | tr X x)
82
85
echo " #elif defined($upper )
83
86
#define CMSIS_STARTUP_FILE \" $f \" " >> $CMSIS_Startupfile
84
87
done
88
91
# main
89
92
# Check if this is the right place
90
93
if [ ! -d $HALDrivers_path ]; then
91
- echo " Could not find $HAL_outSrcpath !"
94
+ echo " Could not find $HALDrivers_path !"
92
95
echo " Launch $0 from scripts folder!"
93
96
exit 1
94
97
fi
97
100
rm -f $HALoutSrc_path /* $LLoutSrc_path /* $LLoutInc_path /* $CMSIS_Startupfile
98
101
99
102
# Search all files for each series
100
- for serie in ${series[@]}
103
+ for serie in " ${series[@]} "
101
104
do
102
- if [ -d $HALDrivers_path /STM32${serie} xx_HAL_Driver/Src ]; then
103
- lower=` echo $serie | awk ' {print tolower($0)}' `
105
+ if [ -d $HALDrivers_path /STM32" ${serie} " xx_HAL_Driver/Src ]; then
106
+ lower=$( echo " $serie " | awk ' {print tolower($0)}' )
104
107
echo -n " Generating for $serie ..."
105
108
106
109
# Generate stm32yyxx_[hal|ll]*.c file
107
- filelist=(` find $HALDrivers_path /STM32${serie} xx_HAL_Driver/Src -maxdepth 1 -name " stm32${lower} xx_*.c" ` )
108
- for fp in ${filelist[@]}
110
+ filelist=($( find $HALDrivers_path /STM32" ${serie} " xx_HAL_Driver/Src -maxdepth 1 -name " stm32${lower} xx_*.c" ) )
111
+ for fp in " ${filelist[@]} "
109
112
do
110
113
outp=$HALoutSrc_path
111
114
# File name
112
- f=` echo $fp | awk -F/ ' {print $NF}' `
115
+ f=$( echo " $fp " | awk -F/ ' {print $NF}' )
113
116
# Compute generic file name
114
- g=` echo $f | sed -e " s/ $lower /yy/g " `
117
+ g=" ${f // $lower / yy} "
115
118
if [[ $f = * " _ll_" * ]]; then
116
119
outp=$LLoutSrc_path
117
120
fi
118
- if [ ! -f $outp /$g ]; then
119
- print_C_header $outp /$g
121
+ if [ ! -f $outp /" $g " ]; then
122
+ print_C_header $outp /" $g "
120
123
fi
121
124
# Amend file name under serie switch
122
- echo " #ifdef STM32${serie} xx" >> $outp /$g
123
- echo " #include \" $f \" " >> $outp /$g
124
- echo " #endif" >> $outp /$g
125
+ {
126
+ echo " #ifdef STM32${serie} xx"
127
+ echo " #include \" $f \" "
128
+ echo " #endif"
129
+ } >> $outp /" $g "
125
130
done
126
131
127
132
# Generate stm32yyxx_ll_*.h file
128
- filelist=(` find $HALDrivers_path /STM32${serie} xx_HAL_Driver/Inc -maxdepth 2 -name " stm32${lower} xx_ll_*.h" ` )
129
- for fp in ${filelist[@]}
133
+ filelist=($( find $HALDrivers_path /STM32" ${serie} " xx_HAL_Driver/Inc -maxdepth 2 -name " stm32${lower} xx_ll_*.h" ) )
134
+ for fp in " ${filelist[@]} "
130
135
do
131
136
# File name
132
- f=` echo $fp | awk -F/ ' {print $NF}' `
137
+ f=$( echo " $fp " | awk -F/ ' {print $NF}' )
133
138
# Compute generic file name
134
- g=` echo $f | sed -e " s/ $lower /yy/g " `
139
+ g=" ${f // $lower / yy} "
135
140
136
- if [ ! -f $LLoutInc_path /$g ]; then
137
- print_LL_header $g
141
+ if [ ! -f $LLoutInc_path /" $g " ]; then
142
+ print_LL_header " $g "
138
143
fi
139
144
# Amend full LL header file
140
145
echo " #include \" $g \" " >> $LLoutInc_path /${all_LL_file} .tmp
141
146
# Amend file name under serie switch
142
- echo " #ifdef STM32${serie} xx" >> $LLoutInc_path /$g
143
- echo " #include \" $f \" " >> $LLoutInc_path /$g
144
- echo " #endif" >> $LLoutInc_path /$g
147
+ {
148
+ echo " #ifdef STM32${serie} xx"
149
+ echo " #include \" $f \" "
150
+ echo " #endif"
151
+ } >> $LLoutInc_path /" $g "
145
152
done
146
153
echo " done"
147
154
fi
@@ -156,23 +163,23 @@ sort -u $LLoutInc_path/${all_LL_file}.tmp >> $LLoutInc_path/${all_LL_file}
156
163
rm -f $LLoutInc_path /${all_LL_file} .tmp
157
164
158
165
# Search all template file to end "#if 0"
159
- filelist=(` find $HALoutSrc_path -maxdepth 1 -name " stm32*_template.c" ` )
160
- for fp in ${filelist[@]}
166
+ filelist=($( find $HALoutSrc_path -maxdepth 1 -name " stm32*_template.c" ) )
167
+ for fp in " ${filelist[@]} "
161
168
do
162
- echo " #endif /* 0 */" >> $fp
169
+ echo " #endif /* 0 */" >> " $fp "
163
170
done
164
171
165
172
# Search all LL header files to end guard
166
- filelist=(` find $LLoutInc_path -maxdepth 1 -name " stm32yyxx_ll*.h" ` )
167
- for fp in ${filelist[@]}
173
+ filelist=($( find $LLoutInc_path -maxdepth 1 -name " stm32yyxx_ll*.h" ) )
174
+ for fp in " ${filelist[@]} "
168
175
do
169
- upper=` basename $fp | awk ' {print toupper($1)}' | sed -e " s/\./_/g" `
170
- echo " #pragma GCC diagnostic pop" >> $fp
171
- echo " #endif /* _${upper} _ */" >> $fp
176
+ upper=$( basename " $fp " | awk ' {print toupper($1)}' | sed -e " s/\./_/g" )
177
+ echo " #pragma GCC diagnostic pop" >> " $fp "
178
+ echo " #endif /* _${upper} _ */" >> " $fp "
172
179
done
173
180
174
181
# CMSIS startup files
175
- list=(` find $CMSIS_Device_ST_path -name " startup_*.s" | grep gcc | sort -u ` )
182
+ list=($( find $CMSIS_Device_ST_path -name " startup_*.s" | grep gcc | sort -du ) )
176
183
if [ ${# list[@]} -ne 0 ]; then
177
184
echo " Number of startup files: ${# list[@]} "
178
185
print_CMSIS_Startup_header
@@ -189,16 +196,16 @@ if [ ! -d $CMSIS_DSPSrc_path ]; then
189
196
echo " Skip CMSIS DSP generation."
190
197
else
191
198
# Remove old file
192
- rm -fr $ CMSIS_DSP_outSrc_path /* /
199
+ rm -fr " ${ CMSIS_DSP_outSrc_path:? } " /* /
193
200
194
- filelist=(` find $CMSIS_DSPSrc_path -name " *.c" | sed -e " s#$CMSIS_DSPSrc_path /##g" | sort -u` )
195
- for fp in ${filelist[@]}
201
+ filelist=($( find $CMSIS_DSPSrc_path -name " *.c" | sed -e " s#$CMSIS_DSPSrc_path /##g" | sort -u) )
202
+ for fp in " ${filelist[@]} "
196
203
do
197
204
# Directory name
198
- d=` echo $fp | awk -F/ ' {print $(NF-1)}' `
199
- if [ ! -d $CMSIS_DSP_outSrc_path /$d ]; then
200
- mkdir $CMSIS_DSP_outSrc_path /$d
201
- echo " #include \" ../Source/$d /$d .c\" " > $CMSIS_DSP_outSrc_path /$d / $d .c
205
+ d=$( echo " $fp " | awk -F/ ' {print $(NF-1)}' )
206
+ if [ ! -d $CMSIS_DSP_outSrc_path /" $d " ]; then
207
+ mkdir $CMSIS_DSP_outSrc_path /" $d "
208
+ echo " #include \" ../Source/$d /$d .c\" " > $CMSIS_DSP_outSrc_path /" $d " / " $d " .c
202
209
fi
203
210
done
204
211
fi
0 commit comments