chipKIT® Development Platform

Inspired by Arduino™

Trying to use MPIDE with bootloader.

Created Thu, 11 Feb 2016 11:23:04 +0000 by keithsloan52


keithsloan52

Thu, 11 Feb 2016 11:23:04 +0000

Hi

I have a PICmx250f128 on a breadboard hooked up to a Raspberry Pi.

I seem to be able to program the PICmx250f128 with pickle as per http://wiki.kewl.org/dokuwiki/projects:pickle#installation like it responds to p32 id and will upload & verify a hex file.

I have built the various Chipkit firmewares as per http://wiki.kewl.org/dokuwiki/projects:chipkit32 I assume I am supposed to use firmware/CHIPKIT_PI.hex and have loaded and verified it,

I start mpide on the Raspberry Pi, but a bit stuck with loading a sketch to the PIC. I assume I set the board to Tools/Board/chipKIT/chipKit Pi. Serial Port is /dev/ttyS0 Not sure what to set programmer to if anything

Trying to load a basic sketch like blink Get an error "couldnt determine program size java.io.IOException: Cannot run program "avr-size": error=2 No such file or directory

Version of MPIDE installed "mpide being mpide-0150-raspberrypi-20150820"


majenko

Thu, 11 Feb 2016 11:31:45 +0000

That error message is a common one, and one that has been fixed. What version of MPIDE are you using?

Can you describe (or better still show us) your breadboard setup? What do you have connected to what and where?


keithsloan52

Thu, 11 Feb 2016 11:40:14 +0000

MPID version Version of MPIDE installed "mpide being mpide-0150-raspberrypi-20150820" [attachment=1]Schematic.png[/attachment] [attachment=0]Breadboard.png[/attachment]


majenko

Thu, 11 Feb 2016 12:02:17 +0000

Ok, so you are using a UART bootloader on the PIC32, and that bootloader is using the internal oscillator? I am not familiar with the actual bootloader you are using TBH, so I don't know what settings it has.

On the Pi I would expect the serial port to be /dev/ttyAMA0 if it is wired to the UART on the GPIO header.

In order to perform the programming the reset pin MCLR has to be toggled LOW then HIGH to reset the chip and enter the bootloader for 2 seconds. You have that wired in to the "AN" pin of your cobbler I see. MPIDE has no way of manually toggling that pin - normally it's done by the DTR pin of an FT232R chip - so I don't know how that is going to be done. You should be able to program it once without that since it will remain in the bootloader, but from then on you will need to toggle that pin at the right time in order to do the programming.

The normal bootloader for the chipKIT Pi, which is basically what you are replicating but without a crystal, has a bootloader enable input that you hold while resetting the board to force it to remain in the bootloader while you program it. Looking at the link to the bootloader you provided it looks like that might also be available to you, which would mean you need to add some buttons to your breadboard to do that bootloader enable sequence.

I see they seem to be using their own program "pload" to upload the sketch. Again that is not something I am familiar with.

TBH you would probably be best off adding a crystal and load capacitors and installing the chipKIT Pi UART bootloader from the official chipKIT repository and then using the chipKIT Pi board definition and the standard avrdude as MPIDE uses to upload the HEX file.


majenko

Thu, 11 Feb 2016 12:09:59 +0000

Oh, and you can "fix" the avr-size problem by installing the package "gcc-avr" on the Pi using apt-get (or whatever preferred method of package installation you like)


keithsloan52

Thu, 11 Feb 2016 13:24:07 +0000

On the Pi I would expect the serial port to be /dev/ttyAMA0 if it is wired to the UART on the GPIO header.

I ran the script at http://wiki.kewl.org/dokuwiki/boards:chipkitpi:mpide but with version changed to mpide-0150-raspberrypi-20150820 The script has a symbolic link #SETUP TTYS0 FOR MPIDE ON REBOOT echo "ln -f /dev/ttyAMA0 /dev/ttyS0" >> /etc/rc.local So I think I should be okay with /dev/ttyS0

What about the error message? Is their a later version than mpide-0150-raspberrypi-20150820? Am I right with my board settings and do I have to worry about programmer?

In order to perform the programming the reset pin MCLR has to be toggled LOW then HIGH to reset the chip and enter the bootloader for 2 seconds. You have that wired in to the "AN" pin of your cobbler I see. MPIDE has no way of manually toggling that pin - normally it's done by the DTR pin of an FT232R chip - so I don't know how that is going to be done. You should be able to program it once without that since it will remain in the bootloader, but from then on you will need to toggle that pin at the right time in order to do the programming.

