There are two ways in which you can upgrade the firmware for the PiJuice. You can use the command line tool provided here or refer to the Software section to find out how to perform a firmware update via the GUI.
pijuiceboot needs to be made executable by running:
chmod 755 pijuiceboot
or
chmod a+x pijuiceboot
./pijuiceboot i2c_address path_to_firmware_binary
./pijuiceboot 14 PiJuice-V1.1_2018_01_15.elf.binary
The firmware source code is not intended to be made openly available as it requires deep understanding of the hardware design and the programming involved if you wanted to customise it. Making changes to the firmware may even harm components or damage the battery. The majority of customisation can anyway be done by using the I2C command interface provided through the Python API that is installed together with configuration GUI. This is the best approach for end users wishing to customise further PiJuice for their needs.
pijucetest.py is an example made available to demonstrate how to communicate with PiJuice using Python.
The script can be found under /home/pi/PiJuice/Software/Test/pijuicetest.py
Make a copy into your home folder and run it to see a display a demo:
cp /home/pi/PiJuice/Software/Test/pijuicetest.py /home/pi/.
cd ~
python pijuicetest.py
The script should display the firmware status, it will print data read from the MCU on screen like battery voltage, charge, battery profile, etc.
Note: For old firmwares (prior to V1.0_2017_08_15) try to use the old firmware updater with a new firmware binary, or use ST debuger to erase flash.
PiJuice bricked after successful firmware update
To recover from this issue follow these steps:
- Make sure that you Raspberry Pi is shutdown
- Disconnect all power to the PiJuice or Raspberry Pi and remove the PiJuice battery
- Hold down SW3 button on the PiJuice and connect power to the Raspberry Pi
- Release SW3 button after few seconds to enter bootloader mode
NOTE: LEDs on the PiJuice will remain off - Stop the pijuice service with
sudo systemctl stop pijuice.service
- Download the Github repository
sudo git clone https://github.com/PiSupply/PiJuice.git
- Enter the Firmware directory
cd PiJuice/Firmware/
- Run
pijuiceboot 14 PiJuice-V1.2_2018_05_02.elf.binary
- Wait until the Firmware has successfully flashed
- Shutdown the Raspberry Pi and remove power
- Connect the battery to the PiJuice and boot up as normal