Trouble figuring out .hex uploads

Hello everyone! I’m new to Blinks and Arduino in general and I’m completely lost when it comes to uploading code to my blinks. Now if its a sketch I can open in arduino, I have no issues uploading. This AVRDude .hex file stuff? Completely lost. AVRDude doesn’t seem to be on my pc at all and I tried finding a way to install it separately but I can’t figure it out. I’d appreciate some assistance!

1 Like

Hi @Zephurious!

Happy to help with this. First of all, awesome that you up and running w/ the Arduino IDE and that upload is working as expected. I personally don’t use the the .hex file upload except for when we are testing the binaries we are sending off to be manufactured. Another good use case of the .hex file is if you don’t want to share your source code. For that reason, I wouldn’t recommend this as a necessary tool and this next part will be more technical than anyone programming with Blinks needs to be.

That being said, I would love to share how to do this.

Arduino IDE is essentially a text editor, C++ compiler (avr-gcc), and AVRDude bundled, and AVRDude is responsible for uploading the compiled code onto the Blink. When you press upload in Arduino, the code is first being compiled and then Arduino calls a command for AVRDude and the upload process begins. This same use of AVRDude can be performed outside of the Arduino IDE and in the MacOS Terminal or Windows Command Line.

First, you need to export a binary (.hex file).
Screen Shot 2020-05-02 at 9.45.22 PM

You will see that inside of the Sketch folder, two binaries have been created. The one you care about is the one that sayd [Name-Of-Game].ino.with_bootloader.standard.hex. This contains the game and the bootloader (which is the code that allows Blinks to virally transmit their game to other Blinks).

Now that you have the .hex file, or you got to this step because someone shared a .hex file with you, you’ll need to get AVRDude running on your machine. If you are on a mac, installing w/ homebrew like this should do the trick. On a PC, following Lady Ada’s instructions here will get you running.

You’ll then want to open Terminal or Command Prompt and navigate to the .hex file and type the following:

avrdude -p m168pb -P usb -c usbtiny -U flash:w:<name-of-file>.hex 

Before pressing enter, make sure you have your USB programmer plugged in and the the Blink connected, pressing enter will start the upload.

That should be it. If I missed something here, let me know. I feel like @bigjosh could give some more insight on why this is a great tool, but honestly, I would stick to the Arduino IDE upload until you need to upload a binary from someone else. I think that the binary is a nice way to ensure someone is uploading exactly what you sent them, but other than that, might as well be in Arduino where you can play with the code :slight_smile:

all my best,
Jonathan

If it helps (and your running on a mac) I included a upload script in each of my games releases. Its similar to what @jbobrow posted, it just assumes you have Arduino IDE and the blinks library installed at the default locations. Just swap the main.ino.with_bootloader.standard.hex with your hex file name.

@Zephurious Just curious what you are trying to do with a HEX file that you can not instead do using the Arduino IDE? One reason why the Arduino IDE was invented was so people didn’t have to deal with HEX files directly anymore! :slight_smile:

I’m just trying to flash a .hex to a blink. wanted to try out overtake with my gf!

2 Likes

Hmm, I’m getting an error! AVR Part “m168pb” not found.

A good reason :slight_smile: but you can still use the Arduino IDE. In the Overtake folder, inside of main there is an Arduino file main.ino double click that and Overtake will open in Arduino so you can upload from there.

Now i’m getting a different error:

Arduino: 1.8.12 (Windows 10), Board: “Blink”

Sketch uses 5786 bytes (98%) of program storage space. Maximum is 5888 bytes.
Global variables use 757 bytes (73%) of dynamic memory, leaving 267 bytes for local variables. Maximum is 1024 bytes.
avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

Ok I got it fixed! I suspected I was having driver issues; I was correct. Thanks guys!

1 Like

I’m having a similar issue. I am also trying to install Raid/Overtake to my blinks. I am opening the main.ino file, but the Blinks are not accepting it. Here’s what I get:

sketch\global-events.cpp: In function 'void globalEvents::changeAllToReset()':

sketch\global-events.cpp:9:86: warning: narrowing conversion of 'millis()' from 'long unsigned int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

         action::broadcast(action::Action{.type=GAME_DEF_ACTION_RESET, .payload=millis()});

                                                                                ~~~~~~^~

sketch\state-board.cpp: In function 'bool stateBoard::handleProgression(const stateCommon::LoopData&)':

sketch\state-board.cpp:107:88: warning: narrowing conversion of 'millis()' from 'long unsigned int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

             action::broadcast(action::Action{.type=GAME_DEF_ACTION_END, .payload=millis()});

                                                                                  ~~~~~~^~

