chipKIT® Development Platform

Inspired by Arduino™

Remote programming a chipKIT Pi

Created Tue, 16 Feb 2016 10:21:20 +0000 by keithsloan52


keithsloan52

Tue, 16 Feb 2016 10:21:20 +0000

I am trying to setup remote programming of a chipKIT Pi.

I found [url]http://chipkit.net/remote-programming-a-chipkit-pi/[/url]

But I have the following problems

  1. dist.majenko.co.uk does not seem to exist
  2. The latest version of Rasbian is jessie not wheeze as used at the time of the article

majenko

Tue, 16 Feb 2016 10:23:53 +0000

Hmmm... I'll have to see if I can dig out the old Pi scripts. It's been a while since I looked at that.

UECIDE's latest downloads though are here: http://uecide.org/download

Wheezy, jessie, it shouldn't matter. The Pi side of things is mostly shell scripts anyway.


majenko

Tue, 16 Feb 2016 10:46:24 +0000

Damn, I really can't find those old scripts! No idea where they might have gone...!

Never mind, it won't take me long to re-create them - as long as I can set up the old Pi again :/


keithsloan52

Tue, 16 Feb 2016 11:53:06 +0000

Before I found the chpKIT forum item I was going to try and use a couple of socat or netcat commands to forward a serial port on the Mac to the serial port to a serial port on the Pi. i.e. One socat command running on Mac listening on a port and forwarding to a tty on the Mac and another socat comand on the pi forwarding /dev/ttyS0 to the tcp port on the Mac, but I could not figure out how to tell uecide to use a certain serial port


majenko

Tue, 16 Feb 2016 14:20:26 +0000

This is actually proving harder than I was thinking... Not the UECIDE side of things - but the Raspberry Pi side of things. For a start avrdude that installes via apt-get is much too new a version to work with the chipKIT boards, so I have to adapt it all to use pic32prog now, and I can't get that to work right at the moment either... :(


keithsloan52

Tue, 16 Feb 2016 14:51:02 +0000

I am using the boot loaders available at [url]http://wiki.kewl.org/dokuwiki/projects:chipkit32[/url] by Darron Broad

They are a fork of the official bootloader and you can use an open source compiler to build these versions, where as the official one you need to have a paid for version of microchips C complier.

Just install the C compiler that he links to. Grab the repository - To run the hg command on raspberry pi you have to install with sudo apt-get install mercurial

To load the bootloader I use pickle see [url]http://wiki.kewl.org/dokuwiki/projects:pickle#installation[/url]


keithsloan52

Tue, 16 Feb 2016 14:57:16 +0000

How do I tell UECIDE to use a certain tty?

If I could set the tty it uses then I feel I could program the chipKIT pi via the Raspberry Pi using a couple of socat commands.


majenko

Tue, 16 Feb 2016 14:59:07 +0000

I have it all working now. I am just building packages of what's needed - you'll need to update the ckPi in UECIDE. I'll update the blog post with updated details of what and where things are.


majenko

Tue, 16 Feb 2016 15:29:48 +0000

Adding extra serial ports is only supported under Linux, but it might be possible to "fool" it into working on OS X.

You will need to edit the preferences.txt file in your UECIDE data folder and add the line:

editor.serial.port.0=/dev/cu.whatever.it.is

No guarantees that it'd work in OS X, but worth a try. Also note that your socat/netcat way of doing things wouldn't deal with entering the bootloader like the ckpi-support scripts do. You'd still have to do that manually.


majenko

Tue, 16 Feb 2016 15:30:40 +0000

Ok, I have updated the blog post with slight changes to the details there. Mostly it's the same.


majenko

Tue, 16 Feb 2016 15:39:07 +0000

If you're interested in how it all works, and also so they don't get lost again, all the pi-side of things is on github: https://github.com/UECIDE/ckpi-support


keithsloan52

Tue, 16 Feb 2016 16:02:36 +0000

My UECIDE on the Mac 0.8.8alpha22 is not seeing the Raspberry Pi.

How can I check the mDNS service is up and running okay,

BTW in your instructions on Jessie /boot/cmdline is now /boot/cmdline.txt ( Well it is on my system )


majenko

Tue, 16 Feb 2016 16:06:18 +0000

I have absolutely no idea on the mac. On Linux I use avahi-browse -a but that won't work on OS X.


majenko

Tue, 16 Feb 2016 16:47:04 +0000

If you want to specify the IP address of the Pi manually so it doesn't rely on mDNS to find it you can add this to the top of your sketch:

#pragma parameter ip=192.168.0.38

That will then use the IP you provide there for the upload.

Also useful if the Pi is on a different network segment, or on the internet somewhere.


keithsloan52

Tue, 16 Feb 2016 17:08:17 +0000

Okay I installed UECIDE on a Linux machine and the Pi does not show up avahibrowse output as follows [attachment=0]list.txt[/attachment]

The machine I am trying to program via is pi-three

I checked the etc/avahi/services/ckpi.service and its there on the Pi. I tried a reboot.

