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 4 commits
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
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,25 @@ 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:

brew tap ArmMbed/homebrew-formulae
brew install arm-none-eabi-gcc

On Windows Subsystem for Linux (WSL):

sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
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 [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
18 changes: 14 additions & 4 deletions make/Program.mk
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,26 @@ endif

.PHONY: flash
flash: all test_softdevice flash_mbr
$(Q)printf "r\n" > $(BUILDDIR)flash.jlink
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
ifeq ($(USE_BOOTLOADER),1)
$(Q)printf "r\n" > $(BUILDDIR)flash.jlink
$(Q)printf "loadfile $(MERGED_HEX) \nr\ng\nexit\n" >> $(BUILDDIR)flash.jlink
else
$(Q)printf "loadfile $(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
$(Q)printf "loadfile $(HEX) \nr\ng\nexit\n" >> $(BUILDDIR)flash.jlink
$(Q)$(JLINK) $(JLINK_FLAGS) $(BUILDDIR)flash.jlink
endif


.PHONY: test_softdevice
test_softdevice: $(BUILDDIR)
Expand Down
9 changes: 5 additions & 4 deletions make/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ This folder contains the GCC build system for the nRF5x platforms. It
originally comes from
[hlnd/nrf51-pure-gcc-setup](https://github.com/hlnd/nrf51-pure-gcc-setup).

We develop on Linux. Original files still exist for Windows, but have not been
tested in some time. Feel free to submit a pull request if you find something
that doesn't work.
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 [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 @@ -17,8 +17,9 @@ 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
3. The [jlink tools](https://www.segger.com/jlink-software.html) for linux / windows for WSL
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