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

CM-5 Hello world in C

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

CM-5 Hello world in C

Post by Marmakoide » Fri Mar 16, 2007 5:49 pm

Post by Marmakoide
Fri Mar 16, 2007 5:49 pm

I'am trying to program the CM- in C, with a Linux environment.

I was able to compile a GCC toolchain for ATMega128 with :
* binutils-2.17
* avr-libc-1.4.4
* gcc-4.1.1

I was able to compile the Example.c from Robotis, uploading it, and playing it. It works fine.

Now, I'am trying to remove as much I can from Example.c to just put a 'Hello world' on the RobotTerminal. My main function is simply the following code
Code: Select all
int main(void)
{
  byte bCount,bID, bTxPacketLength,bRxPacketLength;
 
  PortInitialize(); //Port In/Out Direction Definition
  RS485_RXD; //Set RS485 Direction to Input State.
  SerialInitialize(SERIAL_PORT0,1,RX_INTERRUPT);//RS485 Initializing(RxInterrupt)
  SerialInitialize(SERIAL_PORT1,DEFAULT_BAUD_RATE,0); //RS232 Initializing(None Interrupt)
 
  gbRxBufferReadPointer = gbRxBufferWritePointer = 0;  //RS485 RxBuffer Clearing.

  sei();  //Enable Interrupt -- Compiler Function
  TxDString("\r\n Hello from the CM-5 !\r\n");
  while(1);
}


No suprises, it works. But if I remove the function void PrintBaudrate(void) or [void PrintBuffer(byte *bpPrintBuffer, byte bLength)/i], that are not used by [i]main(), then the programm doesn't display "Hello from the CM-5 !".
Removing void PrintBaudrate(void) -> Just "o" is displayed
Removing [i][void PrintBuffer(byte *bpPrintBuffer, byte bLength)/i] -> Just "o from the CM-5 !" is displayed

Here it my Makefile
Code: Select all
GNU_AVR_PATH=/home/marmakoide/Bioloid/tools

CC=$(GNU_AVR_PATH)/bin/avr-gcc
OBJCOPY=$(GNU_AVR_PATH)/bin/avr-objcopy
CFLAGS=-O2 -mmcu=atmega128 -Wall

OBJECTS=\
./Example.o

TARGET=example


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

$(TARGET).elf: $(OBJECTS)
   $(CC) -o $@ $(OBJECTS)

%.hex:%.elf
   $(OBJCOPY) --output-target ihex -R .eeprom $< $@

%.bin:%.elf
   $(OBJCOPY) --output-target binary -R .eeprom $< $@
