Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do a better job of detecting if a tftp server is running and configured correctly #3

Open
mithro opened this issue Jan 11, 2018 · 5 comments

Comments

@mithro
Copy link
Member

mithro commented Jan 11, 2018

@cr1901 hit this problem when getting set up.....

@cr1901
Copy link
Contributor

cr1901 commented Jan 11, 2018

The first failure was indeed due to inetd. This got lost in my scrollback:

+ case $QEMU_NETWORK in
+ '[' '!' -e /dev/net/tap0 ']'
+ echo 'Need to create and bring up a tun device, needing sudo...'
Need to create and bring up a tun device, needing sudo...
+ sudo true
+ sudo mknod /dev/net/tap0 c 10 200
+ sudo which openvpn
+ sudo openvpn --mktun --dev tap0
Thu Jan 11 00:12:53 2018 TUN/TAP device tap0 opened
Thu Jan 11 00:12:53 2018 Persist state set to: ON
++ whoami
+ sudo chown william /dev/net/tap0
+ sudo ifconfig tap0 192.168.100.100 up
+ make tftpd_start
mkdir -p build/tftpd/
sudo true
Starting aftpd
+ EXTRA_ARGS+=("-net nic -net tap,ifname=tap0,script=no,downscript=no")
+ make tftp
mkdir -p build/arty_net_or1k/
time python -u ./make.py --platform=arty --target=net --cpu-type=or1k --iprange=192.168.100 -Ob toolchain_path //opt/Xilinx/    --no-compile-gateware \
        2>&1 | tee -a /home/william/Projects/litex-buildenv/build/arty_net_or1k//output.20180111-001254.log; (exit ${PIPESTATUS[0]})
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/libcompiler_rt'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/libcompiler_rt'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/libbase'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/libbase'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/libnet'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/libnet'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/bios'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/bios'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
Jan 11 00:12:54 xubuntu-dtrain atftpd[1445.140634394527488]: Advanced Trivial FTP server started (0.7)
Jan 11 00:12:54 xubuntu-dtrain atftpd[1445.140634394527488]: atftpd: can't bind port 192.168.100.100:69/udp
make[1]: Entering directory '/home/william/Projects/litex-buildenv/build/arty_net_or1k/software/uip'
make[1]: Nothing to be done for 'all'.

All subsequent failures were due to the fact that the tftpd_start target is only run once, and that's only if tap0 doesn't already exist. Perhaps if tap0 is known to exist, we should check for an existing atftpd and then attempt to invoke it if a daemon doesn't exist?

@mithro
Copy link
Member Author

mithro commented Jan 11, 2018

I think we should probably do something like trying to tftp fetch the binary and see if that works?

@ewenmcneill
Copy link
Contributor

I also encountered this issue when doing my preparation build -- the tftpd server didn't start for some reason on the first run (I had atftpd in /etc/inetd.conf from something earlier, but thought I'd disabled it early enough in the setup process), and then on subsequent runs the scripts/build-qemu.sh skipped past the part where make tftpd_start got run because the tap0 interface had already been configured. Once I figured that out, running make tftpd_start by hand got everything working.

IMHO it'd be better if the call to make tftpd_start was dependent on either:

  • whether atftpd was already running with the right TFTP directory (eg parsing ps axu looking for a process running with the right parameters); or

  • whether there was something listening on UDP/69, perhaps on the relevant IP (which would help catch "you have a TFTP server, but it's not the right one")

(plus of course that the tap0 interface configuration had worked). Ie, making the script a bit more idempotent.

At minimum given the volume of output it'd be worth trying to hint that "if TFTP fails, check that atftpd server is running" immediately before booting qemu, so it's more easily found in the console output, given that TFTP has basically no error checking.

Ewen

PS: The trouble with "try to fetch" as a test for "is it running" is that the only error reporting that TFTP has is basically a timeout, or a "not found" message; and the BIOS boot already shows the timeout behaviour...

@mithro
Copy link
Member Author

mithro commented Jan 14, 2018

Other things to think about is the tun/tap interface setup - some people have needed things like;

sudo ip tuntap add dev tap0 mode tap user mwheeler group mwheeler

@ewenmcneill
Copy link
Contributor

Also, if you follow the instructions, do the scripts/build-qemu.sh, switch over to real hardware, and follow the instructions to delete the IP from tap0 you will be left with a tap0 interface, with no IP on it. Once you unplug the hardware board again (eg, to reset it), you'll lose the hardware interface that had 192.168.100.100 on it, which means that then make tftpd_start will fail because there's no interface with that IP on it, and scripts/build-qemu.sh will fail to configure an IP on tap0 because it assumes "tap0 exists" is the same as "everything configured". Sigh.

