Development Tools

New Version of Fx2tools

Posted in Development Tools, Software on August 20th, 2010 by Chris – Be the first to comment

Recently I updated Fx2tools. Now you can:

  • Upload SDCC-generated HEX records directly to an FX2LP chip's RAM and EEPROM
  • Backup & restore EEPROM (e.g firmware for Digilent's FX2-based FPGA development products)
  • Send arbitrary commands to the chip's control endpoint
  • Benchmark bulk writes to the FX2LP chip

I have successfully tested it with

Cross-Platform Builds

Posted in Development Tools, Software on April 5th, 2010 by Chris – 2 Comments

For a while now I've been getting worried about the amount of boilerplate source code I'm copying around from one project to another, so yesterday I refactored all the general-interest code out of my current mini-project and wrote a cross-platform build infrastructure which can build and test each mini-library in isolation, and automatically integrate with github for fetching dependencies. Doing such a thing in a language like Java is very easy, but doing it in C is far harder.

Firstly the directory structure. Each project lives in a structure like this:

src
|
+-apps
| |
| +-nanduinoJtag
|
+-libs
| |
| +-argtypes
| +-buffer
| +-dump
| +-hexreader
| +-usbwrap
|
+-3rd
  |
  +-argtable2-12
  +-LUFA091223
  +-UnitTest++

The idea is to maintain a clear separation between 3rd-party ("3rd") code, my own library ("libs") code and my own application ("apps") code, and to automatically fetch any dependencies, downloading my own libs if necessary from github and building them, and downloading 3rd-party libs and tools from wherever and building them.

The build infrastructure itself is based on GNU make, and it supports Linux and Windows builds.

Windows Builds

The Windows platform introduces some unique challenges. Tooling on Windows is characterised by large-scale tools, usually relying heavily on IDE integration, rather than the more expressive Unix environment which is based on a large number of small-scale tools which cooperate with eachother. So to get off the ground on Windows you will need a couple of prerequisites:

  • A functional GNU environment. I do a lot of stuff using Atmel AVR microcontrollers, so I have WinAVR installed, which comes with such an environment, but you will probably get away with a more minimal cygwin or mingw installation, so long as it has basic stuff like make, tar, mv, cp, wget, etc.
  • An installation of Microsoft Visual C++ 2008 Express Edition which is available from Microsoft as a free download. The 2010 edition will not work because vcbuild.exe has been deprecated.

Once you have the prerequisites you can go ahead and build an application (this one really does need WinAVR since it contains AVR code)...

C:\temp>mkdir foo-src
C:\temp>cd foo-src
C:\temp\foo-src>mkdir apps
C:\temp\foo-src>cd apps
C:\temp\foo-src\apps>wget http://github.com/makestuff/nanduinoJtag/tarball/master
C:\temp\foo-src\apps>tar xvzf makestuff-nanduinoJtag-*.tar.gz
C:\temp\foo-src\apps>cd makestuff-nanduinoJtag-*
C:\temp\foo-src\apps\makestuff-nanduinoJtag-c9d3c67>make -f Makefile.win32
C:\temp\foo-src\apps\makestuff-nanduinoJtag-c9d3c67>cd ..\..
C:\temp\foo-src>find . -maxdepth 2 -type d
.
./3rd
./3rd/argtable2-12
./3rd/libusb-win32-device-bin-0.1.12.2
./3rd/LUFA091223
./3rd/UnitTest++
./3rd/unz600
./apps
./apps/makestuff-nanduinoJtag-c9d3c67
./libs
./libs/argtypes
./libs/buffer
./libs/dump
./libs/hexreader
./libs/usbwrap

After the build completes you will notice that the requisite dependencies for this particular project have been downloaded and built for you. Where possible I have used the vcbuild tool rather than invoking the compiler and linker directly, so you should be able to run the apps in the Visual Studio IDE without problems.

Linux Builds

Achieving the same thing on Linux is considerably simpler. The requisite tools are usually already installed, and if not can easily be installed using your favourite package manager.

> mkdir foo-src
> cd foo-src/
> mkdir apps
> cd apps/
> wget http://github.com/makestuff/nanduinoJtag/tarball/master
> tar xvzf makestuff-nanduinoJtag-*.tar.gz
> cd makestuff-nanduinoJtag-*
> make -f Makefile.linux
> cd ../..
> find . -maxdepth 2 -type d
.
./apps
./apps/makestuff-nanduinoJtag-c9d3c67
./libs
./libs/dump
./libs/usbwrap
./libs/hexreader
./libs/buffer
./libs/argtypes
./3rd
./3rd/UnitTest++
./3rd/argtable2-12
./3rd/LUFA091223

After the build completes you will notice that the requisite dependencies for this particular project have been downloaded and built for you.

You GIT!

Posted in Development Tools on August 7th, 2009 by Chris – Be the first to comment

I always forget how to use git, so here's a quick reminder (for myself as much as anything):

How can I create a new repository?

git init

How can I add this new file?

git add newFile.txt

What have I edited?

git diff

How do I delete some files?

rm file1.c file3.c file5.c
git add -u  # Update: pick up changes only to known files

Commit my changes!

git commit -a -m "Fixed all the bugs!"

Rollback my changes!

git checkout -- myEditedFile.txt

Push changes to github.com

git push

Make a local copy of a github.com repository

git clone git@github.com:makestuff/fx2tools.git fx2tools