alchitry / Alchitry-Labs

https://alchitry.com/
GNU General Public License v3.0
28 stars 12 forks source link

Alchitry 1.2.5 Cannot Build Default Project (Lucid or Verilog) #31

Closed BrianCechmanek closed 3 years ago

BrianCechmanek commented 3 years ago

May be related to #21 .

Using the base files for both Lucid and Verilog projects, Build Project fails:

Starting iceCube2...

C:\Program Files\Alchitry\Alchitry Labs>SET TCL_LIBRARY=C:\lscc\iCEcube2.2020.12\\Aldec\Active-HDL\tcl\lib\tcl 

C:\Program Files\Alchitry\Alchitry Labs>SET LM_LICENSE_FILE=C:\Users\USER\Documents\FPGA\license.dat 

C:\Program Files\Alchitry\Alchitry Labs>SET SYNPLIFY_PATH=C:\lscc\iCEcube2.2020.12\\synpbase 

C:\Program Files\Alchitry\Alchitry Labs>SET SBT_DIR=C:\lscc\iCEcube2.2020.12\\sbt_backend 

C:\Program Files\Alchitry\Alchitry Labs>C:\lscc\iCEcube2.2020.12\\sbt_backend\bin\win32\opt\synpwrap\synpwrap.exe -prj "C:\Users\USER\Documents\FPGA\rstLed\work\alchitry_syn.prj" -log "C:\Users\USER\Documents\FPGA\rstLed\work\icelog.log" 
Copyright (C) 1992-2014 Lattice Semiconductor Corporation. All rights reserved.
Error of dumping file C:\Users\USER\Documents\FPGA\rstLed\work\icelog.log, 'stdout.log' is instead. 
Synthesis exit by 0.

C:\Program Files\Alchitry\Alchitry Labs>C:\lscc\iCEcube2.2020.12\\Aldec\Active-HDL\BIN\tclsh85.exe "C:\Users\USER\Documents\FPGA\rstLed\work\iCEcube2_flow.tcl" 
Error : can not print out log file stdout.log
The system cannot find the path specified.

Bin file (C:\Users\USER\Documents\FPGA\rstLed\work\alchitry_imp\sbt\outputs\bitmap\cu_top_0_bitmap.bin) could not be found! The build probably failed.

iCEcube2 version: 2020.12.27943 , Edit: this is for the Cu+ base project template.

tkphd commented 3 years ago

Similar error on Debian Linux for the Alchitry Cu rst2led tutorial.

iCEcube2

Starting iceCube2...
/opt/lscc/iCEcube2//synpbase/bin/synplify_pro: 137: [: unexpected operator
/opt/lscc/iCEcube2//synpbase/bin/synplify_pro: 151: [: !=: argument expected
/opt/lscc/iCEcube2//synpbase/bin/synplify_pro: 321: /opt/lscc/iCEcube2/synpbase/bin/config/execute: Syntax error: "(" unexpected (expecting ";;")
Error : can not print out log file stdout.log
Copyright (C) 1992-2014 Lattice Semiconductor Corporation. All rights reserved.
Child process exit with 2.
Error of dumping file alchitry/workspace/button2led/work/icelog.log, 'stdout.log' is instead. 
Synthesis exit by 2.

