README: Add fetch_from_upstream.sh script and instructions on its use.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
1d9e6947ee
commit
8cda90cb1f
16
README.md
16
README.md
@ -23,7 +23,8 @@ conflict resolution) to newer vendor tags to create the next working branch.
|
||||
Original sources
|
||||
================
|
||||
|
||||
The sources are obtained from ``http://st.com``
|
||||
The sources are obtained from ``http://st.com``, and also from the git
|
||||
repositories found at ``https://github.com/STMicroelectronics/``.
|
||||
|
||||
For all .c and .h files the following processing has been done to the original
|
||||
files before committing them here:
|
||||
@ -32,16 +33,6 @@ files before committing them here:
|
||||
- tabs expanded to 4 spaces
|
||||
- non-ASCII chars converted to their ASCII equivalent
|
||||
|
||||
A shell function to do this processing is:
|
||||
```sh
|
||||
function clean_code() {
|
||||
chmod 644 $1
|
||||
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$$
|
||||
mv tmp$$ $1
|
||||
}
|
||||
find path -type f | while read file; do echo "$file"; clean_code "$file"; done
|
||||
```
|
||||
|
||||
Directories from the original sources are mapped into this repository according
|
||||
to the following:
|
||||
```
|
||||
@ -51,3 +42,6 @@ Drivers/CMSIS/Device/ST/STM32F4xx/Include -> CMSIS/STM32F4xx/Include
|
||||
Drivers/CMSIS/Device/ST/STM32F4xx/Source -> CMSIS/STM32F4xx/Source
|
||||
```
|
||||
And similar for the other microcontroller classes.
|
||||
|
||||
The included `fetch_from_upstream.sh` script can automatically copy and process
|
||||
new source code from an STM git repository.
|
||||
|
||||
57
fetch_from_upstream.sh
Executable file
57
fetch_from_upstream.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Fetch new code for an entire MCU series from an upstream STM repository.
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "usage: $0 <mcu> <src>"
|
||||
echo ""
|
||||
echo "eg: $0 STM32WB path/to/STM32CubeWB"
|
||||
echo "where STM32CubeWB is from https://github.com/STMicroelectronics/STM32CubeWB.git"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mcu=$1
|
||||
gitsrc=$2
|
||||
|
||||
cmsis=CMSIS/${mcu}xx
|
||||
hal=${mcu}xx_HAL_Driver
|
||||
|
||||
if [ ! -d $cmsis ]; then
|
||||
echo "WARNING: $cmsis is not an existing directory, assuming a new MCU series"
|
||||
mkdir -p $cmsis
|
||||
fi
|
||||
|
||||
if [ ! -d $hal ]; then
|
||||
echo "WARNING: $hal is not an existing directory, assuming a new MCU series"
|
||||
mkdir -p $hal
|
||||
fi
|
||||
|
||||
# CMSIS: remove any old files and copy across the new ones.
|
||||
echo "Fetching CMSIS to $cmsis"
|
||||
rm -rf $cmsis/Include
|
||||
rm -rf $cmsis/Source
|
||||
cp -r $gitsrc/Drivers/CMSIS/Device/ST/${mcu}xx/Include $cmsis/
|
||||
cp -r $gitsrc/Drivers/CMSIS/Device/ST/${mcu}xx/Source $cmsis/
|
||||
rm -rf CMSIS/${mcu}xx/Source/Templates/*/linker
|
||||
|
||||
# HAL: remove any old files and copy across the new ones.
|
||||
echo "Fetching HAL to $hal"
|
||||
rm -rf $hal/Inc
|
||||
rm -rf $hal/Src
|
||||
cp -r $gitsrc/Drivers/${mcu}xx_HAL_Driver/Inc $hal/
|
||||
cp -r $gitsrc/Drivers/${mcu}xx_HAL_Driver/Src $hal/
|
||||
|
||||
for dir in $cmsis $hal; do
|
||||
# Process the new source code to:
|
||||
# - remove trailing white-space
|
||||
# - convert to unix line-endings
|
||||
# - expand tabs with 4 spaces
|
||||
# - convert non-ascii chars to ascii equivalent (should only be in comments)
|
||||
echo "Processing source code in $dir"
|
||||
for file in $(find $dir -name "*.[chs]"); do
|
||||
chmod 644 $file
|
||||
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$$
|
||||
/bin/mv tmp$$ $file
|
||||
done
|
||||
done
|
||||
|
||||
Loading…
Reference in New Issue
Block a user