m-labs / artiq

A leading-edge control system for quantum information experiments
https://m-labs.hk/artiq
GNU Lesser General Public License v3.0
437 stars 201 forks source link

Kasli-SoC build instructions fail to build #2578

Closed jbqubit closed 1 month ago

jbqubit commented 2 months ago

The updated ARTIQ developer build documentation provides several methods for building for Kasli-SoC. Both methods fail for various reasons. Tests are conducted on a system that successfully builds for kasli.

nix makeArtiqZynqPackage

$ vivado
****** Vivado v2022.2 (64-bit)
  **** SW Build 3671981 on Fri Oct 14 04:59:54 MDT 2022
  **** IP Build 3669848 on Fri Oct 14 08:30:02 MDT 2022
    ** Copyright 1986-2022 Xilinx, Inc. All Rights Reserved.

$ nix build --print-build-logs --impure --expr 'let fl = builtins.getFlake "git+https://git.m-labs.hk/m-labs/artiq-zynq?ref=release-8"; in (fl.makeArtiqZynqPackage {target="kasli_soc"; variant="master"; json=/home/britton/experiment/cryo0/cryo0.json;}).kasli_soc-master-sd' 

kasli_soc-master-gateware> DIO (EEM0) starting at RTIO channel 0x000000
kasli_soc-master-gateware> DIO (EEM1) starting at RTIO channel 0x00000c
kasli_soc-master-gateware> Urukul (EEM2) starting at RTIO channel 0x000014
kasli_soc-master-gateware> Urukul (EEM4) starting at RTIO channel 0x00001a
kasli_soc-master-gateware> Sampler (EEM6) starting at RTIO channel 0x000020
kasli_soc-master-gateware> Zotino (EEM10) starting at RTIO channel 0x000023
kasli_soc-master-gateware> USER LED at RTIO channel 0x000026
kasli_soc-master-gateware> USER LED at RTIO channel 0x000027
kasli_soc-master-gateware> /etc/profile: line 37: /opt/Xilinx/Vivado/2022.2/settings64.sh: No such file or directory
kasli_soc-master-gateware> Traceback (most recent call last):
kasli_soc-master-gateware>   File "/nix/store/a2iy41gccss952qhh8vnaivxjla29alq-gateware/kasli_soc.py", line 672, in <module>
kasli_soc-master-gateware>     main()
kasli_soc-master-gateware>   File "/nix/store/a2iy41gccss952qhh8vnaivxjla29alq-gateware/kasli_soc.py", line 668, in main
kasli_soc-master-gateware>     soc.build(build_dir=args.g)
kasli_soc-master-gateware>   File "/nix/store/vbv516vz6qi4m4wgavbdb1m1qwq7qnc4-python3-3.11.9-env/lib/python3.11/site-packages/migen_axi/integration/soc_core.py", line 169, in build
kasli_soc-master-gateware>     self.platform.build(self, *args, **kwargs)
kasli_soc-master-gateware>   File "/nix/store/vbv516vz6qi4m4wgavbdb1m1qwq7qnc4-python3-3.11.9-env/lib/python3.11/site-packages/migen/build/xilinx/platform.py", line 59, in build
kasli_soc-master-gateware>     return self.toolchain.build(self, *args, **kwargs)
kasli_soc-master-gateware>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
kasli_soc-master-gateware>   File "/nix/store/vbv516vz6qi4m4wgavbdb1m1qwq7qnc4-python3-3.11.9-env/lib/python3.11/site-packages/migen/build/xilinx/vivado.py", line 224, in build
kasli_soc-master-gateware>     _run_vivado(build_name)
kasli_soc-master-gateware>   File "/nix/store/vbv516vz6qi4m4wgavbdb1m1qwq7qnc4-python3-3.11.9-env/lib/python3.11/site-packages/migen/build/xilinx/vivado.py", line 69, in _run_vivado
kasli_soc-master-gateware>     raise OSError("Subprocess failed")
kasli_soc-master-gateware> OSError: Subprocess failed
kasli_soc-master-gateware> 
error: builder for '/nix/store/bs3sksq2xlx8iw9dgjldfn224aq1r6fq-kasli_soc-master-gateware.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/a3s5lylm1rqlvb9jam38bfi3fgf7sb5v-kasli_soc-master-sd.drv' failed to build

