|
2 | 2 | set -o nounset# Treat unset variables as an error
|
3 | 3 | # set -o xtrace # Print command traces before executing command.
|
4 | 4 |
|
| 5 | +UNAME_OS="$(uname -s)" |
5 | 6 | STM32CP_CLI=
|
6 | 7 | INTERFACE=
|
7 | 8 | PORT=
|
@@ -55,11 +56,21 @@ aborting() {
|
55 | 56 |
|
56 | 57 | # parse command line arguments
|
57 | 58 | # options may be followed by one colon to indicate they have a required arg
|
58 |
| -if! options=$(getopt -a -o hi:ef:o:c:r:d:v:p: --long help,interface:,erase,file:,offset:,com:,rts:,dtr:,vid:,pid: --"$@");then |
59 |
| -echo"Terminating...">&2 |
60 |
| -exit 1 |
61 |
| -fi |
62 |
| - |
| 59 | +case"${UNAME_OS}"in |
| 60 | + Darwin*) |
| 61 | +echo"Warning: long options not supported due to getopt from FreeBSD usage." |
| 62 | +if! options=$(getopt hi:ef:o:c:r:d:v:p:"$@");then |
| 63 | +echo"Terminating...">&2 |
| 64 | +exit 1 |
| 65 | +fi |
| 66 | + ;; |
| 67 | +*) |
| 68 | +if! options=$(getopt -a -o hi:ef:o:c:r:d:v:p: --long help,interface:,erase,file:,offset:,com:,rts:,dtr:,vid:,pid: --"$@");then |
| 69 | +echo"Terminating...">&2 |
| 70 | +exit 1 |
| 71 | +fi |
| 72 | + ;; |
| 73 | +esac |
63 | 74 | evalset --"$options"
|
64 | 75 |
|
65 | 76 | whiletrue;do
|
@@ -109,10 +120,13 @@ while true; do
|
109 | 120 | shift
|
110 | 121 | break
|
111 | 122 | ;;
|
| 123 | +*) |
| 124 | +echo"Unknown option$1" |
| 125 | + usage 1 |
| 126 | + ;; |
112 | 127 | esac
|
113 | 128 | done
|
114 |
| -# Check STM32CubeProgrammer cli availability, fallback to dfu-util if protocol dfu |
115 |
| -UNAME_OS="$(uname -s)" |
| 129 | +# Check STM32CubeProgrammer cli availability |
116 | 130 | case"${UNAME_OS}"in
|
117 | 131 | Linux*)
|
118 | 132 | STM32CP_CLI=STM32_Programmer.sh
|
|