Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

Programming on C (Linux -> Ubuntu)

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
16 postsPage 1 of 21, 2
16 postsPage 1 of 21, 2

Programming on C (Linux -> Ubuntu)

Post by danog8 » Thu Feb 28, 2008 3:42 pm

Post by danog8
Thu Feb 28, 2008 3:42 pm

Hi everybody,

I just modified the example.c code given in the comprehensive kit cd, compiled it, load it to the cm5 and executed with success on Windows.

Now i need to do the same, but this time on Linux. The first problem I encountered is that the compiler (gcc) it doesn't recognize the libraries
(avr/io.h , inttypes.h etc) but I guess that's not the real problem because i just have to look up and download them.

so my real question is, how can I develop a C code on Linux and load it to the cm5?, is there anything equivalent to the "Robot terminal" for Linux?

i need the robot terminal not just to load the .hex file into the cm5 but also to command the robot with the keyboard

thanks and btw ..nice forum!

DaNoG
Hi everybody,

I just modified the example.c code given in the comprehensive kit cd, compiled it, load it to the cm5 and executed with success on Windows.

Now i need to do the same, but this time on Linux. The first problem I encountered is that the compiler (gcc) it doesn't recognize the libraries
(avr/io.h , inttypes.h etc) but I guess that's not the real problem because i just have to look up and download them.

so my real question is, how can I develop a C code on Linux and load it to the cm5?, is there anything equivalent to the "Robot terminal" for Linux?

i need the robot terminal not just to load the .hex file into the cm5 but also to command the robot with the keyboard

thanks and btw ..nice forum!

DaNoG
danog8
Newbie
Newbie
User avatar
Posts: 3
Joined: Thu Nov 29, 2007 7:22 pm
Location: France or Colombia

Post by limor » Thu Feb 28, 2008 4:22 pm

Post by limor
Thu Feb 28, 2008 4:22 pm

Hi danog8,

serial terminal emulation on linux:
http://robosavvy.com/forum/viewtopic.php?t=433

To upload firmware to the CM5 I think you need to use the xmodem protocol. can't remember but search the forum because linux/CM5 and as i remember that this was discussed here before.

Atmega128 gcc compiler for linux:
http://www.avrfreaks.net/wiki/index.php ... on:AVR_GCC
Hi danog8,

serial terminal emulation on linux:
http://robosavvy.com/forum/viewtopic.php?t=433

To upload firmware to the CM5 I think you need to use the xmodem protocol. can't remember but search the forum because linux/CM5 and as i remember that this was discussed here before.

Atmega128 gcc compiler for linux:
http://www.avrfreaks.net/wiki/index.php ... on:AVR_GCC
limor
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK

Post by danog8 » Fri Feb 29, 2008 2:24 pm

Post by danog8
Fri Feb 29, 2008 2:24 pm

Thanks!

now i can connect and upload programs to the CM5 using the Gtkterm !

the problem now is that i can't compile my new program, I've downloaded and installed avr-lib and used a makefile that i found in this forum and apparently worked for the person who posted,

but i don't know what to put in GNU_AVR_PATH = ...?

when i try tocompile usin
gcc -c myproject.c

i get a lot of errors cause it doesn't know the following libaries

error: avr/io.h: No such file or directory
error: avr/interrupt.h: No such file or directory
error: avr/signal.h: No such file or directory

although i've already installed the avrlib :cry:


TARGET=example

GNU_AVR_PATH = /home
CC = $(GNU_AVR_PATH)/bin/avr-gcc
OBJCOPY = $(GNU_AVR_PATH)/bin/avr-objcopy

OPTIM_LEVEL = s

#
# Compiler flags
#
CFLAGS = -g
CFLAGS += -O$(OPTIM_LEVEL)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += -std=gnu99

OBJECTS =\
./Example.o

LDFLAGS =


all: $(TARGET).hex $(TARGET).bin

$(TARGET).elf: $(OBJECTS)
$(CC) -mmcu=atmega128 $(LDFLAGS) -o $@ $(OBJECTS)