Zynq incremental build

$ git status
On branch release-8
Your branch is up to date with 'origin/release-8'.

$ pwd
~/experiment/artiq-zynq/src

$ rm -rf ~/experiment/artiq-zynq/build

$ gateware/kasli_soc.py -g ../build/gateware /home/britton/experiment/cryo0/cryo0.json

$ make TARGET=kasli_soc GWARGS="/home/britton/experiment/cryo0/cryo0.json" runtime
mkdir -p ../build
python gateware/kasli_soc.py -r ../build/pl.rs -c ../build/rustc-cfg -m ../build/mem.rs /home/britton/experiment/cryo0/cryo0.json
DIO (EEM0) starting at RTIO channel 0x000000
DIO (EEM1) starting at RTIO channel 0x00000c
Urukul (EEM2) starting at RTIO channel 0x000014
Urukul (EEM4) starting at RTIO channel 0x00001a
Sampler (EEM6) starting at RTIO channel 0x000020
Zotino (EEM10) starting at RTIO channel 0x000023
USER LED at RTIO channel 0x000026
USER LED at RTIO channel 0x000027
cd runtime && \
XBUILD_SYSROOT_PATH=`pwd`/../../build/sysroot \
cargo xbuild --release \
    --target-dir ../../build/firmware \
    --no-default-features --features=target_kasli_soc
