Would it not be great to use a small computer board like the BeagleBone Black to contol your Canon CHDK enabled camera?

Then via using the remoteshoot analyze, alter, detect or do whatever with the picture taken. Or imagine even running a small webserver on the board where everyone could just connect to look at your pictures of a slow growing flower in your garden. The possibilities would be endless!

So that is what we are set out to do; Make CHDKPTP work on a Beagle Bone Black.

And the "We" is "You" here. As you know, Open-source does not work without your contribution in whatever way. So, take your chance for for fame and glory, try it, improve this page; let's get it to work together.


The wished outcome of this combined effort is a working crosscompiled chdkptp non gui client that runs on a BeagleBone black mini computer board. Note: and this via pure cross compiling, thus not compiling on the BBB but on the local PC with ARM GCC crosscompiler of choice installed.

We assume you use Linux and have basic knowlege about using the bash shell.

What this page is not about[]

  • learning to use CHDK
  • letting you know how to use the CHDKPTP client
  • educating about crosscompiling
  • using the Linux shell

For all of the above there are other resources


Let's start by taking a coffee and listening to some uplifting music, e,g, Marasco - It's a feeling

Then first compile CDKPTP to be able to test on local PC

$ sudo apt-get install liblua5.1 liblua5.1-dev
$ sudo apt-get install libusb-1.0-0 libusb-1.0-dev

Let's get the CHDKPTP source

$ mkdir -p ~/develop/
$ cd ~/develop/
$ svn co chdkptp
$ cd ~/develop/chdkptp/

Ok now copy the basic config file

$ cp -av

Edit and disable the GUI settings

$ nano

Compile the local CHDKPTP client via

$ make

Local PC Test[]

Grab your camera. We assume you already have CHDK working on your camera. If not, make that happen first before you continue. Also be sure you installed the latest CHDK version on your SD of the camera. Older versions of CHDK tend to not work with well together with CHDKPTP.

To run chdkptp on Linux, the Lua path must be set, or the chdkptp must be run from the lua sub-directory. The recommended way to do this is using a shell script, like the example provided in Edit, change CHDKPTP_DIR to the full path to the directory where the chdkptp binary is and save the file as Remember to make executable.

1. Connect your CHDK enabled camera, in our test case my Canon IXUS200 IS. Power up the camera in playback mode.

2. Run chdkptp

$ ./ -i -c
<con> =switch_mode_usb(1)
<con> lua shoot()
<con> =switch_mode_usb(0) 
<con> download A/DCIM/123CANON/IMG_6666.JPG IMG_6666.jpg 

Note that IMG_6666.jpg is fictional, will be different on your camera. To learn more about how to use the cleint read: This page is not about learning to use CHDK


Now on to the real deal of what this what page is all about:


First a small cross compile "Hello world" tryout to get in the crosscompiling mood

$ nano hello.c
#include <stdio.h>

int main(int argc, char* argv[])
  printf("Hello ARM World!\n");
  return 0;
$ nano
arm-linux-gnueabi-gcc -march=armv7-a -mtune=cortex-a8 -mfpu=neon -o hello hello.c
$ sh

Now let see if it is really for an ARM

$ file hello

Yes, it gives:

hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31, Builld[sha1]=0xd0aa97ca192c969e7111e97aaa4604983ca62196, not stripped

Connect BBB to UAB port, we can connect to it by default using the Agstrom Linux already installed from the factory

So let's copy our "Hello" over to your BBB via

$ rsync -av --progress hello root@
$ ssh root@
$ cd ~
$ ./hello

This should give:

Hello ARM World!

Crosscompile LUA[]

We must get the **liblua.a** file... then we can link that later on to chdkptp (static), maybe we even start using dynamic libraries if it will save humongoes memory...)

Cross compiled Lua for ARM architecture via:

$ mkdir -p ~/develop/
$ cd ~/develop/
$ svn co chdkptp-bbb
$ cd ./chdkptp-bbb/ 
$ wget
$ tar -xvzf lua-5.1.5.tar.gz
$ cd ./lua-5.1.5

Disable readline library, it is optional feature we do not use, we get a compile error if we don't disable it. So alter it via:

$ nano src/luaconf.h

So it will become like:

/* #define LUA_USE_READLINE*/   /* needs some extra libraries */

And also the Makefile via:

$ nano src/Makefile

So it becomes:

       $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl"

Time to change the Makefile in the src directory:

$ cd ~/develop/chdkptp-bbb/lua-5.1.5/src
$ nano Makefile

Chnage the lines so the look like:

MYCFLAGS=-march=armv7-a -mtune=cortex-a8 -mfpu=neon

Now crosscompile it via:

$ make linux

Wait and discover after compiling if the file is compiled for the correct platform processor architecture via:

$ file lua

This will give someting like:

ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31 BuildID[sha1]=0x4cafebabe74366e902dc33deba62443b5cfa2044, not stripped

Test Lua[]

For fun we can see if the Lua executable works on the BBB, just to boost confidence that the Lua library also compiled correctly

$ rsync -av --progress root@lua
$ ssh root@lua
$ cd ~
$ ./lua

On he Lua prompt type:

> a=1
> b=2
> print(a+b)



Yes? wow, it worked(tm). We do not need this Lua executable, we only want the library to link to the CHDKPTP executable, but it was nice to toy around with it a little.


Now let's see if the compiler has created the library file we need for CHDKPTP to link to:

$ ls *.a

Is it there? great! ...on to compiling other code needed

Crosscompile LibUSB[]

And we also need to crosscompile LibUSB ( ). CHDKPTP interacts over USB and for this uses libusb, so on to compiling the library

$ cd ~/develop/chdkptp-bbb
$ wget
$ tar -xvf libusb-1.0.18.tar.bz2 
$ cd ./libusb-1.0.18
$ ./configure --host=arm-linux-gnueabi --disable-udev --disable-shared
$ make

If everything was correct, the UAS library to link to is now compiled...

As is look like LibUSB for ARM will not work CHDKPTP still ses the old function o we need to add the Compat LIBUSB library

{TODO} determine if we use a shared lib and also if fPIC (--with-pic) is needed

This "usb-1.0.a" library file can be found in ~develop/chdkptp-bbb/libusb-1.0.18/libusb/.libs

Crosscompile CHDKPTP[]

We know we had already create a "liblua.a" and a "libusb-1.0.a" Note that the lib part of the filename is always left off if used in a config file.

$ cd ~/develop/chdk-bbb/
$ cp -av

Edit and disable the GUI settings

$ nano

And also let's put those locations in the path of the CHDK so the compiler knows where it can find the libraries to link to


And also change the LUA_LIB in

$ nano

Now give the compiler a good hint where to find the location of libusb


Add the crosscopile extra option st

Now we will crosscompile CHDKPTP via

{TODO} add much more explaination here

$ make


We have Hard Float options, but not of real bennefit for this as far as I can see, so for now , being able to compile is enough, no optimalization, only if needed. Boring, no doubt, however feel free to add it, it is a Wiki afteral

The Future[]

Help us out to realize our dream; CHDKPTP on the BeagleBone Black by improving this page.