Install CHDK on Canon camera from Mac when Firmware Update does not show up in the menus

; Date: Thu Dec 05 2019

Tags: Canon Powershot Cameras »»»» Canon Hack Development Kit »»»» CHDK

CHDK is a tool for making a camera do pretty much anything. Instead of the prebaked functionality created by the camera manufacturer, CHDK is a geeks tool letting you write programs that run on the camera, or otherwise tweak any setting. At least that's what the project promised. I bought a cheap Canon PowerShot A4000 to try it out, but couldn't get the instructions to work. Turns out the solution was easy.

I'm a Mac user, and have been using Mac's since the beginning of Mac OS X. The promise is "UNIX with a pretty face" meaning Mac OS X (a.k.a. macOS) is an ingenious combination of Unix-style command line tools with a great GUI system. After 20 years of using it, I'm very happy. However there are idiosyncrasies that sometimes crop up from time to time and this is one of them. Namely, Mac file permissions were carried to the SD card causing problems, that we discuss in more depth below. First we need a bit of basic introduction.

Over on the CHDK website the simple/easy way to run CHDK on a Canon PowerShot camera is

  • With an SD card formatted by the camera (so it uses FAT16?)
  • Download the firmware build matching your camera
  • Unpack the ZIP file
  • Copy the contents over to the ROOT of the SD card
  • Insert the SD card into the camera
  • Start the camera by pressing the PREVIEW button, rather than pressing the normal power button
  • Press the MENU button
  • Browse the menus to find the FIRMWARE UPDATE choice
  • Select FIRMWARE UPDATE then follow the instructions
  • Note the CHDK logo
  • Learn how to enter the CHDK menu tree - and get lost in the geekery

All this is easy and straight forward, but in my case the FIRMWARE UPDATE choice did not show up in the menu. A search for advice told me some basic things like making sure the contents of the ZIP file are in the ROOT of the SD card. I'm a certified geek and know how to do that.

Since this is a common problem, we'll go over what it means to put files in the ROOT of the SD card - here's a little picture to help:

The drive CANON_DC is the SD card as formatted by the camera. You'll recognize the DCIM directory as the place the camera stores pictures you've taken. The other stuff is what was unpacked from the CHDK ZIP file. It is placed next to the DCIM directory.

In other words, I'd done everything correctly but still the FIRMWARE UPDATE menu did not appear.

Rather than give up on this as a bad joke - I found there is a forum for discussing the CHDK system. Asking a question, got me a pointer to the answer that was right there on the CHDK wiki. But - let me say that the CHDK Wiki is badly organized and hard to follow.

The answer is on the (chdk.fandom.com) FAQ page for Mac users. You'll have to search for "permissions" on that page. Even then the issue is badly explained, and therefore let me try a go at explaining things.

A nifty feature of macOS is that when you download a file it remembers that you downloaded the file. For certain uses like executing the file as an application the OS will ask you - Hey, you downloaded this file, are you sure you want to execute it? That's for safety, and it's useful.

In the back of my mind I always wondered how that was implemented. And now I do. Some data is added to the "extended attributes" of the files to record they were downloaded. Using Finder to unpack the ZIP file passes the extended attributes, and then using Finder to copy files to the ZIP drive also carries along the extended attributes. And of course I used Finder to do all that because it's the easiest way.

Bottom line is that macOS has made sure to mark the files as unexecutable, and therefore the camera does not recognize them as a firmware update.

$ ls -al /Volumes/CANON_DC/
total 1600
drwxrwxrwx@  1 david  staff   32768 Dec  5 09:05 .
drwxr-xr-x+ 10 root   wheel     320 Dec  5 09:05 ..
drwxrwxrwx   1 david  staff   32768 Dec  4 21:17 .Spotlight-V100
drwxrwxrwx   1 david  staff   32768 Dec  4 22:18 .TemporaryItems
drwxrwxrwx   1 david  staff   32768 Dec  4 21:19 .Trashes
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._CHDK
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._DISKBOOT.BIN
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._PS.FI2
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._camnotes.txt
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._changelog.txt
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._readme.txt
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._vers.req
drwxrwxrwx   1 david  staff   32768 Dec  5 09:05 .fseventsd
drwxrwxrwx@  1 david  staff   32768 Dec  4 22:18 CHDK
drwxrwxrwx   1 david  staff   32768 Dec  5 00:38 DCIM
-rwxrwxrwx@  1 david  staff  130089 Oct 19 06:53 DISKBOOT.BIN
-rwxrwxrwx@  1 david  staff   80032 Oct 19 06:53 PS.FI2
-rwxrwxrwx@  1 david  staff     888 Oct 19 06:53 camnotes.txt
-rwxrwxrwx@  1 david  staff    7901 Nov 29  2015 changelog.txt
-rwxrwxrwx@  1 david  staff   11126 Oct 19 06:53 readme.txt
-rwxrwxrwx@  1 david  staff     107 Aug  1  2008 vers.req

Since the FAT16 file system on the SD card does not support extended attributes, macOS helpfully put the extended attributes into these ._ files. That's another puzzle solved since I always wondered what those ._ files were.

The solution is not to delete the ._ files but instead use the xattr command to remove this attribute.

$ xattr -d com.apple.quarantine DISKBOOT.BIN PS.FI2 
...
$ ls -al
total 1472
drwxrwxrwx@  1 david  staff   32768 Dec  5 09:07 .
drwxr-xr-x+ 10 root   wheel     320 Dec  5 09:05 ..
drwxrwxrwx   1 david  staff   32768 Dec  4 21:17 .Spotlight-V100
drwxrwxrwx   1 david  staff   32768 Dec  4 22:18 .TemporaryItems
drwxrwxrwx   1 david  staff   32768 Dec  4 21:19 .Trashes
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._CHDK
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._camnotes.txt
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._changelog.txt
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._readme.txt
-rwxrwxrwx   1 david  staff    4096 Dec  4 22:18 ._vers.req
drwxrwxrwx   1 david  staff   32768 Dec  5 09:05 .fseventsd
drwxrwxrwx@  1 david  staff   32768 Dec  4 22:18 CHDK
drwxrwxrwx   1 david  staff   32768 Dec  5 00:38 DCIM
-rwxrwxrwx   1 david  staff  130089 Oct 19 06:53 DISKBOOT.BIN
-rwxrwxrwx   1 david  staff   80032 Oct 19 06:53 PS.FI2
-rwxrwxrwx@  1 david  staff     888 Oct 19 06:53 camnotes.txt
-rwxrwxrwx@  1 david  staff    7901 Nov 29  2015 changelog.txt
-rwxrwxrwx@  1 david  staff   11126 Oct 19 06:53 readme.txt
-rwxrwxrwx@  1 david  staff     107 Aug  1  2008 vers.req

Note how the ._ files for the two named files are now gone. But there are still ._ files for the other files. Hence we need to repeat this for all the other files which were added to this SD card.

Being a certified UNIX geek, this is how to do so:

$ find . -print | xargs xattr -d com.apple.quarantine

That command will probably print a bunch of error messages, but don't worry about those. Instead take the SD card over to your camera and now you'll be able to get into CHDK with no problem.

The official documentation for setting up CHDK - (chdk.fandom.com) Prepare your SD Card

About the Author(s)

(davidherron.com) David Herron : David Herron is a writer and software engineer focusing on the wise use of technology. He is especially interested in clean energy technologies like solar power, wind power, and electric cars. David worked for nearly 30 years in Silicon Valley on software ranging from electronic mail systems, to video streaming, to the Java programming language, and has published several books on Node.js programming and electric vehicles.