example.hex:
$(OBJCOPY) -O ihex -R .eeprom $< $@

example.bin:
$(OBJCOPY) -O binary -R .eeprom $< $@

example.o:%.c
$(CC) -mmcu=atmega128 $(CFLAGS) -o $@ -c $<

clean:
rm -f $(OBJECTS)

cleaner: clean
rm -f $(TARGET).elf \
$(TARGET).hex \
$(TARGET).bin


DaNoG
Thanks!

now i can connect and upload programs to the CM5 using the Gtkterm !

the problem now is that i can't compile my new program, I've downloaded and installed avr-lib and used a makefile that i found in this forum and apparently worked for the person who posted,

but i don't know what to put in GNU_AVR_PATH = ...?

when i try tocompile usin
gcc -c myproject.c

i get a lot of errors cause it doesn't know the following libaries

error: avr/io.h: No such file or directory
error: avr/interrupt.h: No such file or directory
error: avr/signal.h: No such file or directory

although i've already installed the avrlib :cry:


TARGET=example

GNU_AVR_PATH = /home
CC = $(GNU_AVR_PATH)/bin/avr-gcc
OBJCOPY = $(GNU_AVR_PATH)/bin/avr-objcopy

OPTIM_LEVEL = s

#
# Compiler flags
#
CFLAGS = -g
CFLAGS += -O$(OPTIM_LEVEL)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += -std=gnu99

OBJECTS =\
./Example.o

LDFLAGS =


all: $(TARGET).hex $(TARGET).bin

$(TARGET).elf: $(OBJECTS)
$(CC) -mmcu=atmega128 $(LDFLAGS) -o $@ $(OBJECTS)

example.hex:
$(OBJCOPY) -O ihex -R .eeprom $< $@

example.bin:
$(OBJCOPY) -O binary -R .eeprom $< $@

example.o:%.c
$(CC) -mmcu=atmega128 $(CFLAGS) -o $@ -c $<

clean:
rm -f $(OBJECTS)

cleaner: clean
rm -f $(TARGET).elf \
$(TARGET).hex \
$(TARGET).bin


DaNoG
DaNoG
danog8
Newbie
Newbie
User avatar
Posts: 3
Joined: Thu Nov 29, 2007 7:22 pm
Location: France or Colombia

Post by linux23dragon1 » Sun Mar 02, 2008 11:48 am

Post by linux23dragon1
Sun Mar 02, 2008 11:48 am

danog8 wrote:Thanks!

now i can connect and upload programs to the CM5 using the Gtkterm !

the problem now is that i can't compile my new program, I've downloaded and installed avr-lib and used a makefile that i found in this forum and apparently worked for the person who posted,

but i don't know what to put in GNU_AVR_PATH = ...?

when i try tocompile usin
gcc -c myproject.c

i get a lot of errors cause it doesn't know the following libaries

error: avr/io.h: No such file or directory
error: avr/interrupt.h: No such file or directory
error: avr/signal.h: No such file or directory

although i've already installed the avrlib :cry:


TARGET=example

GNU_AVR_PATH = /home
CC = $(GNU_AVR_PATH)/bin/avr-gcc
OBJCOPY = $(GNU_AVR_PATH)/bin/avr-objcopy

OPTIM_LEVEL = s


DaNoG

Hello

You need to change the "GNU_AVR_PATH = /home" (in the C file) or comment out the "GNU_AVR_PATH = /home", and export your $(GNU_AVR_PATH) in the terminal,like this example ; -

Code: Select all
export GNU_AVR_PATH="/path/to/avr-gcc Directory"

##include the quotes as well##

I suspect that the avr-gcc will be located in /opt/avr-gcc, or /home/user/avr-gcc. I have not installed avr-gcc on my system yet, but you get the idea.

To see if the $GNU_AVR_PATH command works, issue this command : -
Code: Select all
echo $GNU_AVR_PATH


That should fix that issue. You can make the $(GNU_AVR_PATH) permanent by entering the full $PATH command in ~/home/user/.bashrc file

