[Solved] Avr-size error: file format not recognized when loading HEX file

Hi, I am following the setup instructions with a brewpi photon that i bought in August. I got the script running on the web interface and downloaded brewpi-0.2.11-photon.bin to install, but I am getting a file format error. I am also doing this on a computer that is running Ubuntu.

to make matters worse i hit the reset button and held down the setup button for 5 seconds, but now when i plug in the brewpi to a power outlet all i get is a white screen instead of the test screen that I saw when i first unboxed it.

-Nick

I haven’t actually done this since I ran my update from the commandline, but did you choose the correct board type in the drop down? In the capture above it’s not set correctly to Spark. Again not sure if this is what is going on here, but that might fix things, else you can always run the updater script from the commandline and see if that works.

Cheers,
-Stephen

changing boardtype does nothing. And I’m not sure how to run the update from the command line. I am assuming the script is looking for a .HEX file, but for the photon all files are in a .BIN format.

And I don’t know how to update the script as mentioned below. i was assuming since i just did this install everything would be updated so I tried running the flashDfu.py, but it’s giving me an import error and then a syntax error

-thanks Nick

For me it seems that the problem is, that the script doesn’t recognize the actual firmware on the brewpi, which leads to the updating problems. I have similar problems (I get the same error: “Warning: Cannot recieve version number from controller…”) when connecting the brewpi spark to the raspberry pi.
The solution which works for me: 1. Unplug (and power off, if you use an additional 12V power supply) the brewpi spark. 2. Restart the raspberry pi and wait until the log of the webinterface says, that the script searches on the serial ports 3. Plug in the USB connection between Brewpi and Raspberry pi. Then the log should say, which controller and version of the brewpi is recognized.
Then you hopefully should be able to upload the new firmware via the web interface

Thanks Norn, maybe if I was using a raspberry pi I wouldn’t have this problemt. Im using Ubuntu however. restarting seems like a good idea anyway. I will try restarting - No Good. still same issues…

I tried running the flashDfu.py and per the instructions here:

But I get this error:

I also read that I should update the script before running this, but I cannot find the updater.py file.

again I’m using Ubuntu to do this and I am really at a loss now. when I plug the brewpi straight into a power outlet all I get is a white screen now, instead of the test screen that I saw when I first did that out of the box.

It seems I need to update my script to be able to move forward, can anyone point me in the right direction?

thanks Nick

You can try to locate the updater.py file with the command "find ~ -name updater.py"
If it isn’t anywhere i think you can run “git clone https://github.com/BrewPi/brewpi-tools.git ~/brewpi-tools” and then “/home/hello/brewpi-tools/updater.py”.

Did you put the Spark Core(Particle) in the DFU mode before trying to run the flashDFU.py script?

Yes it was in DFU mode (flashing yellow).

FYI: the script will not go in a RUN state when it is in DFU mode only when it is flashing blue will the script go in a RUN state. Not sure if that is normal or not.

I did a complete auto reinstall of everything, but still same issues.

I did notice after the auto-reinstall i do not have a drop down choice for board type. i can only choose Leonardo.
The first time I did the install was a manual install. I guess my board type is a Leonardo.

I have tried different USB cables - still same issue.
I will try running the updater.py later tonight.

Thank You Norn

-Nick

For the Photon, you should use flashDfu.py.
Put it in dfu mode by holding the setup button while you plug in USB, until it is flashing yellow.

Run it with:

sudo python flashDfu.py

@Elco I ran that. This is what I get:

hello@PCstream:~$ sudo python flashDfu.py
[sudo] password for hello:
python: can’t open file ‘flashDfu.py’: [Errno 2] No such file or directory

so I tried to run it with specifying the directory it is in and get:

hello@PCstream:~$ sudo python /home/brewpi/utils/flashDfu.py
[sudo] password for hello:
Detecting DFU devices
/home/brewpi/utils/downloads/dfu-util: 1: /home/brewpi/utils/downloads/dfu-util: Syntax error: word unexpected (expecting “)”)

Did not find any DFU devices.
Is your Photon or Spark Core running in DFU mode (blinking yellow)?
Waiting until a DFU device is connected…
/home/brewpi/utils/downloads/dfu-util: 1: /home/brewpi/utils/downloads/dfu-util: Syntax error: word unexpected (expecting “)”)

/home/brewpi/utils/downloads/dfu-util: 1: /home/brewpi/utils/downloads/dfu-util: Syntax error: word unexpected (expecting “)”)

and from there it goes into an endless loop. Yes the Brewpi is connected in DFU mode (Yellow flashing light is present)

@Norn I got the updater to Run. it seems everything is up to date, but when it tries to connect to the photon. I get the same issue. it is unable to locate it.

hello@PCstream:~$ sudo python /home/hello/brewpi-tools/updater.py
######################################################

Welcome to the BrewPi Updater!

######################################################

Checking whether the update script is up to date
/home/hello/brewpi-tools is up-to-date.

*** Updating BrewPi script repository ***

Stopping running instances of BrewPi
Quit message sent to BrewPi instance with pid 20122!
You are on branch master
The latest commit in /home/brewpi is 4c7dfa342d8403eb2b485e9970e2cdec9e53c9e4 on Wed, 05 Aug 2015 14:15:44
The latest commit on origin/master is 4c7dfa342d8403eb2b485e9970e2cdec9e53c9e4 on Wed, 05 Aug 2015 14:15:44
Your local version of /home/brewpi is up to date!

*** Updating BrewPi web interface repository ***
You are on branch master
The latest commit in /var/www is d44c03e786d0bde0dc43f86a8bd655659f3f3d2b on Wed, 11 Mar 2015 14:59:39
The latest commit on origin/master is d44c03e786d0bde0dc43f86a8bd655659f3f3d2b on Wed, 11 Mar 2015 14:59:39
Your local version of /var/www is up to date!

No changes were made, skipping runAfterUpdate.sh.
If you encounter problems, you can start it manually with:
sudo /home/brewpi/utils/runAfterUpdate.sh

The update script can automatically check your controller firmware version and program it with the latest release on GitHub, would you like to do this now? [Y/n]:y
Stopping any running instances of BrewPi to check/update controller…

Checking current firmware version…
Oct 23 2015 19:47:27 Opening serial port
Oct 23 2015 19:47:37 Errors while opening serial port:
Could not find compatible serial devices

Unable to connect to controller, perhaps it is disconnected or otherwise unavailable.

*** Done updating BrewPi! ***

with the brewpi photon in DFU mode I verify the Port, and I get:

hello@PCstream:~$ ls /dev/ttyA*
ls: cannot access /dev/ttyA*: No such file or directory

Now if I unplug the photon and plug just plug it in (light is now flashing Blue, white screen, no beeps) and check the Port, I get:

hello@PCstream:~$ ls /dev/ttyA*
/dev/ttyACM0

Is there something wrong with my Photon?

-thanks Nick

I really have no idea about DFU flashing but perhaps you could try the manual way Elco posted a time ago Flashing a Spark Core you bought elsewhere or in case of emergency

Edit: Didn’t saw that the wget source in the instructions is only for ARM systems. You should try instead “sudo apt-get install dfu-util”.

What Norn says above:
the script downloads dfu-util for ARM systems, because the version on apt-get is outdated.
I think the problem is that the script/shell cannot find dfu-util

@Norn & @Elco I ran the sudo apt-get install dfu-util without any problems.

I tried to download the binary to my home directory: I get 404 page not found error.

then I read:

I find it easiest to hold the mode button down with a pin, while plugging in the USB cable. After 3 seconds, the light should flash. If you hold it for 10 seconds, this will do a factory reset. Don’t do this.

I am certain I may have done a factory reset on the photon the other day when I was trying to do step 4 in the online guide, hence causing all my issues. And furthermore I just read on the community that step 4 isn’t needed anymore, because they already come programmed.

I have my device in DFU mode and run the following command and it does not find it.

List devices with dfu-util:

./dfu-util -l

hello@PCstream:~$ ./dfu-util -1
bash: ./dfu-util: No such file or directory

Again I am trying all this on a computer that is running Ubuntu, do you think I would have better results if got a raspberry pi? Or did I screw everything up by doing a factory reset?

-Thanks for all your help with this Norn and Elco.

Look at the output of “dfu-util -l” (without the ./). ."/dfu-util -l" won’t work with your installation.

greetz
Felix

OK I got it to find the brewpi by using only dfu-util -l

I then moved the brewpi to my home folder manually, now dfu-util and brewpi-0.2.11-photon.bin are in the same folder.

and ran the next line of code:

hello@PCstream:~$ sudo dfu-util -d 2b04:d006 -a 0 -s 0x08005000:leave -D brewpi-0.2.11-photon.bin
invalid dfuse address: 0x08005000:leave

but i get the invalid dfuse address error. any suggestions?

