chipKIT® Development Platform

Inspired by Arduino™

Install MPIDE on raspbian

Created Wed, 19 Feb 2014 10:19:47 +0000 by eloots


eloots

Wed, 19 Feb 2014 10:19:47 +0000

Hi,

Just wanted to share how I set-ip MPIDE on a vanilla Rasbian distribution (I'm using it on a ChipKit Pi plugged into an RPi). This because I already had it installed and customized, and didn't want to install the MPIDE image from element14 as it would force me to repeat the customization. I guess this repeats a lot of what has been said on different postings, but I never found a comprehensive and complete guide for doing this.

[color=#008000]1. Base Raspberry Pi installation[/color]

Raspbian (2014-01-07-wheezy-raspbian.zip from http://www.raspberrypi.org/downloads)

[color=#008000]2. Download and install MPIDE image[/color]

http://chipkit.s3.amazonaws.com/index.html?sort=lastmod&sortdir=desc

The latest image for RPi is mpide-0023-raspberrypi-20130920.tgz

Installation comes down to un-compressing/un-tarring of archive in your preferred location

[color=#008000]3. Install gcc-avr[/color]

pi@raspberrypi ~ $ sudo apt-get install gcc-avr

[color=#008000]4. Install RXTX[/color]

pi@raspberrypi ~ $ sudo apt-get install librxtx-java

[color=#008000]5. Set CLASSPATH & LD_LIBRARY_PATH[/color]

Add the following lines to your .profile:

if [[ X${LD_LIBRARY_PATH} = X ]]; then
  export LD_LIBRARY_PATH=/usr/lib/jni
else
  export LD_LIBRARY_PATH=/usr/lib/jni:${LD_LIBRARY_PATH}
fi

if [[ X${CLASSPATH} = X ]]; then
  export CLASSPATH=/usr/share/java/RXTXcomm.jar
else
  export CLASSPATH=/usr/share/java/RXTXcomm.jar:${CLASSPATH}
fi

[color=#008000]6. Disable console on serial port on RPi[/color]

Use Andrew Scheller's script (https://github.com/lurch/rpi-serial-console)

pi@raspberrypi ~ $ sudo wget https://raw.github.com/lurch/rpi-serial-console/master/rpi-serial-console -O /usr/bin/rpi-serial-console && sudo chmod +x /usr/bin/rpi-serial-console
pi@raspberrypi ~ $ rpi-serial-console status
pi@raspberrypi ~ $ sudo rpi-serial-console disable
pi@raspberrypi ~ $ sudo reboot

[color=#008000]7. Add a boot rc-script to change RPi serial port setting[/color]

The serial port device on a RPi is /dev/ttyAMA0. For some reason, MPIDE doesn't find this port. As a consequence the Serial Port menu item under Tools is greyed out.

The workaround I found for this is to create a hard link named /dev/ttyS0 to /dev/ttyAMA0.

As this link has to be re-created after each reboot, the following rc script can re-creates it during the boot process:

pi@raspberrypi ~ $ cd /etc/init.d
pi@raspberrypi ~ $ sudo vi mpideSerial
pi@raspberrypi /etc/init.d $ cat mpideSerial
#!/bin/sh
### BEGIN INIT INFO
# Provides:          mpideSerial
# Required-Start:    kmod
# Required-Stop:
# Should-Start:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Changes owner/group on SPI devices
# Description:       By default, SPI devices are owned by root.
#                    Change this to pi.pi
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /lib/init/vars.sh

do_start () {
	cd /dev
	ln ttyAMA0 ttyS0
}

do_status () {
	return 0
}

case "$1" in
  start|"")
	do_start
	;;
  restart|reload|force-reload)
	echo "Error: argument '$1' not supported" >&2
	exit 3
	;;
  stop)
	# No-op
	;;
  status)
	do_status
	exit $?
	;;
  *)
	echo "Usage: mpideSerial [start|stop|status]" >&2
	exit 3
	;;
esac
pi@raspberrypi /etc/init.d $ sudo update-rc.d mpideSerial default
pi@raspberrypi /etc/init.d $ sudo reboot

After the reboot, you should see the ttyS0 device under /dev:

pi@raspberrypi /etc/init.d $ ls -l /dev/ttyAMA0 /dev/ttyS0
crw-rw---T 2 root dialout 204, 64 Feb 19 10:32 /dev/ttyAMA0
crw-rw---T 2 root dialout 204, 64 Feb 19 10:32 /dev/ttyS0

[color=#008000]8. Fire-up MPIDE[/color]

pi@raspberrypi ~ $ cd mpide-0023-raspberrypi-20130920/
pi@raspberrypi ~/mpide-0023-raspberrypi-20130920 $ ./mpide

Jacob Christ

Fri, 21 Feb 2014 07:04:03 +0000

Nice, thanks for sharing.

Jacob


djgardn2

Sat, 19 Apr 2014 06:03:18 +0000

Hello,

I was hoping someone could point me in the right direction on why I am unable to launch the MPIDE on my Raspberry Pi.

I have followed the directions but am having issues:

  1. I am having this message show up when I try to open the MPIDE through the command line ([url]http://chipkit.net/wp-content/uploads/2013/02/linux12.png[/url]).

  2. I am having a feeling that my issues are around steps 5 or in step 7 from the above post with the instructions.

Note about #2 issue : ls -l /dev/ttyAMA0 /dev/ttyS0 returns only one of the two shown responses from the instruction guide, my responses I see are "cannot access dev/ttyS0: No such file or directory" and also "crw-rw---T 1 root dialout 204, 64 Jan 1 1970 /dev/ttyAMA0".

I would be happy to post a more detail description or any other details if needed.

Thank you for any help or suggestions.

Aside comments:

I have a fresh install of the latest Raspbian on my SD card and I also updated/upgraded it.

When trying to install the librxtx-java it says it is already installed.

Also, installing the image with the MPIDE pre-installed onto SD card worked fine although it created problems with my wireless keyboard sending repeating letters (plugged in keyboard worked without issues).

Using the builds/mpide-0023-raspberrypi-20140316.tgz installed on the Raspberry Pi.


EmbeddedMan

Mon, 12 May 2014 03:35:11 +0000

I am having these exact same issues.

One thing I figured out : in the instructions above, you see the line

pi@raspberrypi /etc/init.d $ sudo update-rc.d mpideSerial default

and I think it should be

pi@raspberrypi /etc/init.d $ sudo update-rc.d mpideSerial defaults

That fixed the missing serial port hard link problem. Now both show up when doing the ls command.

But I'm still stuck on the 'no rxtxSerial in java.library.path' problem.

*Brian


djgardn2

Tue, 20 May 2014 04:11:29 +0000

@ Brian,

Thank you for that comment, changing the "default" to "defaults" worked.

Also, I have had some more time to look into the issue and I have managed to figure out all the needed changes that need to be made.

About your comment this should fix your problem:

  1. Copy all the files located inside your /usr/lib/jni/ (jni folder), copy all those files and then paste them all inside the /usr/lib/ (lib folder). Once the files are copied to that new location you should be able to launch MPIDE.

  2. You will most likely still have your serial connection greyed out once the MPIDE opens, if that option is not greyed out you most likely can skip this step.

Quick summary of the steps in the link below:

Basically replace the text inside the cmdline.txt file with the posted code as seen in the last comment in the link below. Then inside the inittab file you will scroll to the bottom of the file and basically comment out the last line that looks very close or similar to the code posted in the comment in the link below. I recommended to reboot your Pi once completed.

See this link and follow the following steps : [url]http://www.element14.com/community/community/knode/dev_platforms_kits/element14_dev_kits/microchip-chipkit/chipkit_pi/blog/2014/02/13/mpide-for-raspbian[/url]

  1. Once you have finished the following steps you should now be able to open MPIDE and the serial port will be working. You will still need to do one more thing to get the MPIDE to compile the code (currently it will most likely error out when trying to compile).

Install the following :

sudo apt-get install avr-libc avrdude binutils-avr gcc-avr

This was found by reading over these two links below: [url]http://chipkit.net/forum/viewtopic.php?f=17&t=41[/url] [url]http://chipkit.net/forum/viewtopic.php?f=6&t=90[/url]

Hope it works for you. I am successfully compiling my code on the Raspberry Pi without issues now after all the changes.


perronj2

Fri, 11 Jul 2014 14:51:26 +0000

Hi,

I am brand new to Raspbian and the Chipkit Pi. My background is with PIC MCU's for production appliances and using Arduino for rapid R&D prototypes. So I thought the chipkit Pi could be a perfect bridge for standalone data logging and other applications I might want to do. But I am having issues with the Chipkit_Pi Image not partitioning enough file space, as noted many times before. So I saw this thread and I am trying to follow the instruction line for line but to a noob like myself somethings are pretty vague.

-1st; for some reason I can't not unarchive the mpide file using raspbian's unarchiver. Is there a terminal command to do this? I keep getting error, no idea.

  • 2nd; I have no idea where my .profile folder is and how to add the specified code @ step 5.

Any Help would be great. Thanks again folks.

Jean-Paul


perronj2

Fri, 11 Jul 2014 15:57:04 +0000

Hey folks,

I'm pretty new to the raspbian linux os and chipkit pi. My past expeirence is with PIC MCUs and arduino for rapid prototyping. I was hoping to develop my own stand alone data logger system with a python GUI that interacted with the Chipkit. But unfortunately with the poorly partitioned image coming from element14 I can not do it.

So I saw this thread and I am trying to follow the steps but some things are ambiguous for a noob such as myself.

1st - Step 5, I have no idea how edit my .profile file, any hits would be appreciated

2nd - I can not get the raspberry pi to unzip the file image for mpide.

Thanks again.

Regards, John-Paul


djgardn2

Fri, 08 Aug 2014 19:35:58 +0000

Hello,

Hopefully this will help you with some of your questions or point you in the right direction.

To extract the file you have downloaded you will want to take a look at this link attached for some examples [url]http://www.wikihow.com/Extract-Tar-Files-in-Linux[/url]

Most likely you will have something similar to these steps:

1st Download the latest version of MPIDE [url]http://chipkit.s3.amazonaws.com/index.html[/url] you will want to look for the newest version that is named close or similar to this:

mpide-0023-raspberrypi-20130715.tgz

2nd Once everything is downloaded you can open and use LXTerminal to change to the correct directory for the next step where you have the MPIDE file, typing something similar:

cd /home/pi/Downloads

3rd Now you are in the correct directory (folder) that you have the MPIDE file you will use the following to unpack the tar file into that same folder, similar to this:

tar -xzf mpide-0023-raspberrypi-20130715.tgz

Once completed you should now see a folder that is labeled mpide-0023-raspberrypi-20140316 or similar inside your Downloads folder, open the folder using file manager and then double click the mpide file.

For the .profile you will want to open your file manager program then make sure you are opened to something most likely named like this:

/home/pi

When you are inside that folder you will first want to make sure that you are showing your hidden files by right clicking your mouse and then clicking on the "Show Hidden" option.

You should now be able to see a file called .profile.

Opening the .profile with a program like Leafpad you can add the step 5 code at the very bottom/end of the file. I do not remember if you need to change permissions to that file but you might in order to be able to save the changes made, hopefully someone else can chime in with any tips/suggestions/hints for future reference too.

Sorry for the late reply somehow I missed seeing this post until now. Hope this helps.


mr_fid

Sun, 01 Feb 2015 17:37:26 +0000

Sorry for dragging this up again. I am trying to get my chipKIT Pi working but I cant quite follow all the excellent instruction you have given. I think its the 7th step I get stuck on. I don't really understand what a RC scrip is and how you make it and what it should contain and where it should live?

I basically cant ever find /dev/ttyS0

Any help gratefully appreciated

Thanks