Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Ice Tube GPS Mod
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Ice Tube GPS Mod

by GWDodd on Fri Jul 26, 2013 2:45 am

Hello, Good Day and thanks, kind reader, for entertaining this post!
I have been enjoying this brilliant Ice Tube Clock for a couple of years and have decided to attempt the GPS Mod. Please bear in mind that 5 days ago I had never HEARD of AVR and Arduino so this is a stretch for me. I've ordered the USBtinyISP programmer and a GPS module from Adafruit but what I would like to do is program the microprocessor on a target board instead of "in-clock" (I would rather avoid smoke-checking or otherwise destroying the clock.). I've also decided to order some extra ATMega168 chips (bad things usually happen when I try stuff like this). My other option is to build another Ice Tube Clock kit to be built specifically for the GPS mod (keeping my first clock safely working by my bedside).
So my question is, other than the target board, chip, IP header and programmer, do you think any other components would be required to be connected to the target board for a successful program (for example clock source and/or GPS antenna)?
My apologies (in advance) if this seems silly. Why not try reprogramming using the IP header installed on the clock? Again, I use my clock daily and I'd rather not be without it. I'm completely unsure of the programming procedure (but I'm willing to try). So if I can experiment with this on a target board instead of my nice Ice Tube Clock, that would be optimal.
I look forward to anyone's reply and thanks so much for reading, your consideration and time spent!
GWDodd
 
Posts: 12
Joined: Fri Jul 26, 2013 1:56 am

Re: Ice Tube GPS Mod

by wbp on Fri Jul 26, 2013 10:49 pm

GW, where are you located? I can program a new chip and send it to you for about what it costs me. I use a 328p now because the firmware I use (mine) no longer fits in a 168 with all the features...

I use an Arduino with a ZIF socket to program my AVR chips, then just swap he chip in the clock.

William

wbp
 
Posts: 260
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube GPS Mod

by GWDodd on Sun Jul 28, 2013 4:14 am

Such a nice offer and thanks so much William!
I am happy to take you up on your generous offer but I really have no idea how I could pass you my personal info for mailing (to Washington State) and of course I would reimburse ALL charges for parts, shipping and labor!
And since I have already ordered the stuff to attempt this myself, I will still give it a go since I'm curious if I can actually do this successfully. But since you program your chips using Arduino, are there any other components required on the board besides the chip and IP header?
If you have any ideas how we can exchange details, let me know. I'll be around, off and on, all day!
Greg
GWDodd
 
Posts: 12
Joined: Fri Jul 26, 2013 1:56 am

Re: Ice Tube GPS Mod

by jarchie on Sun Jul 28, 2013 4:42 pm

If you have any ideas how we can exchange details, let me know.


My favorite method is to protect my email from spammers with reCaptcha and post that link on this forum. But that would only work if you or William are willing to publically post your email address.

So my question is, other than the target board, chip, IP header and programmer, do you think any other components would be required to be connected to the target board for a successful program (for example clock source and/or GPS antenna)?


(I'm assuming you mean ISP header, not IP header. ISP = In System Programming)

You shouldn't need any additional components. But to program ATMEGA chips preconfigured with an Arduino bootloader, you will need an AVR board with an external clock crystal, like the Arduino Uno. The exact process will depend on your particular programmer and board. You've mentioned the Adafruit USBtinyISP, but what AVR board are you planning to use? The Arduino Uno?

Why not try reprogramming using the IP header installed on the clock?


The ISP header in the clock can be a bit finicky, but I've used it hundreds of times. You're not likely to damage your clock, but there is a slight chance of bricking the AVR chip. I've done so only on three occasions, so it's a rare event, but nothing to worry about if you are programming a spare chip. Just keep the original out of harm's way.

To be honest, I bricked those chips by leaving the VFD tube PCB installed while programming the clock. Adafruit recommends removing the side PCB before programming the clock, and that seems much safer. Also, I was able to unbrick those three chips using high voltage parallel programming (HVPP) with the AVR Dragon, so the chips themselves were not damaged. They were only left in a state where they could not be programmed in the Ice Tube Clock. After HVPP, the chips worked just fine in the Ice Tube Clock and could be again programmed with the ISP header.

And since I have already ordered the stuff to attempt this myself, I will still give it a go since I'm curious if I can actually do this successfully.


If you're interested in trying other alternative firmwares, I've posted some advice elsewhere on this forum.
--John <www.jarchie.com/email>

jarchie
 
Posts: 595
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube GPS Mod

by GWDodd on Mon Jul 29, 2013 2:15 am

Hi Jarchie and thanks for your very helpful and informative reply!
Yes, I meant ISP header--my bad. A few years of IT system management behind me and sometimes it leaks out! PLUS very recently, Comcast decided to block my email address domain from their servers so I couldn't get thru to my folks and I had to "visit" IP address configuration with the Comcast gurus. I guess that was still floating around in my tired, old head!

I really wasn't sure about any of the Arduino boards on the Adafruit website so I decided to go with the bread-n-butter ATmegaXX8 Target Board from the Evil Mad Scientist. But again, I really only have a faint idea about what's going on. These are unkown waters I'm navigating!
I've ordered spare chips from Digikey and it makes more sense to program them in clock (Thought I'd go the safest route possible). Reviewing the datasheets for the chips (available on the Digikey website), I don't see where they come pre-programmed with an Arduino bootloader. I could be wrong but it reads to me that Atmega leaves all that stuff to the purchaser to determine (depending on application I guess).

Although this stuff is new to me, It's opened up a whole new level of gadgetry and I'm all about that. At this point, HVPP is not necessary, I assure you that I'm going to have another, closer look at the AVR Dragon and the other Arduino boards available here at Adafruit.

Thanks again, Jarchie!
GWDodd
 
Posts: 12
Joined: Fri Jul 26, 2013 1:56 am

Re: Ice Tube GPS Mod

by jarchie on Mon Jul 29, 2013 8:18 pm

Yes, I meant ISP header--my bad.

No explanation necessary... just making sure we're talking apples and apples. :-)


I really wasn't sure about any of the Arduino boards on the Adafruit website so I decided to go with the bread-n-butter ATmegaXX8 Target Board from the Evil Mad Scientist.

Good choice! That board has a place to add an external clock crystal, if desired, but it doesn't look like you will need to do so. When I program a chip using the Evil Mad Scientist board, I program the new chip as follows:

    (1) place the unpowered target board on an insulating surface
    (2) insert the new chip into the target board
    (3) remove the power jumper on the USBtinyISP
    (4) plug the USBtinyISP into the computer's USB port (the USBtinyISP's green indicator light should turn on)
    (5) plug the USBtinyISP's 6-pin ISP cable into the target board's ISP header, ensuring the cable's red wire and marked header pin are on the same side (both mark pin 1)
    (6) connect the power jumper on the USBtinyISP (powers the target board)
    (7) program the chip (the USBtinyISP's red indicator light should flash)
    (8) disconnect the USBtinyISP from the target board and computer
    (9) remove your newly programmed chip
The exact commands you will use to "program the chip" will depend on the particular firmware. My xmas-icetube firmware has decent installation instructions, so that might be a good place to start.

Unfortunately, my installation instructions describe how to program a new chip in the clock. If you chose to install using the target board method, use steps (1)--(6) above in place of step "(3) Connect the Programmer" in the instructions.

For other projects, my generic advice for installing alternative firmwares should be relevant, although you shouldn't need to modify the source code for William's firmware, as it is one of the few that compiles cleanly out-of-the box. William's firmware is excellent, by the way.


I've ordered spare chips from Digikey and it makes more sense to program them in clock (Thought I'd go the safest route possible).

They can be programmed in the clock or in the development board--both methods are safe and should not damage your clock. The method you ultimately use will be personal preference. Programming the chips in the target board should be more reliable, but doing so requires the extra step of removing and inserting a chip into your clock.

When I wrote that programming the chips in the clock with the side PCB removed was safer, I meant that it was safer than programming the chips in the clock with the side PCB in place. I apologize if my statement was unclear.


Reviewing the datasheets for the chips (available on the Digikey website), I don't see where they come pre-programmed with an Arduino bootloader.

You are absolutely correct. The chips from Digikey are fresh from Atmel and have not been programmed with an Arduino bootloader. But some sources, including Adafruit, program an Arduino bootloader before shipping the chips to their customers.


At this point, HVPP is not necessary, I assure you that I'm going to have another, closer look at the AVR Dragon and the other Arduino boards available here at Adafruit.


I apologize for being unclear here. I did not mean to imply that you should be researching HVPP or the Dragon. Of course, if those things interest you, that's a different matter...

What I meant to write is that my bricked chips were bricked for some software reason, and they were not physically damaged. My intended point was that programming a new chip via the clock's ISP header is safe for the hardware, although programming the new chip occasionally fails.


One last bit of advice... when you build the USBtinyISP, use jumpers in place of R4 and R7. That configuration works well for me, both with a target board and with the Ice Tube Clock. It's also what Adafruit recommends for the Ice Tube Clock: "If you are using a USBtinyISP... make sure you have R4 and R7 jumpered."

