hello
I solved the missing separator error and now I got a new one!
I can’t link source files! when I compile and program a project from the orangutan lib, every thing works just fine, when I try to program my own code, I get this error:
root@arbelmichal-desktop:/home/arbelmichal/Desktop/Documents/avrstudio/orangutan/default# make
/usr/bin/avr-gcc -g -Os -Wall -mcall-prologues -mmcu=atmega168 -c -o orangutan.o orangutan.c
orangutan.c:4:20: error: device.h: No such file or directory
In file included from orangutan.c:9:
/usr/lib/gcc/avr/4.2.1/../../../../avr/include/util/delay.h:136:3: warning: #warning "F_CPU not defined for <util/delay.h>"
orangutan.c:22:18: error: lcd.h: No such file or directory
orangutan.c:40:20: error: buzzer.h: No such file or directory
orangutan.c: In function ‘main’:
orangutan.c:69: warning: implicit declaration of function ‘lcd_init’
orangutan.c:76: warning: implicit declaration of function ‘lcd_gotoxy’
orangutan.c:77: warning: implicit declaration of function ‘lcd_string’
make: *** [orangutan.o] Error 1
this is my code:
#define F_CPU 8000000UL // Orangutan frequency (8MHz)
#include "device.h"
#include <avr/io.h>
// Include for using delay routines
#include <util/delay.h>
// Now include the subsystems you want to use:
#include "lcd.h"
#include "buzzer.h"
// Delay for N seconds
void delay_sec(unsigned char sec)
{
unsigned int cycles;
// Delay 25ms at a time (38.4ms is the most we can delay with a
// 20MHz processor, unfortunately. See the delay.h include file
// for more info.)
for(cycles = 0; cycles < (sec * 40); cycles ++)
{
_delay_ms(12);
_delay_ms(13);
}
}
int main(void)
{
//Initialize the lcd
lcd_init();
for (;;){
lcd_gotoxy(0,0);
lcd_string("arbel");
}
}
I will write you the “dir” output so that you will know the files I got in the default folder:
root@arbelmichal-desktop:/home/arbelmichal/Desktop/Documents/avrstudio/orangutan/default# dir
buzzer.o makefile orangutan.c orangutanfunction.o pwm.o
dep makefile~ orangutan.c~ orangutan.hex servo.o
lcd.o Makefile~ orangutan.elf orangutan.o spi.o
I think thats it, if you need more information, let me know.
thanks
Arbel
Hello Arbel,
You need to copy device.h from the orangtuan-lib into the same directory as your other source files. Also, take a look at that file to make sure that it is customized appropriately for your Orangutan.
no good, it steal will not read the lcd functions. I also tried to change some thing in another program from the orangutan lib and even though avrdude programed my orangutan, the changes didn’t take place! I am very frustrated! this is the only thing keeping me from using only ubuntu…
thanks
Arbel
Hi Arbel,
Can you post some more details of the errors you are getting, if any? Regarding the example, did you try just compiling that example alone before making the changes? Which one was it, how did you compile it, and what did you change?
-Paul
after erasing the orangutan lib and reinstalling it, I copied the makefile from the blinkLED example to the default folder of the kitchen-sink example. then I changed the makefile to have the name “kitchen-sink” like this:
then I opened the terminal and got in to the default folder of the kitchen-sink and I wrote “sudo make”
every thing worked. the orangutan is now programmed with the kitchen-sink code and it is working just fine.
I changed some thing in the kitchen-sink code, the welcome display like this:
// Write a welcome message, wait two seconds
lcd_clear();
lcd_line1();
lcd_string("ARBEL");
lcd_line2();
lcd_string("TEST");
delay_sec(2);
I wrote sudo make in the default folder. the orangutan was programmed all right but the changes did not applied. I have to say that after I changed the code of kitchen-sink I saved the file…
BUT, when I make changes in the BLinkLED code, they do apply so I think that the problem is to link all the source files because the BlinkLED has no source files:
// F_CPU tells util/delay.h our clock frequency
#define F_CPU 8000000UL // Orangutan frequency (8MHz)
//#define F_CPU 20000000UL // Baby Orangutan frequency (20MHz)
#include <avr/io.h>
#include <util/delay.h>
void delayms( uint16_t millis ) {
while ( millis ) {
_delay_ms( 1 );
millis--;
}
}
int main( void ) {
DDRD |= 1 << PD1; // set LED pin PD1 to output
while ( 1 ) {
PORTD &= ~( 1 << PD1 ); // LED off
delayms( 300 ); // delay 900 ms
PORTD |= 1 << PD1; // LED on
delayms( 300 ); // delay 100 ms
}
return 0;
}
any thing else? I don’t even want to tell you what happens when I try to add a lcd.h file and then try to compile it…
Arbel
it worked and I got no errors after the changes i made, but the compiler didn’t write nothing to the lcd so I think that the makefile only function is to program the .hex file to the orangutan’ but it will not generate a .hex file on its own. am I right?
here is the BlinkLED code (again… )
// F_CPU tells util/delay.h our clock frequency
#define F_CPU 8000000UL // Orangutan frequency (8MHz)
//#define F_CPU 20000000UL // Baby Orangutan frequency (20MHz)
#include <avr/io.h>
#include <util/delay.h>
#include "device.h"
#include "lcd.h"
void delayms( uint16_t millis ) {
while ( millis ) {
_delay_ms( 1 );
millis--;
}
}
int main( void ) {
DDRD |= 1 << PD1;
lcd_init(); // set LED pin PD1 to output
while ( 1 ) {
PORTD &= ~( 1 << PD1 ); // LED off
delayms( 300 ); // delay 900 ms
PORTD |= 1 << PD1; // LED on
delayms( 300 );
// delay 100 ms
lcd_gotoxy(0,0);
lcd_string("arbel");
}
return 0;
}
I think you should use the Makefiles included with the orangutan-lib when compiling the example programs. They are better written than my Makefile and will be set up to handle the multiple files included with the examples. There is a script included in the top level directory of orangutan-lib that converts the Makefiles to work with linux.
The goal of a Makefile is to automatically compile your code, and in my example Makefile, I have also included an instruction allowing it to automatically program your board. Your trouble with the makefiles right now is probably that you don’t know how to run the correct avr-gcc commands to get everything compiled, so maybe you should start by running those commands by hand before trying to create your own makefiles. You can see the list of commands that is run when you compile a fresh copy of BlinkLED or one of the example programs; try modifying that command sequence to do what you want and just entering it at the command prompt. Then you will be able to understand why the makefile is not doing the right thing.
Paul, I am so sorry, this is very confusing to me, when I tried to use the windows makefile I got this error:
arbelmichal@arbelmichal-desktop:~/Desktop/Documents/orangutan-lib/lcd-test/default$ sudo make
[sudo] password for arbelmichal:
dep/lcd.o.d:1: *** multiple target patterns. Stop.
arbelmichal@arbelmichal-desktop:~/Desktop/Documents/orangutan-lib/lcd-test/default$
I can’t find the avr-gcc commands in the makefile and I don’t know how to use the script in the orangutan lib… please bear with me a little longer…
Arbel
Hello arbel,
Please make sure that you run the script “winavr-to-unix”, which is found in the top-level orangutan-lib directory. This will convert the makefiles to work with linux.
-Paul
When I did this, I saw no output, but the makefiles started working.
I think most people do use avrdude under windows to load the hex file onto their boards - are you thinking about rebooting into linux just to do the programming part? I’m not sure what that would get you.
Having a graphical environment for compiling your code is great, I agree! Makefiles are one of the more tricky things to figure out under linux, and they tend to get more complicated as your program grows.
Sorry Arbel, there is a version of AVR32 Studio for Linux (there had better be, half of the AVR32 devices ship with Linux running on them!), but it will only compile code for the AVR32 32-bit microcontrollers, so you can’t use it with any of the the AVR 8-bit microcontrollers.
I know just how you feel though. I hadn’t even thought about it before reading your posts, but AVR Studio just got added to the list of reasons (programs) I’m still only secondary-dual-booting Linux. Sadly, it’s a very long list.
-Adam
P.S. I just gave up on Open Office 2.4 too, since Calc can’t do polynomial regressions to an arbitrary power (not everything is a parabala after all), or easily display the regression equation like Excel can. Oh well, maybe 3.0.
hay, thanks for the sympathy I wont to use ONLY linux! no more windows at all! and to switch completely in to linux I need to be able to program my bots… the minute it will work, no more windows for me!!!
arbelmichal@arbelmichal-desktop:~/Desktop/Documents/orangutan-lib$ winavr-to-unix
bash: winavr-to-unix: command not found
arbelmichal@arbelmichal-desktop:~/Desktop/Documents/orangutan-lib$
I tried to install programmers notepad and avrstudio4 with wine (windows emulator) but they didn’t work…
do you know a program with GUI that generate .hex files and then I can use them…
Arbel
I think I’m on to some thing!!! remember that you told me to look for the avr-gcc commands in the output of the programmer? well, I tried but I found no such commands. all the commands were avrdude’s. so, I tried to erase the %.obj part completely and what do you know, avrdude programed my orangutan just fine! I think that maybe, for some reason, the make command dose not take the avr-gcc commands and execute them, can I be right?
Arbel
There is a nice graphical environment called “Eclipse” for working with code under linux, and they have an AVR plugin, but I have not tried it. I think it will probably be really difficult to get to work before you understand what is going on with the makefiles, so I’m not recommending it for now.
If you want to keep trying with linux, here’s an introductory tutorial on makefiles: mrbook.org/tutorials/make/
One of the most important features of a makefile is that it doesn’t recompile your code until it’s necessary, which is why you didn’t see the avr-gcc commands until you removed the .obj files. You can usually type “make clean” to delete all of the compiled files and recompile everything from scratch.
-Paul
I am sorry, nothing seem to work. I read the link you sent about the makefiles, I understand that, but I do not know how to create .hex file, the avr-gcc commands don’t even mention it. it’s the same with the command list of the avr-objcopy. when I wrote “make clean” it erased the .hex file and the .o file, but when I tried to to make the makefile again, i got the error "no rule to make BlinkLED.hex…"
so I think that now will be a good time to give up. thanks for every thing
Arbel
I’m sorry you’re having so much trouble! If you download a fresh copy of BlinkLED from our website and type “make”, everything should work, and you should be able to see exactly what commands are being run. On my computer, I see this sequence:
OK, I downloaded a fresh BlinkLED file and cd into the linux folder and typed “make” and got this error:
arbelmichal@arbelmichal-desktop:~/Desktop/BlinkLED/linux$ sudo make
[sudo] password for arbelmichal:
make: *** No rule to make target `BlinkLED.hex', needed by `program'. Stop.
arbelmichal@arbelmichal-desktop:~/Desktop/BlinkLED/linux$