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)

The Arduino™ Blink Sketch on chipKIT DP32

Overview:

In this tutorial, the standard “Hello World” program (blinking LED) is used to help familiarize you with the chipKIT DP32 board and how it will interface with  the Multi-Platform Integrated Development Environment (MPIDE) and basic language functions.  

Reference:

During the course of this tutorial, various terms will be referenced including:
  • Sketch
  • Function
  • Variable
  • HIGH and LOW
  • INPUT and OUTPUT
We recommend that you read the following sections on the Arduino™ homepage to get a better understanding of these terms:

Hardware Used:

The hardware used in this tutorial will be the chipKIT DP32 manufactured by Digilent Inc. The reference guide for this board, schematics and other resources are available on the chipKIT DP32 homepage at: http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,1174&Prod=CHIPKIT-DP32  

Software Used:

In this tutorial, the chipKIT MPIDE will be used. If you haven’t already, follow the instructions at the links below to download MPIDE for your operating system:

Hardware Setup:

The DP32 can be powered in a number of ways including from the USB connection (J2) or over the screw terminal (J6). The user needs to select which method will be used to power the board by configuring the jumpers immediately next to the screw terminal as shown below:  

 jumper config

   

Procedure:

  1. Open MPIDE, by navigating to the extracted files in the folder you selected when you downloaded the source files. Locate the MPIDE executable (Windows® folder shown): openMPIDEopenMPIDE Double click the executable to open the MPIDE  Hint: At this point it is a good idea to create a shortcut to the mpide.exe and place on your desktop.
  2. The first time you open MPIDE, you will be notified that a “sketchbook folder” will be created. In Windows, this folder will be located in the “My Documents” directory. scketchbookFolder Click OK to continue.
  3. The MPIDE Window should appear. Note the following main areas of the IDE Window.MPIDE Workspace button overview
  4. The chipKIT MPIDE comes with a variety of examples that can be used to help explore some of the various features of both the MPIDE and the chipKIT Platform. To access these examples, select File>Examples.EXAMPLES Note that there are all kinds of examples from lighting an LED on the chipKIT Board to different types of displays.Under File>Examples>Basic, there is an example called Blink. This example blinks an LED on the chipKIT Board ON/OFF in 1 second intervals. This little program is what is known as the “Hello World” program as it is usually the first application new users create who are using a Microcontroller for the first time.This example could easily be opened and run as is. However, in order to highlight some of the features of the MPIDE, this example will be recreated from scratch.
  5. Click on the “New” button to open a new sketch window and then click “Save” button. Name the sketch something meaningful like DP32_Blink.  The default directory will be the mpide folder created when the MPIDE was first started. Note: If you navigate to the mpide folder, there will now be a new folder with the name of the sketch you just saved.
  6. In this part of the tutorial, you will create a simple routine that will blink LED 3 on the DP32.dp32 Add the following code into the MPIDE editor:
    int ledPin = 43;                 // LED connected to digital pin 26
    void setup()
    {
      pinMode(ledPin, OUTPUT);      // sets the digital pin as output
    }
    void loop()
    {
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(1000);                  // waits for a second
      digitalWrite(ledPin, LOW);    // sets the LED off
      delay(1000);                  // waits for a second
    }
  7. There are quite a few things going on with this sketch. Under the “References” section at the top of the page, links are provided that will explain much of the content.Next, we will upload our code to the DP32.
  8. Make sure that the chipKIT DP32 is connected via the mini-B connector on the board to an availableUSB port on the computer.
  9. In MPIDE, select Tools>Board>chipKIT>chipKIT DP32 to identify the DP32 Board as a target select boardselectboard

    Next, you will need to place the DP32 into “Programming” or “Bootloader” mode; otherwise, the sketch will not be able to be uploaded to the board. To enter into this mode, hold down the RESET button followed by the PGM button, then release the RESET button first, followed by the PGM button. You will know you’ve done this correctly if LED1 begins to flash repeatedly. dp32_BUTTONS

    When the DP32 is in Bootloader mode, LED1 on the board will begin to flash on/off.

  10. Next, select Tools>Serial Port>COMxx. This will depend on which port was assigned to the chipKIT DP32 Board when first connected.selectserialport
  11. To load your sketch onto the chipKIT DP32 board’s Microcontroller, press the upload button. This will compile your sketch (check for errors) and then send to the Microcontroller.
 

Verifying Operation:

After the sketch is sent to the chipKIT DP32 board’s Microcontroller, LED 3 on the chipKIT DP32 should flash on and off in 1 second intervals.  
VN:F [1.9.22_1171]
Rating: 6.5/10 (6 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 1 vote)

Future online laboratories through chipKIT

A few professionals have published a research paper “A novel concept for configuring online laboratories” with the use of PIC kit in the Experiment International Conference.  (See below abstract)

They are interested in doing this with chipKIT in the future. Abstract—Embedded online laboratories are becoming frequent nowadays, because they can include both the functionality of a data acquisition device and the functionality of a webserver and this, in turn, results in lower implementation costs. However, while it is easy to configure a laboratory server which is located on a computer, the local configuration and control of an embedded laboratory is more challenging, because of the lack of interactive peripherals (such as the keyboard is to a computer). This paper introduces a novel concept which allows administrators to easily achieve the local configuration of the embedded (on-chip) laboratory parameters (including network settings) by using a mobile device.

Reference: B.Deaky, T. F. Andrade, L. Parv, “A novel concept for configuring online laboratories”, in Proceedings of the 2nd Experiment@ International Conference — Online Experimentation (exp.at’13), Coimbra, Portugal, September 18-20, 2013, pp. 79 – 82.

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

TEN-TEC Introduces an open-source QRP transceiver powered by chipKIT Uno32

Rebel

TEN-TEC launched a new QRP transceiver based upon a completely different platform than any other rigs they have in production: a QRP radio, built on the chipKIT Uno32™ (Arduino-based software) to be known as the Model 506 Rebel.

The TEN-TEC Rebel model 506 transceiver is designed with the purpose of providing Ham Radio operators a platform for developing and writing code using the open-source Arduino programming environment. It is a factory built CW QRP radio with a Chip Kit Uno 32 Arduino compatible processing unit that holds the operating program. The radio is provided with programming for basic operating functions that allow it to be used immediately as a basic QRP transceiver. Additional operating functions can be programmed by the user, either by writing the code or copying/adapting code developed by members of a growing  number of Arduino special interest groups. It is this sharing of programming routines and ideas for functionality that is the heart of the Arduino open-source concept.

Basic features include a 40 & 20 meter QRP transceiver with internal jumpers to change bands.  Full band coverage on both bands.  Typical power output will run 4-5 watts with 13.5 VDC.  A drift free operation is achieved through DDS synthesizer technology.  CW sidetone through headphones. Three filter bandwidth choices and three tuning rate adjustments included with the stock program.

You can check the details at the product webpage 

Tom Witherspoon, a hobbyist, wrote a review for the Rebel at his website QRPer

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