chipKIT® Development Platform

Inspired by Arduino™

New to ChipKIT Pi

Created Thu, 05 Mar 2015 05:08:10 +0000 by sethkush


sethkush

Thu, 05 Mar 2015 05:08:10 +0000

I got a used chip kit pi from a friend, and I'm having a bit of trouble getting started. I can't program it by USB, I've installed all the driver software, and neither Windows, OS X, or Linux senses a serial port (lsusb and its alternatives show nothing). Is there any way to fix this?

I could program it from the Pi with avrdude through /dev/ttyAMA0 (I don't have X.org, so an IDE is out of the question). How do I get a hex file, and what arguments should I use to upload it through the Pi's serial port?

Thanks.


nroff-man

Thu, 05 Mar 2015 20:31:07 +0000

Hi

I got a used chip kit pi from a friend, and I'm having a bit of trouble getting started. I can't program it by USB, I've installed all the driver software, and neither Windows, OS X, or Linux senses a serial port (lsusb and its alternatives show nothing). Is there any way to fix this?

The boot loader can only be for the UART or USB but not both simultaneously.

If you have the board attached to an RPi, then you only need the UART boot loader which is the one you have already.

You can reprogram the chip with a USB boot loader if you don't want to use the RPi.

I could program it from the Pi with avrdude through /dev/ttyAMA0 (I don't have X.org, so an IDE is out of the question). How do I get a hex file, and what arguments should I use to upload it through the Pi's serial port? Thanks.

Getting a hex file really depends on how you want to write programs for the board.

I don't use MPIDE so cannot advise if this is what you want to achieve.

Bye-bye


majenko

Thu, 05 Mar 2015 20:32:35 +0000

I have been doing some work today on improving the command line interface to UECIDE. You can install that into the Pi and use that to do all your compilation and uploading from the command line. Be sure to install the beta version to get the best command line experience. Run uecide --help to see all the available options.

I'm going to document all the settings and how to compile and install packages when I get back to my computer shortly.


majenko

Thu, 05 Mar 2015 23:53:23 +0000

Ok.. I just fixed a small bug in UECIDE's ARM repository handling, so now Pi command line usage works properly.

Anything from 0.8.8alpha6 onwards can be used completely from the command line on a Pi.

It's best to install from the apt repository. As root, edit the file /etc/apt/sources.list and add the line:

deb http://dist.majenko.co.uk/ unstable main contrib beta

Then install the respository key:

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

Then update and install UECIDE:

$ sudo apt-get update
$ sudo apt-get install uecide

Now you're ready to rumble with UECIDE. First job is to install the chipKIT Pi and its support files:

$ uecide --update
Making apt folder
Making db folder
Making sources file
1 sources
>>> http://repo.uecide.org/uecide libraries plugins extra compilers cores boards
http://repo.uecide.org/uecide/dists/uecide/libraries/binary-linux-armhf/Packages.gz
http://repo.uecide.org/uecide/dists/uecide/plugins/binary-linux-armhf/Packages.gz
http://repo.uecide.org/uecide/dists/uecide/extra/binary-linux-armhf/Packages.gz
http://repo.uecide.org/uecide/dists/uecide/compilers/binary-linux-armhf/Packages.gz
http://repo.uecide.org/uecide/dists/uecide/cores/binary-linux-armhf/Packages.gz
http://repo.uecide.org/uecide/dists/uecide/boards/binary-linux-armhf/Packages.gz
$ uecide --install=chipkit-pi
Installing chipkit-pi...++++...done.

It takes a while - the compiler is pretty damn huge (hundreds of MB, so make sure you have plenty of room on your SD card...) Now you're ready to compile... Let's compile "Blink" and upload it to the cKPi...

$ uecide --board=chipkit-pi --port=/dev/ttyAMA0 --upload --compile .uecide/cores/chipkit/examples/1.Basics/Blink/
Compiling...
============
    * Compiling sketch...
    * Compiling core...
      > api
    * Compiling libraries...
    * Linking sketch...
Compiling done.
===============
Memory usage
============
    * Program size: 6272 bytes
    * Memory size: 368 bytes
    * Compilation took 39.729 seconds
Uploading firmware...
=====================

At this point on mine it cuts off as I don't have a cKPi connected at the moment - but it would attempt to upload the sketch then - so make sure the cKPi is in programming mode and you have access to the serial port (you're in the dialout group).

There's lots more in UECIDE's internal repository - loads of libraries, other boards, etc. You can use "uecide --search=<term>" to find things to install, then install them with "uecide --install=<package name>".

You can run "uecide --help" to see the full list of commands you can use.


sethkush

Fri, 06 Mar 2015 04:29:22 +0000

I don't use Debian, is there a source tar ball available for the IDE, or will I have to extract the binaries, etc. from the .deb package?

EDIT: I found the linux zip, everything seems to be working. I will update when I get to the actual compiling and transferring part. Thanks for the help.


majenko

Fri, 06 Mar 2015 09:58:24 +0000

What are you running on your Pi then? I should really look into the packaging systems of other distros and maybe provide the packages for them as well...


sethkush

Sat, 07 Mar 2015 04:48:32 +0000

I use Slackware-arm 14.1. I wouldn't worry about a Slackware package if I were you; an RPM might get some use though.

Just a note, it might be nice to have the option to store the IDE files in a more 'System-wide' directory, like /usr/bin. rather than have each user install all the compilers in their home directories.

The compilers it downloads also use /lib/ld-linux-armhf.so.3 as an interpreter; many systems only include /lib/ld-linux.so.3 either changing the compiler binaries or creating a symlink will fix this issue.


sethkush

Sat, 07 Mar 2015 06:13:14 +0000

I'm able to compile now, but avrdude is throwing an error:

Uploading firmware...
=====================
    * Resetting board...
    * Uploading...
avrdude: error at line 620 of /home/seth/.uecide/cores/chipkit/tools/linux_arm/avrdude.conf: pin must be in the range 1-17
    * Resetting board...
Upload Failed

Here is that area of the file:

programmer
  id    = "ponyser";
  desc  = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts";
  type  = serbb;
  reset = ~3;        &lt;----- line 620
  sck   = 7;
  mosi  = 4;
  miso  = 8;
;

nroff-man

Sat, 07 Mar 2015 07:33:54 +0000

hi.

pony serial is an adapter for RS232 AVR ISP and not used for uploading to the boot loader on the chipKIT Pi.

the avrdude command should be something like this:

avrdude -v -v -P /dev/ttyAMA0 -b 115200 -p pic32-250-128 -c stk500v2 -U flash:w:FILE.HEX

Bye


majenko

Sat, 07 Mar 2015 10:15:36 +0000

Looks like there's an error in the avrdude.conf file there... It's poorly maintained and has lots of cruft in it. In my opinion there is no need for anything except the PIC32 stuff in there - all the AVR hardware programmers can be deleted.

Just delete that programmer section and try again. Alternatively you can try (untested as yet on ARM) pic32prog. Add the flag

--programmer=pic32prog

to your command line. We're eventually going to be switching away from avrdude to use pic32prog.


sethkush

Sun, 08 Mar 2015 06:03:09 +0000

pic32prog fails without giving an error. Avrdude gives the following error now:

avrdude: error at /home/seth/.uecide/cores/chipkit/tools/linux_arm/avrdude.conf:2241: must specify page_size for paged memory

The problem is at the end of the PIC32MX250F128B section, so I figured it would be best not to delete it.


nroff-man

Sun, 08 Mar 2015 16:13:45 +0000

Hi

I have no idea what your problem is but are you pressing the BOOTLOAD-EN button and then toggling RESET?

Do you have permission to access the serial port?

Did you disable the serial port in inittab? (does slackware enable it?)

BTW, I have created a HEX file that you can test: [url]http://dev.kewl.org/misc/hex/mx250_ckpi.hex[/url]

Download this and show us what happens when you type:

pic32prog -d /dev/ttyAMA0 mx250_ckpi.hex

It should come up something like:

pic32prog -d /dev/ttyAMA0 mx270_ckpi.hex 
Programmer for Microchip PIC32 microcontrollers, Version 2.0.9986ac0
    Copyright: (C) 2011-2015 Serge Vakulenko
      Adapter: STK500v2 Bootloader
 Program area: 1d000000-1d07ffff
    Processor: Bootloader
 Flash memory: 512 kbytes
  Boot memory: 12 kbytes
         Data: 55880 bytes
        Erase: done
Program flash: ######################################################### done
 Verify flash: ######################################################## done
Rate: 2933 bytes per second

Bye


sethkush

Tue, 10 Mar 2015 04:37:27 +0000

pic32prog seems to be segfaulting. I made sure the necessary libraries were installed, and it still wouldn't run. Strace shows that it happens just after a call to getrlimit():

getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0

I tried to compile my own binary from the git repo, but make failed because 'uint16_t' was undeclared in one of the source files.


nroff-man

Tue, 10 Mar 2015 06:04:42 +0000

hi

pic32prog seems to be segfaulting. I made sure the necessary libraries were installed, and it still wouldn't run. Strace shows that it happens just after a call to getrlimit():

getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0

I tried to compile my own binary from the git repo, but make failed because 'uint16_t' was undeclared in one of the source files.

A missing uint16_t definition tells us that #include <stdint.h> is not being included on your platform, you could try adding that to the offending file(s).

This is how I build pic32prog for the raspberry pi running raspbian: [url]http://wiki.kewl.org/dokuwiki/tools:pic32prog[/url] You may need to solve these dependencies for slackware first.

If none of this works, you could ultimately try my own hex loader. which is part of this project: [url]http://wiki.kewl.org/dokuwiki/projects:pickle[/url]

Using my own tools you can at least check that things are running.

To program the example hex file you would type:

pload program /dev/ttyAMA0 mx250_ckpi.hex 24

If you are curious, the hex file is this: [url]http://wiki.kewl.org/dokuwiki/projects:ape65[/url]

Bye-bye

edit:typo


majenko

Tue, 10 Mar 2015 10:40:13 +0000

pic32prog seems to be segfaulting. I made sure the necessary libraries were installed, and it still wouldn't run. Strace shows that it happens just after a call to getrlimit():

getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0

I tried to compile my own binary from the git repo, but make failed because 'uint16_t' was undeclared in one of the source files.

Can you run it under GDB? Get some idea of the back trace then - see just what's causing it.

There is no mention of getrlimit() in the source, so it must be coming from a library, which means the library function may not be being called right, which means we need to know what is calling it - and that may be three or four functions higher in the chain.


sethkush

Tue, 10 Mar 2015 23:58:49 +0000

pload worked. The 6502 simulator is really cool. I'm afraid I'm not very well versed in gdb, and I wasn't able to get anything useful from it. Adding "#include <stdint.h>" fixed the uint_16_t problem. Unfortunately, the build still fails because ld can't find "-lusb-1.0" which is odd, because when I run simply "ld -lusb-1.0" it does seem to find it and it's dependencies.


majenko

Wed, 11 Mar 2015 00:19:50 +0000

If you prefix the pic32prog command with:

gdb --args pic32prog .... etc ...

Then when gdb loads, press "r" and return to run the program. When it crashes, enter "bt" and press return. Copy the output to here.


sethkush

Wed, 11 Mar 2015 00:22:17 +0000

here is a printout:

Starting program: /home/seth/.uecide/cores/chipkit/tools/linux_arm/pic32prog
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x000593c2 in flash_data ()
(gdb) bt
#0  0x000593c2 in flash_data ()
#1  0x0000a30a in _start ()

majenko

Wed, 11 Mar 2015 00:33:44 +0000

That doesn't look good... It thinks it's executing a function flash_data(), but that is an array, not a function...!

My guess is that the whole execution of the debian compiled version is going completely awry on slackware. So you need a slackware specific one... Maybe I should crack out my old V1 Pi and see about trying slackware on it...


sethkush

Wed, 11 Mar 2015 00:40:42 +0000

That's kind of interesting. I wonder what could possibly cause this kind of incompatibility.


majenko

Wed, 11 Mar 2015 00:41:58 +0000

Maybe something in the C library, maybe something in the ELF decoder - who knows? Be interesting to compare the disassembly of both versions when we have a working slackware one.


nroff-man

Wed, 11 Mar 2015 10:34:20 +0000

Lo

pload worked. The 6502 simulator is really cool. I'm afraid I'm not very well versed in gdb, and I wasn't able to get anything useful from it. Adding "#include <stdint.h>" fixed the uint_16_t problem. Unfortunately, the build still fails because ld can't find "-lusb-1.0" which is odd, because when I run simply "ld -lusb-1.0" it does seem to find it and it's dependencies.

As an alternative to any IDE and high level libraries you can program this chip in a more `bare metal' fashion.

This isn't straightforward and you would need to refer to lengthy Microchip documentation for the part to learn about the peripherals.

This chipKIT Pi project here contains a minimal LED blinky demo. You can use this blinky as a template for any project you like. [url]http://wiki.kewl.org/dokuwiki/projects:chipkit32[/url]

Ultimately though, you need a good idea of what you are setting out to achieve before writing any code. You could do some minimal research do find out if you think you are capable of doing it this way or not in advance.

Good luck, Bye-bye