From d852ca2b2121cb28966d91cc3134f6673eebc38d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 31 May 2018 16:38:58 +0200 Subject: [PATCH 1/5] pic32prog: add pic32prog programming tool pic32prog is a program for flashing pic32 boards from command line on Linux. It works with: * Microchip PICkit2 * Microchip PICkit3 with script firmware. * Other ones: https://github.com/sergev/pic32prog/wiki --- dist/tools/pic32prog/.gitignore | 2 ++ dist/tools/pic32prog/Makefile | 19 +++++++++++++++++++ makefiles/tools/targets.inc.mk | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 dist/tools/pic32prog/.gitignore create mode 100644 dist/tools/pic32prog/Makefile 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/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 From afdddfda143059fdcaf3f76e1174f3cc50a28b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 31 May 2018 16:55:13 +0200 Subject: [PATCH 2/5] pic32prog.inc.mk: add support for pic32prog flasher Define a RIOT_PIC32PROG to allow setting 'PIC32PROG' globally from environment. https://github.com/sergev/pic32prog For PICkit3 it requires having it with scripting mode firware. Source ------ https://github.com/RIOT-OS/RIOT/pull/6092#issuecomment-261987955 --- makefiles/tools/pic32prog.inc.mk | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 makefiles/tools/pic32prog.inc.mk diff --git a/makefiles/tools/pic32prog.inc.mk b/makefiles/tools/pic32prog.inc.mk new file mode 100644 index 0000000000..c7a792c211 --- /dev/null +++ b/makefiles/tools/pic32prog.inc.mk @@ -0,0 +1,34 @@ +# 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 + +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 From 773419e29cc4dc22d50622bc685e7d9f196bc4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 31 May 2018 17:00:08 +0200 Subject: [PATCH 3/5] pic32-wifire: add serial configuration --- boards/pic32-wifire/Makefile.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boards/pic32-wifire/Makefile.include b/boards/pic32-wifire/Makefile.include index c07595ef98..732eede6fc 100644 --- a/boards/pic32-wifire/Makefile.include +++ b/boards/pic32-wifire/Makefile.include @@ -3,4 +3,8 @@ export CPU_MODEL=p32mz2048efg100 export APPDEPS += $(RIOTCPU)/$(CPU)/$(CPU_MODEL)/$(CPU_MODEL).S export USE_UHI_SYSCALLS = 1 +PORT_LINUX ?= /dev/ttyUSB0 +BAUD ?= 9600 +include $(RIOTMAKE)/tools/serial.inc.mk + FLASHFILE ?= $(HEXFILE) From 4eeda215e00d08ac08eecf8cd1ba8b1e1d83c59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 31 May 2018 17:00:30 +0200 Subject: [PATCH 4/5] pic32-wifire: add flasher using pic32prog For PICkit3 it requires having a scripting firmware installed. --- boards/pic32-wifire/Makefile.include | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/boards/pic32-wifire/Makefile.include b/boards/pic32-wifire/Makefile.include index 732eede6fc..1653a8daad 100644 --- a/boards/pic32-wifire/Makefile.include +++ b/boards/pic32-wifire/Makefile.include @@ -7,4 +7,13 @@ PORT_LINUX ?= /dev/ttyUSB0 BAUD ?= 9600 include $(RIOTMAKE)/tools/serial.inc.mk -FLASHFILE ?= $(HEXFILE) +# 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 From be4569e271e29f673b03f96737d28ad76446bd99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Wed, 27 Jun 2018 10:53:09 +0200 Subject: [PATCH 5/5] pic32prog.inc.mk: add udev rule for pic32 programmer Copy the udev rule from dist/tools/pic32prog/doc.md --- makefiles/tools/pic32prog.inc.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/makefiles/tools/pic32prog.inc.mk b/makefiles/tools/pic32prog.inc.mk index c7a792c211..6597ba604f 100644 --- a/makefiles/tools/pic32prog.inc.mk +++ b/makefiles/tools/pic32prog.inc.mk @@ -15,6 +15,18 @@ # 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)