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.

Support Forum » is alive!

January 09, 2010
by Mike
Mike's Avatar

Displays on the first line centered.

But the rest of the message does not display.

Built the kit without a hitch, it seemed. The original message displayed properly and it scrolled, etc..

Ran make, flashed and is alive is all I get.

I found parts of related questions that weren't quite the same in other threads, but no answer that has solved the problem so far.

Thanks for any help.

January 09, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hey Mike,

Sounds like a possible compiler / library issue. What operating system and version are you running? If on Mac OS X, did you run "avr-gcc-select 4"? Let us know exactly what you installed.

Mike

January 10, 2010
by Mike
Mike's Avatar

2.6.23-gentoo-r3

Provided by uname -r.

Need more?

January 10, 2010
by Mike
Mike's Avatar

uname -a Linux gosensgo 2.6.23-gentoo-r3 #1 SMP Wed Dec 26 13:42:38 EST 2007 i686 Intel(R) Pentium(R) 4 CPU 1.80GHz GenuineIntel GNU/Linux

January 10, 2010
by Mike
Mike's Avatar

I used crossdev to install avr-gcc4.4.2 and avrlibc 1.6.2.

Sorry it's across 3 posts.

January 10, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi Mike,

OK, unfortunately I don't have any particular knowledge about problems with those versions. One quick thing to try is to disable compiler optimizations. In the Makefiles (both in the initialload and libnerdkits directories), look at the GCCFLAGS line and change the "-Os" flag to "-O0" (letter O, number 0). Then, remove any .o or .hex files, and finally run "make" again.

