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 » How to program your nerd kits using a mac for beginners

November 30, 2011
by bluestang
bluestang's Avatar

I started this thread for the Mac owners out there that are beginners like me to programming and running terminal. I have had to search thru several forums to find the info I needed and although I am very grateful for this I thought I would just put the basic set of instructions in this thread so others can have it all in one thread.

First Open applications folder / utilites folder / terminal. And it should look like this.

Last login: Wed Nov 30 14:40:14 on ttys000 imac-2:~ drake$

This will list login time on the first line and then your computers name followed by a $ sign.

Second Type in “avr-gcc-select 4” then it should look like this

imac-2:~ drake$ avr-gcc-select 4 Current default compiler: gcc 4 imac-2:~ drake$

Third You need to plug in your usb cable and turn the switch up and plug in the battery so you will see two lines through the lcd and you know that it is ready to accept a program. Once you have done this then go back to your terminal and type in. “ls /dev” This will list all your devices and you will need to look down the list for “cu.PL2303-0000####” The last four numbers will depend on what usb port that you
have plugged it in on.

It should look like this. imac-2:~ Drake$ ls /dev auditpipe ptyt9 ttyr2 autofs ptyta ttyr3 autofs_control ptytb ttyr4 autofs_nowait ptytc ttyr5 bpf0 ptytd ttyr6 bpf1 ptyte ttyr7 bpf2 ptytf ttyr8 bpf3 ptyu0 ttyr9 console ptyu1 ttyra cu.Bluetooth-Modem ptyu2 ttyrb cu.Bluetooth-PDA-Sync ptyu3 ttyrc cu.PL2303-00001004 ptyu4 ttyrd disk0 ptyu5 ttyre disk0s1 ptyu6 ttyrf disk0s2 ptyu7 ttys0 disk0s3 ptyu8 ttys000 dtrace ptyu9 ttys001 dtracehelper ptyua ttys1 fbt ptyub ttys2 fd ptyuc ttys3

Fourth Then when you find the cu.PL2303-0000#### you need to copy this and then open up your nerdkits code folder. When I downloaded this form the website I put it on a folder on the desktop. So for me it was desktop/nerdkits/code/initialload/makefile. You need to open the makefile in a text program so that you can read what is written their and then modify it for your usb destination. It should look like this when you open it.

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/ttyUSB0 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

Fifth Once you have it open you will need to change one line. This is the “AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P /dev/ttyUSB0” And this will need to be changed to “AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P /dev/cu.PL2303-0000####”

Remember that the last four #### will actually be numbers like 1004 or whatever your computer says that you plugged in the usb cable. If you change locations of the usb cable you will have to repeat steps by finding the new port location.

Sixth You will need to go back to the terminal and type in “cd desktopnerdkitscodeinitialload” Or you can type in seperatly “cd desktop” Then “nerkit” hit enter Then “code” hit enter Then “initiaload” It should look like this

imac-2:desktop Drake$ cd nerdkit imac-2:nerdkit Drake$ cd code imac-2:code Drake$ cd initialload imac-2:initialload Drake$

Seventh Then you are in the folder you want to be in and you can type in “make” and the program should compile and load your nerd kit’s chip. This should look like this

imac-2:initialload Drake$ make make -C ../libnerdkits avr-gcc -g -Os -Wall -mmcu=atmega168 -o delay.o -c delay.c avr-gcc -g -Os -Wall -mmcu=atmega168 -o lcd.o -c lcd.c avr-gcc -g -Os -Wall -mmcu=atmega168 -o uart.o -c uart.c avr-gcc -g -Os -Wall -mmcu=atmega168 -Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm -o initialload.o initialload.c ../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o avr-objcopy -j .text -O ihex initialload.o initialload.hex avrdude -c avr109 -p m168 -b 115200 -P /dev/cu.PL2303-00001004 -U flash:w:initialload.hex:a

Connecting to programmer: . Found programmer: Id = "FDL v02"; type = S Software Version = 0.2; No Hardware Version given. Programmer supports auto addr increment. Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices: Device code: 0x35

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9406 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 "initialload.hex" avrdude: input file initialload.hex auto detected as Intel Hex avrdude: writing flash (7838 bytes):

Writing | ################################################## | 100% 8.34s

avrdude: 7838 bytes of flash written avrdude: verifying flash memory against initialload.hex: avrdude: load data flash data from input file initialload.hex: avrdude: input file initialload.hex auto detected as Intel Hex avrdude: input file initialload.hex contains 7838 bytes avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.99s

avrdude: verifying ... avrdude: 7838 bytes of flash verified

avrdude done. Thank you.

imac-2:initialload Drake$

I hope this helps everyone out with compiling your first code form the nerdkits and programming your own chip using a Mac.

Jim

December 01, 2011
by Ralphxyz
Ralphxyz's Avatar

Thanks Jim, wish I had this when I started :-)

You should add this to the Nerdkit Community Library of course the newest Mac OS has changed the USB port naming but still it would be useful.

Ralph

December 01, 2011
by havok310
havok310's Avatar

Thanks so much Jim, this just resolved all my problems. Regards,

Steve

December 02, 2011
by bluestang
bluestang's Avatar

Thanks Ralph I actually used a lot of your answers myself when i originally got this kit and learned how to do this so i am glad you can appreciate what i did because in reality it was due to a lot of your answers that i was able to learn this myself. Thanks for all the community of this forum as it is a great help while i learn how to code in C and build some pretty neat projects.

And Steve i am glad this helped you out I personally love my mac and i have removed the windows machines from my house because i love working with the mac so much lol. I did do this on a imac with 10.6 snow leopard running

December 02, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi bluestang,

Thanks for writing this up. I'm sure lots of people will find it very helpful. If you want, you could try writing up a Library Article about it. It would be in a much more permanent place for people to find it rather than having to trudge through forum posts.

Humberto

December 02, 2011
by bluestang
bluestang's Avatar

I will work on it this weekend and add it there.. I will also clean it up and use screen shots so its easier to read on the eyes. Thanks alot Humberto and I am very happy with this Kit i choose it because i have a mac and wanted to use it and also because i didn't want to learn another kits proprietary code and i felt C would be a gateway to C++ and Java and since i didn't go to collage for this i figured this is the best way to understanding the software side of things. I am an engineering electronics technician at Vermeer in Pella Iowa and I work on our remotes and controllers hardware side of things for my daily job .. my hope is with this i can learn the software side of things and understand what the software engineers and embedded hardware engineers go thru on their daily basis.

Jim

Post a Reply

Please log in to post a reply.

Did you know that you can impress a loved one with a digitally-controlled Valentine's Day Card with randomly twinkling LEDs? Learn more...