Run edifparser ...
{/opt/lscc/iCEcube2//sbt_backend/bin/linux/opt/edifparser} {/opt/lscc/iCEcube2//sbt_backend/devices/ICE40P08.dev} {alchitry/workspace/button2led/work/alchitry_imp/cu_top_0.edf} {alchitry/workspace/button2led/work/alchitry_imp/sbt/netlist}  -p"CB132"  {-y} {"alchitry/workspace/button2led/work/constraint/merged_constraint.pcf "} --devicename  iCE40HX8K
Lattice Semiconductor Corporation  Edif Parser
Release:        2020.12.27943
Build Date:     Dec 10 2020 17:23:29

Parsing edif file: alchitry/workspace/button2led/work/alchitry_imp/cu_top_0.edf...
Error: ParseEDIF alchitry/workspace/button2led/work/alchitry_imp/cu_top_0.edf failed
Kparser Unable to open alchitry/workspace/button2led/work/alchitry_imp/cu_top_0.edf
child process exited abnormally
edifparser failed:CHILDSTATUS 4554 1

Bin file (alchitry/workspace/button2led/work/alchitry_imp/sbt/outputs/bitmap/cu_top_0_bitmap.bin) could not be found! The build probably failed.

After installing the deprecated arachne-pnr tool, the example builds, uploads to the Cu, and runs correctly.

alchitry commented 3 years ago

The original problem was caused by the new iCEcube2 version not including the tcl script interpreter. This is fixed in 1.2.6.

The second problem is the build tools haven't been updated for the open source toolchain in a while and is unrelated to this bug as Brian is using iCEcube2. I'll open a new bug for updating the open source tools.

SengerM commented 2 years ago

I am using Alchitry Labs 1.2.7, iCEcube2 2020.12.27943, on a Ubuntu 20.04 machine, trying to upload the "first FPGA project" to the Cu and I am getting

Starting iceCube2...
Copyright (C) 1992-2014 Lattice Semiconductor Corporation. All rights reserved.
/home/alf/lscc/iCEcube2.2020.12/synpbase/bin/synplify_pro: 137: [: unexpected operator
Child process exit with 2.
/home/alf/lscc/iCEcube2.2020.12/synpbase/bin/synplify_pro: 151: [: !=: argument expected
/home/alf/lscc/iCEcube2.2020.12/synpbase/bin/synplify_pro: 321: /home/alf/lscc/iCEcube2.2020.12/synpbase/bin/config/execute: Syntax error: "(" unexpected (expecting ";;")
Synthesis exit by 2.

Edit (found an easy solution)

Found a fix to this, see here and/or here. Basically the problem is that all the scripts in the iCEcube2 directory start with #!/bin/sh instead of #!/bin/bash. The solution is just to replace it in each file it appears within the iCEcube2.2020.12 installation directory. You can do it by hand, however they are a lot of files, or with a recursive script that searches for the string and replaces it. I have made a Python script for this:

from pathlib import Path
import fileinput

def is_binary_file(file_path):
    # https://stackoverflow.com/a/7392391/8849755
    textchars = bytearray({7,8,9,10,12,13,27} | set(range(0x20, 0x100)) - {0x7f})
    is_binary_string = lambda bytes: bool(bytes.translate(None, textchars))
    return is_binary_string(open(file_path, 'rb').read(1024))

def replace_in_file(file_path, search_text, new_text):
    # https://stackoverflow.com/a/58217364/8849755
    with fileinput.input(file_path, inplace=True) as file:
        for line in file:
            new_line = line.replace(search_text, new_text)
            print(new_line, end='')

def recursive_walk_fixing(path):
    for p in path.iterdir():
        if p.is_dir():
            recursive_walk_fixing(p)
        else: # It is a file, we do what we want.
            if is_binary_file(p):
                continue
            try:
                replace_in_file(p, '#!/bin/sh', '#!/bin/bash')
            except UnicodeDecodeError as e:
                pass

if __name__=='__main__':
    iCEcube_path = Path(input('Path to "iCEcube2" directory? (e.g. "/home/my_name/lscc/iCEcube2.2020.12") '))
    if input(f'This script will replace "#!/bin/sh" with "#!/bin/bash" in all the scripts within the directory you provided. Write "yes" and press enter to continue, or just press enter to quit. ').lower() != 'yes':
        exit()
    recursive_walk_fixing(Path(iCEcube_path))
mattoppenheim commented 9 months ago

Thanks for the information. In Debian I recursively replaced #!/bin/sh with #!/bin/shell with this one liner:

find -type f -print0 | xargs -0 sed -i -e 's/^#!\/bin\/sh/#!\/bin\/bash/g'