Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

sof2flash

Altera_Forum
Honored Contributor II
5,534 Views

Hi All, 

I am using Ubuntu 11.1 to use Quartus, the web version, and I have been putting stuff together for a while. 

However now it's time to put a design onto my dev board (the Embedded Dev board).  

As with all things I need to pipeclean the flow so I have decided to use the my first fpga as a good and known design to start with. 

I've successfully generated the SOF and now attempting to generate the flash file as per the instructions provided by the web server on the dev board (which I think is superb). 

When command sof2flash is entered with the appropriate settings I get a response being (from memory)  

Line 2 Bad Substitution.  

This is from one of the sh scripts that gets called up, think sj_jar ??? 

One of the first few anyway. 

 

So it's probably a short somewhere between the ears but does anyone know of any classic pipe cleaning flow issues that it would be good to know about and thus avoid ? 

 

Thank you for any help :) 

 

Best Regards 

 

Andre'
0 Kudos
16 Replies
Altera_Forum
Honored Contributor II
2,772 Views

that's a rather odd message, I don't remember seeing anything like that... Do you have any spaces if your file paths/names, or any special characters?

0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

seems like an Ubuntu issue 

 

Ubuntu 11.1 Quartus II 11.0sp1 - sof2flash failed 

CentOS 5.0 Quartus II 11.0sp1 - sof2flash passes 

 

it would be worth reporting this to Altera since the next release will support Ubuntu, but you may be out of luck getting official support in 11.1. you might run CentOS 4/5 in a VM if you don't feel like debugging the issue
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

Hi,  

here is the message  

 

/home/andre/altera/11.0sp1/nios2eds/bin/sh_jar.sh: 2: Bad substitution 

 

the line that appears to cause the problem is 

 

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

 

I am running this from a Bash shell, I've also tried it from the nios command line available from the Qsys (sp).
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

for reference here's the output of sof2flash with no arguments: 

 

$ sof2flash /home/tools/altera/11.0sp1/nios2eds/bin/sh_jar.sh: 2: Bad substitution
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

Hi Pancake, 

Thanks for that, I'll pass the information on. I'll see if I can install centos in a VM, but this is a pain. The dev board is very expensive and it means that I can't actually use it :(. 

 

best regards 

 

Andre'
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

sh_jar.sh uses /bin/sh which is actually dash. changing it to /bin/bash doesn't fix it 

 

here's the line in question: 

 

FILEPATH=${0//\\/\/}
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

Thanks guys :)

0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

did you fix it? 

 

the FILEPATH is trying to get the path to the script - i'd like to try and debug the line when i've got time
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

Hi All, 

I've contacted Altera and although Ubuntu isn't on the supported list they have come back with an answer, I've copied below. 

 

One point that we have found with Ubuntu. Most things do work well, however the issue that you mention in your note is very similar to some other .sh issues that we have seen. On Ubuntu, this is commonly resolved by changing the symbolic link for /bin/sh from /bin/dash to /bin/bash: 

 

sudo rm /bin/sh 

sudo ln -s /bin/bash /bin/sh 

 

Dash and Bash have a slightly different syntax, and that gets us around most issues.  

 

I've given it a shot within the nios2 command shell in Qsys and it does indeed generate a flash file. I've not tried it on the board yet but this is significantly better than before. 

 

Thanks to Stef and Kris over at Altera. 

 

 

0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

i thought i tried editing the# ! in the script in question and it didn't fix it. anyhow thanks for reporting back

0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

Great thread. I just ran into this today as well. However, I still can't get sof2flash to work.  

 

I'm on Ubuntu 11.04 Natty 64-bit with Quartus 11.0 SP1 installed. 

 

fast@fourier:qout $ sof2flash --input=proto0.sof --output=proto0.flash --offset=0x00AC0000 --pfl --optionbit=0x00018000 --programmingmode=PS 

Wed Nov 30 @ 10:19 AM (svn:rev 5186:mod ) 

fast(2051)@fourier:qout $ 

 

No love whatsoever. I don't get an output file, and I get no errors or warnings. Just silent failure. :( Unfortunately, I'm no scripting pro. 

 

I relinked sh to bash instead of dash, but still get the same failure. Does anyone have this working on 64-bit Ubuntu? Am I missing a step?
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

I tracked down the problem to $SOMEDIR/11.0/nios2eds/bin/pl_jar.pl 

 

For some reason the variable nios2sh_JRE is set to "/linux/jre/bin/java" 

I just added the line: 

$nios2sh_JRE = "$SOMEDIR/11.0/quartus/linux/jre/bin/java"; 

right before the exit system line and it ran. 

 

I also edited: 

$SOMEDIR/11.0/nios2eds/bin/sof2flash 

$SOMEDIR/11.0/nios2eds/bin/sh_jar.sh 

to reference /bin/bash instead of /bin/sh
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

Thanks Hendry. That resolved it. Great perl'ing.

0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

This also fixes elf2flash. Nice.

0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

Hi, 

 

Thanks for sharing this information! 

 

Tal.
0 Kudos
Altera_Forum
Honored Contributor II
2,772 Views

There is a bug from quartus: 

pl_jar.pl uses sh_launch.pm which is using QUARTUS_ROOTDIR as rootdir path. But all other tools are using QUARTUS_ROOTDIR_OVERRIDE 

 

So you need to add the folowing lines to .bashrc and everything works: 

export QUARTUS_ROOTDIR=~/altera/11.1sp1/quartus 

export QUARTUS_ROOTDIR_OVERRIDE=$QUARTUS_ROOTDIR 

 

I'll add the description for this fix to: 

http://www.alterawiki.com/wiki/quartus_for_debian_wheezy
0 Kudos
Reply