Re: Another Ice Tube Clock Firmware for the Holidays

by jarchie on Sun Feb 24, 2013 10:46 pm

--updated post--

The external oscillator on the Arduino Uno R3 should work just fine. Is this project the only reason you're purchasing an Arduino? If so, I am willing to mail you a chip with Ice-Tube-Clock-compatible fuse settings. jarchieREPjarchie.com where REP is the at symbol.

By the way, congrats on fixing the dim-digit issue. Well done!
--John <www.jarchie.com/email>
jarchie
 
Posts: 408
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Another Ice Tube Clock Firmware for the Holidays

by pgeremia on Sun Feb 24, 2013 10:53 pm

Wow thank you! Actually I have some other projects in mind so I do want to purchase the R3. I will update when I get the unit, program the chip and get it working. Thanks Again!

jarchie wrote:--updated post--

The external oscillator on the Arduino Uno R3 should work just fine. Is this project the only reason you're purchasing an Arduino? If so, I am willing to mail you a chip with Ice-Tube-Clock-compatible fuse settings. jarchieREPjarchie.com where REP is the at symbol.

By the way, congrats on fixing the dim-digit issue. Well done!
pgeremia
 
Posts: 10
Joined: Sun Jan 06, 2013 9:45 pm

Re: Another Ice Tube Clock Firmware for the Holidays

by pgeremia on Fri Mar 01, 2013 7:03 pm

I wanted to let you know that I got my Arduino, programmed the chip with your firmware and everything works great!!!!

Thanks Again!!!

-Pete

jarchie wrote:I have reproduced your error and am wrong about the Adafruit chip working out-of-the-box. I apologize for the inconvenience.

To reproduce the error, I removed the ATmega328p from my GPS-enabled clock, placed it in an Adafruit DC Boarduino, and burned the Arduino bootloader. When I inserted the chip back in my clock, programming failed exactly as you describe.

The problem was that the Arduino uses an external 16 MHz oscillator, so an ATmega328p with an Arduino bootloader has the external oscillator fuse configured. Since the clock does not provide a high-frequency external oscillator, the chip will not function in the clock--not even to be programmed.

To fix the situation, I installed the ATmega328p in my AVR development board (which provides power and an ISP header), wired in a 16 MHz external oscillator, and programmed the new fuse settings using the xmas-icetube's "make install-fuse". (A Boarduino or Arduino board also would have worked, but I wanted to make sure the problem really was the external oscillator.) With the ATmega328p fuses configured to use the internal 8 MHz oscillator, I put the chip back in my clock and was able to program it normally with a "make install."

Do you have access to an Arduino board or something with an ISP header and external crystal oscillator?
pgeremia
 
Posts: 10
Joined: Sun Jan 06, 2013 9:45 pm

Re: Another Ice Tube Clock Firmware for the Holidays

by jarchie on Fri Mar 01, 2013 9:55 pm

Congratulations, Pete! I'm glad everything is working.

By the way, I've updated the xmas-icetube README to include a warning about chips configured with an Arduino bootloader along with instructions on how to reconfigure those chips.
--John <www.jarchie.com/email>
jarchie
 
Posts: 408
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Another Ice Tube Clock Firmware for the Holidays

by BradK-adaf on Sat May 25, 2013 2:03 pm

This is a very basic general question about compiling firmware packages for the ICE Tube Clock.
Note - I am new at this.

I am running Windows 7 Professional (32-Bit)
I have loaded "WinAVR20100110" onto the system.

At first, when I was attempting to run the "make" command, I was having issues with the line associated with "./optgen.pl"
After some research I found out that I needed to have "Perl" loaded on the system - :) Hey - I said am new at this.
So I loaded "ActivePerl 5.16.3 Build 1603" and this resolved this problem.

Now when I run the "make" - I am getting this output -
***********************************************************************************************************************************************
C:\Tools\Code\Clock\xmas-icetube-master-1>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
-DTIME_DEFAULT_SECOND=4 -DTIME_DEFAULT_MINUTE=47 -DTIME_DEFAULT_HOUR=11 -DTIME_DEFAULT_MDAY=25 -DTIME_DEFAULT_MONTH=5 -DTIME_DEFAULT_YEAR=13 -DTI
ME_DEFAULT_WDAY=6 -DTIME_DEFAULT_YDAY=144 -DTIME_DEFAULT_DST=1
./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 m
ode.o usart.o gps.o
avr-gcc: time.o: No such file or directory
make: *** [icetube.elf] Error 1

C:\Tools\Code\Clock\xmas-icetube-master-1>
***********************************************************************************************************************************************


The new problem is the creation of the "ice tube.elf"
Since time.o is missing - this fails.

So going back to Perl - it appears that the creation of time.o is not working.

If I run the following command:
optgen.pl time | xargs avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000 -o time.o time.c

