chipKIT32 boot loader

chipKIT Pi USB standalone

chipKIT Pi USB power

chipKIT Pi breadboard edition

This project is a fork of the chipKIT bootloader for the chipKIT Pi.

The fork exists because the original is designed to compile with the commercial version of the Microchip XC32 compiler, this version builds with the freeware chipKIT MPIDE compiler instead.

This fork also introduces support for the MX270 processor and also the removal of the requirement to press BOOTLOAD-EN to upload firmware, just a reset will do.

Build

First install the PIC32 MPIDE compiler for the RPi.

Now we can fetch and build the firmware package.

hg clone http://hg.kewl.org/pub/chipKITPi
cd chipKITPi
make

If we inspect the firmware build directory we can see the resultant firmware hex files.

ls -1 firmware/*hex
firmware/BREADBOARD_9600.hex
firmware/BREADBOARD.hex
firmware/CHIPKIT_DP32_48.hex
firmware/CHIPKIT_DP32_MX270_48.hex
firmware/CHIPKIT_PI_48.hex
firmware/CHIPKIT_PI.hex
firmware/CHIPKIT_PI_MX270_48.hex
firmware/CHIPKIT_PI_MX270.hex
firmware/CHIPKIT_PI_MX270_USB_48.hex
firmware/CHIPKIT_PI_USB_48.hex
firmware/CHIPKIT_PI_USB.hex
firmware/MAJENKO_SDXL.hex 

The top four files are experimental breadboard firmware, the others are for the chipKIT Pi except for the last one which is for the Majenko SDXL.

The chipKIT Pi firmware targets the MX250 processor except where is obviously targets the enhanced PIC32 processor, the MX270.

If the USB firmware is loaded onto the chipKIT Pi then it no longer needs to be attached to the RPi to operate, however, it cannot stand upright (top picture).

If the chipKIT Pi is attached to the RPi and its USB port is connected to a powered hub then it may power the complete unit (2nd top picture). In this configuration the RPi can be made into a USB device with some programming. Please note that the RPi is powered via the GPIO header in this configuration. Do not connect the RPi micro-usb power simultaneously.

The breadboard firmwares are the only ones which don't require a crystal. The target device is the MX250 with the internal oscillator at 40MHz. The pin configuration is the same as the chipKIT Pi. The 9600 version operates at 9600 baud for upload rather than the standard 115200 baud.

One difference between this firmware and the original is that the BOOTLOAD-EN button is disabled in the boot loader and instead the boot loader will wait a moment after reset for an upload. Pickle's `pctrl restore' may be used to reset the chip when the chipKIT Pi is attached to a RPi.

ICSP

To load a new firmware on the chipKIT Pi we need to utilise in circuit serial programming (ICSP).

The chipKIT Pi board has ICSP wired internally and no wiring is necessary in order to perform this operation. This means that no extra hardware is required only software is required.

PIC32MX250F128B         RASPBERRY Pi
===============         ============

1       !MCLR  --330R-- GPIO4
4       PGD1   -------- GPIO15 Rx
5       PGC1   -------- GPIO14 Tx

The ICSP pins on the PIC32 are also shared with the UART interface, we need to be careful to reassign the pins after any programming. For the breadboard edition (bottom picture) resistors may be placed on the PGD/Rx PGC/Tx pins for safety in the event of misconfiguration.

Programming

Pickle is the tool we will use to interrogate and program the firmware into the chip.

Pickle has a number of configuration options as described on the pickle page.

Configuration
DEVICE=RPI
SLEEP=1
BITRULES=0x4F00
VPP=4
PGC=14
PGD=15
PGM=-1

The BITRULES release the RPi GPIOs after programming and return GPIO14/15 to the UART mode of operation for uploading objects to the bootloader.

Detect chip

When installed and configured we can test the tool by detecting the installed chip. Detection works for all devices whether they contain a firmware or not.

p32 id
[1D000000] [PROGRAM]  00010000 WORDS
[1F80F220] [DEVICEID] 26600053 PIC32MX270F256B
[1FC00000] [BOOT]     00000300 WORDS
[1FC00BF0] [DEVCFG3]  0FFFFFFF
[1FC00BF4] [DEVCFG2]  FFF979F9
[1FC00BF8] [DEVCFG1]  FF6A0E5B
[1FC00BFC] [DEVCFG0]  7FFFFFFB
           [PE]       RIPE_11_000301.bin
Firmware

Now we will program the standard UART firmware for the MX270 running at a top speed of 48 MHz.

p32 program firmware/CHIPKIT_PI_MX270_48.hex
Total: 2900
p32 verify firmware/CHIPKIT_PI_MX270_48.hex
Total: 2900 Fail: 0

Demo

We can upload an LED demo to the bootloader firmware installed above.

First ensure that the serial UART is free (not USB boot loader).

To enter upload mode, perform the following steps.

  1. Press RESET
  2. Release RESET

When attached to an RPi reset may be performed with `pctrl restore' rather than pressing the reset button.

For the MX250.

pload program /dev/ttyAMA0 led/mx250.hex 24

Or, the MX270.

pload program /dev/ttyAMA0 led/mx270.hex 24

This uploads the hex file using 24-bit addressing mode required by the ChipKitPi AVR boot loader.

If you have used the USB bootloader then a virtual com port should have been detected called ttyACM0 and you would use this instead of ttyAMA0 above.

Here is the detection log from dmesg.

usb 1-1.1.4: new full-speed USB device number 23 using ehci-pci
usb 1-1.1.4: New USB device found, idVendor=0403, idProduct=a662
usb 1-1.1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.1.4: Product: Stk500v2
usb 1-1.1.4: Manufacturer: www.cpustick.com
cdc_acm 1-1.1.4:1.0: This device cannot do calls on its own. It is not a modem.
cdc_acm 1-1.1.4:1.0: ttyACM0: USB ACM device
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies