Update BrickPi FW with USBASP Programmer [SOLVED]

I have USB USBASP programmer with correct pins to connect to brickpi. I managed to run THIS script wich I modified to work with USBASP. Here is the output:
https://forum.dexterindustries.com/uploads/short-url/7WEDlLvlkedZiWIMkqwEu87EAYo.PNG

And I run python ev3 sensor testing script from git and got this output:
https://forum.dexterindustries.com/uploads/short-url/hp6OnZMCiEr5o0sA8DfQ1uqqjL3.PNG

Now, as I see it, this update script didn’t updated FW. It made something to the fuses and that’s all. Instructions show different output though. BUT! The script, which should be used according to instructions is the very same I used, and in this script I see no line updating the FW.

What should I do next?

@mike2060: It looks like the firmware was not actually burnt or the screenshot above is not the complete process. The firmware update process involves a couple of steps. First it burns three fuses, then it upload the firmware to the flash memory and then an EEPROM configuration is loaded. This has to be repeated for the second Atmega chip too.

If you have a look here, you can seen in the two screenshots at the end of the page that the firmware upgrade process is longer and the script that you have running there is only burning the fuses and not burning the firmware or EEPROM.

Since you had mentioned earlier that you had modified the firmware update script, can you post the updated script here so that we can have a look at it for any problems.

Also, from the same directory where you have the firmware files, can you run these commands one by one and post the screenshot here and also check from the Python script whether the firmware update did work or not :

avrdude -P usb -c avrispmkII -p m328p -U lfuse:w:0xFF:m
avrdude -P usb -c avrispmkII -p m328p -U hfuse:w:0xDA:m
avrdude -P usb -c avrispmkII -p m328p -U efuse:w:0x05:m
avrdude -P usb -c avrispmkII -p m328p -U flash:w:ATmegaBOOT_168_atmega328.hex
avrdude -P usb -c avrispmkII -p m328p -U flash:w:BrickPiFW_Compressed_Communication.cpp.hex
avrdude -P usb -c avrispmkII -p m328p -U eeprom:w:BrickPi_EEPROM_UC1.hex 

Please do change the -c and -P parameter to what it is for usbasp. Also, if this works, try it for the second chip too with the last command changed to :

avrdude -P usb -c avrispmkII -p m328p -U eeprom:w:BrickPi_EEPROM_UC2.hex  

Do let us know if this works for you.

Hi @karan. This is my modified script:
@echo off
:start
if exist “ATmegaBOOT_168_atmega328.hex” (
if exist “BrickPiFW_Compressed_Communication.cpp.hex” (
if exist “BrickPi_EEPROM_UC1.hex” (
echo All Files found… Proceeding…
pause
) else (
echo File BrickPi_EEPROM_UC1.hex not found
pause
goto start )
) else (
echo File BrickPiFW_Compressed_Communication.cpp.hex not found
pause
goto start )
) else (
echo File ATmegaBOOT_168_atmega328.hex not found
pause
goto start )

: Write the fuses
avrdude -P usb -c usbasp -p m328p -U lfuse:w:0xFF:m
pause
avrdude -P usb  -c usbasp -p m328p -U hfuse:w:0xDA:m
pause
avrdude -P usb -c usbasp -p m328p -U efuse:w:0x05:m
pause

: Write the bootloader hex file.  Assumes it's in the same directory.
avrdude -P usb -c usbasp -p m328p -U flash:w:ATmegaBOOT_168_atmega328.hex
pause

: Write the compiled BrickPi file.  Assumes it's in the same directory.
avrdude -P usb -c usbasp -p m328p -U flash:w:BrickPiFW_Compressed_Communication.cpp.hex
pause

: Write the eeprom file.  Assumes it's in the same directory.
: You willneed to make sure you're putting the right titled firmware on the right micrcontroller on the BrickPi
avrdude -P usb -c usbasp -p m328p -U eeprom:w:BrickPi_EEPROM_UC1.hex

:-P usb
pause

Here Im doing one by one commands you send. The same ones from script:






For second chip:
output2.txt (7.4 KB)
BUT: FW check is reporting error

What have I done wrong? (Sorry for the amount of screens. I thought too late about dumping it to file)
EDIT: turning motor does not work now :frowning:

@karan
Hey, could you tell me what to do next? Im late with my project and I can’t even start developing its program. I need ev3 gyro working and right now I can even run motors. I posted here all the steps I’ve done and it’s output. Electronics,esp. so closely hardware connected is not my thing and I’m afraid I ruin it more. Please help me.

Took us some time to pick this apart. This is why we write scripts! :slight_smile:

The short of it: from your screenshots, you’re writing the EEPROM to flash, not to EEPROM. If you look at this image:

You are writing the command
flash:w:BrickPi_EEPROM_UC1.hex
when you SHOULD be writing the command
eeprom:w:BrickPi_EEPROM_UC1.hex

When you write with flash, it overwrites the main program and you’re putting the memory for EEPROM where the flash should be put. So you should be able to solve this by running all the commands again, but changing the last one to write to eeprom, not flash.

@JohnC
I redid all commands and ran fw check. It freezes on setting up sensors. Same goes when I try to run motor from python console.
input:
script.txt (391 Bytes)

Output :
out1-12.05.16.txt (7.5 KB)
out2-12.05.16.txt (7.5 KB)

I got couple more questions:
in your repo there are few folders with firmware, ie. 2.5, can i go into that folder and run this scripts to get 2.5? I ran script here:

I’d also like to confirm if I properly connected pins to the board. Maybe that causes problems.

I’ll try to go through this one more time, carefully checking for spelling.

Meanwhile your raspian image updated, I got something calling itself google pixel? I also have to run python with sudo because it can’t get access to tty without it. (my user is in tty group)
EDIT: attempt2 fail, stuck at this for few minutes now:

Again, combing carefully through this, in a couple places you’re getting this warning:

avrdude: warning: cannot set sck period. please check for usbasp firmware update.

I’m not sure what that is, but it seems like there’s a problem with the usbasp programmer. Is there any way you could try to do this with an Arduino?

Yes, you should be able to do that. But remember those batch files are written for the spefic mk2 and Arduino programmers.

Just double checked and yes, those are correctly chosen.

Not sure what that is; do you have a screenshot? When did you see something about Google Pixel?

That will certainly happen if you’re not getting a response from your BrickPi; it will just hang and eventually give up.

This might also be helpful: http://www.avrfreaks.net/forum/avrdude-warning-cannot-set-sck-period-please-check-us
If you’re using a long USB cord on your programmer, you might have problems, or a hub or something else.

@JohnC Thank you very much. No I am not using long cord but six single-pin wires about 15cm long. I’ve asked my friend to lend me arduino. Tomorrow I’ll also check if my soldering is properly done. First time I noticed that message about SCK period I tried googling that and found in few places that this can be ignored. But since it’s not working well it might be one of the reasons. Anyway. I’ll get arduino and try again.

As for that update… on your fresh image’s desktop I noticed update software icon so I clicked it. It installed tons of software and after rebooting I got pixel. I will provide screenshots tomorrow, but for now:


Those look exactly the same. I also got problems with bluetooth (it is off but I managed to turn it on once and it worked till reboot) but thats another story I think.

Thanks again for any help, I really do hope to start programming soon and finish my project. It has been one failure after the other disaster till this point :frowning:

Eeeeh
So… I installed Arduino IDE (for drivers) , connected wires (reset one as you said) and ran script (yours, but I had to delete ifs because it didn’t find AT_mega… file… weird it was in the same directory) anwyay… it went on and stopped right on start, on the first fuse… after few minutes of nothing I gave up and got back to usbasp. I added -b 19200 to commands as it is in your script but that didn’t help. Still “cannot set sck period” In the link you gave David says:

Ah-ha. I was going to suggest that you Google: "avrdude : warning : Can not Set sck period . usbasp please check for firmware update "
However most of the first hits gave silly advice.
A modern Chinese USBASP will set the SCK period automagically.
There is NO reason to upgrade the firmware. Just ignore the warning.
Historically, the first USBASP design used a SLOW jumper. The first fischl.de firmware did not support “setting sck period” with the -B# switch.
So the only people who need to upgrade firmware are those with a very old home-made usbasp.
David.

