diff --git a/boards/pic32-wifire/Makefile.include b/boards/pic32-wifire/Makefile.include index 823d462545..31747d23b5 100644 --- a/boards/pic32-wifire/Makefile.include +++ b/boards/pic32-wifire/Makefile.include @@ -1,4 +1,17 @@ export APPDEPS += $(RIOTCPU)/$(CPU)/$(CPU_MODEL)/$(CPU_MODEL).S export USE_UHI_SYSCALLS = 1 -FLASHFILE ?= $(HEXFILE) +PORT_LINUX ?= /dev/ttyUSB0 +BAUD ?= 9600 +include $(RIOTMAKE)/tools/serial.inc.mk + +# pic32prog +# +# For PICkit3: +# +# * Connect the chipKIT-Wi-Fire to USB +# * Connect the PICkit3 to ICSP holes +# * https://docs.creatordev.io/wifire/guides/wifire-programming/ +# * The triangle `▶` goes into the port number 1 (a hole with a square around it) +# opposite side of the JP1 ICSP text. +include $(RIOTMAKE)/tools/pic32prog.inc.mk diff --git a/dist/tools/pic32prog/.gitignore b/dist/tools/pic32prog/.gitignore new file mode 100644 index 0000000000..fd1ef9040c --- /dev/null +++ b/dist/tools/pic32prog/.gitignore @@ -0,0 +1,2 @@ +pic32prog +bin/ diff --git a/dist/tools/pic32prog/Makefile b/dist/tools/pic32prog/Makefile new file mode 100644 index 0000000000..d308c88f1d --- /dev/null +++ b/dist/tools/pic32prog/Makefile @@ -0,0 +1,19 @@ +PKG_NAME = pic32prog +PKG_URL = https://github.com/sergev/pic32prog +PKG_VERSION = b9f8db3b352804392b02b42475fc42874ac8bf04 +PKG_LICENSE = GPL-2 +PKG_BUILDDIR = bin + +# Building it requires some dependencies, on ubuntu: +# +# sudo apt-get install libusb-dev libusb-1.0-0-dev libudev-dev + +all: git-download + @echo "[INFO] compiling pic32prog from source now" + @env -i PATH=$(PATH) TERM=$(TERM) make -C $(PKG_BUILDDIR) + @mv $(PKG_BUILDDIR)/pic32prog pic32prog + +distclean:: + @rm -f pic32prog + +include $(RIOTBASE)/pkg/pkg.mk diff --git a/makefiles/tools/pic32prog.inc.mk b/makefiles/tools/pic32prog.inc.mk new file mode 100644 index 0000000000..6597ba604f --- /dev/null +++ b/makefiles/tools/pic32prog.inc.mk @@ -0,0 +1,46 @@ +# pic32prog flasher +# ================= +# +# https://github.com/sergev/pic32prog +# +# Allow flashing pic32 boards using: +# * Microchip PICkit2 +# * Microchip PICkit3 with script firmware +# +# +# PICkit-3 +# -------- +# +# This requires changing the firmware to 'scripting mode' +# Should be done from a Windows computer/virtual machine as described here +# +# https://github.com/RIOT-OS/RIOT/blob/master/dist/tools/pic32prog/doc.md +# +# +# Udev rule +# --------- +# +# Add yourself to the `plugdev` group, add the following `udev` rule to +# `/etc/udev/rules.d/26-microchip.rules` and reboot. +# +# ``` +# # Adapted from http://en.microstickplus.com/mplabx-on-linux +# ATTR{idVendor}=="04d8", MODE="664", GROUP="plugdev" +# ``` + +RIOT_PIC32PROG = $(RIOTTOOLS)/pic32prog/pic32prog +PIC32PROG ?= $(RIOT_PIC32PROG) + +FLASHFILE ?= $(HEXFILE) + +FLASHER ?= $(PIC32PROG) +FFLAGS ?= $(FLASHFILE) + +# No reset command, but the board resets on terminal open +RESET ?= +RESET_FLAGS ?= + +# Compile pic32prog if using the one provided in RIOT +ifeq ($(PIC32PROG),$(RIOT_PIC32PROG)) + FLASHDEPS += $(RIOT_PIC32PROG) +endif diff --git a/makefiles/tools/targets.inc.mk b/makefiles/tools/targets.inc.mk index 74f1de61d1..f80fa73b31 100644 --- a/makefiles/tools/targets.inc.mk +++ b/makefiles/tools/targets.inc.mk @@ -12,6 +12,11 @@ $(RIOTTOOLS)/bossa/bossac: @make -C $(RIOTTOOLS)/bossa @echo "[INFO] bossac binary successfully build!" +$(RIOTTOOLS)/pic32prog/pic32prog: $(RIOTTOOLS)/pic32prog/Makefile + @echo "[INFO] $(@F) binary not found - building it from source now" + make -C $(@D) + @echo "[INFO] $(@F) binary successfully build!" + $(RIOTTOOLS)/edbg/edbg: $(RIOTTOOLS)/edbg/Makefile @echo "[INFO] edbg binary not found - building it from source now" CC= CFLAGS= make -C $(RIOTTOOLS)/edbg