Code: Select all
PATH=$PATH:/opt/avr-gcc/bin ## May be needed
GNU_AVR_PATH=/opt/avr-gcc ## This line is needed


## Remember. Those are example PATHS##


Also note that the avr-gcc tool chain is a static cross compiler . This means that it could also be looking for another $PATH that may not exist (like temporary file locations). But Hopefully I'm wrong about that. It is a easy fix (Just a matter of creating the temporary $PATH with a symlink).

EDIT:- By the way. Have you set your $TARGET (in the C file) as well?
and you might need to issue the command avr-gcc -c myproject.c (or /opt/avr-gcc/bin/avr-gcc -c myproject.c if you have not setup your $PATH) too.
danog8 wrote:Thanks!

now i can connect and upload programs to the CM5 using the Gtkterm !

the problem now is that i can't compile my new program, I've downloaded and installed avr-lib and used a makefile that i found in this forum and apparently worked for the person who posted,

but i don't know what to put in GNU_AVR_PATH = ...?

when i try tocompile usin
gcc -c myproject.c

i get a lot of errors cause it doesn't know the following libaries

error: avr/io.h: No such file or directory
error: avr/interrupt.h: No such file or directory
error: avr/signal.h: No such file or directory

although i've already installed the avrlib :cry:


TARGET=example

GNU_AVR_PATH = /home
CC = $(GNU_AVR_PATH)/bin/avr-gcc
OBJCOPY = $(GNU_AVR_PATH)/bin/avr-objcopy

OPTIM_LEVEL = s


DaNoG

Hello

You need to change the "GNU_AVR_PATH = /home" (in the C file) or comment out the "GNU_AVR_PATH = /home", and export your $(GNU_AVR_PATH) in the terminal,like this example ; -

Code: Select all
export GNU_AVR_PATH="/path/to/avr-gcc Directory"

##include the quotes as well##

I suspect that the avr-gcc will be located in /opt/avr-gcc, or /home/user/avr-gcc. I have not installed avr-gcc on my system yet, but you get the idea.

To see if the $GNU_AVR_PATH command works, issue this command : -
Code: Select all
echo $GNU_AVR_PATH


That should fix that issue. You can make the $(GNU_AVR_PATH) permanent by entering the full $PATH command in ~/home/user/.bashrc file

Code: Select all
PATH=$PATH:/opt/avr-gcc/bin ## May be needed
GNU_AVR_PATH=/opt/avr-gcc ## This line is needed


## Remember. Those are example PATHS##


Also note that the avr-gcc tool chain is a static cross compiler . This means that it could also be looking for another $PATH that may not exist (like temporary file locations). But Hopefully I'm wrong about that. It is a easy fix (Just a matter of creating the temporary $PATH with a symlink).

EDIT:- By the way. Have you set your $TARGET (in the C file) as well?
and you might need to issue the command avr-gcc -c myproject.c (or /opt/avr-gcc/bin/avr-gcc -c myproject.c if you have not setup your $PATH) too.
Love Linux and 3D Linux Games :)
linux23dragon1
Robot Builder
Robot Builder
User avatar
Posts: 7
Joined: Wed Feb 27, 2008 12:34 pm

Post by danog8 » Wed Mar 19, 2008 10:05 am

Post by danog8
Wed Mar 19, 2008 10:05 am

/* Thanks for all your help; I've found the PATH :D
to avr-gcc and avr-objcopy */

but when I compile i keep getting this error message

/usr/bin/avr-objcopy -0 ihex -R .eeprom myproject.hex
/usr/bin/avr-objcopy: ' myproject.hex' : No such file
make: *** [myproject.hex] Error 1

I think my problem is the makefile but i don't know how to solve it
can someone help me with this please!!

thx agn
/* Thanks for all your help; I've found the PATH :D
to avr-gcc and avr-objcopy */

but when I compile i keep getting this error message

/usr/bin/avr-objcopy -0 ihex -R .eeprom myproject.hex
/usr/bin/avr-objcopy: ' myproject.hex' : No such file
make: *** [myproject.hex] Error 1

