ThorstenGroh failing early by not get nix daemon running without systemd

I think the nix daemon is not necessary for a single-user Nix install. I don't know if OpenOCD works inside WSL though.

    sb10q
    Thanks. Yes, indeed a single-user Nix enables me to install ARTIQ as documented. I added artiq-full.artiq-board-kasli-bonn to the nix file for installation.

    Running artiq_flash -V bonn from within WSL however seems not find the board.

    [nix-shell:~]$ artiq_flash -V bonn
    Design: top;COMPRESS=TRUE;UserID=FFFFFFFF;Version=2021.2
    Part name: 7a100tfgg484
    Date: 2022/04/07
    Time: 15:13:30
    Bitstream payload length: 0x24d334
    Open On-Chip Debugger 0.11.0+dev-snapshot (2022-01-04-10:01)
    Licensed under GNU GPL v2
    For bug reports, read
            http://openocd.org/doc/doxygen/bugs.html
    Error: no device found
    Error: unable to open ftdi device with vid 0403, pid 6011, description 'Quad RS232-HS', serial '*' at bus location '*'
    
    Traceback (most recent call last):
      File "/nix/store/73jhsgwx20xyfmdqqk1cbmg27xv2cg8h-python3.8-artiq-6.7661.ca67ae83/bin/.artiq_flash-wrapped", line 9, in <module>
        sys.exit(main())
      File "/nix/store/6nvdvfqy8xaqb9j8s47clz58ml7rhp5f-python3-3.8.11-env/lib/python3.8/site-packages/artiq/frontend/artiq_flash.py", line 474, in main
        programmer.run()
      File "/nix/store/6nvdvfqy8xaqb9j8s47clz58ml7rhp5f-python3-3.8.11-env/lib/python3.8/site-packages/artiq/frontend/artiq_flash.py", line 207, in run
        self._client.run_command(cmdline)
      File "/nix/store/6nvdvfqy8xaqb9j8s47clz58ml7rhp5f-python3-3.8.11-env/lib/python3.8/site-packages/artiq/remoting.py", line 57, in run_command
        subprocess.check_call([arg.format(tmp=self._tmp, **kws) for arg in cmd])
      File "/nix/store/j2hdhabhzvwy7zbw96pi7m7i066snh2i-python3-3.8.11/lib/python3.8/subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['openocd', '-s', '/nix/store/sxf36v7mradwz1rdi179hi9s4mab0djl-openocd-bscanspi/share/openocd/scripts', '-c', 'source [find board/kasli.cfg]; target create xc7.spi0.proxy testee -chain-position xc7.tap; flash bank spi0 jtagspi 0 0 0 0 xc7.spi0.proxy 0x2; gdb_port disabled; tcl_port disabled; telnet_port disabled; init; xadc_report xc7.tap; pld load 0 {/nix/store/sxf36v7mradwz1rdi179hi9s4mab0djl-openocd-bscanspi/share/bscan-spi-bitstreams/bscan_spi_xc7a100t.bit}; flash probe spi0; flash erase_sector spi0 0 36; flash write_bank spi0 {/tmp/artiq_z6plutr7_top.bit} 0x0; flash verify_bank spi0 {/tmp/artiq_z6plutr7_top.bit} 0x0; flash probe spi0; flash erase_sector spi0 64 66; flash write_bank spi0 {/nix/store/6nvdvfqy8xaqb9j8s47clz58ml7rhp5f-python3-3.8.11-env/lib/python3.8/site-packages/artiq/board-support/kasli-bonn/bootloader.bin} 0x400000; flash verify_bank spi0 {/nix/store/6nvdvfqy8xaqb9j8s47clz58ml7rhp5f-python3-3.8.11-env/lib/python3.8/site-packages/artiq/board-support/kasli-bonn/bootloader.bin} 0x400000; flash probe spi0; flash erase_sector spi0 69 78; flash write_bank spi0 {/nix/store/6nvdvfqy8xaqb9j8s47clz58ml7rhp5f-python3-3.8.11-env/lib/python3.8/site-packages/artiq/board-support/kasli-bonn/runtime.fbi} 0x450000; flash verify_bank spi0 {/nix/store/6nvdvfqy8xaqb9j8s47clz58ml7rhp5f-python3-3.8.11-env/lib/python3.8/site-packages/artiq/board-support/kasli-bonn/runtime.fbi} 0x450000; xc7_program xc7.tap; exit']' returned non-zero exit status 1.

    If you think this might be a Windows/conda issue I can try to get my hands on a linux machine in the next days, but I would really like to make this work under Windows as well.

    invalid command name "xadc_report" looks like a bad openocd package. Is that from the m-labs conda channel?

    Yes, the openocd is from the m-labs conda channel.

    (artiq) qumercury_artiq> mamba list openocd
    # packages in environment at C:\tools\miniconda3\envs\artiq:
    #
    # Name                    Version                   Build  Channel
    openocd                   0.10.0+git2          hf4984f1_0    m-labs

    Reinstalled it via mamba install openocd -c m-labs --force-reinstall, but this did not help.

    With the 0.10.0+git1 or 0.10.0.git versions of openocd I however get a Can't find board/kasli.cfg:

    (artiq) qumercury_artiq> mamba list openocd
    # packages in environment at C:\tools\miniconda3\envs\artiq:
    #
    # Name                    Version                   Build  Channel
    openocd                   0.10.0+git1          h3b6d3d0_0    m-labs
    (artiq) qumercury_artiq> artiq_flash -V bonn
    Design: top;COMPRESS=TRUE;UserID=FFFFFFFF;Version=2021.2
    Part name: 7a100tfgg484
    Date: 2022/04/07
    Time: 15:13:30
    Bitstream payload length: 0x24d334
    Open On-Chip Debugger 0.10.0-00007-g977d9e4 (2017-10-23-23:27)
    Licensed under GNU GPL v2
    For bug reports, read
            http://openocd.org/doc/doxygen/bugs.html
    Can't find board/kasli.cfg
    Traceback (most recent call last):
      File "C:\tools\miniconda3\envs\artiq\Scripts\artiq_flash-script.py", line 9, in <module>
        sys.exit(main())
      File "C:\tools\miniconda3\envs\artiq\lib\site-packages\artiq\frontend\artiq_flash.py", line 474, in main
        programmer.run()
      File "C:\tools\miniconda3\envs\artiq\lib\site-packages\artiq\frontend\artiq_flash.py", line 207, in run
        self._client.run_command(cmdline)
      File "C:\tools\miniconda3\envs\artiq\lib\site-packages\artiq\remoting.py", line 57, in run_command
        subprocess.check_call([arg.format(tmp=self._tmp, **kws) for arg in cmd])
      File "C:\tools\miniconda3\envs\artiq\lib\subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['openocd', '-s', 'C:\\tools\\miniconda3\\envs\\artiq\\Library\\share\\openocd\\scripts', '-c', 'source [find board/kasli.cfg]; target create xc7.spi0.proxy testee -chain-position xc7.tap; flash bank spi0 jtagspi 0 0 0 0 xc7.spi0.proxy 0x2; gdb_port disabled; tcl_port disabled; telnet_port disabled; init; xadc_report xc7.tap; pld load 0 {C:\\tools\\miniconda3\\envs\\artiq\\share\\bscan-spi-bitstreams\\bscan_spi_xc7a100t.bit}; flash probe spi0; flash erase_sector spi0 0 36; flash write_bank spi0 {C:\\Users\\QUMERC~1\\AppData\\Local\\Temp\\artiq_cczlf6u1_top.bit} 0x0; flash verify_bank spi0 {C:\\Users\\QUMERC~1\\AppData\\Local\\Temp\\artiq_cczlf6u1_top.bit} 0x0; flash probe spi0; flash erase_sector spi0 64 66; flash write_bank spi0 {C:\\tools\\miniconda3\\envs\\artiq\\lib\\site-packages\\artiq\\board-support\\kasli-bonn\\bootloader.bin} 0x400000; flash verify_bank spi0 {C:\\tools\\miniconda3\\envs\\artiq\\lib\\site-packages\\artiq\\board-support\\kasli-bonn\\bootloader.bin} 0x400000; flash probe spi0; flash erase_sector spi0 69 78; flash write_bank spi0 {C:\\tools\\miniconda3\\envs\\artiq\\lib\\site-packages\\artiq\\board-support\\kasli-bonn\\runtime.fbi} 0x450000; flash verify_bank spi0 {C:\\tools\\miniconda3\\envs\\artiq\\lib\\site-packages\\artiq\\board-support\\kasli-bonn\\runtime.fbi} 0x450000; xc7_program xc7.tap; exit']' returned non-zero exit status 1.

    With the version 0.10.0+git1 of openocd this is a file problem. The kasli.cfg does not exist under C:\tools\miniconda3\envs\[ENVIRONMENT NAME]\Library\share\openocd\scripts\board. If I copy that file from the 0.10.0+git2 version to the location in the 0.10.0+git1 installation desired folder this specific error message is gone, but I again get the invalid command name "xadc_report" error message from before. So the problem persists.

    Any ideas?

    I just downloaded and installed an older openocd version from anaconda (mamba install https://anaconda.org/m-labs/openocd/0.10.0/download/win-64/openocd-0.10.0-6.tar.bz2).
    This now seems to be more promising. The error message is gone, the flashing is in progress:

    (artiq_20220412) PS C:\Users\quMercury\Software\qumercury_artiq> artiq_flash -V bonn
    Design: top;COMPRESS=TRUE;UserID=FFFFFFFF;Version=2021.2
    Part name: 7a100tfgg484
    Date: 2022/04/07
    Time: 15:13:30
    Bitstream payload length: 0x24d334
    Open On-Chip Debugger 0.10.0-00013-gbb7bedad (2018-02-17-05:04)
    Licensed under GNU GPL v2
    For bug reports, read
            http://openocd.org/doc/doxygen/bugs.html
    none separate
    adapter speed: 25000 kHz
    Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
    Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
    Info : clock speed 25000 kHz
    Info : JTAG tap: xc7.tap tap/device found: 0x13631093 (mfg: 0x049 (Xilinx), part: 0x3631, ver: 0x1)
    Info : gdb server disabled
    TEMP 64.72 C
    VCCINT 0.984 V
    VCCAUX 1.783 V
    VCCBRAM 0.990 V
    VPVN 0.000 V
    VREFP 0.000 V
    VREFN 0.000 V
    VCCPINT 0.000 V
    VCCPAUX 0.000 V
    VCCODDR 0.000 V
    loaded file C:\tools\miniconda3\envs\artiq_20220412\share\bscan-spi-bitstreams\bscan_spi_xc7a100t.bit to pld device 0 in 0s 256024us
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    flash 'jtagspi' found at 0x00000000
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    Info : sector 0 took 1760 ms
    Info : sector 1 took 1785 ms
    Info : sector 2 took 115 ms
    Info : sector 3 took 122 ms
    Info : sector 4 took 116 ms
    Info : sector 5 took 130 ms
    Info : sector 6 took 118 ms
    Info : sector 7 took 115 ms
    Info : sector 8 took 100 ms
    Info : sector 9 took 123 ms
    Info : sector 10 took 115 ms
    Info : sector 11 took 116 ms
    Info : sector 12 took 115 ms
    Info : sector 13 took 116 ms
    Info : sector 14 took 116 ms
    Info : sector 15 took 122 ms
    Info : sector 16 took 116 ms
    Info : sector 17 took 115 ms
    Info : sector 18 took 116 ms
    Info : sector 19 took 115 ms
    Info : sector 20 took 117 ms
    Info : sector 21 took 102 ms
    Info : sector 22 took 120 ms
    Info : sector 23 took 110 ms
    Info : sector 24 took 103 ms
    Info : sector 25 took 116 ms
    Info : sector 26 took 115 ms
    Info : sector 27 took 116 ms
    Info : sector 28 took 116 ms
    Info : sector 29 took 121 ms
    Info : sector 30 took 116 ms
    Info : sector 31 took 116 ms
    Info : sector 32 took 116 ms
    Info : sector 33 took 100 ms
    Info : sector 34 took 115 ms
    Info : sector 35 took 116 ms
    Info : sector 36 took 123 ms
    erased sectors 0 through 36 on flash bank 1 in 7.587875s
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    wrote 2413364 bytes from file C:\Users\QUMERC~1\AppData\Local\Temp\artiq_pcck47z2_top.bit to flash bank 1 at offset 0x00000000 in 158.169235s (14.901 KiB/s)
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    read 2413364 bytes from file C:\Users\QUMERC~1\AppData\Local\Temp\artiq_pcck47z2_top.bit and flash bank 1 at offset 0x00000000 in 1.434285s (1643.189 KiB/s)
    contents match
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    flash 'jtagspi' found at 0x00000000
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    Info : sector 64 took 116 ms
    Info : sector 65 took 116 ms
    Info : sector 66 took 116 ms
    erased sectors 64 through 66 on flash bank 1 in 0.347345s
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    wrote 133860 bytes from file C:\tools\miniconda3\envs\artiq_20220412\lib\site-packages\artiq\board-support\kasli-bonn\bootloader.bin to flash bank 1 at offset 0x00400000 in 8.772617s (14.901 KiB/s)
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    read 133860 bytes from file C:\tools\miniconda3\envs\artiq_20220412\lib\site-packages\artiq\board-support\kasli-bonn\bootloader.bin and flash bank 1 at offset 0x00400000 in 0.084837s (1540.869 KiB/s)
    contents match
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    flash 'jtagspi' found at 0x00000000
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    Info : sector 69 took 131 ms
    Info : sector 70 took 116 ms
    Info : sector 71 took 117 ms
    Info : sector 72 took 114 ms
    Info : sector 73 took 122 ms
    Info : sector 74 took 116 ms
    Info : sector 75 took 116 ms
    Info : sector 76 took 115 ms
    Info : sector 77 took 116 ms
    Info : sector 78 took 103 ms
    erased sectors 69 through 78 on flash bank 1 in 1.166532s
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    wrote 649344 bytes from file C:\tools\miniconda3\envs\artiq_20220412\lib\site-packages\artiq\board-support\kasli-bonn\runtime.fbi to flash bank 1 at offset 0x00450000 in 42.395931s (14.957 KiB/s)
    Info : Found flash device 'sp s25fl128' (ID 0x00182001)
    read 649344 bytes from file C:\tools\miniconda3\envs\artiq_20220412\lib\site-packages\artiq\board-support\kasli-bonn\runtime.fbi and flash bank 1 at offset 0x00450000 in 0.384467s (1649.361 KiB/s)
    contents match

    This finished in a few minutes. Does that look good? Excecuting scripts via artiq_run does not throw the version warning anymore and the simple TTL tests I am running currently still seem to work.

    So that was indeed a problem with openocd. Where is the m-labs version of openocd hosted? Where do I file a bug report for that?

    Another question: Is there a way to revert gateware flashes? How do I obtain older gateware versions? Conda lists one version only.

      That log looks good. Between different git versions of the same stable major release I would not expect any protocol incompatibility. It's only a warning. But certainly good to practice flashing and that also removes the version mismatch warning.
      I think an issue filed would be good. https://git.m-labs.hk/M-Labs/nix-scripts would be the adequate repo most likely.
      I think you can get old conda packages directly from nixbld.m-labs.hk.

        ThorstenGroh Where is the m-labs version of openocd hosted?

        https://anaconda.org/m-labs/openocd/files is the right one currently. How did you install the first one (that did not work)?
        Without conda, I think the upstream MSYS2 package with just the bscanspi bitstreams added should also work (and we will probably switch to that in ARTIQ-8), but I have not tested it yet.

        ThorstenGroh How do I obtain older gateware versions?

        You can use those conda channels: https://conda.m-labs.hk/artiq-archives/ e.g. add https://conda.m-labs.hk/artiq-archives/108802/ as a conda channel instead.
        The numbers are the build numbers of the artiq:full:conda-channel job which can be referenced on the Hydra interface e.g. https://nixbld.m-labs.hk/build/118130

          sb10q How did you install the first one (that did not work)?

          The first package also came from m-labs anaconda repo: conda install -c m-labs openocd, I also tried other versions available there via conda install -c m-labs openocd=0.10.0+git1 for example. Both did not work.

          Well, that doesn't make a lot of sense, conda install -c m-labs is supposed to install the latest version from that very same Anaconda URL. Maybe conda's completely broken dependency handler chose an older version for some reason (this is why, by the way, the channels on conda.m-labs.hk are designed to show conda only one possible version for each package).
          Anyway this problem (and many others in the same vein) will be resolved for good once we stop using conda completely and switch to MSYS2.

          conda install openocd -c m-labs installs the 0.10.0+git2 version on my machine. conda search openocd -c m-labs lists the following packages:

          # Name                       Version           Build  Channel
          openocd                   0.10.0.git               1  m-labs
          openocd                  0.10.0+git1      h3b6d3d0_0  m-labs
          openocd                  0.10.0+git2      hf4984f1_0  m-labs
          openocd                       0.10.0               1  m-labs
          openocd                       0.10.0               6  m-labs
          openocd                       0.10.0      h6833691_3  m-labs
          openocd                       0.10.0      h85cd1cf_4  m-labs
          openocd                       0.10.0      ha3de3d5_6  m-labs

          The older version (conda install https://anaconda.org/m-labs/openocd/0.10.0/download/win-64/openocd-0.10.0-6.tar.bz2) that worked for me lists as:

          # Name                    Version                   Build  Channel
          openocd                   0.10.0                        6    https://anaconda.org/m-labs/openocd/0.10.0/download