From 40081863d5c95c0dea5f0363c04ca0bcd9065860 Mon Sep 17 00:00:00 2001 From: PProvost Date: Wed, 13 May 2020 11:47:56 -0600 Subject: [PATCH] Updated readme, etc. --- CONTRIBUTING.md | 14 ++++++++ README.md | 73 ++++++++++++++++++++++++++++++++++++++- cmake/arm-none-eabi.cmake | 29 ++++++++++++++++ cmake/cortex_m0.cmake | 13 +++++++ cmake/cortex_m3.cmake | 13 +++++++ cmake/cortex_m4.cmake | 13 +++++++ cmake/cortex_m7.cmake | 13 +++++++ cmake/utilities.cmake | 15 ++++++++ 8 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 CONTRIBUTING.md create mode 100644 cmake/arm-none-eabi.cmake create mode 100644 cmake/cortex_m0.cmake create mode 100644 cmake/cortex_m3.cmake create mode 100644 cmake/cortex_m4.cmake create mode 100644 cmake/cortex_m7.cmake create mode 100644 cmake/utilities.cmake diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c282e9a1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,14 @@ +# Contributing + +This project welcomes contributions and suggestions. Most contributions require you to +agree to a Contributor License Agreement (CLA) declaring that you have the right to, +and actually do, grant us the rights to use your contribution. For details, visit +https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need +to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the +instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. \ No newline at end of file diff --git a/README.md b/README.md index bf9a068d..1cf17b0f 100644 --- a/README.md +++ b/README.md @@ -1 +1,72 @@ -# ThreadX \ No newline at end of file +# Azure RTOS ThreadX + +This advanced real-time operating system (RTOS) is designed specifically for deeply embedded applications. Among the multiple benefits it provides are advanced scheduling facilities, message passing, interrupt management, and messaging services. Azure RTOS ThreadX has many advanced features, including picokernel architecture, preemption threshold, event chaining, and a rich set of system services. + +## Documentation + +Documentation for this library can be found here: http://docs.microsoft.com/azure/rtos/threadx + +# Building and using the library + +## Prerequisites + +Install the following tools: + +* [CMake](https://cmake.org/download/) version 3.0 or later +* [GCC compilers for arm-none-eabi](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) +* [Ninja](https://ninja-build.org/) + +## Cloning the repo + +```bash +$ git clone https://github.com/azure-rtos/threadx.git +``` + +## Building the threadx static library + +Each component of Azure RTOS comes with a composible CMake-based build system that supports many different MCUs and host systems. Integrating any of these components into your device app code is as simple as adding a git submodule and then including it in your build using the CMake command `add_subdirectory()`. + +While the typical usage pattern is to include threadx into your device code source tree to be built & linked with your code, you can compile threadx as a standalone static library to confirm your build is set up correctly. + +```bash +$ cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=cmake/cortex_m4.cmake -GNinja . + +$ cmake --build ./build +``` + +# Repository Structure and Usage + +## Branches & Releases + +The master branch has the most recent code with all new features and bug fixes. It does not represent the latest General Availability (GA) release of the library. + +## Releases + +Each official release (preview or GA) will be tagged to mark the commit and push it into the Github releases tab, e.g. `v6.0-rel`. + +## Directory layout + +``` +- cmake +- common + - inc + - src +- ports + - cortex_m0/gnu + - inc + - src + - cortex_m3/gnu + - inc + - src + - cortex_m4/gnu + - inc + - src + - cortex_m7/gnu + - inc + - src +- samples +``` + +# Contribution, feedback and issues + +If you encounter any bugs, have suggestions for new features or if you would like to become an active contributor to this project please follow the instructions provided in the contribution guideline for the corresponding repo. diff --git a/cmake/arm-none-eabi.cmake b/cmake/arm-none-eabi.cmake new file mode 100644 index 00000000..147ce7a2 --- /dev/null +++ b/cmake/arm-none-eabi.cmake @@ -0,0 +1,29 @@ +# Toolchain settings +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) +set(AS arm-none-eabi-as) +set(AR arm-none-eabi-ar) +set(OBJCOPY arm-none-eabi-objcopy) +set(OBJDUMP arm-none-eabi-objdump) +set(SIZE arm-none-eabi-size) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# this makes the test compiles use static library option so that we don't need to pre-set linker flags and scripts +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_C_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} ${SPEC_FLAGS} -fdata-sections -ffunction-sections -mlong-calls" CACHE INTERNAL "c compiler flags") +set(CMAKE_CXX_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -fdata-sections -ffunction-sections -fno-rtti -fno-exceptions -mlong-calls" CACHE INTERNAL "cxx compiler flags") +set(CMAKE_ASM_FLAGS "${MCPU_FLAGS} -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags") +set(CMAKE_EXE_LINKER_FLAGS "${MCPU_FLAGS} ${LD_FLAGS} -Wl,--gc-sections" CACHE INTERNAL "exe link flags") + +SET(CMAKE_C_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "c debug compiler flags") +SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags") +SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags") + +SET(CMAKE_C_FLAGS_RELEASE "-O3" CACHE INTERNAL "c release compiler flags") +SET(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE INTERNAL "cxx release compiler flags") +SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags") \ No newline at end of file diff --git a/cmake/cortex_m0.cmake b/cmake/cortex_m0.cmake new file mode 100644 index 00000000..c1ecc144 --- /dev/null +++ b/cmake/cortex_m0.cmake @@ -0,0 +1,13 @@ +# Name of the target +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR cortex-m4) + +set(THREADX_ARCH "cortex_m0") +set(THREADX_TOOLCHAIN "gnu") + +set(MCPU_FLAGS "-mthumb -mcpu=cortex-m0") +set(VFP_FLAGS "") +set(SPEC_FLAGS "--specs=nosys.specs") +# set(LD_FLAGS "-nostartfiles") + +include(${CMAKE_CURRENT_LIST_DIR}/arm-none-eabi.cmake) \ No newline at end of file diff --git a/cmake/cortex_m3.cmake b/cmake/cortex_m3.cmake new file mode 100644 index 00000000..622c456b --- /dev/null +++ b/cmake/cortex_m3.cmake @@ -0,0 +1,13 @@ +# Name of the target +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR cortex-m4) + +set(THREADX_ARCH "cortex_m3") +set(THREADX_TOOLCHAIN "gnu") + +set(MCPU_FLAGS "-mthumb -mcpu=cortex-m3") +set(VFP_FLAGS "") +set(SPEC_FLAGS "--specs=nosys.specs") +# set(LD_FLAGS "-nostartfiles") + +include(${CMAKE_CURRENT_LIST_DIR}/arm-none-eabi.cmake) \ No newline at end of file diff --git a/cmake/cortex_m4.cmake b/cmake/cortex_m4.cmake new file mode 100644 index 00000000..c391735c --- /dev/null +++ b/cmake/cortex_m4.cmake @@ -0,0 +1,13 @@ +# Name of the target +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR cortex-m4) + +set(THREADX_ARCH "cortex_m4") +set(THREADX_TOOLCHAIN "gnu") + +set(MCPU_FLAGS "-mthumb -mcpu=cortex-m4") +set(VFP_FLAGS "") +set(SPEC_FLAGS "--specs=nosys.specs") +# set(LD_FLAGS "-nostartfiles") + +include(${CMAKE_CURRENT_LIST_DIR}/arm-none-eabi.cmake) \ No newline at end of file diff --git a/cmake/cortex_m7.cmake b/cmake/cortex_m7.cmake new file mode 100644 index 00000000..c4e48fa4 --- /dev/null +++ b/cmake/cortex_m7.cmake @@ -0,0 +1,13 @@ +# Name of the target +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR cortex-m7) + +set(THREADX_ARCH "cortex_m7") +set(THREADX_TOOLCHAIN "gnu") + +set(MCPU_FLAGS "-mthumb -mcpu=cortex-m7") +set(VFP_FLAGS "") +set(SPEC_FLAGS "--specs=nosys.specs") +# set(LD_FLAGS "-nostartfiles") + +include(${CMAKE_CURRENT_LIST_DIR}/arm-none-eabi.cmake) \ No newline at end of file diff --git a/cmake/utilities.cmake b/cmake/utilities.cmake new file mode 100644 index 00000000..801d87ed --- /dev/null +++ b/cmake/utilities.cmake @@ -0,0 +1,15 @@ +# Add the required subdirectory and register it for linkage +function(add_azrtos_component_dir dirname) + # Store the current list in a temp + set(tmp ${azrtos_targets}) + # Add the subdir + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/lib/${dirname}) + # If there is a linker script defined, use it + if(EXISTS ${LINKER_SCRIPT}) + target_link_options(${dirname} INTERFACE -T ${LINKER_SCRIPT}) + endif() + # Add this target into the temp + list(APPEND tmp "azrtos::${dirname}") + # Copy the temp back up to the parent list + set(azrtos_targets ${tmp} PARENT_SCOPE) +endfunction() \ No newline at end of file