I get the following error:
***********************************************************************************************************************************************
Usage: avropt.pl [time|fuse|lock]
time.c:28: error: 'TIME_DEFAULT_YEAR' undeclared here (not in a function)
time.c:29: error: 'TIME_DEFAULT_MONTH' undeclared here (not in a function)
time.c:30: error: 'TIME_DEFAULT_MDAY' undeclared here (not in a function)
time.c:31: error: 'TIME_DEFAULT_HOUR' undeclared here (not in a function)
time.c:32: error: 'TIME_DEFAULT_MINUTE' undeclared here (not in a function)
time.c:33: error: 'TIME_DEFAULT_SECOND' undeclared here (not in a function)
***********************************************************************************************************************************************

If I run the following command:
avr-gcc -c -I. -mmcu=atmega328p -std=gnu99 -Os -Wall -DF_CPU=8000000 -o time.o time.c -DTIME_DEFAULT_SECOND=4 -DTIME_DEFAULT_MINUTE=47 -DTIME_DEFAULT_HOUR=11 -DTIME_DEFAULT_MDAY=25 -DTIME_DEFAULT_MONTH=5 -DTIME_DEFAULT_YEAR=13 -DTI

Then the time.o file is created.

So if I run "make" again

***********************************************************************************************************************************************
C:\Tools\Code\Clock\xmas-icetube-master-1>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
-DTIME_DEFAULT_SECOND=24 -DTIME_DEFAULT_MINUTE=54 -DTIME_DEFAULT_HOUR=14 -DTIME_DEFAULT_MDAY=25 -DTIME_DEFAULT_MONTH=5 -DTIME_DEFAULT_YEAR=13 -D
IME_DEFAULT_WDAY=6 -DTIME_DEFAULT_YDAY=144 -DTIME_DEFAULT_DST=1
./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
ode.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 22564 0
.bss 106 8388872
.eeprom 57 8454144
.fuse 3 8519680
.lock 1 8585216
Total 22739

***********************************************************************************************************************************************


I have done searching here and on Google but I am not getting anywhere.

Two questions -
1) I am not looking to write code right now - I just want to compile existing code and get an understanding on how things work. Any suggestions for Books or Web Sites to get up to speed on this topic.
2) Any suggestion on what my problem is here or how to proceed with troubleshooting it. Considering other people use this code - I don't believe it's the code but something that I am doing wrong on my system.

Thanks for suggestions and guidance you can provide.
Brad
BradK-adaf
 
Posts: 9
Joined: Thu May 02, 2013 11:49 am

Re: Another Ice Tube Clock Firmware for the Holidays

by jarchie on Sun May 26, 2013 2:06 am

Hi Brad,

Any suggestions for Books or Web Sites to get up to speed on this topic.


The ATMEGA328P datasheet was invaluable to me while writing the code. For learning the C language, I highly recommend K&R, and the avr-libc documentation does an excellent job of describing avr-gcc-specific implementation details.

Any suggestion on what my problem is here or how to proceed with troubleshooting it. Considering other people use this code - I don't believe it's the code but something that I am doing wrong on my system.


I don't think you're doing anything wrong, but it looks like xargs isn't doing it's job, which is to convert the output of optgen.pl to avr-gcc command line arguments. On my Windows system, I use Cygwin and Cygwin's Perl package which provide working versions of xargs and Perl.

Since you were able to build time.o successfully, you might remove the "ALWAYS" dependency from the time.o object in the Makefile, which will prevent the Makefile from always trying to rebuild time.o:

Code: Select all | TOGGLE FULL SIZE
# time.o must always be remade to make the current
# system time the default clock time
time.o: time.c optgen.pl
   ./optgen.pl time | xargs $(AVRCPP) -c $(AVRCPPFLAGS) -o $@ $<
   ./optgen.pl time | xargs $(AVRCPP) -MM $(AVRCPPFLAGS) $< > $*.d


A cleaner solution might be to use the backtick notation to get arguments generated by optgen.pl, thus eliminating the need for xargs. To try that, edit the time.o target to read

Code: Select all | TOGGLE FULL SIZE
# time.o must always be remade to make the current
# system time the default clock time
time.o: time.c optgen.pl ALWAYS
   $(AVRCPP) -c $(AVRCPPFLAGS) -o $@ $< `./optgen.pl time`
   $(AVRCPP) -MM $(AVRCPPFLAGS) $< `./optgen.pl time` > $*.d


Good luck and happy hacking!

Cheers,
John
--John <www.jarchie.com/email>
jarchie
 
Posts: 408
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Another Ice Tube Clock Firmware for the Holidays

by motocoder on Fri Jan 17, 2014 7:08 am

This firmware is really cool. I highly recommend anyone with an ATmega328p lying around to program it with this firmware and use it instead of the one that comes with the kit.
motocoder
 
Posts: 15
Joined: Mon Jul 22, 2013 11:49 pm

Re: Another Ice Tube Clock Firmware for the Holidays

by Daave on Wed Mar 26, 2014 5:20 pm

