Skip to content

Commit

Permalink
Fix flash scripts on Raspberry Pi
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Jan 20, 2020
1 parent ea92c60 commit 059b0ef
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"command": "bash",
"args": [
"-c", "-l",
" scripts/nrf52-pi/flash-boot.sh && echo ✅ ◾ ️Done! "
" scripts/nrf52/flash-boot.sh && echo ✅ ◾ ️Done! "
],
},
"problemMatcher": [],
Expand Down Expand Up @@ -167,7 +167,7 @@
"command": "bash",
"args": [
"-c", "-l",
" scripts/nrf52-pi/flash-app.sh && echo ✅ ◾ ️Done! "
" scripts/nrf52/flash-app.sh && echo ✅ ◾ ️Done! "
],
},
"problemMatcher": [],
Expand Down Expand Up @@ -197,7 +197,7 @@
"command": "bash",
"args": [
"-c", "-l",
" scripts/nrf52-pi/flash-erase.sh && echo ✅ ◾ ️Done! "
" scripts/nrf52/flash-erase.sh && echo ✅ ◾ ️Done! "
],
},
"problemMatcher": [],
Expand Down
11 changes: 11 additions & 0 deletions scripts/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Configuration for build, run and flash scripts

# For Raspberry Pi:
# source scripts/nrf52-pi/config.sh

# Select ST-Link v2 as SWD Programmer
swd_device=scripts/nrf52/swd-stlink.ocd

# Select Raspberry Pi as SWD Programmer
# swd_device=scripts/nrf52-pi/swd-pi.ocd
3 changes: 3 additions & 0 deletions scripts/install-pi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ set -x # Echo all commands.
# cd ~/pinetime-rust-mynewt
# scripts/install-pi.sh

# Configure scripts for Raspberry Pi
echo "source scripts/nrf52-pi/config.sh" >scripts/config.sh

set +x; echo; echo "----- Setting versions..."; set -x
source scripts/install-version.sh

Expand Down
5 changes: 5 additions & 0 deletions scripts/nrf52-pi/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Configuration for build, run and flash scripts on Raspberry Pi

# Select Raspberry Pi as SWD Programmer
swd_device=scripts/nrf52-pi/swd-pi.ocd
13 changes: 13 additions & 0 deletions scripts/nrf52-pi/flash-erase.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# # Erase Flash ROM on nRF52 with Raspberry Pi

set -e # Exit when any command fails.
set -x # Echo all commands.

# Configure SWD Programmer
source scripts/config.sh

# Erase the Flash ROM
openocd/bin/openocd \
-f $swd_device \
-f scripts/nrf52/flash-erase.ocd
2 changes: 1 addition & 1 deletion scripts/nrf52/flash-app.ocd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is an OpenOCD script that connects ST-Link to the nRF52 and flashes the Application ROM.
# This is an OpenOCD script that connects ST-Link or Raspberry Pi to the nRF52 and flashes the Application ROM.
# Used by tasks.json for "Load Application" command.
# Equivalent to "newt load -v nrf52_my_sensor".

Expand Down
8 changes: 6 additions & 2 deletions scripts/nrf52/flash-app.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env bash
# Flash Mynewt Application to nRF52 with ST-Link on macOS and Linux
# Flash Mynewt Application to nRF52 on macOS, Linux and Raspberry Pi

set -e # Exit when any command fails.
set -x # Echo all commands.

# Configure SWD Programmer
source scripts/config.sh

# Flash the device
openocd/bin/openocd \
-f scripts/nrf52/swd-stlink.ocd \
-f $swd_device \
-f scripts/nrf52/flash-app.ocd
2 changes: 1 addition & 1 deletion scripts/nrf52/flash-boot.ocd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is an OpenOCD script that connects ST-Link to the nRF52 and flashes the Bootloader ROM.
# This is an OpenOCD script that connects ST-Link or Raspberry Pi to the nRF52 and flashes the Bootloader ROM.
# Used by tasks.json for "Load Bootloader" command.
# Equivalent to "newt load -v nrf52_boot".

Expand Down
14 changes: 5 additions & 9 deletions scripts/nrf52/flash-boot.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#!/usr/bin/env bash
# Flash Mynewt Bootloader to nRF52 with ST-Link on macOS and Linux
# Flash Mynewt Bootloader to nRF52 on macOS, Linux and Raspberry Pi

set -e # Exit when any command fails.
set -x # Echo all commands.

# Identify SWD programmer. /proc/device-tree/model contains
# Raspberry Pi 4 Model B Rev 1.1
# Raspberry Pi 3 Model B Plus Rev 1.3
swd_device=stlink
if [ -e /proc/device-tree/model ]; then
swd_device=pi
fi
# Configure SWD Programmer
source scripts/config.sh

# Flash the device
openocd/bin/openocd \
-f scripts/nrf52/swd-$swd_device.ocd \
-f $swd_device \
-f scripts/nrf52/flash-boot.ocd
2 changes: 1 addition & 1 deletion scripts/nrf52/flash-erase.ocd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is an OpenOCD script that connects ST-Link to the nRF52 and erases the flash ROM.
# This is an OpenOCD script that connects ST-Link or Raspberry Pi to the nRF52 and erases the flash ROM.
# Used by tasks.json for "Erase Flash" command.

# From https://devzone.nordicsemi.com/f/nordic-q-a/42824/flashing-nrf5832-using-only-st-link-v2-and-openocd
Expand Down

0 comments on commit 059b0ef

Please sign in to comment.