PiSupply / PiJuice

Resources for PiJuice HAT for Raspberry Pi - use your Pi Anywhere
https://uk.pi-supply.com/collections/pijuice/products/pijuice-portable-power-raspberry-pi
GNU General Public License v3.0
435 stars 104 forks source link

PiJuice bricked after V1.2 firmware upgrade #105

Closed wboerhout closed 5 years ago

wboerhout commented 6 years ago

PiJuice connected to a Raspberry Pi Model B+ V1.2 running Raspbian Stretch Lite (latest update) and pijuice-base. Worked fine until I downloaded and installed V1.2 firmware with

pijuiceboot 14 PiJuice-V1.2_2018_03_28.elf.binary

The upgrade process went fine, but now the pijuice board is completely unresponsive, no lights, no power to the Pi. All communication with python scripts result in "COMMUNICATION_ERROR"

How do I fix this?

EricS61 commented 6 years ago

Having an issue with firmware update/upgrade as well. Pi/PiJuice is shut down. LED near SW3 is steady blue, and LED near SW1 flashing between Green & Blue. Instructions say to press SW3 before pressing SW1. I've tried press and hold SW3 while momentarily pressing SW1, momentarily pressing both SW3 & SW1, and press and hold both SW3 and SW1 with the Pi not powering up for any combination.

tvoverbeek commented 6 years ago

