|
| 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