Skip to content

Commit 8cda90c

Browse files
committed
README: Add fetch_from_upstream.sh script and instructions on its use.
Signed-off-by: Damien George <[email protected]>
1 parent 1d9e694 commit 8cda90c

File tree

2 files changed

+62
-11
lines changed

2 files changed

+62
-11
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ conflict resolution) to newer vendor tags to create the next working branch.
2323
Original sources
2424
================
2525

26-
The sources are obtained from ``http://st.com``
26+
The sources are obtained from ``http://st.com``, and also from the git
27+
repositories found at ``https://github.com/STMicroelectronics/``.
2728

2829
For all .c and .h files the following processing has been done to the original
2930
files before committing them here:
@@ -32,16 +33,6 @@ files before committing them here:
3233
- tabs expanded to 4 spaces
3334
- non-ASCII chars converted to their ASCII equivalent
3435

35-
A shell function to do this processing is:
36-
```sh
37-
function clean_code() {
38-
chmod 644 $1
39-
cat $1 | awk "{sub(/[\t ]*\r/,\"\")}1" | expand -t 4 | tr \\200\\205\\211\\221\\222\\223\\224\\226\\231\\244\\261\\265\\302\\327\\342 \'??\'\'\"\"\\-\'??u?x\' > tmp$$
40-
mv tmp$$ $1
41-
}
42-
find path -type f | while read file; do echo "$file"; clean_code "$file"; done
43-
```
44-
4536
Directories from the original sources are mapped into this repository according
4637
to the following:
4738
```
@@ -51,3 +42,6 @@ Drivers/CMSIS/Device/ST/STM32F4xx/Include -> CMSIS/STM32F4xx/Include
5142
Drivers/CMSIS/Device/ST/STM32F4xx/Source -> CMSIS/STM32F4xx/Source
5243
```
5344
And similar for the other microcontroller classes.
45+
46+
The included `fetch_from_upstream.sh` script can automatically copy and process
47+
new source code from an STM git repository.

fetch_from_upstream.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
#
3+
# Fetch new code for an entire MCU series from an upstream STM repository.
4+
5+
if [ $# -ne 2 ]; then
6+
echo "usage: $0 <mcu> <src>"
7+
echo ""
8+
echo "eg: $0 STM32WB path/to/STM32CubeWB"
9+
echo "where STM32CubeWB is from https://github.com/STMicroelectronics/STM32CubeWB.git"
10+
exit 1
11+
fi
12+
13+
mcu=$1
14+
gitsrc=$2
15+
16+
cmsis=CMSIS/${mcu}xx
17+
hal=${mcu}xx_HAL_Driver
18+
19+
if [ ! -d $cmsis ]; then
20+
echo "WARNING: $cmsis is not an existing directory, assuming a new MCU series"
21+
mkdir -p $cmsis
22+
fi
23+
24+
if [ ! -d $hal ]; then
25+
echo "WARNING: $hal is not an existing directory, assuming a new MCU series"
26+
mkdir -p $hal
27+
fi
28+
29+
# CMSIS: remove any old files and copy across the new ones.
30+
echo "Fetching CMSIS to $cmsis"
31+
rm -rf $cmsis/Include
32+
rm -rf $cmsis/Source
33+
cp -r $gitsrc/Drivers/CMSIS/Device/ST/${mcu}xx/Include $cmsis/
34+
cp -r $gitsrc/Drivers/CMSIS/Device/ST/${mcu}xx/Source $cmsis/
35+
rm -rf CMSIS/${mcu}xx/Source/Templates/*/linker
36+
37+
# HAL: remove any old files and copy across the new ones.
38+
echo "Fetching HAL to $hal"
39+
rm -rf $hal/Inc
40+
rm -rf $hal/Src
41+
cp -r $gitsrc/Drivers/${mcu}xx_HAL_Driver/Inc $hal/
42+
cp -r $gitsrc/Drivers/${mcu}xx_HAL_Driver/Src $hal/
43+
44+
for dir in $cmsis $hal; do
45+
# Process the new source code to:
46+
# - remove trailing white-space
47+
# - convert to unix line-endings
48+
# - expand tabs with 4 spaces
49+
# - convert non-ascii chars to ascii equivalent (should only be in comments)
50+
echo "Processing source code in $dir"
51+
for file in $(find $dir -name "*.[chs]"); do
52+
chmod 644 $file
53+
cat $file | awk "{sub(/[\t ]*$/,\"\")}1" | expand -t 4 | tr \\200\\205\\211\\221\\222\\223\\224\\226\\231\\244\\261\\265\\302\\327\\342 \'??\'\'\"\"\\-\'??u?x\' > tmp$$
54+
/bin/mv tmp$$ $file
55+
done
56+
done
57+

0 commit comments

Comments
 (0)