Good luck and happy hacking!

[This post has been edited by the author after posting.]
--John <www.jarchie.com/email>

jarchie
 
Posts: 595
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube GPS Mod

by GWDodd on Tue Jul 30, 2013 4:17 pm

Hi Jarchie and thanks for all the info! I'm no longer intimidated by trying this!
I hate to do this but I have a couple more questions. When I build the USBtinyISP, I will certainly use jumpers instead of resistors. But first, why is this necessary and second, what gauge wire would be suitable for the jumper for this application (yes, I'll have to buy)?
And the other thing I've been thinking about since I started looking at firmware files is when I look at William's zip file, there are many different files. And also, when I look at your Xmas Ice-tube firmware, there is also many different files. I see a .hex file in William's zip file but I don't see one in yours. If there is a .hex file, do I still need to compile? I'm totally unsure about all these .c and .h files. I'm guessing that's where compiling comes in to play so I guess I have (a lot) more research to do regarding that step of the process. And then there's the mod referenced on the Ice Tube Clock tutorial page with code written by Devlin Thyne which is different than both yours and William's but maybe it's already compiled? Any thoughts you have regarding this would be appreciated. I'm playing my newbie card here. And I'll be looking a lot more closely at compiling in the various tutorials that are out there.
Gotta run! Thanks again for reading, consideration and time spent!
Greg
GWDodd
 
Posts: 12
Joined: Fri Jul 26, 2013 1:56 am

Re: Ice Tube GPS Mod

by jarchie on Tue Jul 30, 2013 7:25 pm

It occurred to me this morning that you might be interested in reading my GPS mod tutorial.


But first, why is this necessary

Resistors R4 and R7 limit the amount of current the USBtinyISP can use to program a device. With these resistors in place, the USBtinyISP might not be able to deliver sufficient voltage to program the clock.

In USBtinyISP v1.0, these resistors protected the USBtinyISP's microcontroller from excessive current. In v2.0, a buffer chip protects the microcontroller, so R4 and R7 can be replaced by jumpers.


what gauge wire would be suitable for the jumper for this application (yes, I'll have to buy)?

You shouldn't need to buy anything. When building the kit, each component is soldered in place and excess leads are cut flush to the bottom of the circuit board. That produces lots of short wires which are normally discarded. Any of the wires with sufficient length will work fine. Check out the Adafruit USBtinyISP assembly instructions for a picture.


If there is a .hex file, do I still need to compile?

It depends. The .hex file is usually a precompiled version of the firmware, but most firmwares have compile-time options to enable, disable, or modify features. The precompiled version might not always do what you want.


And the other thing I've been thinking about since I started looking at firmware files is when I look at William's zip file, there are many different files. I'm guessing that's where compiling comes in to play so I guess I have (a lot) more research to do regarding that step of the process.

Don't worry... learning to compile is not terribly difficult. I can give you some pointers, but I need to know what operating system you are running.


And then there's the mod referenced on the Ice Tube Clock tutorial page with code written by Devlin Thyne which is different than both yours and William's but maybe it's already compiled?

Yes, it's precompiled. But the precompiled version only works with GPS units communicating at 4800 baud... to work with the Adafruit Ultimate GPS module, which communicates at 9600 baud, the mod must be recompiled.

John
--John <www.jarchie.com/email>

jarchie
 
Posts: 595
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube GPS Mod

by phild13 on Tue Jul 30, 2013 7:54 pm

"... what gauge wire would be suitable for the jumper for this application (yes, I'll have to buy)?...."

Just use a couple of cut offs from one of the resistors that are getting installed on the board for the jumpers. Solder them in where the 2 resistors R4, R7, would go.

" ....When I build the USBtinyISP, I will certainly use jumpers instead of resistors. But first, why is this necessary..."

From the UsbtinyISP solder instructions: If you are using the UsbtinyISP with a SpokePOV kit, install R4 and R7. If not switch these resistors for jumpers so that boards with loaded pins (such as the icetube clock) can be programmed.

My advice would be to read the instruction to flash the firmware by Jarchie after testing the UsbtinyISP. I have read through his instruction on flashing his firmware to a 328 chip and it seems pretty easy to accomplish. If you have a blank chip (purchased from Digi-Key for example) with no bootloader on it you can flash it using the icetube clock board and the USBTinyISP. If the ATMEGA328P chip was purchased from Adafruit or somewhere else and already has a boodloader programmed into it then you will need something like the Arduino Uno R3 (Atmega328) to install the chip in for reprogramming for use in the icetube clock. You would still use the USBTinyISP for the programming. You have to have the ATMEGA328P chip as the one that comes with the icetube clock is to small to hold the firmware. I picked up a ATMEGA328P-PU-ND chip which should work fine at DigiKey for less than 4 bucks ($3.16) less shipping.

Hope this helps some.

phild13
 
Posts: 247
Joined: Mon Sep 10, 2012 1:05 pm

Re: Ice Tube GPS Mod

by GWDodd on Wed Jul 31, 2013 2:12 pm

Thanks a lot guys for all the great help and tips! I need all the help I can get and I will certainly rely on this stuff while I'm working on this project!
And Jarchie, as far as programming goes, I was planning on using an old laptop with Windows XP installed. I can also use this machine that has Windows 7 Pro, 64bit.

Thanks again!
Greg
GWDodd
 
Posts: 12
Joined: Fri Jul 26, 2013 1:56 am

Re: Ice Tube GPS Mod

by jarchie on Wed Jul 31, 2013 7:56 pm

My advice would be to read the instruction to flash the firmware by Jarchie after testing the UsbtinyISP. --PhilD13


Sage advice. Taking things one step at a time is definitely a good idea.

I would recommend approaching this project as several small tasks (1) compiling xmas-icetube, (2) building the AVR development board, (3) building and testing the USBtinyISP, (3) programming a chip with xmas-icetube and using it in your clock, and (4) installing the GPS mod.

And Jarchie, as far as programming goes, I was planning on using an old laptop with Windows XP installed. I can also use this machine that has Windows 7 Pro, 64bit. --GWDodd


I don't think it matters which computer you choose; either should work fine. And you might as well work on compiling xmas-icetube now, as that only requires your computer.


Okay... the first step is to download and install all the necessary tools.

If you don't already have a good text editor, you'll need one for editing the various plain-text files. I recommend Notepad++ for newbies. It's free, intuitive, and fairly powerful.

Since Windows does not come with a standard set of Unix/Linux tools, you'll need to install those as well. I recommend Cygwin. When the installer prompts you with a list of packages to install, change the Perl group from "Default" to "Install." Why? Both Adafruit's firmware and xmas-icetube use Perl scripts during compilation, and other alternative firmwares probably do the same.

The last set of tools you'll need to install is the GNU GCC AVR software development tools; I recommend WinAVR.


Okay... so you've got all the tools installed. Time to examine the xmas-icetube package.

Download xmas-icetube from GitHub using the "Download ZIP" link, and extract the files to a suitable location. I usually use C:\Users\jarchie\Documents\, and will use that directory here. Examine the list of files now in C:\Users\jarchie\Documents\xmas-icetube-master\.

EDIT: The firmware files have been moved into a firmware subdirectory, so the firmware files would now be in C:\Users\jarchie\Documents\xmas-icetube-master\firmware\.

The first file you should notice is the plain-text README which contains installation instructions and other important information. The CREDITS, LICENSE, and MENUS files are all plain-text documentation files.

The source code files end in .c and .h. Open the main file, icetube.c, in Notepad++. At the top of icetube.c, you'll see comment lines starting with "//" which provide human readable descriptions of each .c file. But the compiler needs a more precise description of each .c file, and that is what the .h files do. The contents of the .c and .h files will be mostly unintelligible unless/until you've learned C. That's completely okay.

The last important file is the Makefile. The Makefile automates the compilation process so you can compile the code with one simple command. Open the Makefile and look through it. Human readable comments start with "#"--not with "//" like in the .c and .h files. The first part of the Makefile contains a lot of variable definitions. The second part of the file contains rules for how the computer should compile the firmware. The contents of the Makefile will be mostly unintelligible unless/until you've learned Makefile syntax. That's completely okay.

The remaining .gitignore file is not used when compiling or installing the firmware. It is only used when modifying the firmware and committing those changes to a git repository.


Okay... so you know what comes in the xmas-icetube package. Time to modify the configuration to suit your needs.

Open the README and view the installation section. The first step is to edit the Makefile and config.h as necessary, so open these in files in Notepad++.

In the Makefile, look for where the AVRISP and AVRDUDEOPT variables are defined. Recall that everything after a "#" on each line is a comment. These variables happen to be already set appropriately for programming with the USBtinyISP, so you actually don't need to change the Makefile at all.

Read the config.h file. It's mostly composed of human readable comments describing the different options. Recall that anything after "//" on each line is a comment. You may enable or disable different features by commenting and uncommenting the macro definitions. Because you need GPS support, you will need to uncomment the GPS_TIMEKEEPING macro by changing the line that reads
Code: Select all | TOGGLE FULL SIZE
// #define GPS_TIMEKEEPING
to
Code: Select all | TOGGLE FULL SIZE
#define GPS_TIMEKEEPING
The GPS_TIMEKEEPING macro is now defined, thereby enabling support for the Ultimate GPS Module.


Okay... with that one line change, you are now ready to compile, which is done from a command line shell.

Open the Cygwin Terminal to start BASH (the Bourne-Again Shell): "Start" > "All Programs" > "Cygwin" > "Cygwin Terminal." Next, change to your xmas-icetube source code directory with the cd (change directory) command:
Code: Select all | TOGGLE FULL SIZE
$ cd /cygdrive/c/Users/jarchie/Documents/xmas-icetube-master

Note that the initial "$" and space above is part of the command prompt. You don't type that part. It is displayed on the screen to signify that the shell is ready for you to type a command and press return. Some shells use a "%" as the command prompt which is why the xmas-icetube installation instructions uses that symbol instead of a "$".

EDIT: Again the firmware is in a subdirectory so the previous command would now be "cd /cygdrive/c/Users/jarchie/Documents/xmas-icetube-master/firmware"

Now that you have changed to the source code directory, you may print a directory listing with the ls (list) command.
Code: Select all | TOGGLE FULL SIZE
$ ls
alarm.c    config.h   gps.c      Makefile  optgen.pl  system.c  usart.c
alarm.h    CREDITS    gps.h      MENUS     piezo.c    system.h  usart.h
buttons.c  display.c  icetube.c  mode.c    piezo.h    time.c
buttons.h  display.h  LICENSE    mode.h    README     time.h

To compile the code, use the make command as described in the installation instructions (step two):
Code: Select all | TOGGLE FULL SIZE
$ make
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o icetube.o icetube.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  icetube.c > icetube.d
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o system.o system.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  system.c > system.d
./optgen.pl time | xargs avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o time.o time.c
./optgen.pl time | xargs avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  time.c > time.d
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o alarm.o alarm.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  alarm.c > alarm.d
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o piezo.o piezo.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  piezo.c > piezo.d
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o display.o display.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  display.c > display.d
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o buttons.o buttons.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  buttons.c > buttons.d
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o mode.o mode.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  mode.c > mode.d
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o usart.o usart.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  usart.c > usart.d
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o gps.o gps.c
avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  gps.c > gps.d
avr-gcc -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o icetube.elf icetube.o system.o time.o alarm.o piezo.o display.o buttons.o mode.o usart.o gps.o
avr-objcopy  -R.eeprom -R.fuse -R.lock -O ihex icetube.elf icetube_flash.hex
avr-objcopy  -j .eeprom -O ihex icetube.elf icetube_eeprom.hex

icetube.elf  :
section    size      addr
.data         8   8388864
.text     22674         0
.bss        106   8388872
.eeprom      58   8454144
.fuse         3   8519680
.lock         1   8585216
Total     22850



If you run the ls command again, you'll notice that there are now a lot more files:
Code: Select all | TOGGLE FULL SIZE
$ ls
alarm.c    CREDITS    icetube.c           mode.c     README    usart.c
alarm.d    display.c  icetube.d           mode.d     system.c  usart.d
alarm.h    display.d  icetube.elf         mode.h     system.d  usart.h
alarm.o    display.h  icetube.o           mode.o     system.h  usart.o
buttons.c  display.o  icetube_eeprom.hex  optgen.pl  system.o
buttons.d  gps.c      icetube_flash.hex   piezo.c    time.c
buttons.h  gps.d      LICENSE             piezo.d    time.d
buttons.o  gps.h      Makefile            piezo.h    time.h
config.h   gps.o      MENUS               piezo.o    time.o


The .d files are used by the Makefile to improve compilation efficiency; they are not important. The .o files are the compiled versions of the .c files. These .o files are linked together to create icetube.elf, a single binary containing the entire firmware. But the AVR programming utility, avrdude, cannot read the icetube.elf format, so that file has been converted into two .hex files. As the name implies, icetube_flash.hex contains the executable portion of the firmware to be uploaded to flash (program memory). The icetube_eeprom.hex file contains the initial EEPROM contents to be uploaded to the EEPROM. The EEPROM contains data the clock stores even when power is lost, such as the last known time or the various configuration settings.

Well, congratulations! If you've gotten this far, you've successfully compiled your first firmware.


After you build the USBtinyISP and install the Windows driver according to the Adafruit tutorial, you will be able to program chips with xmas-icetube through BASH within the Cygwin Terminal. As before, you'll need to change to the xmas-icetube directory, and run the make install-fuse, make install, and make install-lock commands as described in the installation instructions:

EDIT: The make install-fuse, make install, and make install-lock still work as described here, but they are no longer documented in the README and might be deprecated someday. To fully configure a chip for my firmware, use the single command make install-all instead of the three commands above.

Code: Select all | TOGGLE FULL SIZE
$ cd /cygdrive/c/Users/jarchie/Documents/xmas-icetube-master


EDIT: Again, the firmware is in a subdirectory so the previous command would now be "cd /cygdrive/c/Users/jarchie/Documents/xmas-icetube-master/firmware"

Code: Select all | TOGGLE FULL SIZE
$ make install-fuse
./optgen.pl time | xargs avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o time.o time.c
./optgen.pl time | xargs avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  time.c > time.d
avr-gcc -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o icetube.elf icetube.o system.o time.o alarm.o piezo.o display.o buttons.o mode.o usart.o gps.o
avr-objcopy  -j.fuse -O ihex icetube.elf icetube_fuse.hex
avrdude -B 4 -P usb -c usbtiny -p atmega328p -u -U lfuse:w:0x62:m -u -U hfuse:w:0xD1:m -u -U efuse:w:0x06:m

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude.exe: Device signature = 0x1e950f
avrdude.exe: reading input file "0x62"
avrdude.exe: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude.exe: 1 bytes of lfuse written
avrdude.exe: verifying lfuse memory against 0x62:
avrdude.exe: load data lfuse data from input file 0x62:
avrdude.exe: input file 0x62 contains 1 bytes
avrdude.exe: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.02s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of lfuse verified
avrdude.exe: reading input file "0xD1"
avrdude.exe: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude.exe: 1 bytes of hfuse written
avrdude.exe: verifying hfuse memory against 0xD1:
avrdude.exe: load data hfuse data from input file 0xD1:
avrdude.exe: input file 0xD1 contains 1 bytes
avrdude.exe: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of hfuse verified
avrdude.exe: reading input file "0x06"
avrdude.exe: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude.exe: 1 bytes of efuse written
avrdude.exe: verifying efuse memory against 0x06:
avrdude.exe: load data efuse data from input file 0x06:
avrdude.exe: input file 0x06 contains 1 bytes
avrdude.exe: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of efuse verified

avrdude.exe done.  Thank you.

rm icetube_fuse.hex

Code: Select all | TOGGLE FULL SIZE
$ make install
./optgen.pl time | xargs avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o time.o time.c
./optgen.pl time | xargs avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  time.c > time.d
avr-gcc -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o icetube.elf icetube.o system.o time.o alarm.o piezo.o display.o buttons.o mode.o usart.o gps.o
avr-objcopy  -R.eeprom -R.fuse -R.lock -O ihex icetube.elf icetube_flash.hex
avr-objcopy  -j .eeprom -O ihex icetube.elf icetube_eeprom.hex
avrdude -B 4 -P usb -c usbtiny -p atmega328p   -U flash:w:icetube_flash.hex:i \
                                 -U eeprom:w:icetube_eeprom.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "icetube_flash.hex"
avrdude: writing flash (22682 bytes):

Writing | ################################################## | 100% 7.63s

avrdude: 22682 bytes of flash written
avrdude: verifying flash memory against icetube_flash.hex:
avrdude: load data flash data from input file icetube_flash.hex:
avrdude: input file icetube_flash.hex contains 22682 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 6.21s

avrdude: verifying ...
avrdude: 22682 bytes of flash verified
avrdude: reading input file "icetube_eeprom.hex"
avrdude: writing eeprom (58 bytes):

Writing | ################################################## | 100% 0.23s

avrdude: 58 bytes of eeprom written
avrdude: verifying eeprom memory against icetube_eeprom.hex:
avrdude: load data eeprom data from input file icetube_eeprom.hex:
avrdude: input file icetube_eeprom.hex contains 58 bytes
avrdude: reading on-chip eeprom data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 58 bytes of eeprom verified

avrdude done.  Thank you.


Code: Select all | TOGGLE FULL SIZE
$ make install-lock
./optgen.pl time | xargs avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o time.o time.c
./optgen.pl time | xargs avr-gcc -MM -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  time.c > time.d
avr-gcc -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000  -o icetube.elf icetube.o system.o time.o alarm.o piezo.o display.o buttons.o mode.o usart.o gps.o
avr-objcopy  -j.lock -O ihex icetube.elf icetube_lock.hex
avrdude -B 4 -P usb -c usbtiny -p atmega328p -U lock:w:0x2B:m

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude.exe: Device signature = 0x1e950f
avrdude.exe: reading input file "0x2B"
avrdude.exe: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude.exe: 1 bytes of lock written
avrdude.exe: verifying lock memory against 0x2B:
avrdude.exe: load data lock data from input file 0x2B:
avrdude.exe: input file 0x2B contains 1 bytes
avrdude.exe: reading on-chip lock data:

Reading | ################################################## | 100% 0.00s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of lock verified

avrdude.exe done.  Thank you.

rm icetube_lock.hex


Good luck and happy hacking!
Last edited by jarchie on Fri Nov 01, 2013 9:44 pm, edited 2 times in total.
--John <www.jarchie.com/email>

jarchie
 
Posts: 595
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube GPS Mod

by GWDodd on Thu Aug 01, 2013 2:32 pm

This is brilliant but I feel bad that you've spent a lot of time helping me out with all of this. I'm going to download/install the programs you've recommended and start looking at your firmware. Thanks so much! After reviewing your instructions, I'm still unsure about compiling but I think when I get that far after working with the files I will see more clearly what it's about. I have experience with Suse Linux and less experience with Solaris but I'm sure I can handle the basics.
I'm guessing if I only need the GPS Timekeeping macro, it should fit on the Atmega168. But I'm still waiting on the target board and USBtinyISP anyway so I have time to fool around with the programs and your firmware.
Thanks to everybody and especially you, John for all the great help and tips!
And with sincere best regards for a safe summer,
Greg
GWDodd
 
Posts: 12
Joined: Fri Jul 26, 2013 1:56 am

Re: Ice Tube GPS Mod

by jarchie on Thu Aug 01, 2013 5:30 pm

This is brilliant but I feel bad that you've spent a lot of time helping me out with all of this.

Don't feel too bad. I am hoping that others will also find this thread useful. That's why I spent a bit more time on my replies than if I were emailing you personally.


After reviewing your instructions, I'm still unsure about compiling but I think when I get that far after working with the files I will see more clearly what it's about.

I agree; you'll figure it out. I think that if you follow my last post step-by-step, things will become more clear as you do them. But the compiling step is essentially just typing "make" and pressing return. To understand precisely what the Makefile and compiler are doing behind the scenes, you'll need to learn Makefile syntax and C programming...


I have experience with Suse Linux and less experience with Solaris but I'm sure I can handle the basics.

That experience will serve you well when using Cygwin. :-)


I'm guessing if I only need the GPS Timekeeping macro, it should fit on the Atmega168.

Most of the features of xmas-icetube cannot be disabled via macros, so the firmware is still to large for the ATmega168V. But your AVR development board should come with an ATmega328P for you to play with. :-)

