# Flashing the Bus Pirate This repo contains everything you need to flash a newly assembled Bus Pirate (BP). Flasing the BP using a Linux machine is significantly more simple than using Windows. ## Basic steps: - Clone this repository (with subrepos) - Build the PiratePICprog tool (or use the prebuild linux binary) - Connect a working Bus Pirate to the BP to be flashed - Flash - ... - Profit...? ### Cloning the repository If you have git installed on your system, it is as simple as running the following from a command line: ``` git clone --recurse-submodules https://git.scintilla.utwente.nl/shock/BusPirateFlashing ``` Otherwise go to the [BusPirateFlashing repo](https://git.scintilla.utwente.nl/shock/BusPirateFlashing) and the [PiratePICProg repo](https://git.scintilla.utwente.nl/shock/PiratePICprog.git) and download both (download > Download zip) ### Building the flashing tool You might be lucky. First test the binaries in the bin folder to see if there is one that works for you. Otherwise you have to build it yourself: Make sure to have make, cmake and a compiler such as gcc or clang on linux/mac, or MinGW on windows installed on your system. Most linux and mac systems already have this installed. On windows figure this out for yourself... Now open the PiratePICProg folder in a terminal and run the following commands to build the tool: ``` cmake CMakeLists.txt make ``` If everything went right the output binary should be in the bin folder (`picprog`). Copy this binary to the BusPirateFlashing folder, where the firmware files are located. ### Connecting your flashing BP to the new BP | Bus Pirate | Dir. | New BP | Description | | ----------:|:----:|:----------:|:-------------------- | | MOSI | → | PGD | Program data | | CLK | → | PGC | Clock signal | | CS | → | VPP/MCLR | Programming control | | GND | ⏚ | GND | Signal Ground | | 3.3v/5v | → | VDD | Power (optional) | ### Flashing the new BP First you need to find the port of the working BP. Connect it to your computer. Then for linux you can find this using `dmesg` and look for a line containing `tty*` where * can by anything: ![Linux Bus Pirate port location](Pics/linux_device_port.png) So for me its `ttyACM0`. The full address is `/dev/ttyACM0`. On windows open Device Manager (search `Device Manager` or `Apparaatbeheer` in the start menu) and look for `Ports (COM & LPT)`: ![Windows Bus Pirate port location](Pics/windows_device_port.png) Here the port is `COM6`. Now open a terminal in the BusPirateFlashing folder and run the following command: ``` ./picprog -p buspirate -u -s 115200 -c 24FJ256GB106 -t hex -w bpv4_boot4.10_fw7.0_optS_18092016.hex ``` If everything went right, you should now have a working Bus Pirate! Now you can update the onboard firmware without any external tools. For more information and the most up to date firmware visit the [Bus\_Pirate community repo](https://github.com/BusPirate/Bus_Pirate) Instructions on building and flashing the most up to date firmware can be found [in their flashing guide](https://github.com/BusPirate/Bus_Pirate/blob/master/Documentation/building-and-flashing-firmware.md)