Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,168 Views

strange make error when cross-compiling C code with DS-5 EDS on Ubuntu 12.04

Hi all, 

 

I'm trying to get through a few simple hello-world-type examples with the Altera SoC Yocto linux running on the HPS of a SoCKit. I've have altera 13.1, the embedded design suite, and DS-5 installed in Ubuntu 12.04. I've been able to boot the HPS with a linux image on a microSD successfully and interface with it from my Ubuntu laptop via both ethernet and a USB connection through Gtkterm. My problem isn't with the device, but rather cross-compiling C code on my Ubuntu system. 

 

The hello world program I'm trying to compile is straight from the examples (this is main.c): 

# include <stdio.h> int main(int argc, char **argv) { printf("'lo world...\r\n"); return(0); }  

 

and so is the Makefile: 

TARGET = my_first_hps CROSS_COMPILE = arm-linux-gnueabihf- CFLAGS = -g -Wall -I${SOCEDS_DEST_ROOT}/ip/altera/hps/altera_hps/hwlib/include LDFLAGS = -g -Wall CC = $(CROSS_COMPILE)gcc ARCH = arm# does this do anything? build: $(TARGET) $(TARGET): main.o $(CC) $(LDFLAGS) $^ -o $@ %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ .PHONY: clean clean: rm -f $(TARGET) *.a *.o *  

 

Before compiling, I make sure I run ~/altera/13.1/embedded/embedded_command_shell.sh, which to my understanding seems to just set up some environmental variables and paths. Then "make clean" works as expected, but when I type "make" I get the following error: 

john@euclid:~/PINGU_firmware/my_first_hps$ make arm-linux-gnueabihf-gcc -g -Wall -I/home/john/altera/13.1/embedded/ip/altera/hps/altera_hps/hwlib/include -c main.c -o main.o /home/john/altera/13.1/embedded/ds-5/bin/arm-linux-gnueabihf-gcc: 15: export: Illegal option -- make: *** Error 2 john@euclid:~/PINGU_firmware/my_first_hps$  

 

As far as I can tell, the error isn't actually coming from arm-linux-gnueabihf-gcc (there is no "export" command on line 15), but rather from a script that gets called inside arm-linux-gnueabihf-gcc, which is ~/altera/13.1/embedded/ds-5/sw/ARM_DS-5/userenv.sh (in which there is an "export" command on line 15), the contents of which I'll print here: 

# An sh source file to load user specific environment variables. # It should be used as: # $ . /path/to/this/file /path/to/user/config/file # Copyright (C) 2013 ARM Ltd. All rights reserved. while read line do kind=`echo $line | /usr/bin/cut -d = -f 1` name=`echo $line | /usr/bin/cut -d = -f 2` value=`echo $line | /usr/bin/cut -d = -f 3-` case $kind in "SET") eval "$name=$value" ;; "PREPEND") eval "$name=$value:\$$name" ;; "POSTPEND") eval "$name=\$$name:$value" ;; esac echo "TEST" export $name done < "$1"  

 

This is very quickly getting over my head and becoming way more trouble than I imagined a hello world example would be. Has anyone experienced this problem before? I've tried every possible combination of running environmental setup scripts that I can, but none of them make a difference. I've even totally uninstalled DS-5 and the altera EDS (even the hidden config files), but with no success. Someone working in the same group as me has gone through the example successfully using Ubuntu 12.04 and the same altera software version as well. 

 

Thanks in advance, 

J
0 Kudos
1 Reply
Altera_Forum
Honored Contributor I
57 Views

Well, I'm not sure if this is the best solution, but commenting out line 14 of ~/altera/13.1/embedded/ds-5/bin/arm-linux-gnueabihf-gcc (the line that calls the offending script) solved the issue: 

# ! /bin/sh # Copyright (C) 2013 ARM Ltd. All rights reserved. case "$0" in /*) full=$0;; *) full=`pwd`"/$0";; esac full_dir=`dirname "${full}"` SUITE_INSTALL_DIR=`cd "${full_dir}"/..; pwd` # POSIX sh does not set positional parameters when using . set -- "${SUITE_INSTALL_DIR}" "$@" . "${SUITE_INSTALL_DIR}/sw/ARM_DS-5/env.sh" if ; then set -- "$HOME/.arm/ARM_DS-5/env.ini" "$@" # . "${SUITE_INSTALL_DIR}/sw/ARM_DS-5/userenv.sh"# This line was causing compilation errors, and commenting it out solves the issue... shift fi shift exec "${SUITE_INSTALL_DIR}/sw/gcc/bin/arm-linux-gnueabihf-gcc" "$@"