Once you are familiar with compilation, you could use the ATmega168V chips you ordered to try other alternative firmwares. Most are designed for the ATmega168V.


Thanks to everybody and especially you, John for all the great help and tips!

You're welcome! Good luck and I hope you'll let us know how things work out.
--John <www.jarchie.com/email>

jarchie
 
Posts: 595
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube GPS Mod

by GWDodd on Fri Aug 02, 2013 3:18 pm

Hey John--I hope you are well and ready for the weekend!
So I've installed Notepad++ (pretty nifty tool) and also Cygwin and have looked over your instructions and tried to follow. I now understand the Make command and what it does. I thought I had to feed more info for the Make command to actually do something. Instead it seems to know what to look for in the directory it's in and compiles whatever it finds to compile, creating whatever it needs to create in the same directory. After trying it a few times (more about this in a minute) I think I get it.

Question: Regarding uncommenting the "GPS_TIMEKEEPING", in the instructions you've provided in this post, you say by uncommenting (removing the forward slashes), it enables support for the ultimate gps module. But in your last post here you say most of the features cannot be disabled via macros. I'm confused about this. I'm guessing this has something to do with the particular file I'm uncommenting in but I'm hoping you can shed some light on this for me.

Next...uhhhhh....situation: When running the Make command, I get "make: avr-gcc: Command not found". I've installed the Perl package and Devel package with no luck. I've searched thru the packages available on the Cygwin website and I find some AVR and I find some GCC but I don't find them together anywhere. I've checked the internet using a simple search thru a popular search engine but I don't find anything helpful related Cygwin. I would rather not install every single available package so I'm hoping you might know something more about this. If not, I'll continue checking (I will anyway). I'm guessing there's probably an easy fix for this somewhere.