Which instruction? A short press on SW1 alone (the one closest to the green & blue flashing led) should power the Pi. The long press on SW3 is to force the start of the bootloader, to be used with the pijuiceboot utility. From the README on the hardware page (https://github.com/PiSupply/PiJuice/tree/master/Hardware):

**Special functions**

- Dual long press of SW1 and SW2 for 20 seconds will reset PiJuice HAT configuration to default.
  This applies to the MCU configuration only.
- Holding pressed SW3 while powering up PiJuice will initiate the bootloader. This is used only
  in cases when ordinary initiation through I2C does not work because of damaged firmware.
EricS61 commented 6 years ago

Following the later "- Holding pressed SW3 while powering up PiJuice will initiate the bootloader. This is used only in cases when ordinary initiation through I2C does not work because of damaged firmware." as the LED next to SW3 is solid blue. Pressing and holding SW3 while momentarily pressing SW1 to power up the Pi produces negative results (Pi will not power up and LED next to SW1 flashes Blue/Green).

EricS61 commented 6 years ago

OK, had to press and hold SW1 until the power LED on the Pi extinguished. Pressed and held SW3 while momentarily pressing SW1 powered up the Pi. Now, LED next to SW3 is still solid blue. How do I rectify this? In the GUI, if I select Configure HAT, and select Firmware tab, there's a notification that New firmware (V1.2) is available. I've clicked on the Update firmware button perviously, clicked on the "OK" for the warning, and the completion. Do I just reboot?

EricS61 commented 6 years ago

Rebooted Pi after firmware update. SW3 LED is now solid blue in color. PiJuice settings > HAT tab indicate a Fault "battery profile invalid charging temperatureCOOL". Selecting Configure HAT tab, the PiJuice HAT Configuration pop-up only shows General, Buttons, & LEDs tabs.

wboerhout commented 6 years ago

The jury is still out on the resolution of my original question. My PiJuice does not communicate anymore after updating it with the V1.2 firmware.

At one point, I saw output from

i2cdetect -y 1

as follows:

    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- 41 -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --

but the 41 (instead of the expected 14) disappears after the first comm attempt. I still go for 'bricked'.

tvoverbeek commented 6 years ago

@wboerhout It is known that the default i2c-driver in Raspbian Stretch sometimes causes problems (i2c transactions fail). Could you try the following: In /boot/config.txt add the line dtoverlay=i2c-bcm2708 and reboot. This loads the previous version of the i2c-driver which seems to work better in these situations. Try the i2cdetect -y 1 again (and report back).

wboerhout commented 6 years ago
pi@raspi1 ~ $ cat /boot/config.txt
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# https://github.com/PiSupply/PiJuice/issues/105
dtoverlay=i2c-bcm2708
pi@raspi1 ~ $ i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
EricS61 commented 6 years ago

I gave up on the latest firmware update (it was draining the PiJuice battery even with the Pi powered down), and have backed down to firmware that was uploaded/installed (V1.1_2018_01_15) when I installed PiJuice application. Battery is now charging, I have all the tabs again in PiJuice HAT Configuration, and no faults.

wboerhout commented 6 years ago

I have all but given up on the PiJuice. Reverting to old firmware would be my next choice, but since the PiJuice is incommunicado since loading V1.2, nothing at all can be loaded now.

EricS61 commented 6 years ago

wboerhout, not sure if this will help, but this is what I did; Press and hold SW1 till the red power light on the Pi turns off. Ensure the power is plugged into the PiJuice, not the Pi itself. Quickly press and release SW1. Pi will power up. Either ssh into the Pi, or open up a terminal window cd /usr/bin ./pijuiceboot 14 /usr/share/pijuice/data/firmware/PiJuice-V1.1_21018_01_14.elf.binary sudo reboot Bring up the PiJuice app. You will have to adjust some settings to suit your tastes/needs.

wboerhout commented 6 years ago

Last week, I had a lengthy conversation outside this forum with Chris from Pi Supply. All this came and went. For good measure, I retried it now the alternative i2c driver is loaded, but no deal:

pi@raspi1 ~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- 41 -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Note the weird "41" where 14 is expected. I guess it is random data. Then:

pi@raspi1 ~ $  pijuiceboot 41 /usr/share/pijuice/data/firmware/PiJuice-V1.1_2018_01_15.elf.binary
using address 41
Input file /usr/share/pijuice/data/firmware/PiJuice-V1.1_2018_01_15.elf.binary
Starting bootloader
Starting bootloader old firmware
Sending get command
error receiving data -1

No communication. Then, after that:

pi@raspi1 ~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Same thing happened when I used "14" as address regardless of the 41 that i2cdetect reported. For all that matters, the PiJuice just isn't there. And, as stated in my original post, I have not seen one LED light up on the PiJuice after flashing V1.2.

wboerhout commented 6 years ago

pijuice-base (1.3.2-1) has replaced 1.3.1-1 after apt-get upgrade. No changes in behaviour after this.

tvoverbeek commented 6 years ago

Managed to get my PiJuice in a state where it reports only 0x41 and also with no replies at all in i2cdetect.

Try this to recover:

For me pijuiceboot runs normally and then starts the just uploaded PiJuice firmware. In case you used the 1.2 firmware you should get the blue LED2 and a red or red/blue LED1 (since no battery connected) For the 1.1 firmware you do not get the blue LED2.

Hope this helps.

wboerhout commented 6 years ago

Brilliant, thanks! I would never have come up with this sequence.

One thing though. I used this procedure to load the V1.1 firmware, and checked that it was working OK. After that, I repeated it with a load of the V1.2 firmware. It appears to flash properly with pijuiceboot, but after rebooting and inserting the battery, it still reports V1.1-0 as firmware version.

LEDs and function appear to be OK.

Before all this, I have reverted to the original confix.txt, without dtoverlay=i2c-bcm2708

Testing with pij.py:

#!/usr/bin/python
# -*- coding: UTF-8 -*-
from __future__ import print_function

import time
from pijuice import PiJuice

# ---
pijuice = PiJuice(1,0x14)

print(time.strftime( "%Y%m%d%H%M%S", time.localtime( time.time() ) ) )

firmware = pijuice.config.GetFirmwareVersion()
if firmware['error'] == 'NO_ERROR':
   fvers = firmware['data']
   print('firmware: V', fvers['version'], '-', fvers['variant'])
else:
   print('firmware: ', firmware['error'])

charge = pijuice.status.GetChargeLevel()
if charge['error'] == 'NO_ERROR':
   charge = charge['data']
   print('  charge: ', charge, '%')
else:
   print('  charge: ', charge['error'])

temp =  pijuice.status.GetBatteryTemperature()
if temp['error'] == 'NO_ERROR':
   temp = temp['data']
   print('    temp: ', temp, '°C')
else:
   print('    temp: ', temp['error'])

vio =  pijuice.status.GetIoVoltage()
if vio['error'] == 'NO_ERROR':
   vio = vio['data']
   print('  iovolt: ', float(vio)/1000.0, 'V')
else:
   print('     vio: ', vio['error'])

with output:

pi@raspi1 ~ $ python pij.py
20180507204850
firmware: V 1.1 - 0
  charge:  63 %
    temp:  37 °C
  iovolt:  5.038 V
tvoverbeek commented 6 years ago

The V1.2 firmware reporting itself as V1.1 is a known problem (See Issue #95). Looks it is working again for you. If it is working fine, no need to change to the i2c-bcm2708 driver.

Are you only using pijuice-base? If so, the pijuice_cli.py now on GitHub has a lot of bug fixes including proper support of new firmwares. By the way, assuming your are Dutch like me. Wens je het allerbeste met je PiJuice.

wboerhout commented 6 years ago

My Pi for this project (mounting a dashcam on my robot lawn mower) doesn't need a GUI so yes, I will look into that, and into pijuice_cli.py as well.

Nogmaals, hartelijk dank.

shawaj commented 6 years ago

@wboerhout we have a new firmware out now which fixes the reporting wrongly issue.

we should also have a package update in the coming week which will fix all the issues and pull the new firmware in also

thanks for your patience and thanks @tvoverbeek for helping!!

rbnpi commented 6 years ago

Just loaded the new V1.2_2018_05_02.elf.binary using pijuice 14 V1.2_2018_05_02.elf.binary Says it went successfully but my board now is totally unresponsive. (I also loaded the new 1.3.3 deb which seemed to work OK. Where do I go from here?

shawaj commented 6 years ago

@rbnpi could you start this as a new issue please? Did you try updating the firmware from inside the GUI first? The manual update is not recommended unless someone tells you to do that

shawaj commented 6 years ago

Also did you try the steps above posted by ton?

wboerhout commented 6 years ago

Well, in all fairness, there absolutely should be a documented way to update without a GUI. None of my projects need a GUI. I have never installed a GUI environment on a Raspberry and I am not planning to do that.

tvoverbeek commented 6 years ago

The pijuice_cli.py in the pijuice_base 1.3.3 package does a proper update. No gui needed. Until the 1.3.3 packages are available in the raspbian archive you will have to download the .deb from GitHub.

On Thu, May 17, 2018 at 3:43 PM, Wilm Boerhout notifications@github.com wrote:

Well, in all fairness, there abosolotely should be a documented way to update without a GUI. None of my projects need a GUI. I have never installed a GUI environment on a Raspberry and I am not planning to do that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PiJuice/issues/105#issuecomment-389986050, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJE7g0GB_qVioImGlW5vREOHIrWtbImks5tzdLogaJpZM4TqJs7 .

rbnpi commented 6 years ago

Well I updated because received a general email sent today which suggested it. I put the 1.3.3 deb in but couldn't upgrade with that, so reverted to using pijuice to do it. This said it installed OK. However now no response from battery leds although they were doing weird things for a bit, and no response from i2cdetect -y 1.

shawaj commented 6 years ago

Have you read the way this was resolved by Ton above?

rbnpi commented 6 years ago

Yes. I have triedd removing the battery and carrying out the process he described, but still no communication when trying pijuiceboot. I've also tried the pijuice_cli.py in the 1.3.3 package. still nothing seen on i2cdetect -y 1

rbnpi commented 6 years ago

OK I used a previous SD card and managed to restore the old firmware using Ton's method. I'll leave it there until the new apt-get packages are released!

shawaj commented 6 years ago

Glad to hear it's working again

wboerhout commented 6 years ago

For my part, I downloaded and installed pijuice_base 1.3.3, then using pijuice_cli.py I upgraded the firmware to V1.2 . All went well, I'm happy

shawaj commented 6 years ago

@wboerhout awesome! glad to hear it. pesky electronics seem to be a bit tempremental. Enjoy your PiJuice and your weekend!

dducret commented 6 years ago

Following the procedure, I was able to flash the board

root@raspberrypi:/home/pi# pijuiceboot 14 PiJuice-V1.2_2018_03_28.elf.binary using address 14 Input file PiJuice-V1.2_2018_03_28.elf.binary Starting bootloader Starting bootloader old firmware Sending get command bytesRead 13 dataLen 11 ack 79 data: b, 10, 92 data received 11 bootloader version: b commands: 10, 0, 1, 2, 11, 21, 31, 44, 63, 73 erase page count 20 first page erase succcess 0 erase success 0 page count 157 mem data read 256, 256 Page 156 programmed successfully ... Page 1 programmed successfully mem data read 256, 256 Page 0 programmed successfully EEPROM programming finished successfully Code executed successfully

After reboot pijuice-cli.py not working and when I am doing i2cdetect -y 1 the second time nothing detected

root@raspberrypi:/home/pi# i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- 41 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
root@raspberrypi:/home/pi# i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

tvoverbeek commented 6 years ago

It seems you are using the wrong firmware file. The correct one (as in the current 1.3.3 pijuice-base package) is PiJuice-V1.2_2018_05_02.elf.binary Also this version programs 276 pages instead of 157. Here is my output:

pijuiceboot 14 ./PiJuice-V1.2_2018_05_02.elf.binary 
using address 14
Input file ./PiJuice-V1.2_2018_05_02.elf.binary
Starting bootloader 
Starting bootloader old firmware
Sending get command 
bytesRead 13  dataLen 11
ack 79
data: b, 10, 92
data received 11
bootloader version: b
commands: 10, 0, 1, 2, 11, 21, 31, 44, 63, 73
erase page count 35
first page erase succcess 0
erase success 0
page count 276
mem data read 256, 256
Page 275 programmed successfully
mem data read 256, 256
Page 274 programmed successfully
mem data read 256, 256
......
Page 4 programmed successfully
mem data read 256, 256
Page 3 programmed successfully
mem data read 256, 256
Page 2 programmed successfully
mem data read 256, 256
Page 1 programmed successfully
mem data read 256, 256
Page 0 programmed successfully
EEPROM programming finished successfully
Code executed successfully

Suggest you try to reflash using the correct firmware (get it from github or the 1.3.3 pijuice-base package). When the flashing is successfull, the firmware restarts and LED D2 should light bright blue.

dducret commented 6 years ago

Previously I did the download with curl

curl https://github.com/PiSupply/PiJuice/blob/master/Firmware/PiJuice-V1.2_2018_03_28.elf.binary -o PiJuice-V1.2_2018_05_02.elf.binary

and the file size was 40067, with git clone the files size is 70452. Can it be a good idea to put a zip version in the repository ? Or do you have another way for doing it ?

tvoverbeek commented 6 years ago

Use the git clone one. 70452 is the correct size. Note with curl you downloaded the March 28 version, while the May 2nd version is the correct one.

tvoverbeek commented 6 years ago

Seems your curl download truncated the file. The correct size for the March 28 version is 70496, but please use the May 2nd version.