I think my problem is the makefile but i don't know how to solve it
can someone help me with this please!!

thx agn
DaNoG
danog8
Newbie
Newbie
User avatar
Posts: 3
Joined: Thu Nov 29, 2007 7:22 pm
Location: France or Colombia

Post by limor » Thu Mar 20, 2008 2:45 pm

Post by limor
Thu Mar 20, 2008 2:45 pm

can you run "make clean" and then "make" and then copy the content of all the output here?
can you run "make clean" and then "make" and then copy the content of all the output here?
limor
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK

Re: Programming on C (Linux -> Ubuntu)

Post by NEVER » Sun Aug 31, 2008 9:19 pm

Post by NEVER
Sun Aug 31, 2008 9:19 pm

danog8 wrote:Hi everybody,

I just modified the example.c code given in the comprehensive kit cd, compiled it, load it to the cm5 and executed with success on Windows.

Now i need to do the same, but this time on Linux. The first problem I encountered is that the compiler (gcc) it doesn't recognize the libraries
(avr/io.h , inttypes.h etc) but I guess that's not the real problem because i just have to look up and download them.

so my real question is, how can I develop a C code on Linux and load it to the cm5?, is there anything equivalent to the "Robot terminal" for Linux?

i need the robot terminal not just to load the .hex file into the cm5 but also to command the robot with the keyboard

thanks and btw ..nice forum!

DaNoG


Can u please tell me how to compile in avr
danog8 wrote:Hi everybody,

I just modified the example.c code given in the comprehensive kit cd, compiled it, load it to the cm5 and executed with success on Windows.

Now i need to do the same, but this time on Linux. The first problem I encountered is that the compiler (gcc) it doesn't recognize the libraries
(avr/io.h , inttypes.h etc) but I guess that's not the real problem because i just have to look up and download them.

so my real question is, how can I develop a C code on Linux and load it to the cm5?, is there anything equivalent to the "Robot terminal" for Linux?

i need the robot terminal not just to load the .hex file into the cm5 but also to command the robot with the keyboard

thanks and btw ..nice forum!

DaNoG


Can u please tell me how to compile in avr
NEVER
Robot Builder
Robot Builder
Posts: 17
Joined: Sun Aug 31, 2008 9:19 pm

Post by clusher » Tue Sep 02, 2008 3:40 pm

Post by clusher
Tue Sep 02, 2008 3:40 pm

Compiling in AVR is kinda tricky, if you're not used to compiling.
First, install WinAVR and say you want to install Programmers Notepad too, when prompted.

The use Programmers notepad to make your .c program. You can use the example.c to start with and search in these forums for a few more examples. It takes some time to learn it well, and you should have some background... Don't forget to create a makefile (or use one from the forums or from the example on the Bioloid CD, changing the name of the files, of course).

When you have the programm ready, open the Tools Menu and select the WinAVR compiler. When it finishes, use Robot Terminal to upload to CM-5.
Compiling in AVR is kinda tricky, if you're not used to compiling.
First, install WinAVR and say you want to install Programmers Notepad too, when prompted.

The use Programmers notepad to make your .c program. You can use the example.c to start with and search in these forums for a few more examples. It takes some time to learn it well, and you should have some background... Don't forget to create a makefile (or use one from the forums or from the example on the Bioloid CD, changing the name of the files, of course).

When you have the programm ready, open the Tools Menu and select the WinAVR compiler. When it finishes, use Robot Terminal to upload to CM-5.
clusher
Savvy Roboteer
Savvy Roboteer
Posts: 57
Joined: Thu Jul 17, 2008 12:27 pm

Post by StuartL » Tue Sep 02, 2008 9:51 pm

Post by StuartL
Tue Sep 02, 2008 9:51 pm

Couple of things to watch out for:

The example.c file has LOTS of mistakes. There's bit masks which are wrong, the charging circuit is turned on by default (look in the post history for the fire this caused on one of my battery packs) and some of the comments are misleading.
Couple of things to watch out for:

