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 » First Program initilload

November 26, 2011
by sazD
sazD's Avatar

The instructions on how to load the first program seem to have a huge gap on how to do this. I finally got the usb cable installed (I cannot get it to work on com1), it puts it on com7 in the device manager. The instructions say to simply type "make" in DOS and everything gets done. Huh????. It does not say where to extract the files, and what directory. I can't get my usb cable to work right, how do you manually set it to com1? And how do you set the DOS shell to "com1"? The program has bugs that don't let it work past com5??. I know it seems so simple for everybody, but this is really hard. I guess I need to be a MIT grad to program my first code. The DOS shell can be very hard to implement because you don't know what is going on in the shell. If I can get just 1 program to load 1 time, then I wont feel so dumb for spending $$$ on a chip I cant program.

November 26, 2011
by Rick_S
Rick_S's Avatar

First, calm down, step back and read. The Nerdkit guide does a pretty good job of explaining how to do things. Other than the creators of this site, I don't know of anyone else here with a degree from MIT. I don't know about your system, but on mine I use COM12 all the time for my adapter. There is no reason I know of to change your default setup to COM1.

I assume you are running windows. Once you have installed WinAVR, you can unzip the code folder wherever you want. Just keep it's structure intact. If everything installed correctly, you should be able to shell to the command prompt, change to the folder for the program you want to work with, edit your makefie to use the com port you have, then type make.

Research the forum (there is a search button at the top) You will find all kinds of help for this and many other problems you may come across. Also, use the library (link at the bottom of the page) you'll find a lot of other info there as well.

Rick

November 27, 2011
by havok310
havok310's Avatar

Hi, I am using a Mac and when I navigate to the folder with the initialload.c and makefile via terminal, list the files, and type "make" like the instructions said, i get the following error:

    steven-chowdhurys-macbook-pro-15:~ Steven$ make
    make -C ../libnerdkits
    make: *** ../libnerdkits: No such file or directory.  Stop.
    make: *** [initialload.hex] Error 2

Any thoughts as to why this might be happening? I already checked that I typed the usb port number correctly, rebooted the nerdkit while it was plugged in, and played around with alot of other things like even directly clicking the makefile itself.

November 27, 2011
by LawnDart
LawnDart's Avatar

For the Mac user - I have OSX 10.7.2, I had to download the latest PL-2303 usb/serial here: http://www.prolific.com.tw/eng/downloads.asp?ID=31 and installed.

Then I downloaded all the NerdKit code (including all sub directories) to a folder.

Using the terminal in the /dev directory the driver will be listed as tty.usbserial <--- this is what needs to be altered in the makefile. Change "/dev/ttyUSB0" to "/dev/tty.usbserial"

Using the terminal, go to your code directory .../.../initialload type "make"

Should work if all is hooked up and wired properly. I have found you may need to run "make" a couple of times or un-plug and re-plug the USB connector to get proper communication with the programmer.

BOL, LawnDart

November 28, 2011
by havok310
havok310's Avatar

@LawnDart I did what you said and everything installed properly, but now when I type "make" i a get this

make: *** No targets specified and no makefile found.  Stop.
November 28, 2011
by missle3944
missle3944's Avatar

havok310,

Make sure you are navigating to your Code folder. It looks like you are just in your Harddrive. You need to have a makefile with the code in a folder and then that folder in the Code folder.

-Dan

November 28, 2011
by LawnDart
LawnDart's Avatar

Havok, Here is my Makefile -

GCCFLAGS=-g -Os -Wall -mmcu=atmega168 
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P /dev/tty.usbserial
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    initialload-upload

initialload.hex:    initialload.c
    make -C ../libnerdkits
    avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o initialload.o initialload.c ${LINKOBJECTS}
    avr-objcopy -j .text -O ihex initialload.o initialload.hex

initialload.ass:    initialload.hex
    avr-objdump -S -d initialload.o > initialload.ass

initialload-upload: initialload.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:initialload.hex:a

As missle3944 mentioned, you will need to be in the same directory as your code and make file for all of this to work.

Cheers, LawnDart

November 28, 2011
by sazD
sazD's Avatar

Yes, that was my mistake as well (zip file extraction). I did not specifically "extract" the zip file, but opened and drop & dragged the file content. Also the com port setting were not correct (115200 bps, 8,n,1,none, no hdw control). I also downloaded winzip and used that as well. -Dan is on the money w/ the prob. (you are not in the correct folder where the code & make file is). Good luck.

December 01, 2011
by havok310
havok310's Avatar

Ok I tried keeping the "code" folder in the same folder I unzipped it to (Desktop), but I get the same problem. This is exactly what I am typing in terminal:

1) I list the files in the initialload folder:

steven-chowdhurys-macbook-pro-15:~ Steven$ ls /Users/Steven/Desktop/Code/initialload

2) then this comes up:

Makefile    initialload.c

3) then I type "make":

steven-chowdhurys-macbook-pro-15:~ Steven$ make

4) then it tells me this

make: *** No targets specified and no makefile found.  Stop.

I'm thinking for some reason I'm either navigating to the folder the wrong way or putting "make" in the wrong section? And if terminal is right and I'm not specifying the files, how exactly do I specify them? Thanks for all your help so far though I really appreciate it.

December 01, 2011
by sazD
sazD's Avatar

Hmm.. I don't know anything about mac's.....so i will try to help.... First you need to extract the code to the desktop, not just drag the files that are zipped open, but "extract" them. If you did it right, you should see a folder (what ever the folder you named to extract them) with a folder called "code" inside it. Double click that folder and you should see about ten sub folders (if you don't something is not right). If you open the folder called "initialload" you will see 2 files (1 called initilload.c and 1 called "make"). If you don't have that, something is wrong. Also before you open a dos dialog box and navigate to that folder, be sure to install "AVRMacPackfor MacOS_X" and install. Then in the dos dialog box in the initialload folder type "make". That will get you a lot closer than where you are now. Sorry, again Im not a Mac guy, so this is the best help I can offer, sorry :( .. Good luck Steven. -sazD

December 01, 2011
by havok310
havok310's Avatar

@sazD Thanks for all your help and I just got the issue resolved :). Instead of "ls .../initialload" I used "cd .../initialload" and then typed "make". Worked perfect! Also thanks to everyone who tried to help me I really appreciate the support!

Post a Reply

Please log in to post a reply.

Did you know that you can control 120 LEDs with just 17 microcontroller pins? Learn more...