Flashing a Spark Core you bought elsewhere or in case of emergency

With the Photon, you have to flash the system modules and the user firmware. If the user firmware is built with a different version of the system modules, it will not work and the LED will flash red.

FlashDfu.py takes care of both for you. FlashDfu.py uses dfu-util, so it is strange if it won’t detect the photon.

Hi, can anyone help please? I’m not sure how, but I think I’ve deleted the firmware on my BrewPi. I’m trying to follow these instructions, but at this point got a “404 Not Found” message. I’m guessing the link is out of date. I’ve searched around for another “brewpi.bin”, but could only find brewpi-x.x.x-photon.bin and brewpi-x.x.x-core.bin. I’m not sure if I should use either, both or one of these. At this point I think it’s better to ask than go ahead and try!
Please help if you can. All the best, Charles.

by the way, I have tried using the python script in /home/brewpi/utils, and got this result:
pi@charlesberg ~ $ sudo python /home/brewpi/utils/flashDfu.py
Traceback (most recent call last):
File “/home/brewpi/utils/flashDfu.py”, line 153, in
dfuUtilVersion = re.search(’(?<=dfu-util\s)\S*’, output).group()
AttributeError: ‘NoneType’ object has no attribute ‘group’

You should not have to download a binary manually anymore.

Can you run this:
dfu-util -V

And paste the output here?
On what kind of system are you running this? A raspberry pi?
I think dfu-util is not running properly on your system and our script does not handle errors well enough to make that clear.

Thanks Elco. I had to put “./” in front of the command to make it work - is that normal? Here’s the output:
pi@charlesberg ~ $ dfu-util -V
bash: dfu-util: command not found
pi@charlesberg ~ $ ./dfu-util -V
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

I am using a raspberry pi.

./ in front of a command runs on local files (the . stands for current directory).
In which directory are you running this?
And in which directory are you when running flashDfu.py?

On the pi, if dfu-util is not installed on the path (which is your case), the update script downloads it.
Did you download install our download it manually yourself?

Sorry it’s taken so long. My pi died (at least, I couldn’t log into it, I’ve no idea why), so I’ve installed a new Raspbian, and re-installed the BrewPi software on the Pi. Now I just need to be able to flash the firmware back onto the Spark Core.

I think I’m back to exactly where I was before. ./dfu-util -V returns this:

pi@charlesberg:~ $ ./dfu-util -V
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

when I try to use FlashDfu.py (I got the yellow flashing light), I get this:

pi@charlesberg:~ $ sudo python /home/brewpi/utils/flashDfu.py
Traceback (most recent call last):
File “/home/brewpi/utils/flashDfu.py”, line 153, in
dfuUtilVersion = re.search(’(?<=dfu-util\s)\S*’, output).group()
AttributeError: ‘NoneType’ object has no attribute ‘group’

running ./dfu-util -l returns this:

pi@charlesberg:~ $ ./dfu-util -l
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Found DFU: [2b04:d006] devnum=0, cfg=1, intf=0, alt=0, name="UNDEFINED"
Found DFU: [2b04:d006] devnum=0, cfg=1, intf=0, alt=1, name=“UNDEFINED”

AS far as I can see, I’m running dfu-util in the home directory.
I’m also in the home directory when running FlashDfu.py, but I include the full path in the command, as shown above.

I’ve downloaded the scripts from here:
git clone https://github.com/BrewPi/brewpi-tools.git ~/brewpi-tools

Sorry if I’m not making it easy for you to diagnose.

What do you get when you run:
which dfu-util ?
It should return nothing.

And if you run:
dfu-util -V

Instead of:
./dfu-util -V

And finally, if you try:

cd /home/brewpi/utils/
sudo python flashDfu.py 

Indeed - running which dfu-util returned nothing.

duf-util still doesn’t seem to work without the “./” :

pi@charlesberg:~ $ dfu-util -V
bash: dfu-util: command not found

however, after running cd /home/brewpi/utils/ and then
sudo python flashDfu.py, it seems to have come alive!!

Thank you very, very much!

Thanks! That gave the enough info to chase the bug.
So apparently the problem arises when not running flashDfu from its local directory.

For anyone else trying to do this I broke it down Barney style:

cd /home/brewpi/utils
sudo python flashDfu.py

I was sliding my second chamber into place and accidentally bumped the USB cable going from the RPi to the BrewPi Spark, which ended up damaging the USB on the Photon. Fortunately, I keep a stash of Photons around and was able to have my chamber up and running again in just a few minutes. The flashDfu.py worked great.

@Elco did this util get broken along the way? I haven’t dug into it yet but it’s bombing out on me with the below error:

root@raspberrypi:/home/brewpi# python utils/flashDfu.py
Traceback (most recent call last):
File “utils/flashDfu.py”, line 204, in
dfuUtilVersion = re.search(’(?<=dfu-util\s)\S*’, output).group()
AttributeError: ‘NoneType’ object has no attribute 'group’
root@raspberrypi:/home/brewpi

I just decided to upgrade my original CORE to the Photon so trying to do a fresh install.

Cheers,
-Stephen

Very odd but updated dfu-util and all seems to be fine now.

Cheers,
-Stephen

Hi there…
I have my spark that was working normally… Suddenly has no connection with raspberry pi. I can set in DFU mode and raspberry pi see him, but can´t flash a firmware… Just no one method i was reading works for me. Spark is reading the degrees of the 2 sensors and also i can manually switch on or off the heater and the cooler from the fridge.
I was installing new raspberry pi software just in case could help, but didn’t work also.
current firmware version on controller: 0.4.3

if i go into web browser to run brewpi, got stuck waiting for extension uBlock Origin

using:sudo python /home/brewpi/utils/flashDfu.py
returns: AttributeError: ´nonetype´object has no attribute ´group´

using: sudo python updater.py at brewpi-tools directory, returns:
problem flashing file:67 try again

Using other raspberry pi that i have with older system, start brewpi with browser and when refresh device list at device configuration, returns: ERROR WHILE RECEIVING DEVICE CONFIGURATION: SYNTAX ERROR: JS0N PARSE ERROR: UNEXPECTED IDENTIFIER “COULDN”

Any help please???

Thanks

Stephen,
How did you update dfu-util? What commands did you run? It sounds like what you saw here may be similar to my current predicament…

Did you try the docker install procedure described in the wiki? Dfu-util is included in the docker image.

When I enter “docker pull brewpi/brewpi-raspbian” into the command prompt, I get an error message: “bash: docker: command not found”. What am I missing here? If I run “sudo docker pull brewpi/brewpi-raspbian”, I get “sudo: docker: command not found”

Did you follow the instructions on our wiki and used the hypriot image?

Hi Elco,

Did you saw my post? Can you give any advise on how to solve it?

Thanks