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.
12366 Discussions

Can you fix stupid scripts error from 19.1 to 20.3?

tommmy
Beginner
355 Views

i can not use nios2 command to generate newlib, do you really checked the nios2eds scripts? such as nios2-newlib-gen, it can not work correctly at all! can you fix this?

and your script not compatible with wsl2 just because these lines: 

uname=$(uname -r)
if [[ $uname =~ "Microsoft" ]]; then
    _IS_WSL=1
    windows_exe=.exe
fi
 
wsl2 use "microsoft" !!!!!!!!
such stuipd!
 
 the only way to build a nios2 project correctly with newlib is to use nios2eds of quartus 18.1, ther last version before you change shell from cygwin to wsl.
0 Kudos
5 Replies
EricMunYew_C_Intel
Moderator
346 Views

Can you follow below to install:

 

1. install WSL for windows

i. https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/nios2/n2sw_nii5v2gen2.pd... (chapter 2.1)

  Note: Windows 10 build version 16215.0 or higher is the recommended operating system version.

ii. After installation has successfully completed, launch Ubuntu 18.04.

iii. Install additional distro packages required for Nios II EDS using the following commands:

 a. sudo apt-get update

b. sudo apt install wsl

 c. sudo apt install dos2unix

 d. sudo apt install make

 

2. install nios2 eclipse folder

https://www.intel.com/content/altera-www/global/en_us/index/support/support-resources/knowledge-base/...


3.  After re-installation, can you download the patch from below KDB:

https://www.intel.com/content/altera-www/global/en_us/index/support/support-resources/knowledge-base...


tommmy
Beginner
331 Views

I installed Quartus Prime Pro 20.2.0.50, please check the scripts file such as "nios2-newlib-gen"

EricMunYew_C_Intel
Moderator
307 Views

can I have your log?


EricMunYew_C_Intel
Moderator
294 Views

can you try below:

Modify <installation location>/nios2eds/sdk/bin/nios2-newlib-gen:

include the following on the top of the script, before "usage()"

uname=$(uname -r | tr A-Z a-z)

if [[ $uname =~ "microsoft" ]]; then

  windows_exe=.exe

fi


tommmy
Beginner
200 Views

I had tried before, not work. 

I am pretty sure, the function build_newlib() in this script file is not right. the STAGE_WRAPPER file not generated correctly.

STAGE_WRAPPER=$BLDDIR/build-newlib-stage-wrapper

in file " build-newlib-stage-wrapper"

#!/bin/bash
#
# A script to intercept and short-circuit the --print-multi-lib option
#
ORIGINAL_ARGS=$(echo $* | sed -e 's,/cygdrive/\([a-zA-Z]\)/,\1:/,g')
CUSTOM=
if [ "x$1" = "xnios2-elf-gcc" ]
then
CUSTOM=" -O3 -g -Wall -mno-hw-div -mhw-mul -mno-hw-mulx -mgpopt=global -fno-math-errno -mcustom-fabss=224 -mcustom-fadds=253 -mcustom-fcmpeqs=227 -mcustom-fcmpges=228 -mcustom-fcmpgts=229 -mcustom-fcmples=230 -mcustom-fcmplts=231 -mcustom-fcmpnes=226 -mcustom-fdivs=255 -mcustom-fixsi=249 -mcustom-floatis=250 -mcustom-fmuls=252 -mcustom-fnegs=225 -mcustom-fsubs=254 "
fi
while [ $# -gt 0 ]
do
case "$1" in
--print-multi-lib)
echo ".;"
exit 0
;;
*)
;;
esac
shift
done
eval $ORIGINAL_ARGS $CUSTOM
 
error log :
 
[my private path]/newlib-build-tmp/build-newlib-stage-wrapper: line 23: nios2-elf-cc: command not found
 
 it shows that the suffix is missing in build-newlib-stage-wrapper, when use command "STAGE_WRAPPER {cmd}"
but if  I change the var ORIGINAL_ARGS and add suffix ".exe"  in file "nios2-newlib-gen"
 
##add suffix for WSL
uname=$(uname -r)
uname=$(echo ${uname} | tr 'A-Z' 'a-z')
if [[ "${uname}" =~ "microsoft" ]]
then
cat >>"$STAGE_WRAPPER" <<"EOF"
echo "ORIGINAL_ARGS = ${ORIGINAL_ARGS}"
#ORIGINAL_ARGS=$(echo ${ORIGINAL_ARGS} | sed -e "s,-B, -B,g")
#ORIGINAL_ARGS=$(echo ${ORIGINAL_ARGS} | sed -e "s,-i, -i,g")
#ORIGINAL_ARGS=$(echo ${ORIGINAL_ARGS} | sed -e "s,^nios2-elf-cc,nios2-elf-gcc,g")
echo "ORIGINAL_ARGS = ${ORIGINAL_ARGS}"
cmd=$(echo $ORIGINAL_ARGS | awk 'NR==1{print $1}')
echo "cmd = $cmd"
ORIGINAL_ARGS=$(echo ${ORIGINAL_ARGS} | sed -e "s,^$cmd,$cmd.exe,g")

EOF
fi
 
it still not work. in newlib tmporary config.log shows that it still not add suffix .exe when configure call nios2-elf-gcc
 
So, it is complicated to fix  script bugs to compile newlib in wsl by using mingw32 tool chain because newlib configure not add suffix for command even throught add suffix in STAGE_WRAPPER file!
 
I doubt!  Why Quartus not just migrate tool chain for linux platform and just remove mingw32 tool chain which has annoying suffix ".exe" because of using WSL , nearly a real linux enviroment!!!!!
 
So, I copy tool chain "H-x86_64-pc-linux-gnu" from linux platform 
and edit "niso2_command_shell.sh" like this:
 
# if grep -q Microsoft /proc/version; then
    if [ -d "${SOPC_KIT_NIOS2}/bin/gnu/H-x86_64-mingw32/bin" ]; then
        env_var_prepend ${SOPC_KIT_NIOS2}/bin/gnu/H-x86_64-mingw32/bin
    else
        env_var_prepend ${SOPC_KIT_NIOS2}/bin/gnu/H-i686-mingw32/bin
    fi
# else
    if [ -d "${SOPC_KIT_NIOS2}/bin/gnu/H-x86_64-pc-linux-gnu/bin" ]; then
        env_var_prepend ${SOPC_KIT_NIOS2}/bin/gnu/H-x86_64-pc-linux-gnu/bin
    else
        env_var_prepend ${SOPC_KIT_NIOS2}/bin/gnu/H-i686-pc-linux-gnu/bin
    fi
# fi
 
comment if-else-if 
and doses not need edit any thing in "nios2-newlib-gen"
 
Be brief:
 there are two methods to solve these issues caused by wsl enviroment:
1. just use nios2eds with Qurtus 18.1 pro, which use cygwin shell enviroment, works perfect on windows platform.
2. copy tool chain "H-x86_64-pc-linux-gnu" form linux version's Quartus Pro to  directory "niso2eds/bin/gnu/", so in makefile, use tool chain "H-x86_64-mingw32" and when compile newlib, use "H-x86_64-pc-linux-gnu" by itself. 
 
[Advice]: 
 it is too complicated to use var WINDOWS_EXE,
If you really want try WSL or WLS2, WHY NOT JUST MINGRATE LINUX TOOL CHAIN AND ERVERY RELATED SCRIPT to WSL enviroment and DISCARD "H-x86_64-mingw32" TOOL CHAIN!!!!!!!!
OR
rollback to use cygwin!
 
these issues had been existed for three years since you discarded cygwin and started to use WSL. CAN ANYBODY FIX IT ?
Reply