Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for WSL #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ you must do.
On Ubuntu:

sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
sudo apt-get install gcc-arm-embedded
sudo apt update
sudo apt install gcc-arm-embedded

On MacOS:

Expand All @@ -90,14 +90,14 @@ you must do.
On Windows Subsystem for Linux (WSL):

sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
sudo apt-get install gcc-arm-embedded
sudo apt update
sudo apt install gcc-arm-embedded


2. Install Nordic's [command line
tools](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf5x_cltools%2FUG%2Fcltools%2Fnrf5x_installation.html)
`mergehex` and `nrfjprog`. Ensure these tools are extracted and added to your path.
For WSL: install the `nrfjprog` for Windows, and not for Linux.
For WSL: install the `nrfjprog` for Windows [installed with nRF-Command-Line-Tools for Windows]([nRF-Command-Line-Tools for Windows](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF5-Command-Line-Tools/Download#infotabs)), and not for Linux. You don't need the JLink software and JLink JTAG programmer for WSL.

3. Install the JLink [software](https://www.segger.com/jlink-software.html)
for your platform. You want the "Software and documentation pack".
Expand Down
19 changes: 8 additions & 11 deletions make/Program.mk
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,27 @@ endif

.PHONY: flash
flash: all test_softdevice flash_mbr
$(Q)printf "r\n" > $(BUILDDIR)flash.jlink
ifdef ID
$(Q)printf "w4 $(ID_FLASH_LOCATION), 0x$(ID_SECON) 0x$(ID_FIRST)\n" >> $(BUILDDIR)flash.jlink
endif
ifeq ($(strip $(grep -q Microsoft /proc/version)),)
@echo Flashing: $(HEX)
nrfjprog.exe -f nrf52 --program $(HEX) --sectorerase
nrfjprog.exe -f nrf52 --reset
else ifeq ($(USE_BOOTLOADER),1)
ifdef ID
$(Q)printf "w4 $(ID_FLASH_LOCATION), 0x$(ID_SECON) 0x$(ID_FIRST)\n" >> $(BUILDDIR)flash.jlink
endif
$(Q)printf "r\n" > $(BUILDDIR)flash.jlink
$(Q)printf "loadfile $(MERGED_HEX) \nr\ng\nexit\n" >> $(BUILDDIR)flash.jlink
$(Q)$(JLINK) $(JLINK_FLAGS) $(BUILDDIR)flash.jlink
else ifeq ($(USE_BOOTLOADER),0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also want to leave this line as just an else with no check. USE_BOOTLOADER may not be defined at all, in which case it won't be equal to zero.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, the better design might just be to leave the logic that creates the flash.jlink file alone. It shouldn't hurt anything to create that file on windows even if you don't use it. Then you can create one if check that decides if you're windows and uses nrfjprog or else falls back on the existing JLINK infrastructure

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, ifeq ($(USE_BOOTLOADER),) will evaluate to true if the variable is undefined

ifdef ID
$(Q)printf "w4 $(ID_FLASH_LOCATION), 0x$(ID_SECON) 0x$(ID_FIRST)\n" >> $(BUILDDIR)flash.jlink
endif
$(Q)printf "r\n" > $(BUILDDIR)flash.jlink
ShishirPatil marked this conversation as resolved.
Show resolved Hide resolved
$(Q)printf "loadfile $(HEX) \nr\ng\nexit\n" >> $(BUILDDIR)flash.jlink
$(Q)$(JLINK) $(JLINK_FLAGS) $(BUILDDIR)flash.jlink
endif


flashWSL: all test_softdevice flash_mbr
@echo Flashing: $(OUTPUT_DIRECTORY)/toxophilite.hex
$(nrfjprog.exe) -f nrf52 --program $(OUTPUT_DIRECTORY)/toxophilite.hex --sectorerase
$(NRFPROG) -f nrf52 --reset



.PHONY: test_softdevice
test_softdevice: $(BUILDDIR)
ifneq ($(SOFTDEVICE_MODEL),blank)
Expand Down
5 changes: 3 additions & 2 deletions make/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ originally comes from

We develop on Linux. This also works on Windows in either of the following ways:
1. Build on WSL (Windows Subsystem for Linux), and `flash` with WSL.
2. Build with SES (Segger Embedded Studio) and `flash` with WSL. Note: For this you will have to manually move the `.hex` file generated from SES to `build/` directory. For e.g. `mv blinky/pca10040/s132/ses/Output/Release/Exe/blinky_pca10040_s132.hex blinky/_build/blink_sdk16_blank.hex`.
2. Build with SES (Segger Embedded Studio) and `flash` with WSL. Note: For this you will have to manually move the `.hex` file generated from SES to `_build/` directory. For e.g. `mv [your_application]/pca10040/s132/ses/Output/Release/Exe/[your_application.hex] [your_application]/_build/[your_application.hex]`.

The currently supported SDK versions are: 9, 10, 11

Expand All @@ -18,7 +18,8 @@ Things to Install
1. `gcc-arm-none-eabi`: https://launchpad.net/gcc-arm-embedded
2. gdb-arm-none-eabi
3. The [jlink tools](https://www.segger.com/jlink-software.html) for linux / windows for WSL
4. The jlink debuger for linux [OR] jlink debuger for Windows for WSL/SES
4. The jlink debuger for linux
5. The [nRF-Command-Line-Tools for Windows](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF5-Command-Line-Tools/Download#infotabs)

Usage
-----
Expand Down