AVRStudio 5 configuration

53 views
Skip to first unread message

Jay Lash

unread,
Nov 23, 2011, 10:25:17 PM11/23/11
to Backwoods Logger development discussion
I finally got an ISP "cable" ordered so I could start making some mods
to the software. I want to capture information about my setup to
hopefully save someone else some time in the future.

As the information is specific to the tools I chose, and mostly not
specific to the BWLogger, it seemed like it would be better to put it
here in the forums than in the wiki. It can be moved/copied if
someone thinks there is value in having it there.

So...lets get started:

1) AVR Programming Interface
I chose the Pololu AVR programmer because it was among the least
expensive programmers I found. And because it has a (unpopulated)
header to use the programmer as a TTL level serial port for use with
BLSync. The Rx and Tx lines are 5V so it will still need the BLSync
adapter or other level shifter.

link: http://www.pololu.com/catalog/product/1300

The "resources" tab has links for all of the software and access to
the users guide.

For developing from Windows the first step is to install the USB
drivers. This creates two new serial ports - one for the ISP
programmer and one for the TTL serial interface.

Linux does not need USB drivers.

Installing the drivers also installs the Configuration Utility. There
is not a Linux version of the configuration utility and there is not a
Linux way to accomplish the configuration. The documents say that the
configuration is stored in the programmer so Linux users only need to
run the configuration utility when they need to change some settings.

We will use the configuration utility to update the programmer
firmware to 1.06. The file is available on the Pololu web site, the
instructions are in in the users guide.
* Put the programmer into boot loader mode by clicking the button in
the config utility. This will create yet another serial port in the
system for the boot loader.
* Open a terminal program and connect to the boot loader serial port
at 9600 8N1.
* Enter "fwbootload" - all lower case and without the quotes. The
programmer will echo the characters back as upper case. The yellow
LED should be on
* Enter "s" - again, lower case, no quotes and echo back upper case.
This causes the programer to erase the current firmware so DO NOT
unplug the programmer until the update is complete.
* Upload the new firmware. The .pgm file from the web site is plain
text so you can copy and paste the contents to the terminal window, or
you can use the "send file" functionality if your term program has
it. Do not use any protocol (i.e. xmodem or kermit).
* The programmer will echo "."s while it is receiving and
programming. When it is done it will echo "|" and turn on the red
LED. It is now safe to disconnect and reconnect the programmer.


2) Development Environment
I chose AVRStudio 5 as my development environment for a couple of
reasons. First is that there is a project file in with the source so
it seemed like the quickest way to get up and running. Second is that
Ive done enough microcontroller development to know that the tools
provided by the vendor usually provide good visibility and access to
the device. So far, AVRStudio seems to be much better than most Ive
used.

Once AVRStudio was installed I loaded the project, selected the "Mini
- Release" target and built. No muss, no fuss, no errors or
warnings. It just worked - nice.


3) Adding the programmer to the Dev Environment
At this point we will get AVRStudio to recognize the programmer and
get it configured for our device.

Select "Add STK500" from the Tools menu and choose the serial port for
the programmer. It doesnt do any harm if you choose the wrong port,
but if you want to remove it, go to "Available AVR Tools" entry on the
View menu. Right click on a tool for the option to remove it.

Now lets select "AVR Programming" from the Tools menu. Choose
"STK500" from the Tools drop-down and ATmega328P from the Device drop-
down. If the 328P is not in the drop down, we'll have to add it.

* Close AVRStudio and browse to the directory where it is installed.
It should be in C:\Program Files\Atmel\AVR Studio 5.0 on an XP or Win7
32bit machine or in C:\Program Files (x86)\Atmel\AVR Studio 5.0\tools
on a Win7 64bit machine. We'll refer to this as the AVRStudio
directory.

* Browse to the <AVRStudio>\devices\ directory and make sure the file
ATmega328P.xml exists

* Browse to the <AVRStudio>\tools\STK500\xml directory.

* Edit ATmega168_stk500.xml. Change occurrences of "ATmega168" to
"ATmega328P". Save the file back to the same directory with the name
ATmega328P_stk500.xml I had problems on Win7 64bit getting the file
to save. Though Im administrator there was some permissions issue
because regardless of which editor I used it would not save to that
directory. I had to save it to the desktop with a different name,
copy it into the directory, rename the original file out of the way
and rename the new file to the right name.

* Restart AVRStudio and Tools|AVR Programming and see that the
ATmega328P devices is now available.

Choose ISP from the Interface drop-down and select "Apply".

