Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12409 Discussions

Trouble building project with Cygwin

Altera_Forum
Honored Contributor II
1,264 Views

Hello, 

 

I am trying to automate my build process, so I installed Cygwin to build my NIOS-II software projects. I am able to build my project with the NIOS II software build tools for Eclipse GUI, but I run into a problem when build from the command line. 

 

I believe I have added the proper directories to my search path, but when I make, I still get a command not found error. I have included the error message below. Any help with solving this will be very much appreciated.  

 

Thanks, 

Nsatyana 

 

$ make 

Info: Building ../hello_0_bsp/ 

C:/altera/11.0/nios2eds/bin/gnu/H-i686-mingw32/bin/make --no-print-directory -C 

../hello_0_bsp/ 

[BSP build complete] 

Info: Linking hello_0.elf 

nios2-elf-g++ -T'../hello_0_bsp//linker.x' -msys-crt0='../hello_0_bsp//obj/HAL/ 

src/crt0.o' -msys-lib=hal_bsp -L../hello_0_bsp/ -Wl,-Map=hello_0.map -O0 -g 

-Wall -EL -mno-hw-div -mhw-mul -mno-hw-mulx -o hello_0.elf obj/hello_world.o 

-lm 

nios2-elf-insert hello_0.elf --thread_model hal --cpu_name cpu --simulation_enab 

led false --id 0 --sidp 0x10022c90 --timestamp 1319134118 --stderr_dev jtag_uart 

--stdin_dev jtag_uart --stdout_dev jtag_uart --sopc_system_name cycloneIII_3c12 

0_dev_niosII_standard_sopc --quartus_project_dir "c:/altera/11.0/kits/CycloneIII 

_3C120_FPGA/examples/NS_cycloneIII_3c120_dev_niosII_standard" --jdi C:/altera/11 

.0/kits/CycloneIII_3C120_FPGA/examples/NS_cycloneIII_3c120_dev_niosII_standard/c 

ycloneIII_3c120_dev_niosII_standard.jdi 

C:\altera\11.0\nios2eds\bin\nios2-stackreport: line 6: /cygdrive/c/altera/11.0/n 

/sh_pl.sh: No such file or directory 

C:\altera\11.0\nios2eds\bin\nios2-stackreport: line 7: $'\r': command not found 

make: *** [hello_0.elf] Error 127 

make: *** Deleting file `hello_0.elf'
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
405 Views

I'd look at the nios2-stackreport file, I think it is being executed as a shell script - but may be some binary file. 

OTOH I'm not at all clear why Altera need to use java to hack elf binaries!
Altera_Forum
Honored Contributor II
405 Views

nios2stackreport is a bash script and its contents are as follows:# !/bin/bash 

FILEPATH=${0//\\/\/} 

_this_script=$(cd ${FILEPATH%[\\/]*} && echo $(pwd 2>/dev/null)/${FILEPATH##*/}) 

_this_script_dir=$(dirname ${_this_script}) 

export SOPC_KIT_NIOS2=${_this_script_dir/\/bin} 

. "${_this_script_dir}/sh_pl.sh" $@ 

 

I was having trouble with the last line. sh_pl.sh was not being properly called, so I located sh_pl.sh on my system and called it explicitly using its absolute path. and i got the following error message: 

 

$ make 

Info: Building ../hello_0_bsp/ 

C:/altera/11.0/nios2eds/bin/gnu/H-i686-mingw32/bin/make --no-print-directory -C 

../hello_0_bsp/ 

[BSP build complete] 

Info: Compiling hello_world.c to obj/hello_world.o 

nios2-elf-gcc -xc -MP -MMD -c -I../hello_0_bsp//drivers/inc -I../hello_0_bsp//HA 

L/inc -I../hello_0_bsp/ -I../hello_0_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pi 

pe -D__hal__ -DALT_NO_INSTRUCTION_EMULATION -DALTERA_TRIPLE_SPEED_MAC -DALT_SING 

LE_THREADED -O0 -g -Wall -EL -mno-hw-div -mhw-mul -mno-hw-mulx -o obj/hell 

o_world.o hello_world.c 

Info: Linking hello_0.elf 

nios2-elf-g++ -T'../hello_0_bsp//linker.x' -msys-crt0='../hello_0_bsp//obj/HAL/ 

src/crt0.o' -msys-lib=hal_bsp -L../hello_0_bsp/ -Wl,-Map=hello_0.map -O0 -g 

-Wall -EL -mno-hw-div -mhw-mul -mno-hw-mulx -o hello_0.elf obj/hello_world.o 

-lm 

nios2-elf-insert hello_0.elf --thread_model hal --cpu_name cpu --simulation_enab 

led false --id 0 --sidp 0x10022c90 --timestamp 1319134118 --stderr_dev jtag_uart 

--stdin_dev jtag_uart --stdout_dev jtag_uart --sopc_system_name cycloneIII_3c12 

0_dev_niosII_standard_sopc --quartus_project_dir "c:/altera/11.0/kits/CycloneIII 

_3C120_FPGA/examples/NS_cycloneIII_3c120_dev_niosII_standard" --jdi C:/altera/11 

.0/kits/CycloneIII_3C120_FPGA/examples/NS_cycloneIII_3c120_dev_niosII_standard/c 

ycloneIII_3c120_dev_niosII_standard.jdi 

perl: warning: Setting locale failed. 

perl: warning: Please check that your locale settings: 

LC_ALL = (unset), 

LANG = "C.UTF-8" 

are supported and installed on your system. 

perl: warning: Falling back to the standard locale ("C"). 

Can't locate sh_launch.pm in @INC (@INC contains: /cygdrive/c/altera/11.0/nios2e 

/bin C:/PROGRA~1/MKS/Toolkit/etc/perl/lib C:/PROGRA~1/MKS/Toolkit/etc/perl/lib C 

:/PROGRA~1/MKS/Toolkit/etc/perl/lib/site_perl C:/PROGRA~1/MKS/Toolkit/reskit/etc 

/perl/lib/i386 .) at C:\altera\11.0\nios2eds\bin\nios2-stackreport.pl line 1. 

BEGIN failed--compilation aborted at C:\altera\11.0\nios2eds\bin\nios2-stackrepo 

rt.pl line 1. 

make: *** [hello_0.elf] Error 2 

make: *** Deleting file `hello_0.elf' 

 

I have no idea how to begin debugging this. I just commented out the last line from nios2-stackreport and the build completes succesfully. I know this work around is going to come back to haunt me later, but it will do for now. Here are the contents of sh_pl.sh 

# !/bin/sh 

PERL5LIB=`cygpath -u "$SOPC_KIT_NIOS2/bin"` perl "${SH_PL:-$0.pl}" $@ 

 

Hopefully this step is not too important, and leaving it out won't affect my build.
Altera_Forum
Honored Contributor II
405 Views

Some observations - not that they probably affect your problem! 

 

Those scripts probably shouldn't be assuming that $0 contains the absolute path of the script. If a unix kernel processes the# ! it has to set $0 to something the process can open to get the script (which is why it is usually the full path), but the actual contents aren't well defined - it can be /dev/fd/n. 

 

The $@ should be "$@" in both scripts - otherwise the parameters are subject to field splitting (bad news if there are any embedded spaces). 

 

Might be worth setting LANG=C before running perl.
Reply