NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Linux Compiled code doesn't work, Windows does

September 15, 2010
by bpenglase
bpenglase's Avatar

Ok, so I installed gcc, avr-libc, binutils using crossdev -t avr (basically making a cross-platform set of utils for AVR), then compiled avrdude. Detailed versions will be below. Basically when I load up the 'initialload.c', compile and load it on the NerdKit, all I get on the LCD is "Is Alive!" on the top line. Which in the code, should be on the fourth line, with three different lines above it.

However, taking the same .c file (from the zip in the downloads), with WinAVR in Windows 7 on my Tablet, then compiling and uploading, that works perfectly.

Any ideas why the Linux compiler seems to work half-way? I would think that if it didn't work right, it wouldn't work it all, but it seems to work part way.

More Details:
Host System:
Gentoo Linux ~AMD64
Linux Nereus 2.6.35-zen3-2+ #2 ZEN SMP Mon Sep 13 17:31:41 EDT 2010 x86_64 Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz GenuineIntel GNU/Linux

Versions:
cross-avr/binutils-2.20.1-r1
cross-avr/avr-libc-1.6.8
cross-avr/gcc-4.4.4-r1

I'm not sure what exact versions are on the Windows machine, but it's the latest download of WinAVR thats available.

If needed, I can provide the code and pictures of what it's doing, but I was just using the code from the downloads. And for display, again when compiled and uploaded from Linux, top line displays what should be the last line "Is Alive!", but on Windows, the same code displays as expected.

September 15, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi bpenglase,

Welcome to the forums!

Two other customers reported a similar issue in this forum thread. Their issues appear to have been resolved by editing the libnerdkits/Makefile and changing the optimization level -Os to -O0 (that's a letter O followed by a zero). After saving that edit, "rm *.o" in the libnerdkits directory. Then, run "make" again to force recompilation.

In any case, this might be Gentoo-specific, and of course changing optimization levels really should not change the result of the code, but in this case it apparently does.

Please give this a try and let me know if it works!

Mike

September 15, 2010
by bpenglase
bpenglase's Avatar

Well look at that, I knew I should have dug into the forums a bit more to see if it was covered. Sure enough, lowering the optimizations did the trick.

Thanks for the quick response, and sorry for the noise of bringing up an old issue thats been resolved :)

Off I go to finish working through the guide!

Post a Reply

Please log in to post a reply.

Did you know that you can connect digital calipers to a microcontroller? Learn more...