Connect the BWLogger to the ISP cable. Pin 1 is toward the middle of
the board.

Attempt to read the Device ID. If everything is happy you will get a
result. If not, you will get an error dialog and the Output pane of
AVRStudio will show the error messages. Refer to the Pololu
programmers guide for troubleshooting help.

Finally...it is time to program something. I took the stock build and
modified a string on the lock screen so I could tell for sure that I
got it reprogrammed. Change the "hold PREV and NEXT" or "to unlock"
strings found near the top of DrawModeScreen() in hikea.c. Rebuild,
open AVR Programming from the Tools menu, apply the choices and read
the device ID. Choose "Memories" from the left side menu and set the
name of the FLASH file to the project output file: <project path>\Mini
- Release\hikea.hex.

If it all goes well, you will see your string(s) on the screen. If an
error occurs, the open the configuration utility and check the "Error
from last programming" area. If the message says something about
"Target VDD" going too low or having too much range you will need to
adjust the "Target VDD Monitor" settings. If the error is something
else, check the troubleshooting section of the Pololu programmers
guide.

For Target VDD errors, basically the reprogramming is aborted if the
voltage falls below the set threshold or if there is more than the
defined swing from the highest to the lowest voltage measured during
programming. In theory you could just set the minimum to 0mv and the
range to 5000mv. In practice you should be more conservative. To
dial it in, I set to a bit above the reported measurement values and
tried programming. I had to repeat this a few times before I got a
value that was consistently good. Right now Im set at 2496 and 320
and my measurements are consistently 3200 and 256.

Hope this helps someone.

Steve Chamberlin

unread,
Nov 24, 2011, 10:49:33 AM11/24/11
to backwoods-lo...@googlegroups.com
Awesome Jay! Got any interesting plans for firmware hacking?

That Pololu programmer looks pretty nice-- I've never seen it before. I guess it's basically both of these combined into one?

It looks like you should be able to get the blsync software working with that programmer too, using the TTL serial port, following the blsync schematic from the project web site. You only need to do level conversion for one signal, which you can do using a transistor like the schematic shows, or just a simple resistor voltage divider or any other method. 

The only drawback I've found to AVR Studio 5 is that if you also have Microsoft Visual Studio 2008 or newer on your PC, installing AVR Studio will break the MSVC debugger. There's some DLL magic you can do to fix it, which is described in the AVR Freaks forums.

I went running a week ago with one of the Rev. A Logger Minis in my hip pocket, and I tripped on the sidewalk and somehow fell directly on top of it, smashing it. Ouch!


I still have more of the Rev. A Logger Minis for sale, so if you know anyone who might like one, please spread the word.

Steve

Jay Lash

unread,
Nov 24, 2011, 8:24:25 PM11/24/11
to Backwoods Logger development discussion
Yeah, it is about the same as those two in one.

Good to know about messing with DevStudio - Im working on the machine
at home right now and dont have DevStudio there. But I did put
AVRStudio on the machine at work the other day and have not used
DevStudio since. Ill have to check it out next week and get it fixed
so it is ready next time I need it.


Got a list of things I want to do:

* At the moment Im adding an alternate lock screen that displays the
time, temp and pressure. I was going to just replace the BMOW lock
screen but the new BWLogger logo is awfully nice so Im thinking Ill
leave the logo for 1/2 the sleep time and show the data for 1/2. Or
maybe Ill show the logo if the enter button was pressed but showing
the data if next or prev was pressed.

* I want to add a 24hr high and low temp (maybe others) and have them
available on the main and lock screens

* Would like to add an alarm functionality. Would also be nice to set
the date/time from the PC via BLSync

* Add a "mods & credits" screen - this would accompany some
discussions about how to manage different developers making mods that
may or may not be incorporated into the main build. Ive never worked
on a project where the functionality is so segmented like this has the
potential to be so I dont know how that is typically handled. I see
the confusion it causes in the Android "custom ROMs" community.

* The big one that Im after for next summer is reallocating sample
storage and increasing sample rate so I can get a full three weeks
worth of temperature readings. Got to get a better handle on how
samples are stored etc.


Ill let some folks know what you have on hand. Still going to be $59
shipped and without an enclosure?
Jay


On Nov 24, 9:49 am, Steve Chamberlin <steve.chamber...@gmail.com>
wrote:


> Awesome Jay! Got any interesting plans for firmware hacking?
>

> That Pololu programmer looks pretty nice-- I've never seen it before. I guess it's basically both of these combined into one?http://www.sparkfun.com/products/9825http://www.sparkfun.com/products/9716


