Firefly Design LLC

Product Design Consulting

Firefly Ice: Getting Started: Firmware Development

Compiling the Firmware

The Firefly firmware uses freely available libraries and tools.  To get setup for building the Firefly Ice firmware you will need the following:

The following commands can be used in the Mac OS X terminal to download and extract all of the above:

curl -O https://launchpadlibrarian.net/135590305/gcc-arm-none-eabi-4_7-2013q1-20130313-mac.tar.bz2
tar jxf gcc-arm-none-eabi-4_7-2013q1-20130313-mac.tar.bz2
export PATH=`pwd`/gcc-arm-none-eabi-4_7-2013q1/bin:$PATH

curl -O http://cdn.energymicro.com/dl/packages/EM_CMSIS_3.0.2.zip
unzip -d energymicro EM_CMSIS_3.0.2.zip
git clone https://github.com/denisbohm/energymicro-usb.git
git clone https://github.com/denisbohm/firefly-ice-firmware.git
cd firefly-ice-firmware
mkdir obj bin

Finally, from within the firefly-ice-firmware directory you can build the firmware using make:

make

The resulting FireflyIce.elf binary file can be found in the bin directory.

Note that newer versions of gcc can be found at https://launchpad.net/gcc-arm-embedded/+download.

Loading the Firmware

It's time to get the hardware setup.  In addition to a Firefly Ice PCBA, you will need the following:

Connect everything together, plug the USB cable from the ARM-USB-TINY-H into your Mac, and plug the USB cable from the Firefly Ice into any USB port for power.

connections

The Firefly Flash production software will be used to load the compiled FireflyIce.elf binary into the Firefly Ice PCBA.  Download and run FireflyFlash.zip (it should automatically unzip when downloaded by Safari).

FireflyFlash

Click on "Select firmware ELF file..." and select the FireflyIce.elf file that you compiled in the steps above.  Click "Program" and in a few seconds the indicators on the Firefly Ice should indicate that the firmware is running.

Debugging the Firmware

The Firefly Flash software acts as a gdb remote target for debugging.  To start debugging with gdb:

arm-none-eabi-gdb

then enter the following gdb commands:

target extended-remote tcp:127.0.0.1:9000
set architecture armv3m
file bin/FireflyIce.elf

Now you can use gdb commands for debugging.

Here is a quick example of setting a break in the main event loop, stepping into event processing, and then continuing program execution:

$ arm-none-eabi-gdb
GNU gdb (GNU Tools for ARM Embedded Processors) 7.4.1.20130312-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin10 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) target extended-remote tcp:127.0.0.1:9000
Remote debugging using tcp:127.0.0.1:9000
(gdb) set architecture armv3m
The target architecture is assumed to be armv3m
(gdb) file bin/FireflyIce.elf
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from /Users/denis/Desktop/test/firefly-ice-firmware/bin/FireflyIce.elf...done.
(gdb) break fd_event_process
Breakpoint 1 at 0x1153e: file src/fd_event.c, line 109.
(gdb) info break
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0x0001153e in fd_event_process at src/fd_event.c:109
(gdb) continue
Continuing.

Breakpoint 1, fd_event_process () at src/fd_event.c:109
109	    fd_interrupts_disable();
(gdb) list
104	        fd_event_set(FD_EVENT_CHG_STAT);
105	    }
106	}
107	
108	void fd_event_process(void) {
109	    fd_interrupts_disable();
110	    uint32_t pending = fd_event_pending & ~fd_event_mask;
111	    fd_event_pending = 0;
112	    fd_interrupts_enable();
113	
(gdb) step
fd_interrupts_disable () at src/fd_processor.c:22
22	    INT_Disable();
(gdb) delete 1
(gdb) continue
Continuing.

Alternatives

The process above is one way to build, run, and debug Firefly Ice.  But it isn't the only option.  For example, a project file for the Rowley Associates CrossWorks for ARM development system is included in the Firefly Ice firmware repository as well.  CrossWorks runs on Windows, Linux, and the Mac.

Any ARM Cortex-M3 gcc distribution could be used for compiling.

Any JTAG with SWD capability and the associated tool chain could be used for running and debugging.  For example, the Olimex ARM-JTAG-SWD in combination with the Olimex ARM-JTAG-20-10 can be used instead of the Rowley ARM SWD Adapter with the same tool chain as above.

References