Page tree
Skip to end of metadata
Go to start of metadata
Q

How to run waf build under Linux?

A

1. Setup the GCC ARM Embedded toolchain

First we download and extract the toolchain:

~/Test$ wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update/+download/gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2
~/Test$ tar -xf gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2

Attempting to run arm-none-eabi-gcc directly fails:

~/Test$ gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc -v
bash: arm-none-eabi-gcc: No such file or directory

Apparently we get this error because we are trying to run a 32-bit binary on a 64-bit architecture. The solution is to install the 32-bit libraries needed with: 

~/Test$ sudo apt-get install gcc-multilib

See https://answers.launchpad.net/gcc-arm-embedded/+question/403082 for more information about this issue.

Now we can run arm-none-eabi-gcc without a problem:

~/Test$ gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc -v
...
gcc version 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 227977] (GNU Tools for ARM Embedded Processors)

2. Install Python 2

The next step is to install python 2:

~/Test$ sudo apt-get install python-is-python2

It should be possible to run the build also with python 3, but attempting to build waf 1.6.11 with python3 failed, so we stick to python 2 instead.

3. Download and build waf 1.6.11

Next we download and build waf 1.6.11:

~/Test$ wget https://github.com/waf-project/waf/archive/refs/tags/waf-1.6.11.tar.gz
~/Test$ tar -xf waf-1.6.11.tar.gz
~/Test$ cd waf-waf-1.6.11/
~/Test/waf-waf-1.6.11$ ./waf-light configure build
------> Executing code from the top-level wscript <-----
Setting top to                           : /home/plamena/Test/waf-waf-1.6.11 
Setting out to                           : /home/plamena/Test/waf-waf-1.6.11/build 
Checking for program python              : /usr/bin/python 
Checking for python version              : (2, 7, 18, 'final', 0) 
'configure' finished successfully (0.049s)
Waf: Entering directory `/home/plamena/Test/waf-waf-1.6.11/build'
[1/1] create_waf:  -> waf
-> preparing 'tmp-waf-1.6.11'
Waf: Leaving directory `/home/plamena/Test/waf-waf-1.6.11/build'
'build' finished successfully (0.260s)

The build produces the waf executable which should be placed at the root directory of the project we want to build.

4. Setup the example project to build

Download and extract one of the netX 90 example projects:

~/Test$ wget https://kb.hilscher.com/download/attachments/119491200/netXStudio_PNSV5_simpleConfig_V3.0.0.0.zip
~/Test$ unzip netXStudio_PNSV5_simpleConfig_V3.0.0.0.zip

Place the waf executable into the project root folder:

~/Test$ cp waf-waf-1.6.11/waf netXStudio_PNSV5_simpleConfig_V3.0.0.0/waf

If we try to configure the project now we will get an error:

~/Test$ cd netXStudio_PNSV5_simpleConfig_V3.0.0.0/
~/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0$ ./waf configure
Traceback (most recent call last):
  ....
ImportError: No module named hilscher_libsused

To fix the error, we have to patch the WAF/hilscher_firmware.py script which is part of the project build. The file should look like this:

WAF/hilscher_firmware.py
# waf buildsystem related hooks to initialize this module
def options(opt):
    global hilscher_tooldir
    opt.load('hilscher_libsused', tooldir = os.path.relpath(hilscher_tooldir, opt.path.abspath())) # changed opt.root.abspath() to opt.path.abspath()

def configure(conf):
    global hilscher_tooldir
    conf.load('hilscher_libsused', tooldir = os.path.relpath(hilscher_tooldir, conf.path.abspath())) # changed conf.root.abspath() to conf.path.abspath()

Try to configure the project again and this time the "No module named hilscher_libsused" error should be gone:

~/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0$ ./waf configure
Loaded WAF options from project.
Setting top to                           : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0 
Setting out to                           : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/build 
Hilscher Waf version                     : 1.10.1.0 
Checking for waf version in 1.6.11-1.7.0 : ok 
Checking for program patch               : /usr/bin/patch 
Checking for program svn                 : not found 
Checking for program python              : /usr/bin/python 
Checking for hboot image compiler        : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler 
Checking for app intflash image update tool : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler/netx90_app_iflash_image.py 
Checking for app image update tool          : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler/netx90_app_image.py 
Toolchain 'gccarmemb'                       : not found (Some projects may not be available for building) 
Loaded WAF configuration from project.
'configure' finished successfully (0.006s)

5. Setup the GCC ARM toolchain path for waf

Now we need to tell the waf build where to look for the GCC ARM Embedded toolchain. This is done by setting the GCC_ARM_PATH environment variable:

~/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0$ export GCC_ARM_PATH=/home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3

Now we should be able to configure the project successfully:

~/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0$ ./waf configure
Loaded WAF options from project.
Setting top to                           : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0 
Setting out to                           : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/build 
Hilscher Waf version                     : 1.10.1.0 
Checking for waf version in 1.6.11-1.7.0 : ok 
Checking for program patch               : /usr/bin/patch 
Checking for program svn                 : not found 
Checking for program python              : /usr/bin/python 
Checking for hboot image compiler        : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler 
Checking for app intflash image update tool : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler/netx90_app_iflash_image.py 
Checking for app image update tool          : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler/netx90_app_image.py 
Checking for program arm-none-eabi-ar       : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-ar 
Checking for program arm-none-eabi-readelf  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-readelf 
Checking for program arm-none-eabi-objdump  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-objdump 
Checking for program arm-none-eabi-objcopy  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-objcopy 
Checking for program arm-none-eabi-strip    : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-strip 
Checking for program arm-none-eabi-nm       : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-nm 
Checking for program arm-none-eabi-gcc      : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc 
Checking for program arm-none-eabi-g++      : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-g++ 
Toolchain 'gccarmemb'                       : gcc 4.9.3 
Loaded WAF configuration from project.
'configure' finished successfully (0.027s)

6. Build the project

Now we can build the project with "waf configure build":

~/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0$ ./waf configure build
Loaded WAF options from project.
Setting top to                           : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0 
Setting out to                           : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/build 
Hilscher Waf version                     : 1.10.1.0 
Checking for waf version in 1.6.11-1.7.0 : ok 
Checking for program patch               : /usr/bin/patch 
Checking for program svn                 : not found 
Checking for program python              : /usr/bin/python 
Checking for hboot image compiler        : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler 
Checking for app intflash image update tool : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler/netx90_app_iflash_image.py 
Checking for app image update tool          : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler/netx90_app_image.py 
Checking for program arm-none-eabi-ar       : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-ar 
Checking for program arm-none-eabi-readelf  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-readelf 
Checking for program arm-none-eabi-objdump  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-objdump 
Checking for program arm-none-eabi-objcopy  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-objcopy 
Checking for program arm-none-eabi-strip    : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-strip 
Checking for program arm-none-eabi-nm       : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-nm 
Checking for program arm-none-eabi-gcc      : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc 
Checking for program arm-none-eabi-g++      : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-g++ 
Toolchain 'gccarmemb'                       : gcc 4.9.3 
Loaded WAF configuration from project.
'configure' finished successfully (0.023s)
Waf: Entering directory `/home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/build/release'
Skipping target 'arm-none-eabi/x.x.x/cifXApplicationDemo/cifXApplicationDemo' because toolchain 'codesourcery' not found. 
Components/cifXApplicationDemoPNSDefinitions/wscript: Path 'Includes\\GenericAP_API' specified in arg 'export_includes' for target 'GenericAPDefinitions_sdk' does not exists

There is one more small error to fix - one of the component wscript files uses a path with the wrong slash, which results in the error seen above. This can be easily fixed by adjusting the component wscript:

Components/cifXApplicationDemoPNSDefinitions/wscript
    bld.sdkcomponent(
        name            = "GenericAPDefinitions_sdk",
        export_includes = "Includes/GenericAP_API", # changed "Includes\GenericAP_API" to "Includes/GenericAP_API"
        )

Finally we can build the project successfully:

~/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0$ ./waf configure build
Loaded WAF options from project.
Setting top to                           : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0 
Setting out to                           : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/build 
Hilscher Waf version                     : 1.10.1.0 
Checking for waf version in 1.6.11-1.7.0 : ok 
Checking for program patch               : /usr/bin/patch 
Checking for program svn                 : not found 
Checking for program python              : /usr/bin/python 
Checking for hboot image compiler        : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler 
Checking for app intflash image update tool : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler/netx90_app_iflash_image.py 
Checking for app image update tool          : /home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/WAF/hboot_image_compiler/netx90_app_image.py 
Checking for program arm-none-eabi-ar       : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-ar 
Checking for program arm-none-eabi-readelf  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-readelf 
Checking for program arm-none-eabi-objdump  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-objdump 
Checking for program arm-none-eabi-objcopy  : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-objcopy 
Checking for program arm-none-eabi-strip    : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-strip 
Checking for program arm-none-eabi-nm       : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-nm 
Checking for program arm-none-eabi-gcc      : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc 
Checking for program arm-none-eabi-g++      : /home/plamena/Test/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-g++ 
Toolchain 'gccarmemb'                       : gcc 4.9.3 
Loaded WAF configuration from project.
'configure' finished successfully (0.017s)
Waf: Entering directory `/home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/build/release'
...
...
...
[61/70] [CC]        Targets/NXHX90-JTAG/Sources/handler.c
[62/70] [CC]        Targets/NXHX90-JTAG/Sources/main.c
[63/70] [CC]        Targets/NXHX90-JTAG/Sources/netx90_app_header_useCaseC.c
[64/70] [ELF]       build/release/Targets/netx90_sdram.elf build/release/Targets/netx...
[65/70] [CC]        Targets/NXHX90-JTAG/Sources/handler.c
[66/70] [CC]        Targets/NXHX90-JTAG/Sources/main.c
[67/70] [CC]        Targets/NXHX90-JTAG/Sources/netx90_app_header_useCaseC.c
[68/70] [ELF]       build/release/Targets/nx90_app.elf build/release/Targets/nx90_app...
[69/70] [APPIMG]    build/release/Targets/nx90_app.nai.unpatched
[70/70] [GENERATE_NAI] build/release/Targets/nx90_app.nai.unpatched build/release/Tar...
Waf: Leaving directory `/home/plamena/Test/netXStudio_PNSV5_simpleConfig_V3.0.0.0/build/release'
'build' finished successfully (8.525s)


Tested with Ubuntu 20.04.2.0 LTS.