>
> It looks like you should be able to get the blsync software working with that programmer too, using the TTL serial port, following the blsync schematic from the project web site. You only need to do level conversion for one signal, which you can do using a transistor like the schematic shows, or just a simple resistor voltage divider or any other method.
>
> The only drawback I've found to AVR Studio 5 is that if you also have Microsoft Visual Studio 2008 or newer on your PC, installing AVR Studio will break the MSVC debugger. There's some DLL magic you can do to fix it, which is described in the AVR Freaks forums.
>
> I went running a week ago with one of the Rev. A Logger Minis in my hip pocket, and I tripped on the sidewalk and somehow fell directly on top of it, smashing it. Ouch!
>

Steve Chamberlin

unread,
Nov 25, 2011, 11:58:51 AM11/25/11
to backwoods-lo...@googlegroups.com
Yup, still $59. A more detailed announcement is here: http://www.bigmessowires.com/2011/11/21/backwoods-logger-prototypes-available-now/

To change the sampling rate, you should be able to just change the minutesPerSample and scaleStrings arrays at the top of sampling.c. The displayed time intervals aren't exact, but are rounded for space and readability, which is why there are two different arrays. For instance, the middle time scale is displayed as 10 hours, but is actually 5 minutes * 128 = 10.666 hours. Due to the sampling method used, the sampling intervals must evenly divide into 1440 (number of minutes in a day).

Good question about how to manage and install different function modules! Something like that will likely be needed, since the Logger program memory is very close to full already, and there's little space remaining to add new functions. I'm also hoping to add a bootloader at some point, which will require 2K.

One approach would be to put a unique #ifdef around the code for each module, like #if DISPLAY_DAILY_HIGH_LOW_TEMPERATURE, and then create a config.h file where each symbol is listed and set to 0 or 1 to enable it. That would work fine for people who are compiling the firmware themselves and burning it to the Logger, but doesn't do anything for people who have a pre-assembled Logger without an ISP programmer, or just went a precompiled firmware image. Maybe that's fine though.

I wish there were a better enclosure solution that was the right size to fit the Logger Mini. Maybe something 3D printed? Custom injection molded enclosures are pretty expensive for a production run. I ordered a bunch of "key fob" enclosure samples from OKC, but none of them were quite the right size. It might work better to choose a good commercially-available enclosure, then redesign the hardware to fit it.

Steve

Jay Lash

unread,
Nov 25, 2011, 7:28:41 PM11/25/11
to Backwoods Logger development discussion
Ill look at those for changing the sample rate, thanks.

Yep, Im isolating my mods with #ifdef. Ive been enabling them from
the project settings but a config.h would work too. Could even add a
struct with some version/description info that could be displayed.

That enclosure I mentioned in the "Got my mini" thread fits quite
well. Ill check the parts room on Monday and send you one to try if
we have a few extras.


On Nov 25, 10:58 am, Steve Chamberlin <steve.chamber...@gmail.com>
wrote:
> Yup, still $59. A more detailed announcement is here:http://www.bigmessowires.com/2011/11/21/backwoods-logger-prototypes-a...

Rubi

unread,
Nov 27, 2011, 3:30:05 AM11/27/11
to Backwoods Logger development discussion
Hi

I also played with the code a little and changed the clock display to
24h format.
24h are displayed when metric settings are chosen.

A config.h file would be a great idea, I hate messing around in the
make files.

Cheers
Rubi

Jay Lash

unread,
Nov 30, 2011, 1:50:22 PM11/30/11
to Backwoods Logger development discussion

On Nov 24, 9:49 am, Steve Chamberlin <steve.chamber...@gmail.com>
wrote:
>

> The only drawback I've found to AVR Studio 5 is that if you also have Microsoft Visual Studio 2008 or newer on your PC, installing AVR Studio will break the MSVC debugger. There's some DLL magic you can do to fix it, which is described in the AVR Freaks forums.
>

I had intended to look into this on my work machine so it was fixed
before I needed to do any Dev Studio debugging again. That was the
plan...unfortunately the need arose yesterday afternoon.

When I tried to attach to a process running on my CE device, Dev
Studio gave an error that said the error usually indicates a corrupt
installation and I should use the "repair" option of the installer. I
tried the repair and got the same results so I searched around at AVR
Freaks forums like Steve suggested and found the solution is simply to
re-register one of Dev Studios DLLs:

regsvr32 "C:\Program Files\Common Files\Microsoft Shared\VS7Debug
\msdbg2.dll"

Reply all
Reply to author
Forward
0 new messages