WARNING: There is no root package to read the cargo-xbuild config from.
   Compiling core v0.0.0 (/nix/store/z7jzg45rdh4nzaa35sfj1j6bimr798j1-rust-1.51.0-nightly-2021-01-28-c0b64d97b/lib/rustlib/src/rust/library/core)
   Compiling compiler_builtins v0.1.39
   Compiling rustc-std-workspace-core v1.99.0 (/nix/store/z7jzg45rdh4nzaa35sfj1j6bimr798j1-rust-1.51.0-nightly-2021-01-28-c0b64d97b/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/tmp/nix-shell.3YH9ia/nix-shell.QxI6at/cargo-xbuild63MSkH)
    Finished release [optimized + debuginfo] target(s) in 4.71s
   Compiling vcell v0.1.3
   Compiling log v0.4.17
   Compiling bitflags v1.3.2
   Compiling cc v1.0.77
   Compiling bit_field v0.10.1
   Compiling cfg-if v1.0.0
   Compiling nb v1.0.0
   Compiling byteorder v1.4.3
   Compiling pin-utils v0.1.0
   Compiling void v1.0.2
   Compiling managed v0.7.2
   Compiling compiler_builtins v0.1.39
   Compiling proc-macro2 v1.0.43
   Compiling semver v0.1.20
   Compiling build_zynq v0.0.0 (/home/britton/experiment/artiq-zynq/src/libbuild_zynq)
   Compiling quote v1.0.21
   Compiling unicode-ident v1.0.5
   Compiling syn v1.0.101
   Compiling build_const v0.2.2
   Compiling futures-core v0.3.25
   Compiling r0 v1.0.0
   Compiling futures-task v0.3.25
   Compiling linked_list_allocator v0.8.11
   Compiling futures-channel v0.3.25
   Compiling futures-sink v0.3.25
   Compiling futures-util v0.3.25
   Compiling autocfg v1.1.0
   Compiling libm v0.2.6
   Compiling cfg-if v0.1.10
   Compiling log_buffer v1.2.0
   Compiling cslice v0.3.0
   Compiling pin-project-lite v0.2.9
   Compiling arrayvec v0.7.4
   Compiling futures-io v0.3.25
   Compiling volatile-register v0.2.1
   Compiling nb v0.1.3
   Compiling smoltcp v0.7.5
   Compiling embedded-hal v0.2.7
   Compiling libregister v0.0.0 (/nix/store/0wgl1kcha6gh1z9brvg8vnrp4p7dwp88-source/libregister)
   Compiling rustc_version v0.1.7
   Compiling crc v1.8.1
   Compiling libcortex_a9 v0.0.0 (/nix/store/0wgl1kcha6gh1z9brvg8vnrp4p7dwp88-source/libcortex_a9)
   Compiling libboard_artiq v0.0.0 (/home/britton/experiment/artiq-zynq/src/libboard_artiq)
   Compiling ksupport v0.1.0 (/home/britton/experiment/artiq-zynq/src/libksupport)
   Compiling runtime v0.1.0 (/home/britton/experiment/artiq-zynq/src/runtime)
   Compiling tar-no-std v0.1.8 (https://git.m-labs.hk/M-Labs/tar-no-std?rev=2ab6dc5#2ab6dc58)
   Compiling core_io v0.1.20210325
   Compiling num-traits v0.2.15
   Compiling dyld v0.1.0 (/home/britton/experiment/artiq-zynq/src/libdyld)
   Compiling libsupport_zynq v0.0.0 (/nix/store/0wgl1kcha6gh1z9brvg8vnrp4p7dwp88-source/libsupport_zynq)
   Compiling libc v0.1.0 (/home/britton/experiment/artiq-zynq/src/libc)
   Compiling unwind v0.0.0 (/home/britton/experiment/artiq-zynq/src/libunwind)
   Compiling fatfs v0.3.5
   Compiling libasync v0.0.0 (/nix/store/0wgl1kcha6gh1z9brvg8vnrp4p7dwp88-source/libasync)
   Compiling libboard_zynq v0.0.0 (/nix/store/0wgl1kcha6gh1z9brvg8vnrp4p7dwp88-source/libboard_zynq)
warning: In file included from ../llvm_libunwind/src/libunwind.cpp:22:
warning: ../llvm_libunwind/src/UnwindCursor.hpp:1437:51: warning: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Wbitwise-conditional-parentheses]
warning:   _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
warning:                                       ~~~~~~~~~~~ ^
warning: ../llvm_libunwind/src/UnwindCursor.hpp:1437:51: note: place parentheses around the '|' expression to silence this warning
warning:   _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
warning:                                                   ^
warning:                                       (          )
warning: ../llvm_libunwind/src/UnwindCursor.hpp:1437:51: note: place parentheses around the '?:' expression to evaluate it first
warning:   _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
warning:                                                   ^
warning:                                           (                )
warning: ../llvm_libunwind/src/UnwindCursor.hpp:1437:51: warning: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Wbitwise-conditional-parentheses]
warning:   _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
warning:                                       ~~~~~~~~~~~ ^
warning: ../llvm_libunwind/src/UnwindCursor.hpp:1884:41: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm>::getInfoFromEHABISection' requested here
warning:     if (sects.arm_section != 0 && this->getInfoFromEHABISection(pc, sects))
warning:                                         ^
warning: ../llvm_libunwind/src/UnwindCursor.hpp:881:23: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm>::setInfoBasedOnIPRegister' requested here
warning:                       UnwindCursor(unw_context_t *context, A &as);
warning:                       ^
warning: ../llvm_libunwind/src/libunwind.cpp:66:7: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm>::UnwindCursor' requested here
warning:       UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
warning:       ^
warning: ../llvm_libunwind/src/UnwindCursor.hpp:1437:51: note: place parentheses around the '|' expression to silence this warning
warning:   _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
warning:                                                   ^
warning:                                       (          )
warning: ../llvm_libunwind/src/UnwindCursor.hpp:1437:51: note: place parentheses around the '?:' expression to evaluate it first
warning:   _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
warning:                                                   ^
warning:                                           (                )
warning: 2 warnings generated.
   Compiling libconfig v0.1.0 (/nix/store/0wgl1kcha6gh1z9brvg8vnrp4p7dwp88-source/libconfig)
   Compiling io v0.0.0 (/home/britton/experiment/artiq-zynq/src/libio)
   Compiling dwarf v0.0.0 (/home/britton/experiment/artiq-zynq/src/libdwarf)
   Compiling futures-macro v0.3.25
   Compiling num-derive v0.3.3
   Compiling async-recursion v0.3.2
   Compiling futures v0.3.25
