From 8948704d4a74a2989bd0284d8c030d1af96c8281 Mon Sep 17 00:00:00 2001 From: Kristofer Jonsson Date: Tue, 16 Nov 2021 16:26:41 +0100 Subject: Add support for Ninja Add support for Ninja buider under both Linux and Windows. Updating generate_binaries.py to produce dependencies file. Removing files by wild card does not work with Ninja under Windows. Change-Id: I486463603de7413e09edcd959c329253867f4564 --- README.md | 22 +++++++++++++++----- README_WINDOWS.md | 48 -------------------------------------------- cmake/helpers.cmake | 5 ++--- scripts/generate_binaries.py | 10 ++++++++- 4 files changed, 28 insertions(+), 57 deletions(-) delete mode 100644 README_WINDOWS.md diff --git a/README.md b/README.md index e8281b3..278f54d 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ downloaded from the Ecosystem page at ## Building -Building core platform requires a recent version of CMake to be installed -together with a compiler capable of cross compiling for Arm Cortex-M. There are -sample toolchain files provided for Arm Clang and Arm GCC. +Building core platform requires a recent version of CMake, Python 3 and a C/C++ +cross comiler for Arm Cortex-M. There are sample toolchain files provided for +Arm Clang and Arm GCC. To run the helper scripts Python 3 is required with the packages listed in `requirements.txt`. @@ -47,8 +47,20 @@ $ cmake -B build targets/corstone-300 -DCMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchai $ cmake --build build ``` -Please see [README_WINDOWS.md](README_WINDOWS.md) for additional information -regarding building on a Windows system. +## Building on Windows + +Building on a Windows host requires no special tools or shells, and can for +example be done from a CMD prompt, Git Bash or from the CMake GUI. Only +requirment is the build tools have been added to the path variable. + +CMake supports a long list of generators, for example Ninja, NMake or Makefiles. +For Windows Ninja has been verified to work well, but any of the supported +generators should be possible to use. + +``` +CMD> cmake -G Ninja -B build targets/corstone-300 -DCMAKE_TOOLCHAIN_FILE=%CD%\cmake\toolchain\arm-none-eabi-gcc.cmake +CMD> cmake --build build +``` ## run_platform.py diff --git a/README_WINDOWS.md b/README_WINDOWS.md deleted file mode 100644 index d453cd9..0000000 --- a/README_WINDOWS.md +++ /dev/null @@ -1,48 +0,0 @@ -# Building on Windows Systems -Linux is the main development environment recommended ("Windows Subsystem for -Linux" can be used for a full Linux Bash environment under Windows), especially -with regards to building the TensorFlow Lite for Microcontrollers (TFLu) -library, which depends on GNU Make and are using a number of Bash shell scripts. -However, there are a number of possibilities for building on a Windows system. - -## Requirements -- **CMake**. E.g. Windows native CMake, MSYS CMake, Cygwin CMake, or MinGW - CMake. (Note: Supported generators may differ). -- **make tool**. E.g. GNU Make, NMAKE, Jom, mingw32-make, GNU Make under MSYS or - Cygwin. -- **ARM toolchain**. - [Arm Clang](https://developer.arm.com/tools-and-software/embedded/arm-compiler) - or - [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm) - -### Building with TensorFlow Lite for Microcontrollers -- **Shell**. E.g. "MSYS shell", "GIT Bash", or "Cygwin Terminal" -- **GNU Make**. (NOTE: required when building TFLu even if another generator is - used in CMake). -- **GNU Wget**. - -### Using a prebuilt TensorFlow Lite for Microcontrollers library -A prebuilt TFLu library can be supplied via the variable - `TFLU_PREBUILT_LIBRARY_PATH`. The project can then be built without the -requirements under -[Building with TensorFlow Lite for Microcontrollers](#Building-with-TensorFlow-Lite-for-Microcontrollers) -(apart from the initially build of the library). - -## Troubleshooting -There are many options for tools and environment to build in, and the behaviour -in each specific development environment might differ slightly. - -* Cross drive locations might not work. If this is the case mount to a usable - path in the shell used. -* There might be issues with NSYS/CMake and some toolchain paths, i.e. 'Program - Files (x86)'. Can be solved by mounting in MSYS to a usable path, or the - native Windows CMake can be called from the MSYS shell. -* GNU Wget is needed for downloads in TFLu. -* There might be issues rebuilding with CMake 3.20, with erroneous dependency - make files generated. Update to CMake 3.20.1, or downgrade to an earlier CMake - version. -* May need to unset TMPDIR environmental variable to get FlatBuffers download in - TFLu to work. -* When using Cygwin Terminal there might be error messages concerning '\r' in - the TFLu Bash scripts. In this case run dos2unix on these scripts. - diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index f9c3be0..11c57d0 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -64,7 +64,6 @@ function(ethosu_eval_link_options target) add_custom_command( OUTPUT ${LINK_FILE_OUT} DEPENDS ${LINK_FILE_IN} - BYPRODUCTS ${LINK_FILE_OUT} COMMAND ${CMAKE_C_COMPILER} ${COMPILER_PREPROCESSOR_OPTIONS} -o ${LINK_FILE_OUT} ${LINK_FILE_IN} COMMAND_EXPAND_LISTS "-D$" COMMAND_EXPAND_LISTS "-I$,;-I>" @@ -148,8 +147,8 @@ function(ethosu_add_binaries target) set(SCRIPTS_DIR ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../scripts) add_custom_command(TARGET ${target} POST_BUILD - COMMAND ${SCRIPTS_DIR}/generate_binaries.py --output ./fw $ - BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/fw/* + COMMAND ${SCRIPTS_DIR}/generate_binaries.py --output ./fw $ -d ${target}.d + DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${target}.d WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generate binaries for ${target}") endfunction() diff --git a/scripts/generate_binaries.py b/scripts/generate_binaries.py index 8eccc14..705bff8 100755 --- a/scripts/generate_binaries.py +++ b/scripts/generate_binaries.py @@ -26,7 +26,8 @@ import sys import elftools.elf.elffile as elffile def generate_binaries(args): - load_segments = []; + outfiles = [] + with open(args.input, 'rb') as f: elf = elffile.ELFFile(f) for segment in elf.iter_segments(): @@ -38,9 +39,16 @@ def generate_binaries(args): with open(out, 'wb') as of: of.write(segment.data()) + outfiles.append(out) + + if args.d: + with open(args.d, 'w') as f: + f.writelines(outfiles) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Generate binaries from ELF file') parser.add_argument('-o', '--output', default='.', required=False, help='Output directory for binaries') + parser.add_argument('-d', help='Dependency file') parser.add_argument('input', metavar='inputfile', type=str, help='ELF file to extract binaries from') args = parser.parse_args() -- cgit v1.2.1