So Im left with nothing solid. I guess I have to find AVRISPMK2 but that is hard because it seem old and Im in different country, and I don’t feel like paying more than 15USD for something I’ll use only once

I think Im giving up… Could I maybe send it to you guys so you could check whats wrong with it?

We’re going to check into the Pixel issue, I’m not sure why that’s happening.

Let me think about this a little more, we might be missing something on the software programming side.

Update BrickPi FW with USBASP Programmer [SOLVED][quote=“mike2060, post:11, topic:2122”]
So… I installed Arduino IDE (for drivers) , connected wires (reset one as you said) and ran script (yours, but I had to delete ifs because it didn’t find AT_mega… file… weird it was in the same directory) anwyay… it went on and stopped right on start, on the first fuse… after few minutes of nothing I gave up and got back to usbasp. I added -b 19200 to commands as it is in your script but that didn’t help.
[/quote]

With the Arduino, did you install the ISP program on the Arduino? This is the tutorial that walks you through that here.

Steps 1-4 are crucial, and note that they vary a little if you’re using Arduino 1.0. Did you take this step with the Arduino programmer?

Yesterday I borrowed another USBASP. Updating process lasted way longer with the first usbasp but it didn’t work. In python IDLE it still stucks on BrickPiSetupSensors(). I also tried uploading FW 2.5. Also not working.

Today I took arduino. I’m not sure if it is 1.0 so I used unmodified ISP example. Updating process went faster than with that second usbasp but slower that the first. And also failed on BrickPiSetupSensors().
Here the outputs:
out1-10.12.16-arduino.txt (8.3 KB)
out2-10.12.16-arduino.txt (7.5 KB)

That pixel image. It looks nice. There might be a chance that it prevents brickpi from working, I doubt it, but who knows?

Hey @Mike2060 re: Pixel. We had three folks try the update out and it did not change the Raspbian for Robots image over to Pixel. So I’m wondering if you might have manually done a sudo apt-get upgrade in the command line manually? This might have caused Pixel to come up.

And this ties into something else we dealt with earlier this week; if you’re running the Pi 3 (and even maybe the other Pi’s) and you have upgraded to Pixel, you might be inhibiting the serial lines. There’s a known issue that we put a workaround in for the BrickPi, where the new Bluetooth lines break the serial lines unless you use a special dt overlay. I would recommend re-burning a new card with our December image; I just updated it last week.

Again, I admire your patience and persistence with this.

And I just went through those two scripts; they look like the firmware was updated correctly and successfully. I will double check them again, but it looks like they went well and verified. And I double checked your eeprom write, great job! :slight_smile:

There is such possibility. I was trying very hard to make BT working using several tutorials so I might have run apt-get upgrade. I’ll load your image right now.
Thanks, I got similar amount of problems in any project I start so, yeah, I have to be very patient ;D

@JohnC
Alright finally some good news. I’m able to run motor, so I guess rest of NXT stuff works to. However running EV3-Firmware_Check produces following output:
Trying to communicate with firmware.
PASS: Serial line setup.

Setup sensors returns: 0
Checking Firmware Version of BrickPi.
Firmware version is: 1023
DOH!  Please update your firmware to run EV3 sensors!
You should be able to run NXT sensors, but not EV3 sensors. 

So I think my ev3 gyro wont work.
Should I rerun update procedure for software from 2.5 folder?

Hey @mike2060 does updating the firmware to 2.5 work then?

Hi @JohnC
No, it’s worse. FW check says

Trying to communicate with firmware.
PASS: Serial line setup.

Setup sensors returns: -1
Checking Firmware Version of BrickPi.
Firmware version is: None
DOH!  Please update your firmware to run EV3 sensors!
You should be able to run NXT sensors, but not EV3 sensors.

And on BrickPiSetupSensors() it returns -1

does python have any debug log? maybe there are some clues there?

Well at least updating procedure works :slight_smile: (with arduino though)