I note the service uses port 22, Does that not clash with ssh?

Tried the #pragma and get a Timestamp error

Until I get a new crystal my bootloader only works at 9600. Is there a way to tell it to use 9600


majenko

Tue, 16 Feb 2016 17:14:11 +0000

The timestamp error might be because of a difference in clock times between the Pi and your computer.

The avahi service just advertises a port, it doesn't "use" a port. You can have as many services pointing to the same port as you like. UECIDE uses SSH to copy the hex file across and then

To change the baud you will need to edit the chipkit-pi board.txt file to add a baud rate (-b 9600) to the pic32prog command:

upload.pissh.script.3=__builtin_ssh::${board.user}@${ip}::ckpi-program && pic32prog -S -d /dev/ttyAMA0 -b 9600 /tmp/${filename}.hex && ckpi-reboot

majenko

Tue, 16 Feb 2016 17:27:06 +0000

In fact you can edit the command to be anything you want that meets your needs. That whole block of text in the board.txt file is a script that copies the file and executes commands to upload. You can write your own script to do your own things if you like - even using socat and netcat and things to transfer data.


keithsloan52

Tue, 16 Feb 2016 17:41:17 +0000

Okay my board file in Users/keith/Library/uecide/boards/chipKIT/chipkit-pi Had

upload.pissh.script.3=__builtin_ssh::${board.user}@${ip}::ckpi-program && avrdude -V -p${build.mcu} -P/dev/ttyAMA0 -b${upload.speed} -C/etc/avrdude-ckpi.conf -cstk500v2 -Uflash:w:/tmp/${filename}.hex:i ${verbose} && ckpi-reboot

I assume because you altered your system and I have the installed dmg from a few days ago.

I changed to upload.pissh.script.3=__builtin_ssh::${board.user}@${ip}::ckpi-program && pic32prog -S -d /dev/ttyAMA0 -b 9600 /tmp/${filename}.hex && ckpi-reboot

Added the #pragma ip=192.168.1.17

Now I get an error following Uploading firmware image com.jcraft.jsch.JSchException : Algorithm negotiation fail


majenko

Tue, 16 Feb 2016 17:48:12 +0000

Updating the chipkit Pi board in the plugin manager should have changed all that. It should also have added a few other things to the file as well that were stopping it from finding the board with mDNS. You did update the board like I said, didn't you?


keithsloan52

Tue, 16 Feb 2016 20:18:04 +0000

Sorry about that. I got mislead as it says latest available 10.9.0 installed 10.9.0 I had to click refresh to see that the latest was 10.9.1

Have now updated to 10.9.1 But still have the same problem on the Mac with the java error. Would post more details but I cannot figure out how to cut & paste from the console view.

On my linux machine it says timestamp error. Times on the two machines are more or less the same. They both get their time from the internet but Pi is UTC and unix is GMT.

I note that the Mac is also GMT and it does not give the timestamp error.

Its now finding the Pi and offering upload via a remote Pi at 192.168.1.17


keithsloan52

Wed, 17 Feb 2016 08:41:21 +0000

I note that if I leave my Pi powered off. I get a Connection Exception timed out at the same place as when its powered on but with the com.jcraft.jsch.JSchException : Algorithm negotiation fail.

Looking at the board.txt file I assume its trying to do the scp copy command at this time to move the hex file to the pi.

Could it be that the Algorithm negotiation fail is due to an incompatibility with the Jessie version of sshd


majenko

Wed, 17 Feb 2016 10:45:23 +0000

Unlikely to be an incompatibility, no, since I was using it yesterday with the latest image off the Raspberry site.

You can right-click on the console to copy. It should pop up a menu with "Copy" and "Copy All" in it. The latter will copy the whole content of the console to the clipboard without needing to select anything.


majenko

Wed, 17 Feb 2016 10:47:36 +0000

Actually, since you're on OS X you can completely bypass the whole builtin SSH/SCP if you like.

  1. Set up public key login to the "ckpi" account
  2. Remove "_builtin" from the scp and ssh commands

It should then use the system scp and ssh commands to do the work for you instead. You need the public key login setting up because there is no way for you to enter a password otherwise.


keithsloan52

Wed, 17 Feb 2016 20:34:15 +0000

Unlikely to be an incompatibility, no, since I was using it yesterday with the latest image off the Raspberry site. You can right-click on the console to copy. It should pop up a menu with "Copy" and "Copy All" in it. The latter will copy the whole content of the console to the clipboard without needing to select anything.

Does not work on the Mac. Just ignores the clicks


keithsloan52

Wed, 17 Feb 2016 21:13:19 +0000

Actually, since you're on OS X you can completely bypass the whole builtin SSH/SCP if you like.

  1. Set up public key login to the "ckpi" account
  2. Remove "_builtin" from the scp and ssh commands It should then use the system scp and ssh commands to do the work for you instead. You need the public key login setting up because there is no way for you to enter a password otherwise.

Okay got this working after I found I had to do a refresh of things to do a new scan to pick up changes in the board.txt file.