I am having issues putting this firmware on my v1.1 Ice Tube Clock. I picked up a ATMEGA328P-PU and used the "make install-fuse" command successfully with no issues at all on an Uno board. Then I plugged the USBtinyISP back into my Ice Tube Clock with the jumper removed, and the Ice Tube Clock powered on from the wall. No matter what I do (Yes the 6-pin cable is plugged in the correct way), I get the following error:

Code: Select all | TOGGLE FULL SIZE
avrdude.exe: initialization failed, rc=-1
             Double check connections and try again, or use -F to override
             this check.


avrdude.exe done.  Thank you.


I am using this version of the USBtinyISP.

Do you have any thoughts on what I could be doing incorrectly? The USBtinyISP seems to work properly since I have 0 issues with it when connecting to the Uno board. I'm running this on Windows 7 x64 with Cygwin (With Perl installed) & WinAVR.
Daave
 
Posts: 5
Joined: Wed Mar 26, 2014 5:02 pm

Re: Another Ice Tube Clock Firmware for the Holidays

by jarchie on Wed Mar 26, 2014 5:59 pm

Did you remove the display before programming with "make install-all"? Most people find that they cannot program the clock with the tube installed.

Alternatively, it should be possible to program the chip while installed in a development board like the Arduino Uno. Just move the chip back to the Uno and program it as you did before, except with the "make install-all" command instead of the "make install-fuse" command.
--John <www.jarchie.com/email>
jarchie
 
Posts: 408
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Another Ice Tube Clock Firmware for the Holidays

by Daave on Wed Mar 26, 2014 6:05 pm

Yeah, the tube was removed.

I was actually just able to get it working after reading a thread where someone had to change the -B value in the avrdude command. I changed line 45 in my makefile to:

Code: Select all | TOGGLE FULL SIZE
AVRDUDEOPT    ?= -B 25 -P usb -c $(AVRISP) -p $(AVRMCU)  # usbtiny & dragon_isp


By using a value of 25 for -B, everything "just worked"!!
Daave
 
Posts: 5
Joined: Wed Mar 26, 2014 5:02 pm

Re: Another Ice Tube Clock Firmware for the Holidays

by jarchie on Wed Mar 26, 2014 6:14 pm

I would not have guessed that speed was the issue, as the default Makefile settings seemed to work fairly well across platforms. Apparently the default settings weren't as robust as I thought!

I'll add an entry to the troubleshooting section of the firmware/README file in case other users run into the same problem. Thank you for letting me know!
--John <www.jarchie.com/email>
jarchie
 
Posts: 408
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Another Ice Tube Clock Firmware for the Holidays

by Daave on Wed Mar 26, 2014 6:17 pm

So I may have gotten excited a little too soon. While everything did flash properly & verify, my tube isn't lighting up when I plug it in.

I'm trying a different value for -B to see if that helps. I'll keep you posted...
Daave
 
Posts: 5
Joined: Wed Mar 26, 2014 5:02 pm

Re: Another Ice Tube Clock Firmware for the Holidays

by jarchie on Wed Mar 26, 2014 6:28 pm

Oh, yuck. If you get stuck, would you post the full output of the "make install-all" command when it seems to be working? That might help me figure out what's going on.
--John <www.jarchie.com/email>
jarchie
 
Posts: 408
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States

Re: Another Ice Tube Clock Firmware for the Holidays

by Daave on Wed Mar 26, 2014 6:35 pm

I wonder if I'm running into unrelated issues. The buttons definitely seem to work as I get the little noise from the speaker when I press "Set", which makes me think the firmware was properly flashed. It also verifies properly with make verify-all.

When I was running the default firmware, I replaced the default ZVP3306A MOSFET with a PN2907 + 1k resistor per this post. I also threw in a PDV-P8001-ND + 5.6k resistor for the auto-dimming mod.

Perhaps I should remove one of these mods and see if that makes a difference?
Daave
 
Posts: 5
Joined: Wed Mar 26, 2014 5:02 pm

Re: Another Ice Tube Clock Firmware for the Holidays

by jarchie on Wed Mar 26, 2014 6:50 pm

Daave wrote:I wonder if I'm running into unrelated issues.

That's possible. Are you in a bright room? It could be that the display is set to the dimmest setting, which is a bit dimmer than with the Adafruit firmware.

Alternatively, have you made any changes to config.h? Some options, like the to-spec hack, will cause the display to be nonfunctional without the corresponding hardware mod.

Daave wrote:I also threw in a PDV-P8001-ND + 5.6k resistor for the auto-dimming mod.

Are they installed as shown here?

Daave wrote:Perhaps I should remove one of these mods and see if that makes a difference?

Those mods shouldn't cause any issues. I think it's safe to leave them in place.
--John <www.jarchie.com/email>
jarchie
 
Posts: 408
Joined: Sun Jun 24, 2012 1:16 pm
Location: Santa Cruz, California, United States