# Porting PX4 to the Sparky2 flight controller
## Overview
## Status
### Bootloader
Since the Sparky2 doesn't use the same pin as the PX4 boards, some hacking is required to disable VBUS sensing (if I recall correctly). I forked the repository and made a small patch to the bootloader. It seems to be working fine.
* [PX4_Bootloader](https://github.com/RedoXyde/PX4_Bootloader) in the _sparky2_ branch.
### Firmware
#### PX4
* [PX4_Firmware](https://github.com/RedoXyde/PX4_Firmware) in the _sparky2_ branch.
#### NuttX
The PX4 fork of NuttX is a little bit old and some drivers are not available. ie: the M25P16 flash is not supported, so I backported the patch from the original repository. It's enough to be able to use the flash, but it stil l doesn't work (yet); more details below.
* [PX4_NuttX](https://github.com/RedoXyde/PX4_NuttX) in the _sparky2_ branch.
#### Drivers/Susbsytems
##### Working
* Serial (57600, 8N1) * USB (CDC-ACM) * MPU9250
##### Not Working
* MTD
The M25P16 is only page erasable (64 kiB) and the MTD subsystem tries to `kmalloc` enough memory to be able to copy the whole page in RAM before erasing (and re-writing). Since PX4 uses two partitions, it requires 128 kiB of RAM only for the MTD subsystem. The Sparky2 only has 192 kiB of RAM, it's not possible to waste 128kiB for just nothing. Possible workaround is to use M25PE16 flash, which is subsector erasable (4 kiB). The Flash ID is not the same (80h instead of 20h), so going back to TauLabs will be a bit tricky but it's worth a try (the chips are not really expensive).
* UAVCAN
libuavcan does not compile with current stable PX4 firmware, some C++-related issue
##### Unknown
* …
## Links
* [F4by](http://www.megapirateng.com/2014/02/f4by-entering-32bit-world/) THis board uses a M25P16 flash as well, but I don't know if/how they got it working with the MTD subsystem