Hmm, I just looked at the flashDfu script again and I see an error. At this line:

It checks whether it is running on linux and then downloads a dfu-util binary. However, this binary is for ARM, for the pi. If the system is Linux, but not a pi, it won’t work.

If you change line 100 to if 0:, so the download is skipped, it will use to the dfu-util you installed with apt-get.

OK I changed Line 100 to if 0: -however I got:

This script is written for Linux or Windows only. We’ll gladly take pull requests for other platforms.

I then put Line 100 back to the original ELIF statement and just deleted the download part lines 101 & 102, and replaced it with a print “Linux” statement. It seemed like it was working, but then I got stuck in an endless loop and noticed this again: invalid dfuse address: 0x80A0000:leave.

hello@PCstream:~$ sudo python /home/brewpi/utils/flashDfu.py
Linux
Detecting DFU devices
Found 1 devices: [‘2b04:d006’]
Device identified as Particle Photon
Downloading latest firmware…
Latest stable version on GitHub: 0.2.11
downloading https://github.com/BrewPi/firmware/releases/download/0.2.11/brewpi-0.2.11-photon.bin
Firmware downloaded to /home/brewpi/utils/downloads/0.2.11/brewpi-0.2.11-photon.bin
downloading https://github.com/BrewPi/firmware/releases/download/0.2.11/system-part1-09dd809-photon.bin
downloading https://github.com/BrewPi/firmware/releases/download/0.2.11/system-part2-09dd809-photon.bin
Release contains updated system firmware for the photon
First updating system firmware for the Photon
dfu-util 0.5

© 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.
© 2010-2011 Tormod Volden (DfuSe support)
This program is Free Software and has ABSOLUTELY NO WARRANTY

dfu-util does currently only support DFU version 1.0

Filter on vendor = 0x2b04 product = 0xd006
Opening DFU USB device… ID 2b04:d006
Run-time device DFU version 011a
Found DFU: [2b04:d006] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/03016Ka,01016Kg,01064Kg,07128Kg"
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
DfuSe interface name: "Internal Flash "
dfu-util 0.5

© 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.
© 2010-2011 Tormod Volden (DfuSe support)
This program is Free Software and has ABSOLUTELY NO WARRANTY

dfu-util does currently only support DFU version 1.0

Filter on vendor = 0x2b04 product = 0xd006
Opening DFU USB device… ID 2b04:d006
Run-time device DFU version 011a
Found DFU: [2b04:d006] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/03016Ka,01016Kg,01064Kg,07128Kg"
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuDNLOAD-IDLE, status = 0
aborting previous incomplete transfer
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
DfuSe interface name: "Internal Flash "
Now writing BrewPi firmware /home/brewpi/utils/downloads/0.2.11/brewpi-0.2.11-photon.bin
invalid dfuse address: 0x80A0000:leave
Programming done, now resetting EEPROM to defaults
Opening serial port
Oct 24 2015 18:59:34 Opening serial port
Oct 24 2015 18:59:44 Errors while opening serial port:
Could not find compatible serial devices

Oct 24 2015 18:59:45 Opening serial port
Oct 24 2015 18:59:55 Errors while opening serial port:
Could not find compatible serial devices

Oct 24 2015 18:59:56 Opening serial port
Oct 24 2015 19:00:06 Errors while opening serial port:
Could not find compatible serial devices

Oct 24 2015 19:00:07 Opening serial port
Oct 24 2015 19:00:17 Errors while opening serial port:
Could not find compatible serial devices

Oct 24 2015 19:00:18 Opening serial port
Oct 24 2015 19:00:28 Errors while opening serial port:
Could not find compatible serial devices

Oct 24 2015 19:00:29 Opening serial port
^CTraceback (most recent call last):
File “/home/brewpi/utils/flashDfu.py”, line 193, in
if programmer.open_serial(config, 57600, 0.2):
File “/home/brewpi/utils/…/programController.py”, line 287, in open_serial
self.ser = util.setupSerial(config, baud, timeout)
File “/home/brewpi/utils/…/BrewPiUtil.py”, line 138, in setupSerial
time.sleep(1)
KeyboardInterrupt

yay! got it to flash. I read online that I should update to Dfu-util 0.7 or that I can remove the :leave because all that does is reset the system. I removed the :leave and when it was trying to open the serial port I hit reset on the back of the photon. And then I heard two beaps and the photon GUI appeared.

@Elco & @Norn - Thanks Elco and Felix for all your help!

Cheers!
-Nick