AN on the Mikrobus is connected to GPIO 4 on the Raspberry Pi as required by pickle. I could write a python program to toggle GPIO LOW then High, but not sure what you mean when you say enter the bootloader for 2 secs.

I guess I could always use pickle to blank & reload the bootloader each time before programming but not very convenient.


keithsloan52

Thu, 11 Feb 2016 13:26:22 +0000

Oh, and you can "fix" the avr-size problem by installing the package "gcc-avr" on the Pi using apt-get (or whatever preferred method of package installation you like)

Okay thanks I will give that a try.

(Sorry did not see this before my previous post)


keithsloan52

Thu, 11 Feb 2016 21:36:29 +0000

On page http://wiki.kewl.org/dokuwiki/projects:chipkit32 It mentions Demo

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

First ensure that the serial UART is free to use.

To enter upload mode, perform the following steps.

Press BOOTLOAD-EN
Press RESET
Release RESET
Release BOOTLOAD-EN

On page http://wiki.kewl.org/dokuwiki/boards:chipkitpi It has SW PIC32MX250F128B == =============== BOOTLOAD-EN 18 RB9 RESET 1 !MCLR

Now I have AN which is Raspberry Pi GPIO 4 connected tp !MCLR If I use another GPIO and connect to pin 18 RB9 then is there any reason I cannot do the setting of upload mode in software. I assume Press would be taking the pin Low and release setting high


keithsloan52

Sat, 13 Feb 2016 14:24:08 +0000

Okay I cleared the PIC with p32 blank

Reloaded the bootloader with p32 program CHIPKIT_PI.hex

Started mpide with mpide

Loaded sketch and tried to upload to PIC came back with

Binary sketch size: 6916 bytes (of a 122880 byte maximum)

But then gives messages

200907 [Thread-1] DEBUG processing.app.Base  - Base: getTarget() : Target Name: pic32
200909 [Thread-1] DEBUG processing.app.Base  - Target: getBoards(): pic32
200911 [Thread-1] DEBUG processing.app.Base  - *** UPLOAD USING: bootloader
200913 [Thread-1] DEBUG processing.app.Base  - Base: getTarget() : Target Name: pic32
200916 [Thread-1] DEBUG processing.app.Base  - Target: getBoards(): pic32
201896 [Thread-1] DEBUG processing.app.Base  - Base: getTarget() : Target Name: pic32
201899 [Thread-1] DEBUG processing.app.Base  - Target: getBoards(): pic32
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout

I have board set to chipKIT pi, but no idea what I should set programmer to be.


keithsloan52

Sat, 13 Feb 2016 15:27:51 +0000

I even tried running my python reset program to emulate the button press whilst the timeouts are occuring. But my understanding is that I should be able to load the first sketch after blanking the pic and reloading the boot loader. ( I have added a wire from SDA on the Mikrobus cobbler to RB9 on the PIC )

cat reset.py
# External module imports
import RPi.GPIO as GPIO
import time

delay = 1

# Declare Pins
mclrPin = 4 # AN  GPIO4 -> MCLR
blenPin = 2 # SDA GPIO2 -> RB9

# Pin Setup:
GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
# GPIO 4 MCLR pin set as output
GPIO.setup(mclrPin, GPIO.OUT, initial=GPIO.HIGH)
# GPIO 5 BootLoad Enable pin set as output
GPIO.setup(blenPin, GPIO.OUT, initial=GPIO.HIGH)

# Press BOOTLOAD-EN
print("Press BOOTLOAD-EN")
GPIO.output(blenPin, GPIO.LOW)
time.sleep(delay)

# Press Reset
print("Press Reset")
GPIO.output(mclrPin, GPIO.LOW)
time.sleep(delay)

# Release RESET
print("Release Reset")
GPIO.output(mclrPin, GPIO.HIGH)
time.sleep(delay)

# Release BOOTLOAD-EN
print("Release BOOTLOAD-EN")
GPIO.output(blenPin, GPIO.HIGH)
time.sleep(delay)

# cleanup GPIO
GPIO.cleanup()
pi@pi-three:~/Mikrobus-chipKIT-Pi $