howto: Use Atmel AVR Studio 5 to make a .hex file

The version of Atmel AVR Studio 5 that works is 'as5installer-stable-5.1.208-full.exe' - the version you'll find if you get it through Atmel's site IS BROKEN AND WILL NOT INSTALL! Search for the exact filename above to get the one that works.

This applies to firmwares where the authors have released the source code - so for instance, minimo (momentary switches), minidrv (clicky switches), and the older version of luxdrv. NLITE is supplied only as a pre-built ready to use hex file so the steps shown here aren't needed, it's ready to be flashed as-is. I'm not sure if these same steps work with the BLF-VLD code, I haven't tried editing the included files (only flashed the ready-to-go hex/eep files) but unless there's something particular about Tido's code that needs tweaking to be used in AS5, it should work. Tido uses a completely different set of tools and I don't know if the code works the same across platforms. If you have any specific troubles with building (turning raw code into a hex file that can be flashed to the driver) of these firmwares it's probably best to ask for help in that FW's own thread, as I don't know squat about the code or even how/why this works, only that if I poke at the right buttons in the right order something usable comes out at the end (most of the time!).

Open your sample file (could be a plain txt file, .c file, or anything that looks like what's shown below when you open it), make any changes needed (mode levels/order, uncomment lines to enable/disable features, etc.). 'Select all', copy, then open AVR Studio 5.

Click 'New Project':

'AVRGCC C Executable Project', then 'OK':

Select 'tinyAVR, 8-bit' from the dropdown box...

...which will reduce the number of options, ATtiny13A is conveniently right there at the top. Then click 'OK':

It'll open the project with a generic template:

'Select all'...

...then paste in what you copied from the txt file:

Build > Build AVRGCCxx

If you get 'Build succeeded' and no errors in the status window at the bottom, it worked:

Go up to the R/H corner, expand the Output Files item, then double-click 'AVRGCCxx.hex'...

...the .hex will appear in the main window:

File > Save AVRGCCxx.hex As...

Name it something relevant and put it somewhere convenient:

Now you have a .hex file, ready to be put into avrdude and sent to the driver!

Thanks a lot CC. I was reading through the other thread on perfect modes the other day until my head was spinning. Would it be possible to add a couple of links for the tools used in the actual programming to keep it all in the one spot? I may never be able to do this but one must try these things. Cheers and thanks again.

I use 6.0 - never had a problem...

Great! I guess if you know this kind of stuff, you can choose to use all kinds of different tools to do different things without any problems. But if you dive in without a clue, it helps to have the stuff on your screen exactly match the pictures in the guide. It doesn't help to be buried under a giant pile of 300 different options and opinions about which one is best for one thing, but another thing you have to use that one instead, and so on.

I mean, still today I really don't know the difference in 'Build' and 'Compile'... I just know that if I click things in the right order, something usable comes out the other end. I couldn't find a step-by-step guide anywhere that was relevant to only the things needed to put a custom firmware onto a driver. Lots of generalized stuff with a million distractions, and not knowing what any of it meant made it impossible to weed out the stuff that only applied to different hardware or different types of projects.

Yes, nice work comfy! I totally understand - everyone is at a different level. I've been doing C programming since about 1980, so, got a little unfair background. I was going to attempt a step-by-step install, but seems like the 5.x was more commonly adopted, and I would have had to start from scratch all over again, then I would assume too much knowledge for sure...

I think sometimes it's easier to give a clear explanation of something when you've only just figured it out - you still remember all the things you didn't know before you started. But something you know really well, inside out and backwards, you end up taking a lot of things for granted. I'm as bad about that as anybody.

What's that saying - 'experts are people who know more and more about less and less, until they know nothing at all'? Not really, it just sounds that way when they talk about what they know... watch some NASA press conferences on youtube for examples. I swear they have forgotten how to construct an actual sentence in English. I wonder what happens when they pull up at the McDonalds drive-thru? It must be hilarious. :D

Thanks for the clear presentation. This should take a lot of the fear and learning curve out of the process.

I wish someone had written a detailed guide like this when I started, quite a bit of a learning curve for me. I don’t claim to be all that smart anyway. So I would just like to say thanks for the time spent on this detailed guide, I’am sure it will help others who have had problems or some of those who might say “I got to try this, comfychair makes it look easy”.
I don’t do it the same way as you do, but the results are the same. Nice to see how a expert does it. :bigsmile:

The Tiny13A gets all the attention, deservedly so, but I'm liking the Tivo532 Z8 setup so far. It's really nice to be able to reprogram on-the-fly by just plugging in the connector to the exposed back of the driver. I'm using it in a P60 (L2T) and it's really nice to try different PWM levels, and turn around your source code changes to actually testing in a light in seconds. First couple of times you try it, think anyone will be amazed when coming from the Tiny13A environment. The Z8 has 8K bytes of program space - 8X more than the Tiny13A, so plenty of space to put in all the bells and whistles, not to mention 7135 regulation combined with direct drive mode.

Sorry to go little off topic here, but I'm thinking this Z8 setup may be getting hot soon so don't get too used to AVR Studio and Tiny13A's . I got 4.7A in a P60 on a Pana PF (over 1,300 lumens), in turbo mode, then Hi mode at a regulated 1.5A, and a nice low, then moonlight level -- nice...

I use Atmel Studio 6.1 without problem. Well, in fact there was one problem with luxdrv 0.30b source code, where there is “PROGMEM byte modes={ MODES };” I had to change it to “const PROGMEM byte modes={ MODES };”.
I found this on the big tread for AVR.

I stick to luxdrv code because I really like the short term memory and I’m not skilled enough to implement that short term memory in minidrv.

Yesterday I received a Convoy S6 from banggood, I flashed it right away.
My method is to use extreme burner AVR to check connection, erase chip (mainly to release lockbit fuse) and set low and high fuse. Then I use avrdude to flash hex as extreme burner AVR can’t do it properly (why?)

And in the end of the tutorial, once buildt, it should appear in “my documents”, you don’t need to save hex again.

AS5 takes whatever I paste into it and spits out a hex file ready to use, I don't really care other than that.

I know the project folder created as soon as you hit 'build' contains the .hex, but it also has a bunch of other files that aren't needed. I find it easier to save the hex directly on its own, give it a name that identifies it, instead of going through all the crap of naming the AVRGCC projects. Paste, build, save, then I'm done with it and don't want to see it anymore. I do all the editing of the input files in notepad beforehand, unless I miss something and it fails to build correctly. Even then, after I make changes and get it to go through so I know it works, I copy the source from the AS5 window and paste it back into the txt file I keep in the folders with each version of FW (along with a .bat file with the avrdude commands in it, so I can just connect to a driver and double-click, no futzing with opening command windows for me please, unless I just have to).

I have WinAVR installed, just because it automatically sets up avrdude - I'm sure there's a way to do it without the unneeded WinAVR stuff, but this works for now, it should work for anybody else who just wants to stick firmware onto a driver and isn't really interested in launching a new career as a (apologies in advance for the following link) software developer. I only care about this stuff to the extent it lets me make better flashlights. :p

Driver for the USBASP programmer is libusb-win32, again, no real reason other than because it works and that's really all I care about.

Brilliant!!!

I have AVR Studio 6 so I will be building the .hex file soon...just waiting on my daggum programmer!

There is this combobox that says ‘debug’. I’d switch it to ‘release’ if you are not planning on actually using a debugger. That debug stuff just uses up space in the controller for nothing then.
Very nice how-to! It’s no fun to find out all that stuff alone if you are not to familiar with that kind of software!

I don’t have anything against that Z8, but keep in mind that that 13A is not exactly the pinnacle of the Tiny family, more like an ancient dinosaur or something. :wink: Some of them have really nice features (like 16bit timers for more pwm steps than you will ever want for dimming), and they are just a few lines of code away if you already have invested time and money in the AVR platform.

It's also very good to use Notepad++ (portable) to read the *******.c file to edit ;)

Thanks Comfychair,

That was very clear, much better than just words written in the flashlight wiki, or the long thread...

For a good overview, could you post a few links in your OP with other useful information about the setup, different firmware etc to keep it all easy to find...

Really appreciate your work!

thanks Comfy, that’s a great help. I knew that if I procrastinated long enough the good peeps on here would help me get started with the minimum of fuss. I’ll bookmark this and come back to it in a few days to kick myself into gear. This electronics/ code stuff doesn’t come easily to me!

Added a paragraph at the top with links to the free-to-use firmwares.

Great help, thanks

Tido's code is missing

#define F_CPU 4800000 in the BLF_VFD zip file

It fails to compile the driver.c code in the main dir, the sub directories (Fixed Modes, Programmable, Simple) have pre-compiled .hex files in them based upon the default driver.c code, has 3 mode levels...I compiled one with the mode setting to 5 with nothing else changed (but it's untested)

This is under Atmel Studio 6.1

Don't use 6.1, it just doesn't compile these, the 5.1 as mentioned above works like a champ...go figure

Pardon me while I smack myself in the forehead and have a V8