Compile the Bus Pirate firmware

From DP

Jump to: navigation , search

There is also generic guide to compiling PIC projects.

Contents

Prepare your build environment

You need to download and install Microchip's IDE called MPLAB X and then MPLAB XC16 compiler. Below I will give an example of how to do it for Linux:

1) Download MPLABX-vVERSION-linux-installer.tar then extract and launch it:

tar -xvf ./MPLABX-vVERSION-linux-installer.tar
sudo ./MPLABX-vVERSION-linux-installer.sh

Installer needs to be run as root. If it complains about the missing libraries you will need to search and install them (32-bit versions, both "normal" and "development" packages) before trying again. At Fedora I had to install 32-bit versions of libX11-devel, libXau, libXau-devel, libxcb, libxcb-devel, libXect, libXect-devel

2) Download and run xc16-vVERSION-full-install-linux-installer.run installer:

sudo ./xc16-vVERSION-full-install-linux-installer.run


3) (OPTIONAL) Run a following command to get your HostID (if you forgot it) :

/opt/microchip/xc16/vVERSION/bin/xclm -hostinfo

Register and login to website, then go to this page. Write your HostID, choose your OS (Linux) and your product (XC 16), then click "Download". You will get a YOURHOSTID-xc16-demo.sh file, which you need to run under root:

sudo ./YOURHOSTID-xc16-demo.sh

Then launch MPLAB X to see the duration and ending time of your evaluation period

Example of a build environment:

[*] Ubuntu Linux 16.04.1 x64
[*] MPLAB X v3.40
[*] MPLAB XC v1.26 compiler with PRO mode enabled (60 days free evaluation license)
[*] Project Properties -> Conf: [default] -> XC16 (Global Options) -> x16-gcc -> Option Categories: Optimizations -> Optimization Level -> changed from 0 (no opt) to 3 (optimize yet more favoring speed)


Get the code of Community Firmware v7.0 from Github

Get the latest revision of Bus Pirate repository containing Community Firmware v7.0 project by running

git clone https://www.github.com/BusPirate/Bus_Pirate.git


Or if you are on Windows and don't know how to use git, just download this file:

https://github.com/BusPirate/Bus_Pirate/archive/master.zip


Your feedback and patches are welcome!

Building with MPLAB X (Win, Linux, Mac)

Repository contains the following MPLABX project files:

./BPv4-bootloader/firmware-v1/bpv4-bootloader.X
./Firmware/busPirate.X


Firmware project file is universal, while a bootloader project file is only for Bus Pirate v4 .

1) Open a desired project file with MPLAB X:

File -> Open project -> ...


2) If this project is a firmware, you need to choose a configuration that matches your device:

Run -> Project configuration -> Bus Pirate v3 or v4
(depends on for what device you want to build) ^


3) (OPTIONAL) Right click on a project, then go through the menus to choose the optimization level:

Project Properties -> Conf: ... -> XC16 (Global Options) -> xc16-gcc -> Option categories: Optimizations -> Opimization Level

Note: this option is available only if you got 60 days of PRO evaluation from Microchip

About the optimization levels:

- 0 - Do not optimize. The compiler’s goal is to reduce the cost of compilation and to make debugging produce the expected results
- 1 - Optimize. Optimizing compilation takes somewhat longer, and a lot more host memory for a large function. The compiler tries to reduce code size and execution time
- 2 - Optimize even more. The compiler performs nearly all supported optimizations that do not involve a space-speed trade-off
- s - Optimize yet more favoring size (superset of O2)
- 3 - Optimize yet more favoring speed (superset of O2)

Even on level 3 my BPv4 passes a self test successfully, no errors. So you could try a stronger optimization first, and then - if it is causing you some issues - you tell us about them on Github and meanwhile could use a lighter optimization version (such as level 0 or 1)

4) Clean and build - press this button to build a project

5) The primary result of project build is a .hex file.

    Bootloader:
./BPv4-bootloader/firmware-v1/bpv4-bootloader.X/dist/default/production/bpv4-bootloader.X.production.hex
     Firmware:
./Firmware/busPirate.X/dist/BusPirate_v3/production/busPirate.X.production.hex
./Firmware/busPirate.X/dist/BusPirate_v4/production/busPirate.X.production.hex


What to do next?

After you obtain the results of your build, install the recently compiled firmware/bootloader using this guide: http://dangerousprototypes.com/docs/Bus_Pirate#Firmware_upgrades