Thanks in advance and I look forward to your reply (he writes hopefully!)

Greg
GWDodd
 
Posts: 12
Joined: Fri Jul 26, 2013 1:56 am

Re: Ice Tube GPS Mod

by jarchie on Fri Aug 02, 2013 4:09 pm

Instead it seems to know what to look for in the directory it's in and compiles whatever it finds to compile, creating whatever it needs to create in the same directory. After trying it a few times (more about this in a minute) I think I get it.

Yes, the make command follows rules written in the Makefile, which is how it knows what to do.


Regarding uncommenting the "GPS_TIMEKEEPING", in the instructions you've provided in this post, you say by uncommenting (removing the forward slashes), it enables support for the ultimate gps module. But in your last post here you say most of the features cannot be disabled via macros. I'm confused about this. I'm guessing this has something to do with the particular file I'm uncommenting in but I'm hoping you can shed some light on this for me.

I apologize for my lack of clarity. All of the features listed in config.h can be enabled and disabled by commenting or uncommenting the relevant macros.

But xmas-icetube has many features not mentioned in configh.h, including automatic daylight saving time adjustment, multiple alarm sounds, and extended backup battery life. See the README for a comprehensive list. Most of these features are not listed in config.h and cannot be disabled.


When running the Make command, I get "make: avr-gcc: Command not found".

The avr-gcc command should invoke the AVR compiler. This should have come with WinAVR. Did you install that?
--John <www.jarchie.com/email>

jarchie
 
Posts: 595
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Please be positive and constructive with your questions and comments.