The example.c file has LOTS of mistakes. There's bit masks which are wrong, the charging circuit is turned on by default (look in the post history for the fire this caused on one of my battery packs) and some of the comments are misleading.
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Post by clusher » Wed Sep 03, 2008 3:53 pm

Post by clusher
Wed Sep 03, 2008 3:53 pm

Yeah, I based my C programming on the example.c nad noticed a couple mistakes but I actually didn't pay too much attention on bits they used... I probably should, now that I understand what they are...

The charging circuit seems serious... I'll take a look at it!
Yeah, I based my C programming on the example.c nad noticed a couple mistakes but I actually didn't pay too much attention on bits they used... I probably should, now that I understand what they are...

The charging circuit seems serious... I'll take a look at it!
clusher
Savvy Roboteer
Savvy Roboteer
Posts: 57
Joined: Thu Jul 17, 2008 12:27 pm

Post by Mandor » Sat Sep 20, 2008 1:49 pm

Post by Mandor
Sat Sep 20, 2008 1:49 pm

Hi,

StuartL wrote:Couple of things to watch out for:

The example.c file has LOTS of mistakes. There's bit masks which are wrong, the charging circuit is turned on by default (look in the post history for the fire this caused on one of my battery packs) and some of the comments are misleading.

'so, where could we found a debugged example.c (or an equivalent working example) ?

Thanks.
Hi,

StuartL wrote:Couple of things to watch out for:

The example.c file has LOTS of mistakes. There's bit masks which are wrong, the charging circuit is turned on by default (look in the post history for the fire this caused on one of my battery packs) and some of the comments are misleading.

'so, where could we found a debugged example.c (or an equivalent working example) ?

Thanks.
Mandor
Newbie
Newbie
Posts: 6
Joined: Sat Sep 20, 2008 1:48 pm

Post by StuartL » Sat Sep 20, 2008 2:40 pm

Post by StuartL
Sat Sep 20, 2008 2:40 pm

Mandor wrote:Hi,

StuartL wrote:Couple of things to watch out for:

The example.c file has LOTS of mistakes. There's bit masks which are wrong, the charging circuit is turned on by default (look in the post history for the fire this caused on one of my battery packs) and some of the comments are misleading.

'so, where could we found a debugged example.c (or an equivalent working example) ?

Thanks.


We never wrote a debugged example.c as example.c slowly evolved into our C library. Which is probably ready for release now, I'll talk to Matt about it.
Mandor wrote:Hi,

StuartL wrote:Couple of things to watch out for:

The example.c file has LOTS of mistakes. There's bit masks which are wrong, the charging circuit is turned on by default (look in the post history for the fire this caused on one of my battery packs) and some of the comments are misleading.

'so, where could we found a debugged example.c (or an equivalent working example) ?

Thanks.


We never wrote a debugged example.c as example.c slowly evolved into our C library. Which is probably ready for release now, I'll talk to Matt about it.
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Is the C library ready for release ?

Post by ksamay » Mon Dec 01, 2008 6:03 pm

Post by ksamay
Mon Dec 01, 2008 6:03 pm

Hi StuartL,

By when are you planning to release the C library ?
Hi StuartL,

By when are you planning to release the C library ?
ksamay
Robot Builder
Robot Builder
Posts: 13
Joined: Tue Oct 28, 2008 5:55 am

Re: Is the C library ready for release ?

Post by StuartL » Mon Dec 01, 2008 10:00 pm

Post by StuartL
Mon Dec 01, 2008 10:00 pm

ksamay wrote:Hi StuartL,

By when are you planning to release the C library ?


About six months ago? ;)
ksamay wrote:Hi StuartL,

By when are you planning to release the C library ?


About six months ago? ;)
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

:)

Post by ksamay » Wed Dec 03, 2008 1:22 pm

Post by ksamay
Wed Dec 03, 2008 1:22 pm

:). Thanks .

I think i missed it :) .
:). Thanks .

I think i missed it :) .
ksamay
Robot Builder
Robot Builder
Posts: 13
Joined: Tue Oct 28, 2008 5:55 am

Next
16 postsPage 1 of 21, 2
16 postsPage 1 of 21, 2