sketch\state-board.cpp:114:95: warning: narrowing conversion of 'millis()' from 'long unsigned int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

             action::broadcast(action::Action{.type=GAME_DEF_ACTION_PROGRESS, .payload = millis()});

                                                                                         ~~~~~~^~

C:\Users\carte\Documents\Arduino\Hardware\Blinks-SDK-1.1.0-GM\avr\cores\blinklib\blinklib.cpp: In function 'void RX_IRFaces()':

C:\Users\carte\Documents\Arduino\Hardware\Blinks-SDK-1.1.0-GM\avr\cores\blinklib\blinklib.cpp:600:78: warning: invalid conversion from 'const volatile uint8_t* {aka const volatile unsigned char*}' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

                             const uint8_t *datagramPayloadData =   packetData+1;    // Skip the packet header byte

                                                                    ~~~~~~~~~~^~

Sketch uses 5786 bytes (98%) of program storage space. Maximum is 5888 bytes.
Global variables use 757 bytes (73%) of dynamic memory, leaving 267 bytes for local variables. Maximum is 1024 bytes.
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta

As a side note, the Invalid Library messages, I get every time I do any simple little upload to a blink and, until now, they have all worked just fine. For example, I got Paintbrush to work and I have been able to successfully write simple commands on my own to the Blinks.

Any thoughts? Warning, I’m a total noob at this, and do not have a background in programming.

Hi @WillowDreamer!

I think I see what is missing here. Did you select your hardware type as Blink?
Screen Shot 2020-05-03 at 6.21.22 PM

Hi @jbobrow

Yes, I do have that board selected:

Oh, taking another guess here.

It looks like you have the sketches in the libraries folder, which could be throwing some warnings/errors. Otherwise it looks like the program did compile, since it shows the amount of space it takes up.

Can you see if the compile succeeds? I am trying to figure out if the sketch will compile for you, but not upload.

First, @jbobrow, THANK YOU for your time and help! I really appreciate it! I’m very excited about learning how to program Blinks and create some cool games. I have some cool ideas! (At least I think they are cool! lol)

Anywho…

Yes, the compile succeeds and it even thinks it finished uploading successfully. Yet, when I try using the blink it just flashes between blue and white.

When I run the “Verify” command, it looks like this:

I get the rest of the errors during upload. (I probably should have told you that previously, but I didn’t. Sorry about that)

Cool, super helpful and it seems like you know more than you let on :slight_smile:

For my own sanity check, have you tried uploading one of the games from the examples?
Screen Shot 2020-05-03 at 6.37.42 PM

just want to make sure you can successfully upload a simple program first and verify that the Blink you are programming works properly.

I just started playing with this last night. I’ve never done any of this type of stuff before. So I really don’t know what I know/don’t know. I’m just trying to learn it all.

I was just able to successfully upload Astro to the Blinks from the examples. Very smooth.

Interestingly enough, I still got these messages on that upload, but it works just fine:

C:\Users\carte\Documents\Arduino\Hardware\Blinks-SDK-1.1.0-GM\avr\cores\blinklib\blinklib.cpp: In function 'void RX_IRFaces()':

C:\Users\carte\Documents\Arduino\Hardware\Blinks-SDK-1.1.0-GM\avr\cores\blinklib\blinklib.cpp:600:78: warning: invalid conversion from 'const volatile uint8_t* {aka const volatile unsigned char*}' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

                             const uint8_t *datagramPayloadData =   packetData+1;    // Skip the packet header byte

                                                                    ~~~~~~~~~~^~

Sketch uses 4492 bytes (76%) of program storage space. Maximum is 5888 bytes.
Global variables use 738 bytes (72%) of dynamic memory, leaving 286 bytes for local variables. Maximum is 1024 bytes.
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\Bink_blink
Invalid library found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta: no headers files (.h) found in C:\Users\carte\Documents\Arduino\libraries\blinks-overtake-1.1.0-beta

I wonder if I somehow have a bad file for Raid? I got the download from here: https://github.com/Move38/Raid

These parts are because of the location of the sketches. I recommend putting these not in the folder called libraries but simply inside of the folder called Arduino or in a folder called Games inside of the folder Arduino this way they’ll show up in the sketches dropdown (not really important, but will most likely get rid of those Invalid messages.

I think the latest version of Raid is here: https://github.com/mdm373/blinks-overtake

Our repo looks out of date. Which we should take care of this week :slight_smile:

1 Like

Thank you, @jbobrow! I’m no longer getting the error messages AND IT IS WORKING! WOO HOOOOO!

Thank you so much. I really appreciate your help!!

Dawn :grin:

1 Like