%.o:%.c
   $(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<

clean:
   rm -f $(OBJECTS)

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


Is it because the new program is shorther than the older, and when uploading, the new is written over the older ?
I'am trying to program the CM- in C, with a Linux environment.

I was able to compile a GCC toolchain for ATMega128 with :
* binutils-2.17
* avr-libc-1.4.4
* gcc-4.1.1

I was able to compile the Example.c from Robotis, uploading it, and playing it. It works fine.

Now, I'am trying to remove as much I can from Example.c to just put a 'Hello world' on the RobotTerminal. My main function is simply the following code
Code: Select all
int main(void)
{
  byte bCount,bID, bTxPacketLength,bRxPacketLength;
 
  PortInitialize(); //Port In/Out Direction Definition
  RS485_RXD; //Set RS485 Direction to Input State.
  SerialInitialize(SERIAL_PORT0,1,RX_INTERRUPT);//RS485 Initializing(RxInterrupt)
  SerialInitialize(SERIAL_PORT1,DEFAULT_BAUD_RATE,0); //RS232 Initializing(None Interrupt)
 
  gbRxBufferReadPointer = gbRxBufferWritePointer = 0;  //RS485 RxBuffer Clearing.

  sei();  //Enable Interrupt -- Compiler Function
  TxDString("\r\n Hello from the CM-5 !\r\n");
  while(1);
}


No suprises, it works. But if I remove the function void PrintBaudrate(void) or [void PrintBuffer(byte *bpPrintBuffer, byte bLength)/i], that are not used by [i]main(), then the programm doesn't display "Hello from the CM-5 !".
Removing void PrintBaudrate(void) -> Just "o" is displayed
Removing [i][void PrintBuffer(byte *bpPrintBuffer, byte bLength)/i] -> Just "o from the CM-5 !" is displayed

Here it my Makefile
Code: Select all
GNU_AVR_PATH=/home/marmakoide/Bioloid/tools

CC=$(GNU_AVR_PATH)/bin/avr-gcc
OBJCOPY=$(GNU_AVR_PATH)/bin/avr-objcopy
CFLAGS=-O2 -mmcu=atmega128 -Wall

OBJECTS=\
./Example.o

TARGET=example


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

$(TARGET).elf: $(OBJECTS)
   $(CC) -o $@ $(OBJECTS)

%.hex:%.elf
   $(OBJCOPY) --output-target ihex -R .eeprom $< $@

%.bin:%.elf
   $(OBJCOPY) --output-target binary -R .eeprom $< $@
%.o:%.c
   $(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<

clean:
   rm -f $(OBJECTS)

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


Is it because the new program is shorther than the older, and when uploading, the new is written over the older ?
Marmakoide
Robot Builder
Robot Builder
Posts: 13
Joined: Fri Mar 02, 2007 6:57 pm

Post by Marmakoide » Tue Mar 20, 2007 10:52 am

Post by Marmakoide
Tue Mar 20, 2007 10:52 am

Problem solved, seems to be a compiler flag order issue :shock:

Here it is the script I made to build my Linux/GCC cross-compiler
Code: Select all
#!/bin/bash

# ----------------------------------------------------------------------------
# build-toolchain.sh $1
#
# $1 Where to install the tools
#
# Build a toolchain for the AVR Atmel GCC C compiler
#
# Based on the following docs :
#   http://lists.gnu.org/archive/html/avr-gcc-list/2006-08/msg00098.html
# ----------------------------------------------------------------------------


function download {
  if [ ! -f $2 ]; then
    wget $1/$2

    if [ "$?" -ne "0" ]; then
      echo "Fail to download" $2 "at" $1
      return 1
    fi
  fi
}


# --- Init ---
BUILD_TMP=/tmp/
ORIGIN=`pwd`

if [ "$#" -lt 1 ]; then
  echo "No installation path specified"
  return 1
fi

INSTALL_PATH=$1



# --- Get the packages to install from the net ---
download ftp://sourceware.org/pub/binutils/releases binutils-2.17.tar.bz2
download ftp://ftp.gnu.org/gnu/gcc/gcc-4.1.1 gcc-core-4.1.1.tar.bz2
download http://download.savannah.gnu.org/releases/avr-libc avr-libc-1.4.5.tar.bz2



# --- Build the binutils ---
if [ ! -f ${INSTALL_PATH}/bin/avr-as ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/binutils-2.17.tar.bz2
  cd binutils-2.17
  ./configure --target=avr \
              --prefix=${INSTALL_PATH} \
              --disable-nls
  make
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/binutils-2.17
fi



# --- Build gcc ---
export PATH=${INSTALL_PATH}/bin:$PATH

if [ ! -f ${INSTALL_PATH}/bin/avr-gcc-4.1.1 ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/gcc-core-4.1.1.tar.bz2
  cd gcc-4.1.1
  ./configure  --target=avr \
               --prefix=${INSTALL_PATH} \
               --enable-languages="c" \
               --disable-libssp \
               --disable-nls \
               --enable-clocale=gnu

  #./configure  --target=avr \
  #             --prefix=${INSTALL_PATH} \
  #             --enable-languages=c \
  #             --disable-libssp \
  #             --enable-__cxa_atexit \
  #             --enable-clocale=gnu \
  #             --disable-nls

  make
  make check
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/gcc-4.1.1
fi



# --- Build the libc ---
if [ ! -f ${INSTALL_PATH}/avr/include/stdio.h ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/avr-libc-1.4.5.tar.bz2
  cd avr-libc-1.4.5

  ./configure --host=avr --prefix=${INSTALL_PATH} CC="$INSTALL_PATH/bin/avr-gcc"
  #./configure --build=`./config.guess` --host=avr --prefix=${INSTALL_PATH}
 
  make
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/avr-libc-1.4.5
fi


Here it is the Makefile that works
Code: Select all
TARGET=example

GNU_AVR_PATH = /home/xxx/Bioloid/tools

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)

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

%.bin:%.elf
   $(OBJCOPY) -O binary -R .eeprom $< $@
%.o:%.c
   $(CC) -mmcu=atmega128 $(CFLAGS) -o $@ -c $<

clean:
   rm -f $(OBJECTS)

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


My procedure to upload a .bin executable to the CM-5 :
* lauching gtkterm (As minicom but with a more handy user interface)
* setting the connection to 57600 bauds, 1 stop bit, no parity bits, no stream control
* doing the #-and-red-button trick to enter in the bootloader (Matrix, here we come :lol: )
* typing load in the gtkterm shell
* sending my .bin file with the gtkterm ASCII file send functionality
* it's done, don't care about the CM-5 checksum complaints
Problem solved, seems to be a compiler flag order issue :shock:

Here it is the script I made to build my Linux/GCC cross-compiler
Code: Select all
#!/bin/bash

# ----------------------------------------------------------------------------
# build-toolchain.sh $1
#
# $1 Where to install the tools
#
# Build a toolchain for the AVR Atmel GCC C compiler
#
# Based on the following docs :
#   http://lists.gnu.org/archive/html/avr-gcc-list/2006-08/msg00098.html
# ----------------------------------------------------------------------------


function download {
  if [ ! -f $2 ]; then
    wget $1/$2

    if [ "$?" -ne "0" ]; then
      echo "Fail to download" $2 "at" $1
      return 1
    fi
  fi
}


# --- Init ---
BUILD_TMP=/tmp/
ORIGIN=`pwd`

if [ "$#" -lt 1 ]; then
  echo "No installation path specified"
  return 1
fi

INSTALL_PATH=$1



# --- Get the packages to install from the net ---
download ftp://sourceware.org/pub/binutils/releases binutils-2.17.tar.bz2
download ftp://ftp.gnu.org/gnu/gcc/gcc-4.1.1 gcc-core-4.1.1.tar.bz2
download http://download.savannah.gnu.org/releases/avr-libc avr-libc-1.4.5.tar.bz2



# --- Build the binutils ---
if [ ! -f ${INSTALL_PATH}/bin/avr-as ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/binutils-2.17.tar.bz2
  cd binutils-2.17
  ./configure --target=avr \
              --prefix=${INSTALL_PATH} \
              --disable-nls
  make
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/binutils-2.17
fi



# --- Build gcc ---
export PATH=${INSTALL_PATH}/bin:$PATH

if [ ! -f ${INSTALL_PATH}/bin/avr-gcc-4.1.1 ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/gcc-core-4.1.1.tar.bz2
  cd gcc-4.1.1
  ./configure  --target=avr \
               --prefix=${INSTALL_PATH} \
               --enable-languages="c" \
               --disable-libssp \
               --disable-nls \
               --enable-clocale=gnu

  #./configure  --target=avr \
  #             --prefix=${INSTALL_PATH} \
  #             --enable-languages=c \
  #             --disable-libssp \
  #             --enable-__cxa_atexit \
  #             --enable-clocale=gnu \
  #             --disable-nls

  make
  make check
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/gcc-4.1.1
fi



# --- Build the libc ---
if [ ! -f ${INSTALL_PATH}/avr/include/stdio.h ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/avr-libc-1.4.5.tar.bz2
  cd avr-libc-1.4.5

  ./configure --host=avr --prefix=${INSTALL_PATH} CC="$INSTALL_PATH/bin/avr-gcc"
  #./configure --build=`./config.guess` --host=avr --prefix=${INSTALL_PATH}
 
  make
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/avr-libc-1.4.5
fi


Here it is the Makefile that works
Code: Select all
TARGET=example

GNU_AVR_PATH = /home/xxx/Bioloid/tools

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)

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

%.bin:%.elf
   $(OBJCOPY) -O binary -R .eeprom $< $@
%.o:%.c
   $(CC) -mmcu=atmega128 $(CFLAGS) -o $@ -c $<

clean:
   rm -f $(OBJECTS)

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


My procedure to upload a .bin executable to the CM-5 :
* lauching gtkterm (As minicom but with a more handy user interface)
* setting the connection to 57600 bauds, 1 stop bit, no parity bits, no stream control
* doing the #-and-red-button trick to enter in the bootloader (Matrix, here we come :lol: )
* typing load in the gtkterm shell
* sending my .bin file with the gtkterm ASCII file send functionality
* it's done, don't care about the CM-5 checksum complaints
Marmakoide
Robot Builder
Robot Builder
Posts: 13
Joined: Fri Mar 02, 2007 6:57 pm

compilation

Post by Igga » Wed Dec 26, 2007 11:34 am

Post by Igga
Wed Dec 26, 2007 11:34 am

Hi,

How do you compile your project?
From the terminal?

Thanks.


Marmakoide wrote:Problem solved, seems to be a compiler flag order issue :shock:

Here it is the script I made to build my Linux/GCC cross-compiler
Code: Select all
#!/bin/bash

# ----------------------------------------------------------------------------
# build-toolchain.sh $1
#
# $1 Where to install the tools
#
# Build a toolchain for the AVR Atmel GCC C compiler
#
# Based on the following docs :
#   http://lists.gnu.org/archive/html/avr-gcc-list/2006-08/msg00098.html
# ----------------------------------------------------------------------------


function download {
  if [ ! -f $2 ]; then
    wget $1/$2

    if [ "$?" -ne "0" ]; then
      echo "Fail to download" $2 "at" $1
      return 1
    fi
  fi
}


# --- Init ---
BUILD_TMP=/tmp/
ORIGIN=`pwd`

if [ "$#" -lt 1 ]; then
  echo "No installation path specified"
  return 1
fi

INSTALL_PATH=$1



# --- Get the packages to install from the net ---
download ftp://sourceware.org/pub/binutils/releases binutils-2.17.tar.bz2
download ftp://ftp.gnu.org/gnu/gcc/gcc-4.1.1 gcc-core-4.1.1.tar.bz2
download http://download.savannah.gnu.org/releases/avr-libc avr-libc-1.4.5.tar.bz2



# --- Build the binutils ---
if [ ! -f ${INSTALL_PATH}/bin/avr-as ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/binutils-2.17.tar.bz2
  cd binutils-2.17
  ./configure --target=avr \
              --prefix=${INSTALL_PATH} \
              --disable-nls
  make
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/binutils-2.17
fi



# --- Build gcc ---
export PATH=${INSTALL_PATH}/bin:$PATH

if [ ! -f ${INSTALL_PATH}/bin/avr-gcc-4.1.1 ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/gcc-core-4.1.1.tar.bz2
  cd gcc-4.1.1
  ./configure  --target=avr \
               --prefix=${INSTALL_PATH} \
               --enable-languages="c" \
               --disable-libssp \
               --disable-nls \
               --enable-clocale=gnu

  #./configure  --target=avr \
  #             --prefix=${INSTALL_PATH} \
  #             --enable-languages=c \
  #             --disable-libssp \
  #             --enable-__cxa_atexit \
  #             --enable-clocale=gnu \
  #             --disable-nls

  make
  make check
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/gcc-4.1.1
fi



# --- Build the libc ---
if [ ! -f ${INSTALL_PATH}/avr/include/stdio.h ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/avr-libc-1.4.5.tar.bz2
  cd avr-libc-1.4.5

  ./configure --host=avr --prefix=${INSTALL_PATH} CC="$INSTALL_PATH/bin/avr-gcc"
  #./configure --build=`./config.guess` --host=avr --prefix=${INSTALL_PATH}
 
  make
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/avr-libc-1.4.5
fi


Here it is the Makefile that works
Code: Select all
TARGET=example

GNU_AVR_PATH = /home/xxx/Bioloid/tools

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)

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

%.bin:%.elf
   $(OBJCOPY) -O binary -R .eeprom $< $@
%.o:%.c
   $(CC) -mmcu=atmega128 $(CFLAGS) -o $@ -c $<

clean:
   rm -f $(OBJECTS)

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


My procedure to upload a .bin executable to the CM-5 :
* lauching gtkterm (As minicom but with a more handy user interface)
* setting the connection to 57600 bauds, 1 stop bit, no parity bits, no stream control
* doing the #-and-red-button trick to enter in the bootloader (Matrix, here we come :lol: )
* typing load in the gtkterm shell
* sending my .bin file with the gtkterm ASCII file send functionality
* it's done, don't care about the CM-5 checksum complaints
Hi,

How do you compile your project?
From the terminal?

Thanks.


Marmakoide wrote:Problem solved, seems to be a compiler flag order issue :shock:

Here it is the script I made to build my Linux/GCC cross-compiler
Code: Select all
#!/bin/bash

# ----------------------------------------------------------------------------
# build-toolchain.sh $1
#
# $1 Where to install the tools
#
# Build a toolchain for the AVR Atmel GCC C compiler
#
# Based on the following docs :
#   http://lists.gnu.org/archive/html/avr-gcc-list/2006-08/msg00098.html
# ----------------------------------------------------------------------------


function download {
  if [ ! -f $2 ]; then
    wget $1/$2

    if [ "$?" -ne "0" ]; then
      echo "Fail to download" $2 "at" $1
      return 1
    fi
  fi
}


# --- Init ---
BUILD_TMP=/tmp/
ORIGIN=`pwd`

if [ "$#" -lt 1 ]; then
  echo "No installation path specified"
  return 1
fi

INSTALL_PATH=$1



# --- Get the packages to install from the net ---
download ftp://sourceware.org/pub/binutils/releases binutils-2.17.tar.bz2
download ftp://ftp.gnu.org/gnu/gcc/gcc-4.1.1 gcc-core-4.1.1.tar.bz2
download http://download.savannah.gnu.org/releases/avr-libc avr-libc-1.4.5.tar.bz2



# --- Build the binutils ---
if [ ! -f ${INSTALL_PATH}/bin/avr-as ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/binutils-2.17.tar.bz2
  cd binutils-2.17
  ./configure --target=avr \
              --prefix=${INSTALL_PATH} \
              --disable-nls
  make
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/binutils-2.17
fi



# --- Build gcc ---
export PATH=${INSTALL_PATH}/bin:$PATH

if [ ! -f ${INSTALL_PATH}/bin/avr-gcc-4.1.1 ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/gcc-core-4.1.1.tar.bz2
  cd gcc-4.1.1
  ./configure  --target=avr \
               --prefix=${INSTALL_PATH} \
               --enable-languages="c" \
               --disable-libssp \
               --disable-nls \
               --enable-clocale=gnu

  #./configure  --target=avr \
  #             --prefix=${INSTALL_PATH} \
  #             --enable-languages=c \
  #             --disable-libssp \
  #             --enable-__cxa_atexit \
  #             --enable-clocale=gnu \
  #             --disable-nls

  make
  make check
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/gcc-4.1.1
fi



# --- Build the libc ---
if [ ! -f ${INSTALL_PATH}/avr/include/stdio.h ]; then
  cd ${BUILD_TMP}
  tar xjf ${ORIGIN}/avr-libc-1.4.5.tar.bz2
  cd avr-libc-1.4.5

  ./configure --host=avr --prefix=${INSTALL_PATH} CC="$INSTALL_PATH/bin/avr-gcc"
  #./configure --build=`./config.guess` --host=avr --prefix=${INSTALL_PATH}
 
  make
  make install
  cd ${ORIGIN}
  rm -rf ${BUILD_TMP}/avr-libc-1.4.5
fi


Here it is the Makefile that works
Code: Select all
TARGET=example

GNU_AVR_PATH = /home/xxx/Bioloid/tools

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)

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

%.bin:%.elf
   $(OBJCOPY) -O binary -R .eeprom $< $@
%.o:%.c
   $(CC) -mmcu=atmega128 $(CFLAGS) -o $@ -c $<

clean:
   rm -f $(OBJECTS)

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


My procedure to upload a .bin executable to the CM-5 :
* lauching gtkterm (As minicom but with a more handy user interface)
* setting the connection to 57600 bauds, 1 stop bit, no parity bits, no stream control
* doing the #-and-red-button trick to enter in the bootloader (Matrix, here we come :lol: )
* typing load in the gtkterm shell
* sending my .bin file with the gtkterm ASCII file send functionality
* it's done, don't care about the CM-5 checksum complaints
Igga
Newbie
Newbie
Posts: 3
Joined: Tue Nov 06, 2007 12:29 pm
Location: Riga

Post by Marmakoide » Fri Dec 28, 2007 3:41 pm

Post by Marmakoide
Fri Dec 28, 2007 3:41 pm

If by terminal you mean the gtkterm program, you're wrong. But if you mean a Unix shell then you're right. The Unix terminal allow to run commands, and gtkterm is used to send and receive data from a serial port.

Using the Makefile I posted should help too.[/i]
If by terminal you mean the gtkterm program, you're wrong. But if you mean a Unix shell then you're right. The Unix terminal allow to run commands, and gtkterm is used to send and receive data from a serial port.

Using the Makefile I posted should help too.[/i]
Marmakoide
Robot Builder
Robot Builder
Posts: 13
Joined: Fri Mar 02, 2007 6:57 pm

Post by Igga » Fri Dec 28, 2007 4:23 pm

Post by Igga
Fri Dec 28, 2007 4:23 pm

Thank you friend,

I understood my mistake.

Could you help with two more question:

1) Did you change the rs232 interface part in the example program.
I tried to compile it as you suggested, but it showed many errors
related to interface. Linux has different communication procedure with the interface, right?

Could you send the whole C code of your project?

2) Is there a linux driver for usb2dynamixel?


Thank you and best wishes for the New Year!!
Thank you friend,

I understood my mistake.

Could you help with two more question:

1) Did you change the rs232 interface part in the example program.
I tried to compile it as you suggested, but it showed many errors
related to interface. Linux has different communication procedure with the interface, right?

Could you send the whole C code of your project?

2) Is there a linux driver for usb2dynamixel?


Thank you and best wishes for the New Year!!
Igga
Newbie
Newbie
Posts: 3
Joined: Tue Nov 06, 2007 12:29 pm
Location: Riga

Post by siempre.aprendiendo » Fri Dec 28, 2007 5:37 pm

Post by siempre.aprendiendo
Fri Dec 28, 2007 5:37 pm

Igga wrote:Thank you friend,

I understood my mistake.

Could you help with two more question:

1) Did you change the rs232 interface part in the example program.
I tried to compile it as you suggested, but it showed many errors
related to interface. Linux has different communication procedure with the interface, right?

Could you send the whole C code of your project?

2) Is there a linux driver for usb2dynamixel?


Thank you and best wishes for the New Year!!


There is no "official" linux driver for usb2dynamixel, but browsing the zip file contents I've found this URL:

ftdichip InstallGuides.htm

among other FTDI files, so I suppose the linux drivers from FTDI should work...

I don't have the usb2dynamixel, could you post your results? :)
Igga wrote:Thank you friend,

I understood my mistake.

Could you help with two more question:

1) Did you change the rs232 interface part in the example program.
I tried to compile it as you suggested, but it showed many errors
related to interface. Linux has different communication procedure with the interface, right?

Could you send the whole C code of your project?

2) Is there a linux driver for usb2dynamixel?


Thank you and best wishes for the New Year!!


There is no "official" linux driver for usb2dynamixel, but browsing the zip file contents I've found this URL:

ftdichip InstallGuides.htm

among other FTDI files, so I suppose the linux drivers from FTDI should work...

I don't have the usb2dynamixel, could you post your results? :)
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by Igga » Sat Dec 29, 2007 12:16 pm

Post by Igga
Sat Dec 29, 2007 12:16 pm

Hi,

USB2dynamixel is working perfectly under Linux.
The program BRLTTY didnt allow the driver to work properly.
It is explained here:
http://www.ladyada.net/learn/arduino/lesson0-lin.html

However my example.hex program is not working if i program the CM-5 under linux.

Cheers!
Hi,

USB2dynamixel is working perfectly under Linux.
The program BRLTTY didnt allow the driver to work properly.
It is explained here:
http://www.ladyada.net/learn/arduino/lesson0-lin.html

However my example.hex program is not working if i program the CM-5 under linux.

Cheers!
Igga
Newbie
Newbie
Posts: 3
Joined: Tue Nov 06, 2007 12:29 pm
Location: Riga

Post by siempre.aprendiendo » Sat Dec 29, 2007 2:05 pm

Post by siempre.aprendiendo
Sat Dec 29, 2007 2:05 pm

Igga wrote:Hi,

USB2dynamixel is working perfectly under Linux.
The program BRLTTY didnt allow the driver to work properly.
It is explained here:
http://www.ladyada.net/learn/arduino/lesson0-lin.html

Thanks!

Which Linux distribution do you use?

Igga wrote:However my example.hex program is not working if i program the CM-5 under linux.

Cheers!


Humm, it's strange... which compiler/environment do you use? AVR GCC?
Igga wrote:Hi,

USB2dynamixel is working perfectly under Linux.
The program BRLTTY didnt allow the driver to work properly.
It is explained here:
http://www.ladyada.net/learn/arduino/lesson0-lin.html

Thanks!

Which Linux distribution do you use?

Igga wrote:However my example.hex program is not working if i program the CM-5 under linux.

Cheers!


Humm, it's strange... which compiler/environment do you use? AVR GCC?
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by limor » Sun Dec 30, 2007 11:39 pm

Post by limor
Sun Dec 30, 2007 11:39 pm

There are a couple of C libraries for bioloid that have sanitized the original example.c from Robotis.

http://robosavvy.com/site/index.php?opt ... is_bioloid
There are a couple of C libraries for bioloid that have sanitized the original example.c from Robotis.

http://robosavvy.com/site/index.php?opt ... is_bioloid
limor
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK


9 postsPage 1 of 1
9 postsPage 1 of 1