error[E0425]: cannot find function `sed_spread_enable_write` in module `csr::rtio_core`
   --> runtime/src/rtio_mgt.rs:910:25
    |
910 |         csr::rtio_core::sed_spread_enable_write(val);
    |                         ^^^^^^^^^^^^^^^^^^^^^^^ not found in `csr::rtio_core`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
error: could not compile `runtime`

To learn more, run the command again with --verbose.
make: *** [Makefile:24: ../build/firmware/armv7-none-eabihf/release/runtime] Error 101

cryo0.json

$ cat /home/britton/experiment/cryo0/cryo0.json 
{
    "target": "kasli_soc",
    "variant": "brittonlab-cryo0",
    "hw_rev": "v1.1",
    "base": "standalone",
    "core_addr": "192.168.1.44",
    "peripherals": [
        {
            "type": "dio",
            "hw_rev": "v1.2",
            "ports": [0],
            "bank_direction_low": "input",
            "bank_direction_high": "output",
            "edge_counter": true
        },
        {
            "type": "dio",
            "hw_rev": "v1.2",
            "ports": [1],
            "bank_direction_low": "output",
            "bank_direction_high": "output"
        },
        {
            "type": "urukul",
            "hw_rev": "v1.3",
            "ports": [2, 3],
            "clk_sel": 1,
            "refclk": 100e6,
            "pll_vco": 5,
            "pll_n": 40
        },
        {
            "type": "urukul",
            "hw_rev": "v1.3",
            "ports": [4, 5],
            "clk_sel": 1,
            "refclk": 100e6,
            "pll_vco": 5,
            "pll_n": 40
        },
    {
        "type": "sampler",
        "hw_rev": "v1.2",
        "ports": [6,7]
    }, 
        {
            "type": "zotino",
            "hw_rev": "v1.1",
            "ports": [10]
        }
   ]
}
SimonRenblad commented 2 months ago

/opt/Xilinx/Vivado/2022.2/settings64.sh: No such file or directory

Did you run nix develop git+https://git.m-labs.hk/m-labs/artiq-zynq\?ref=release-8 before running this command? I copied the provided JSON and was able to build it using both methods on my machine, as long as I am in the devShell. For the incremental method, I also run the make command with the -B flag to ensure that the manifests get updated correctly.

gateware/kasli_soc.py -g ../build/gateware /home/britton/experiment/cryo0/cryo0.json

Did this command not output anything, or was it cut for length? Normally this would take some time for the gateware to build...

Here is an additional link that may be helpful: https://git.m-labs.hk/sinara-hw/assembly/src/branch/master/src/sw_sup/setup_build_pc.md#installation. AFAIK it is not linked in the manual but there are some forum posts that discuss this.

EDIT: Provided link may not be helpful given that the system builds mainline Kasli just fine, but provided for completeness regardless.

jbqubit commented 2 months ago

Thanks for the quick advice.

I made the following edits to my system. 1) In ~/.local/share/nix/trusted-settings.json add the following

{
   "extra-sandbox-paths":{
      "/opt":true
   },
   "extra-substituters":{
      "https://nixbld.m-labs.hk":true
   },
   "extra-trusted-public-keys":{
      "nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc=":true
   }
}

2) In ~/.config/nix/nix.conf add extra-sandbox-paths = /opt

And both build methods now work.

If I revert (2) I see that the makeArtiqZynqPackage error recurs.

I'm running Ubuntu 2022.04 LTS.

architeuthidae commented 2 months ago

ACK. Will see about adding the additional Nix configuration tips to the manual as soon as I've gotten the chance to try and recreate the original problem (just have to get a Vivado install going again first...)