mithro added a commit that referenced this issue Jan 26, 2018
 * flash_proxies changed from 070d8b2 to c506426
    * c506426 - Merge pull request #3 from cr1901/master <Robert Jördens>
    * bf63a40 - Add Spartan 7 (xc7s50) bitstream, plus corresponding logic to regenerate. <William D. Jones>

 * litedram changed from a09b7a0 to 13d41f6
    * 13d41f6 - Merge pull request #9 from felixheld/indentation-fixes <Tim Ansell>
    * 72b1b10 - Fix all remaining indentation issues in python code <Felix Held>

 * litepcie changed from 09dbd6d to 945963d
    * 945963d - phy/s7pciephy: set sys_rst_n to 1 if no rst_n pad <Florent Kermarrec>
    *   5590f11 - Merge pull request #7 from felixheld/indentation-fixes <Tim Ansell>
    |\
    | * d602010 - Fix all remaining indentation issues in python code <Felix Held>
    * 9469929 - Merge pull request #6 from felixheld/indentation-fixes <Tim Ansell>
    * 5376257 - fix code indentation <Felix Held>

 * litesata changed from a8bf0d4 to af00fa6
    * af00fa6 - Merge pull request #13 from felixheld/indentation-fixes <Tim Ansell>
    * 220b601 - Fix all indentation issues in python code <Felix Held>

 * litescope changed from 7757727 to aa44da3
    * aa44da3 - example_designs/make.py: fix typos <Florent Kermarrec>
    * 72e71e7 - core: simplify <Florent Kermarrec>
    * 7803591 - Merge pull request #9 from felixheld/indentation-fixes <Tim Ansell>
    * febb358 - Fix all remaining indentation issues in python code <Felix Held>

 * liteusb changed from 9a78586 to 0b05b6c
    * 0b05b6c - +x on scripts <Florent Kermarrec>

 * litevideo changed from c9770cc to 8d940dc
    * 8d940dc - output: add raw support (10 bits tmds in dram), untested <Florent Kermarrec>
    * 5c168aa - input: add capability to get raw 10 bits data when not using dram port <Florent Kermarrec>
    * dcd9624 - input/edid: simplify scl inversion <Florent Kermarrec>
    *   3b04d1b - Merge pull request #14 from bunnie/scl-merge <enjoy-digital>
    |\
    | * 7845c85 - add inverted attribute to SCL <bunnie>
    |/
    *   a7fd5f6 - Merge pull request #13 from felixheld/indentation-fixes <Tim Ansell>
    |\
    | * 34b1a0f - Fix all remaining indentation issues in python code <Felix Held>
    |/
    * 4d6bc46 - input/datacapture: simplify inverted data in S7DataCapture <Florent Kermarrec>
    * af096a5 - input/clocking/s7: use bufr and fix input connection to mmcm <Florent Kermarrec>
    * 9ebdd1b - output: use new inverted property of pads to invert polarity <Florent Kermarrec>
    * 218b708 - output: add assertion if inverted property is used (since not yet implemented) <Florent Kermarrec>
    * 113bdb7 - input: use new inverted property of pads to invert polarity <Florent Kermarrec>
    * 091c9ec - litevideo: add __init__.py, fix install <Florent Kermarrec>
    * 9aae319 - input: add clk_polarity parameter, rename data_polarities to datas_polarity <Florent Kermarrec>

 * litex changed from v0.1-251-gead88ed6 to v0.1-270-g4f272580
    * 4f272580 - software/common: revert PYTHON to python3 (since breaking things) <Florent Kermarrec>
    * 4e168221 - bios: fix riscv processor print <Florent Kermarrec>
    * d4488748 - sim: rename top module to dut and use --top-module parameter (needed for picorv32 simulation) <Florent Kermarrec>
    *   a3851437 - Merge pull request #59 from q3k/for-upstream/multiple-synthesis-directives <enjoy-digital>
    |\
    | * 21bd26dc - Allow for multiple synthesis directives in specials. <Sergiusz Bazanski>
    |/
    * 67f8718b - minor cleanup <Florent Kermarrec>
    *   d07ddd11 - Merge pull request #58 from q3k/for-upstream/picorv32-support <enjoy-digital>
    |\
    | * 6daf3eab - Implement IRQ software support for RISC-V. <Sergiusz Bazanski>
    | * 2108c97b - Import PicoRV32-specific instruction macros. <Sergiusz Bazanski>
    | * cf74c781 - Write init files that respect CPU's endianness. <Sergiusz Bazanski>
    | * 71764922 - Set the MABI and MArch of the riscv target. <Sergiusz Bazanski>
    | * 7ea5a267 - Enable hardware multiplier and divider in PicoRV32 <Sergiusz Bazanski>
    | * 75e230aa - Replace __riscv__ macros with __riscv. <Sergiusz Bazanski>
    | * 20ed2344 - Export trap signal from PicoRV32. <Sergiusz Bazanski>
    | * b0be5630 - Bump PicoRV32 version. <Sergiusz Bazanski>
    |/
    * 3a5f93db - software/bios: add litex logo <Florent Kermarrec>
    *   d6877300 - Merge pull request #56 from cr1901/mimasv2 <enjoy-digital>
    |\
    | * c553fe2b - Add mimasv2 platform (pulled from litex-buildenv). <William D. Jones>
    |/
    * d6f2f637 - Merge pull request #53 from mithro/allow-forcing-colorama <Tim Ansell>

Full submodule status
--
 f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master)
 c5064269868396b2c7a78bff28f8e3cf421d1f6e flash_proxies (remotes/origin/HEAD)
 13d41f67ab3070f6af955aa8752c616d034f82f6 litedram (remotes/origin/HEAD)
 8fc716103670e703c7fe98c9bdf653b9b53ca12a liteeth (remotes/origin/HEAD)
 945963d186b3c0287426ef6655e00ad4e250d279 litepcie (remotes/origin/HEAD)
 af00fa613f1b6921e14788dd0ebf301e51009e74 litesata (remotes/origin/HEAD)
 aa44da35c6a232a9e39c43987a3afc9b025ab614 litescope (remotes/origin/HEAD)
 0b05b6c8f9279bb7e476b2c8ae4f39ea88534f08 liteusb (remotes/origin/HEAD)
 8d940dcaf21cffb18cd157e079ec94946878a5d7 litevideo (remotes/origin/HEAD)
 4f2725809e0b9b6cee94cb569c1878f48ab52a15 litex (v0.1-270-g4f272580)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants