Compiling ArduPilot: Errors re Waf

Hi! I’m having trouble testing a new target. Following Porting to a new flight controller board — Dev documentation and Building the code — Dev documentation.

Of note:
Tools/environment_install/install-prereqs-ubuntu.sh -y crashes with this error:

+ echo source /mnt/c/Users/david/Desktop/ardupilot/Tools/completion/completion.bash
+ eval source /mnt/c/Users/david/Desktop/ardupilot/Tools/completion/completion.bash
++ source /mnt/c/Users/david/Desktop/ardupilot/Tools/completion/completion.bash
+++ $'\r'
/mnt/c/Users/david/Desktop/ardupilot/Tools/completion/completion.bash: line 2: $'\r': command not found

./waf results in this error:

david@Data-Desktop:/mnt/c/Users/david/Desktop/ardupilot$ ./waf
/usr/bin/env: ‘python\r’: No such file or directory

python3 waf results in this error:

david@Data-Desktop:/mnt/c/Users/david/Desktop/ardupilot$ python3 waf
The project was not configured: run "waf configure" first!

waf configure results in this:

david@Data-Desktop:/mnt/c/Users/david/Desktop/ardupilot$ waf configure
Command 'waf' not found, did you mean:
  command 'wtf' from deb bsdgames (2.17-29)
  command 'caf' from deb libcoarrays-mpich-dev (2.9.2-3)
  command 'caf' from deb libcoarrays-openmpi-dev (2.9.2-3)
  command 'paf' from deb libpod-abstract-perl (0.20-3)
  command 'wmf' from deb wmf (1.0.5-8.1)
  command 'wdf' from deb wit (3.01a-4)
Try: sudo apt install <deb name>
david@Data-Desktop:/mnt/c/Users/david/Desktop/ardupilot$

Any ideas? Thanks!

Those look like line termination errors like those that can appear when you move files between operating systems like Windows and Linux.

I suspect you downloaded and unzipped the repo using Windows. Instead, install git within WSL and use git clone to retrieve the repository.

Thank you. Indeed, that solves the first problem, re install-prereqs-ubuntu. Unfortunately, I’m still not sure how to install WAF. (Same errors as above after cloning natively)

edit: Solved! python3 waf configure. Works on the Windows, or Linux-cloned versions. So, it sounds like the line endings issue is only if trying to use the shebang to find python, ie if running it as an executable.

Thank you!

./waf works fine on properly configured WSL environments. You have some lingering issues.

Continued one step further. Unable to execute python waf copter:

Embedding file hwdef.dat:/mnt/c/Users/david/Desktop/ardupilot/build/AnyleafH7/hw.dat
Traceback (most recent call last):
  File "/mnt/c/Users/david/Desktop/ardupilot/modules/waf/waflib/Scripting.py", line 158, in waf_entry_point
    run_commands()
  File "/mnt/c/Users/david/Desktop/ardupilot/modules/waf/waflib/Scripting.py", line 251, in run_commands
    ctx = run_command(cmd_name)
  File "/mnt/c/Users/david/Desktop/ardupilot/modules/waf/waflib/Scripting.py", line 235, in run_command
    ctx.execute()
  File "/mnt/c/Users/david/Desktop/ardupilot/Tools/ardupilotwaf/ardupilotwaf.py", line 207, in execute
    return execute_method(self)
  File "/mnt/c/Users/david/Desktop/ardupilot/modules/waf/waflib/Scripting.py", line 573, in execute
    return execute_method(self)
  File "/mnt/c/Users/david/Desktop/ardupilot/modules/waf/waflib/Build.py", line 231, in execute
    self.execute_build()
  File "/mnt/c/Users/david/Desktop/ardupilot/modules/waf/waflib/Build.py", line 244, in execute_build
    self.recurse([self.run_dir])
  File "/mnt/c/Users/david/Desktop/ardupilot/modules/waf/waflib/Context.py", line 286, in recurse
    user_function(self)
  File "/mnt/c/Users/david/Desktop/ardupilot/wscript", line 849, in build
    _build_dynamic_sources(bld)
  File "/mnt/c/Users/david/Desktop/ardupilot/wscript", line 680, in _build_dynamic_sources
    bld.srcnode.find_dir('modules/uavcan/libuavcan/include').abspath()
AttributeError: 'NoneType' object has no attribute 'abspath'
david@Data-Desktop:/mnt/c/Users/david/Desktop/ardupilot$