New experimental USB stack

We in the chipKIT programming dungeons have been slaving away for the past few weeks to bring you a new, long awaited, USB stack for your USB-based chipKIT boards.

Finally we can say the PIC32MZ based boards have full USB support!

Continue reading New experimental USB stack

VN:F [1.9.22_1171]
Rating: 10.0/10 (3 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

HelveKit Robot: A chipKIT Robot Design

HelveKit Robot

There are plenty of “how to design a robot” tutorials out there; this is not one of them. Why is this one different? Because the author, GastonLagaffe, doesn’t want to tell you what to do, as he doesn’t want to limit your creativity. 🙂 His personal goals for this robot were for it to be small, autonomous, cheap, easy to solder, easy to program, with plenty of holes, and swarm capable, and although the journey to get from concept to implementation took him 12 months, he learned a lot along the way.

So if you want to make a robot, why not dream big as you read about how Gaston took what started as a small wish and made it a reality, Gaston-style. To see his journey, check out this HelveKit Robot Design Journey on Instructables. You may smile as you see his approach and decide you would have done it differently, but that’s exactly what Gaston would want you to do!

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

HelvePic32 chipKIT-based Thru-Hole Beginner Board

HelvePic32 chipKIT-based board by Dr. Mathias Wilhelm
HelvePic32 chipKIT-based board by Dr. Mathias Wilhelm

Rejoice! A new chipKIT-based board is born! Dr. Mathias Wilhelm describes his brilliant design, the HelvePic32, a board to which he’s obviously given a lot of thought. This board incorporates the PIC32MX250F128B MCU and uses the chipKIT DP32 bootloader. However, the HelvePic32 expands on the through-hole concept and provides more components and headers, so it makes for a sort of expanded DP32 board. The pinouts are organized for convenient use and he explains all of this and more in his beginner-friendly tutorial. Check it out, and see Dr. Wilhelm describe why he selected the 32-bit chipKIT embedded platform for his HelvePic32 board.

VN:F [1.9.22_1171]
Rating: 9.0/10 (6 votes cast)
VN:F [1.9.22_1171]
Rating: +3 (from 3 votes)

How to Restore a chipKIT Bootloader

How to connect a PICkit 3 programmer, leaving the Power Jack and USB port accessible
How to connect a PICkit 3 programmer, leaving the Power Jack and USB port accessible

Did you know that chipKIT boards can also be used as generic embedded controllers? chipKIT-compatible boards can be programmed not only with MPIDE or UECIDE, but also in several other IDEs using programming languages such C, C++, Pascal or Basic. When using another IDE such as MPLAB X, the chipKIT bootloader may become erased or over-written, which is fine, if you plan to stick with that environment. However, if you want to use MPIDE or UECIDE again after your bootloader has been erased, you’ll need to restore the chipKIT bootloader. To do so, you can follow the Restore Your chipKIT Bootloader Guide with step-by-step instructions and lots of pictures. Knowing how to do this might save you from a massive headache 😉

Good luck!

VN:F [1.9.22_1171]
Rating: 9.8/10 (4 votes cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Remote programming a chipKIT Pi

So you have a chipKIT Pi, which you have dutifully attached to a Raspberry Pi, and you’d like to deploy it “in the field” (with the cows). That’s fair enough. What you’d like to be able to do, though, is upgrade the firmware on the chipKIT Pi without having to go into the field (those cows are scary, man!).

pi-on-pi

So how would you do that? You can’t program the chipKIT Pi without pressing the RESET and BOOTLOAD-EN buttons (and you’re not about to train cows to do that for you), so what are your options?

Well, UECIDE has the answer for you.

pi-modFirst you will need to modify your chipKIT Pi. Don’t worry, it’s only a simple small modification. Basically you need to connect the BOOTLOAD-EN signal to one of the GPIO pins on the Raspberry Pi header.

Connect pin 8 of the chipKIT Pi pass-through header (GPIO17 on the Raspberry Pi) to the nearest pin of JP6 with a piece of fine wire. I use 30AWG wire-wrapping wire. This will allow the Raspberry Pi to trigger the bootloader automatically (hopefully future versions of the chipKIT Pi will have this modification in place already).

Now you can enter programming mode from the Raspberry Pi by setting GPIO 17 to an output and driving it LOW, then setting GPIO 4 to an output and driving that low too (it is connected to RESET), then releasing both the GPIO lines in reverse order. It’s good to put a short delay between releasing GPIO 4 and GPIO 17.

To make things even easier we have a chipKIT Pi support package in our Debian repository. Add the repository to your /etc/apt/sources.list file:

$ sudo nano /etc/apt/sources.list

Add the line:

deb http://dist.majenko.co.uk/ stable main

You can also add our signing key so it doesn’t ask if you want to install unauthorized packages:

$ wget -O - http://dist.majenko.co.uk/key.asc | sudo apt-key add -

The package is called “ckpi-support” and it sets up all you will need in order to program the chipKIT Pi remotely from UECIDE. It will:

  • Install avahi-daemon (if not already installed)
  • Configure a “ckpi” user
  • Install “pic32prog”
  • Install scripts for controlling the chipKIT Pi:
    • ckpi-reboot (reboots the chipKIT Pi)
    • ckpi-program (reboots the chipKIT Pi and triggers the bootloader)
  • Install an mDNS service so UECIDE can find the board on the network

So go ahead and install the package now:

$ sudo apt-get update
$ sudo apt-get install ckpi-support

If all goes well it will have asked you for a new password to give to the “ckpi” user. Remember this, as you will want it again later.

One more small modification you will need to make (if you haven’t done it in the past) is to disable the “getty” process on /dev/ttyAMA0 (the serial port).

First edit (as root) the file /boot/cmdline

$ sudo nano /boot/cmdline

Remove from that file any references to ttyAMA0 (there should be a console= entry in one line that points to it – remove it) and save the file.

DEBIAN WHEEZY

Edit the file /etc/inittab

$ sudo nano /etc/inittab

and look for the line:

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

It is most probably right at the end of the file. Comment the line out by placing a # at the start of it and save the file out. You can now either reboot to enable the change, or trigger a reload of the file:

$ sudo kill -HUP 1

Now you’re good to go!

DEBIAN JESSIE

Disable and permanently kill the serial-getty service:

$ sudo systemctl disable serial-getty@ttyAMA0
$ sudo systemctl mask serial-getty@ttyAMA0

You might need to reboot after this to restore the /dev/ttyAMA0 permissions back to what they should be since the getty service leaves them in a rather odd state.

Now on to the UECIDE side of things… 

You’ll need the latest version of UECIDE as it has the networking support you’ll be using, so if you aren’t already running it then go ahead and download it. This is the version for your PC of course, not for the Pi. You don’t need it on the Pi.

Load UECIDE up, ensure the chipKIT Pi board is installed (and the latest version), and after a few moments it should detect the Raspberry Pi for you:

detected

You should now be able to select the board from the “Discovered Boards” menu:

discovered

And there should now be a suitable entry in the “Programmers” menu:

bootloader

Important note: Those images are from a slightly older version of UECIDE.  The current version lists the boards under the “Devices” menu in Hardware, not “Discovered Boards”.  Also it doesn’t currently notify you of boards as it finds them. Just check the menu to see if the board is there.

Now you can just compile and upload your sketch as if you were directly connected to the chipKIT Pi. The first time you upload it will ask you for the password for the “ckpi” user – the password you entered when installing the support package. If you want you can tell UECIDE to save the password forever (it puts it in your preferences.txt file), but even if you don’t do that it will still remember it for the rest of your session so you won’t need to re-enter it again until you next load UECIDE.

upload

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

USB Bootloader

The PIC32-avrdude-bootloader communicates over either a serial port (UART) or the USB port (on those pic32 chips that support USB.)  It can be built for either serial or USB communication with the PC. The bootloader communicates with the avrdude executable on the PC side of the connection. The following boards have been tested using the PIC32-avrdude-bootloader:
  • Microchip PIC32 USB starter kit
  • Microchip PIC32 Ethernet starter kit
  • UBW32 – MX460
  • UBW32 – MX795
  • Fubarino SD
  • Fubarino Mini
In order to use this bootloader, you can either download the full source from github, or just pick and choose the HEX file that is right for your board. There are three bootloaders that have been created for chipKIT and chipKIT compatible boards:
  • PIC32-avrdude-bootloader – This new bootloader for MPIDE/chipKIT PIC32 boards is buildable for all currently available  chipKIT boards (UNO32, MAX32, uC32) as well as other PIC32 based boards like the UBW32 and Fubarino boards.
  • pic32-Arduino-USB-Bootloader-original – This is the original version of the bootloader that works only if compiled with the C32 v1.xx version due to changes in the way that newer version of C32/XC32 handles the linker scripts files.
  • pic32-Arduino-Bootloader – This is the older original version of the bootloader which supports only Digilent uno and mega pic32 boards.This bootloader is compatible with v5.8 of avrdude.
  • For Digilent pic32 boards, it is highly recommended to download the Digilent official bootloader from the Digilent website at http://www.digilentinc.com/.
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Using USB

The PIC32MX3xx series parts do not have a USB controller. The other PIC32 series (i.e. PIC32MX4xx/5xx/6xx/7xx) all have a USB controller. The Uno32 uses a PIC32MX320F128H and therefore does not have a USB controller. The Uno32 and Max32 have standard FTDI serial to USB interface chips (FT232R) to keep consistent with the Arduino way of interfacing. However, it is also nice to be able to use the built in USB port. Many other PIC32 boards have this USB port brought out to a standard connector such as the Microchip USB Starter Kit and the Digilent Cerebot 32MX4 and Cerebot 32MX7. The latest version of HardwareSerial.cpp now supports the first serial port (Serial.begin(), Serial.print() etc) can be reconfigured to use the USB port instead. In order to take full advantage of this, first you have to program the board with the USB bootloader, then use the appropriate board setting in the BOARDS menu. If you are using a custom board in the boards file you can just add the following to your board description: custom_pic32.compiler.define=-D_USE_USB_FOR_SERIAL_ When using the USB for Serial, UART1 becomes Serial0 Serial1 etc, are still there normal configurations Serial.begin(baudrate); //The baudrate is ignored, when doing real USB, there is no baudrate. Receive is interrupt driven and behaves EXACTLY like regular Serial. NO CODE CHANGES REQUIRED. If you want to see how this is done, look at HardwareSerial.h and HardwareSerial.cpp, the actual usb code is in HardwareSerial_cdcacm.c and HardwareSerial_usb.c. The USB code was written by Rich T (http://www.cpustick.com/) More documentation will be provided on how to do this soon. (Created 7/3/2011)
VN:F [1.9.22_1171]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)