2 ###############################
4 # Uncomment to override #
5 ###############################
6 #export SerialPort="/dev/ttyACM0"
7 #export DebuggerPath="/usr/bin/gdb"
8 #export JLinkServerPath="/opt/SEGGER/JLink/JLinkGDBServerCLExe"
10 ###############################
12 # Uncomment to override #
13 ###############################
14 #export SerialPort="/dev/ttyS4"
15 #export DebuggerPath="/usr/bin/gdb"
16 #export JLinkServerPath="/mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe"
18 ###############################
20 # Uncomment to override #
21 ###############################
22 #export SerialPort="COM5"
23 #export JLinkServerPath="C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe"
25 #Debugging on 256KB systems is not recommended
26 #This option does not override PLATFORM_SIZE
27 export DeviceMem
="512"
30 VSCODEPATH
=$
(dirname "$0")
32 function print_config
{
33 echo "Updating with following configuration:"
34 echo "SerialPort: $SerialPort"
35 echo "DebuggerPath: $DebuggerPath"
36 echo "JLinkServerPath: $JLinkServerPath"
39 function setup_serial_port
{
40 if [ -z "$SerialPort" ]; then
41 pm3list
=$
($VSCODEPATH/..
/pm3
--list 2>/dev
/null
)
42 #Use first port listed
43 export SerialPort
=$
(echo $pm3list |
head -n 1 | cut
-c 4-)
44 if [ -z "$SerialPort" ]; then
45 echo >&2 "[!!] No serial port found, please set SerialPort manually"
51 function setup_gdb_linux
{
52 if [ -z "$DebuggerPath" ]; then
53 export DebuggerPath
="/usr/bin/gdb"
55 if [ ! -x "$DebuggerPath" ]; then
56 echo >&2 "[!!] gdb not found, please set DebuggerPath manually"
61 function setup_jlink_linux
{
62 if [ -z "$JLinkServerPath" ]; then
63 export JLinkServerPath
="/opt/SEGGER/JLink/JLinkGDBServerCLExe"
65 if [ ! -x "$JLinkServerPath" ]; then
66 echo >&2 "[!!] JLinkGDBServerCLExe not found, please set JLinkServerPath manually"
72 function setup_jlink_wsl
{
73 if [ -z "$JLinkServerPath" ]; then
74 export JLinkServerPath
="/mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe"
76 if [ ! -x "$JLinkServerPath" ]; then
77 echo >&2 "[!!] JLinkGDBServerCL.exe not found, please set JLinkServerPath manually"
82 function setup_jlink_ps
{
83 if [ -z "$JLinkServerPath" ]; then
84 export JLinkServerPath
="c:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe"
86 jlinkpath
=$
(cygpath
"$JLinkServerPath")
87 if [ ! -x "$jlinkpath" ]; then
88 echo >&2 "[!!] JLinkGDBServerCL.exe not found, please set JLinkServerPath manually"
98 envsubst
'${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_wsl.json" > "$VSCODEPATH/launch.json"
101 function setup_linux
{
106 envsubst
'${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_linux.json" > "$VSCODEPATH/launch.json"
112 export DebuggerPath
="Using ProxSpace gbd"
114 envsubst
'${SerialPort} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_ps.json" > "$VSCODEPATH/launch.json"
117 if [ -f "$VSCODEPATH/launch.json" ]; then
118 read -p "Existing configuration found, do you want to override it? " -n 1 -r
119 if [[ $REPLY =~ ^
[Yy
]$
]]
121 rm "$VSCODEPATH/launch.json.bak" 2> /dev
/null
122 mv "$VSCODEPATH/launch.json" "$VSCODEPATH/launch.json.bak" 2> /dev
/null
124 echo >&2 "[!!] user abort"
130 HOSTOS
=$
(uname |
awk '{print toupper($0)}')
131 if [ "$HOSTOS" = "LINUX" ]; then
132 if uname
-a|
grep -q Microsoft
; then
137 elif [ "$HOSTOS" = "DARWIN" ]; then
138 echo >&2 "[!!] MacOS not supported, sorry!"
140 elif [[ "$HOSTOS" =~ MINGW
(32|
64)_NT
* ]]; then
143 echo >&2 "[!!] Host OS not recognized, abort: $HOSTOS"