|
Compiling
Compiling the Proxmark from source and flashing
Generic notesNOTE: this page is currently being changed and updated to reflect the most recent changes to the USB protocol and bootloader updates. Flash sectionsThe firmware of the proxmark3 contains three distinct sections that can be flashed independently: bootloader, fpga image and os image. Bootloader
The bootloader (sometimes also called bootrom) is a small piece of code that enables writing to the flash over USB in the first place. It's updated very infrequently and, due to its importance, should be left alone most of the time. As long as your bootloader is intact you can recover any firmware error of your proxmark3 with just an USB connection and the provided flash tools. When you destroy your bootloader, you will need a JTAG connection and associated tools to recover the device. FPGA image
The FPGA image is the configuration/code that runs on the FPGA that sits on the proxmark3. Since the FPGA doesn't have flash memory of its own, this configuration is stored in the flash memory of the ARM processor and downloaded into the FPGA on each boot of the device. The FPGA code (called bit stream) is updated fairly infrequently, and special tools are needed to compile the bit stream from the verilog sources. The proxmark3 firmware source releases and SVN checkouts always contain a compiled bit stream (in fpga/fpga.bit) which is then simply wrapped into an image file for you to flash onto the proxmark3. OS image
The OS image is the main firmware code that runs on your proxmark3. It is developed and regularly updated in the SVN, but if you don't need the latest features you are well off using the provided binary releases. (Note also: since the SVN is considered eternal work-in-progess, a current SVN version might not work or even build.) The OS image and FPGA image work in tandem, so you should always flash them from the same SVN revision. Revision history and flashing proceduresAs mentioned above, the Proxmark3 is largely a constant work in progress. Its firmware started off as a big update from the older ProxmarkII project, and was mainly aimed at demonstrating a few key concepts rather than provide a polished end-user interface. Over time, and thanks to the many contributions of all the developers on the project, the firmware has evolved in many ways: new commands and features, more refined firmware architecture, etc. While very exciting, this has also led to a bit of confusion as to exactly how to load firmware onto a Proxmark3 board, and what releases should be used. This section tries to explain the main milestones and how to get from one milestone to the next. Original firmwareThe original firmware which is the one shipped on some pre-built Proxmark3 devices is now generally considered as outdated. If your Proxmark3 is loaded with the original firmware, you should consider upgrading to the most recent binary release. With this original firmware, there is no Linux client, and flashing is done using the "prox" windows command. Note that normally, you should never need to use those since this firmware is outdated: you should use the flashing commands provided by more recent versions of the PM3 to upgrade your board. Summer '09 release (SVN r216)Upgrading from the original firmware: you should first of all upgrade the bootloader, by entering the (original) bootloaded by keeping the PM3's button pressed and launch the prox or flasher command depending on your OS (please refer to the 'flashing the bootloader' instructions further below on this page). Once the bootloader is upgraded, the PM3 will be confused and won't find its OS image. This is fine: by using the flasher tool you will be able to first flash the FPGA image, then OS image (instructions further below as well). Winter '10 release (SVN r412)This release introduces other major changes to the firmware, and the bootloader as well as FPGA & OS images should be updated, using the "flasher" command on both Windows and Linux. The flashing commands have changed a lot as well as the USB protocol, so you will first need to install a specific PM3 driver is you are on Windows, as described below: - Start / Control Panel / System / Hardware / Device Manager - Find the Proxmark under "Human Interface Devices", it will show up as a "USB Human Interface Device". Pay attention to the "USB" in the name of the device: do not choose the "HID Compliant device" with the same PID/VID - Right click the device and select "Update Driver" - Choose "No, not this time" if Windows asks you for Windows update permission - Choose "install from a list or specific location" - Select "Don't search, I will choose" and on the next dialog press "Have Disk..." - Browse for your PM3's driver directory Once the driver is installed, you can move on to first flashing the new bootloader, then the "fullimage.elf" provided in the ZIP archive: D:\Documents\Hobbies\RFID\Proxmark Firmware\Winter 2010 Release r419>flasher.exe -b bootrom.elf Loading ELF file 'bootrom.elf'... Loading usable ELF segments: 0: V 0x00100000 P 0x00100000 (0x00000200->0x00000200) [R X] @0x94 1: V 0x00200000 P 0x00100200 (0x0000175c->0x0000175c) [R X] @0x294 Waiting for Proxmark to appear on USB... Found. Entering bootloader... (Press and release the button only to abort) Waiting for Proxmark to reappear on USB... Found. Flashing... Writing segments for file: bootrom.elf 0x00100000..0x001001ff [0x200 / 2 blocks].. OK 0x00100200..0x0010195b [0x175c / 24 blocks]........................ OK Resetting hardware... All done. Have a nice day! D:\Documents\Hobbies\RFID\Proxmark Firmware\Winter 2010 Release r419>flasher.exe fullimage.elf Loading ELF file 'fullimage.elf'... Loading usable ELF segments: 0: V 0x00102000 P 0x00102000 (0x0000a4bc->0x0000a4bc) [R ] @0xb4 1: V 0x00110000 P 0x00110000 (0x000140b8->0x000140b8) [R X] @0xa570 2: V 0x00200000 P 0x001240b8 (0x00000004->0x00000004) [RW ] @0x1e628 Note: Extending previous segment from 0x140b8 to 0x140bc bytes Waiting for Proxmark to appear on USB... Found. Entering bootloader... (Press and release the button only to abort) Waiting for Proxmark to reappear on USB... Found. Flashing... Writing segments for file: fullimage.elf 0x00102000..0x0010c4bb [0xa4bc / 165 blocks]................................... ................................................................................ .................................................. OK 0x00110000..0x001240bb [0x140bc / 321 blocks].................................. ................................................................................ ................................................................................ ................................................................................ ............................................... OK Resetting hardware... All done. Have a nice day! D:\Documents\Hobbies\RFID\Proxmark Firmware\Winter 2010 Release r419> From there on, you should not need to update the Bootloader upon new firmware releases - unless of course there is another large bootloader upgrade at a later stage! Flash toolsOn older SVN versions (up to Summer of '09):
On newer SVN versions (Winter of '10 onwards):
Entering the bootloaderSince the proxmark3 can execute in two distinct modes (main os, and bootloader) it needs to be in bootloader mode if you want to write to the flash. There are two ways of entering bootloader mode:
The second option only works with a new bootrom and a new osimage (SVN revision 201 or later; summer '09 release or later), the first option should always work with all bootroms since at least SVN revision 2. Host tool
Known incompatibilitiesUnless otherwise noted these incompatibilities are not mutual, f.e. a new flash tool will work with both new and old bootroms.
Prerequisites for compiling from sourceFor the bootrom and armsrc directories you need GNU make and a GNU arm toolchain (at least gcc and binutils). For Windows a complete ARM toolchain is provided in the "Windows development environment" zip file. For Linux you need to get your own toolchain, though there is a script in tools/install-gnuarm4.sh that can greatly automate the process. Optionally, to build images that contain version information, you need perl (provided in the Windows development environment) and svn. For the client directory you need pkg-config, gcc, GNU binutils, GNU make, libusb, libreadline, QtCore, QtGui as well as the header/development files for the latter four packages. For the winsrc directory you need FIXME. This is provided in the "Windows development environment" zip file. Windows PlatformSetting up SubversionIn order to obtain the latest source code you need to check it out of the SVN repository. To do that you can use any number of free clients. This guide will show you how to use Subcommander which is a good choice for n00bs as it has a graphical interface and does not require command line access.
You're now ready to download the source code. In your Projects pane on the left, expand the proxmark tree and you should now see an entry called trunk. Right click on it and select check out from the menu. In the working copy path field type C:\prox-dev\proxmark then click OK and wait for the checkout to complete. Using your file explorer, browse to C:\prox-dev\proxmark and you should see a number of subdirectories with source files in them. Rejoice! Setting up the compile environmentDownload the Compile Environment archive. Extract the archive to C:\prox-dev then check that you have the following subdirectories:
Compiling the codeBrowse to the folder C:\prox-dev\proxmark\cockpit and run the file 0setpath.bat A command window opens up. At the prompt type 5makeall.bat and wait for the compile to finish.
Flashing the boardPlease refer to the Flashing instructions above, depending on your SVN revision. Browse to the folder C:\prox-dev\proxmark\cockpit and run the file 0setpath.bat A command window opens up. Flashing the bootloaderNote: Since SVN revision 201 (2009-09-01 16:44:38 +0200) the bootloader protocol is incompatible with old flash tools. Please use only new flash tools to prevent any problems. The new Linux flash tool is available since SVN revision 200, the new Windows flash tool is available since SVN revision 209. On Windows, newer SVN versions require a libUSB driver to be installed on your computer, not the standard HID driver. Instructions for upgrade/installation are documented in the "Winter of '10" section above. You only have to do this step once if you have an older or unknown firmware board. It is not recommended to keep reflashing the bootloader every time there's a code change unless the change applies to the bootloader. It is however strongly recommended to update to the new revision 201 bootloader (as included in the summer '09 release), if you don't already have it (the flash tool will inform you of this). Type prox bootrom ..\bootrom\obj\bootrom.s19 but do not press enter yet.
Flashing the FPGAYou only have to flash the FPGA if there has been a change in the FPGA code. This happens fairly infrequently. Connect the PM3 board via the USB cable. Type prox fpga ..\armsrc\obj\fpgaimage.s19 and hit enter. See above for button pressing instructions. Flashing the ARMThis is the code that changes most often and needs to be flashed. Connect the PM3 board via the USB cable. Type prox os ..\armsrc\obj\osimage.s19 and hit enter. See above for button pressing instructions. Flashing more than one partition at a timeWith the new flash tool you can do things like prox os,fpga ..\armsrc\obj\osimage.s19 ..\armsrc\obj\fpgaimage.s19 Linux PlatformThe following detail has been created for Ubuntu and other Debian-like (BackTrack) distributions... Setting up Subversionsudo apt-get install subversion Check out the proxmark3 subversion directory below your home directory and change into it: svn co http://proxmark3.googlecode.com/svn/trunk proxmark3-read-only cd proxmark3-read-only Getting the prerequisitesFor the host tool: sudo apt-get install build-essential libreadline5 libreadline-dev libusb-0.1-4 libusb-dev libqt4-dev perl pkg-config For the ARM toolchain: Option 1: Use the provided automatic toolchain build script like this: sudo apt-get install wget tools/install-gnuarm4.sh ~/gnuarm `pwd`/tmp This will build the toolchain and keep temporary directories in tmp under the current directory and install the toolchain to gnuarm under your home directory. When the build is finished it will output something like set environment variable ARMLIB to /home/YOURUSERNAME/gnuarm/lib/gcc/arm-elf/4.3.3/interwork. Follow this advice by executing: export ARMLIB=/home/YOURUSERNAME/gnuarm/lib/gcc/arm-elf/4.3.3/interwork
export PATH=${PATH}:/home/YOURUSERNAME/gnuarm/bin/You should also append these two lines to your ~/.bashrc so that they apply every time you login. Option 2: sudo apt-get install wget
wget http://sourceforge.net/projects/devkitpro/files/devkitARM/previous/devkitARM_r32-i686-linux.tar.bz2/download
tar jxvf devkitARM_r32-i686-linux.tar.bz2
sudo mkdir /opt/devkitpro/
sudo mv devkitARM /opt/devkitpro/
export PATH=${PATH}:/opt/devkitpro/devkitARM/bin/You should also append the export line to your ~/.bashrc so that the PATH changes apply every time you login. BuildingYou are now ready to simply execute make from the main proxmark directory which will build all parts: bootrom (check that bootrom/obj/bootrom.s19 is created), fpga image (armsrc/obj/fpgaimage.s19), os image (armsrc/obj/osimage.s19) and the host tool (client/proxmark3). Flashing the boardBrowse to the linux source folder in your SVN repo: .../client Flashing the bootloaderNote: Since SVN revision 201 (2009-09-01 16:44:38 +0200) the bootloader protocol is incompatible with old flash tools. Please use only new flash tools to prevent any problems. The new Linux flash tool is available since SVN revision 200, the new Windows flash tool is available since SVN revision 209. You only have to do this step once if you have an older or unknown firmware board. It is not recommended to keep reflashing the bootloader every time there's a code change unless the change applies to the bootloader. It is however strongly recommended to update to the new revision 201 bootloader (as included in the summer '09 release), if you don't already have it (the flash tool will inform you of this). Type ./flasher bootrom ../bootrom/obj/bootrom.s19 but do not press enter yet.
Flashing the FPGAYou only have to flash the FPGA if there has been a change in the FPGA code. This happens fairly infrequently. Connect the PM3 board via the USB cable. Type ./flasher fpga ../armsrc/obj/fpgaimage.s19 and hit enter. See above for button pressing instructions. Flashing the ARMThis is the code that changes most often and needs to be flashed. Connect the PM3 board via the USB cable. Type ./flasher os ../armsrc/obj/osimage.s19 and hit enter. See above for button pressing instructions. Flashing both the FPGA and the ARM in one goIf you know you need to flash both FPGA and ARM code, this will save time as it will not reboot the PM3 between flashes. Connect the PM3 board via the USB cable. Type ./flasher os,fpga ../armsrc/obj/osimage.s19 ../armsrc/obj/fpgaimage.s19 and hit enter. See above for button pressing instructions. OSX PlatformTo be added. | |
doc is old
dir linux renames in my svn revision 291 to client
Two changes:
# since rev 301 the flasher does not work with the s19 files any more but expects elf files.
# to compile the os under linux you have to set LIBGCC instead of ARMLIB export LIBGCC=/home/YOURUSERNAME/gnuarm/lib/gcc/arm-elf/4.3.3/interwork/libgcc.a
For the installation under Linux you will also need the devkitARM. I found a good script that will install it here:
http://wiki.devkitpro.org/index.php/Getting_Started/devkitARM (Goto "Alternative installation script")
To compile under vista, you would need the recent GNU ARM toolchain since the version (4.1.0) bundled with the Summer 09 release has some issues. You would normally proceed by replacing the bundled version with the new 4.3.2, and edit the common/Make.common (line 37) to reflect the changes. You should then run a clean build.