See this thread where another Linux user found that changing the optimization flags in the "libnerdkits" directory to "-O0" made it work. (Of course, compiler optimizations should not have an effect on end behavior, but that's a story for another day...)

Please give this a try and let us know if it works.

Mike

January 11, 2010
by Mike
Mike's Avatar

Here is the file as I read it in Kate. (I don't know why the text is so large(?))

// initialload.c // for NerdKits with ATmega168 // mrobbins@mit.edu

define F_CPU 14745600

include <stdio.h>

include <avr/io.h>

include <avr/interrupt.h>

include <avr/pgmspace.h>

include <inttypes.h>

include "../libnerdkits/delay.h"

include "../libnerdkits/lcd.h"

// PIN DEFINITIONS: // // PC4 -- LED anode

int main() { // LED as output DDRC |= (1<<PC4);

// turn on LED PORTC |= (1<<PC4);

// fire up the LCD lcd_init(); lcd_home();

// print message to screen // 20 columns wide: // 01234567890123456789 lcd_line_one(); lcd_write_string(PSTR(" Congratulations! ")); lcd_line_two(); lcd_write_string(PSTR("****")); lcd_line_three(); lcd_write_string(PSTR(" Your USB NerdKit ")); lcd_line_four(); lcd_write_string(PSTR(" is alive! "));

// turn off that LED PORTC &= ~(1<<PC4);

// busy loop while(1) { // do nothing }

return 0; }

Now, I know squat, but my son, who is the expert around here, is back at work an hour away. I sent him an email to this link.

How is the above code putting the data through the other display lines?

January 14, 2010
by treymd
treymd's Avatar

Ran into the same issue...

The -O0 works just make sure you read the above post closely, unlike what I did! The flag must be changed both in the current directory, and the libnerdkits directory, or you will continue getting the same results.

A suggestion: could use a "make clean" directive in the makefiles, though rm *.o works just as good!

January 14, 2010
by Mike
Mike's Avatar

Good catch, I had not changed that. Thanks for noticing.

However, it still doesn't work.

January 14, 2010
by Mike
Mike's Avatar

Might as well go all out and show just how little i know.

Here's the error message from Kate:

initialload # gcc initialload.c -o initialload initialload.c:9:20: error: avr/io.h: No such file or directory initialload.c:10:27: error: avr/interrupt.h: No such file or directory initialload.c:11:26: error: avr/pgmspace.h: No such file or directory initialload.c: In function 'main': initialload.c:23: error: 'DDRC' undeclared (first use in this function) initialload.c:23: error: (Each undeclared identifier is reported only once initialload.c:23: error: for each function it appears in.) initialload.c:23: error: 'PC4' undeclared (first use in this function) initialload.c:26: error: 'PORTC' undeclared (first use in this function) initialload.c:36: warning: passing argument 1 of 'lcd_write_string' makes pointer from integer without a cast initialload.c:38: warning: passing argument 1 of 'lcd_write_string' makes pointer from integer without a cast initialload.c:40: warning: passing argument 1 of 'lcd_write_string' makes pointer from integer without a cast initialload.c:42: warning: passing argument 1 of 'lcd_write_string' makes pointer from integer without a cast

January 14, 2010
by treymd
treymd's Avatar

It looks like your toolchain is not complete, did you install all the packages the guide asked for? I believe there were 3.

I'm guessing maybe avr-libc is not installed maybe?

you shouldn't be getting those errors about not finding *.h files if all is set up right.

January 14, 2010
by Mike
Mike's Avatar

Sounds like I need to check that out more closely.

I'll do that and get back.

Thanks again.

January 14, 2010
by Mike
Mike's Avatar

Ok after running make clean in both directories I get:

mike@gosensgo ~/Code/initialload $ make clean initialload make: *** No rule to make target `clean'. Stop.

The avr-libs is in ./usr/portage/dev-embedded and in /usr/portage/cross-avr.

Is that where it's supposed to be?

January 14, 2010
by Mike
Mike's Avatar

Ok, it works!

The only problem I had was that I had to login to root as it gave a permission error.

Otherwise 100%!

January 14, 2010
by Mike
Mike's Avatar

What I did was erase .o and .hex in both directories and after logging into root, it ran.

I also had a low battery, but I don't think that had anything to do with it.

Think I'll rig up a connector for the power supply.

Thanks for everyone's help.

I'm sure I'll ask some more.

January 15, 2010
by Mike
Mike's Avatar

Oh yeah, I also changed -Os to O0 in those files.

February 25, 2010
by Hexorg
Hexorg's Avatar

Hey everyone, I just got my kit today! XD I run gentoo with 2.6.31-r6 custom built kernel.

Had some trouble setting up the toolchain, but that's offtop anyway.

I'm not too good at programing, but i've played with the toolchain a bit, and it seems like applying -Os flags to tempsensor.c is OK, as long as lcd.c are compiled with -O0 flag.

If anyone is wondering about what this flags are: in short - they are optimization flags(actually, they are "pseudo" flags - they just turn a bunch of other flags), -O0 being the lowest optimization level (no optimization), -O2 being the highest. You can specify -O5, but gcc is written so that anything higher then -O2 is treated just like -O2. -Os flag optimises for size. If you want to learn more - read http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

Optimization flags can be an A** when programming for hardware.

April 13, 2010
by activechaos128
activechaos128's Avatar

Hey guys I need some help. I'm completely new at this so hopefully my problems aren't to hard to solve. I assembled the kit, not a bother. however I couldn't get the usb driver to work so I downloaded one that i found on google @ http://www.serialgear.com/USB-Serial-adapter-drivers-windows-mac-linux.cfm and my computer was able to recognize it. I still changed the port from COM11 to COM2 just in case that could still be a problem. I've downloaded the source code and programmers notepad. I'm running windows 7 on a 64 bit system. I think I'm fine up to step 10b when it says to open makefile in a text editor. after that I'm lost.

April 13, 2010
by bretm
bretm's Avatar

If find that you need to use -O0 to get it to work right, it's a strong clue that you might be coding something wrong. The #1 culprit in my experience is sharing variables between interrupt handlers and the main program loop but not declaring them as volatile. Example:

uint8_t count;

ISR(INT0_vect)
{
   count++;
}

int main()
{
    count = 0;
    initialize(); // set up interrupts, etc.
    while (1)
    {
        if (count == 10)
        {
            // do something special
            count = 0;
        }
    }
    return 0;
}

In this case, the compiler looks at main(), sees that count is set to 0, also sees that count never changes, so it completely omits the code for the "if" statement because count will never equal 10. This is a sensible optimization if the code isn't being interrupted. It is being interrupted but the compiler can't know that.

However, if you declare count as volatile by doing

volatile uint8_t count;

then the compiler realizes that count might be modified by other code or hardware while main() is running, and it won't optimize the "if" statement away.

April 13, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

activechaos128. Could you describe the issue you are experiencing in more detail. A screenshot of the command line error messages you are seeing, would really help us in figuring out what is wrong so we can get you on your way.

As for the driver, did you happen to try this Windows 7 Driver for PL2303.

Humberto

September 25, 2012
by kimondo
kimondo's Avatar

Hi - just came across this thread as I ran into the same issue with the Raspberry pi - changing Os to O0 and deleting the .hex and .o files from the directories work fine. Other than that works straight out of the box - the Pi makes a nice ($35) add on to the nerdkit!

Post a Reply

Please log in to post a reply.

Did you know that you can build a circuit to convert the "dit" and "dah" of Morse code back into letters automatically? Learn more...