-
Notifications
You must be signed in to change notification settings - Fork 62
Fetch REx drivers dependencies automatically #218
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
Open
ekoeppen
wants to merge
1
commit into
master
Choose a base branch
from
rex-build
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,104 +1,53 @@ | ||
| cmake_minimum_required(VERSION 3.10) | ||
| enable_language(ASM) | ||
|
|
||
| set(NCT_PROJECTS $ENV{NCT_PROJECTS}) | ||
|
|
||
| set(LINK_OPTIONS | ||
| -L ${CMAKE_SOURCE_DIR} | ||
| -Tprotocol.ld --version-script=protocol.map) | ||
|
|
||
| set(INCLUDE_DIRECTORIES | ||
| . | ||
| ${CMAKE_SOURCE_DIR}/.. | ||
| ${NCT_PROJECTS}/DDKIncludes | ||
| ${NCT_PROJECTS}/DDKIncludes/Bootstrap | ||
| ${NCT_PROJECTS}/DDKIncludes/CLibrary | ||
| ${NCT_PROJECTS}/DDKIncludes/CommAPI | ||
| ${NCT_PROJECTS}/DDKIncludes/Communications | ||
| ${NCT_PROJECTS}/DDKIncludes/Frames | ||
| ${NCT_PROJECTS}/DDKIncludes/HAL | ||
| ${NCT_PROJECTS}/DDKIncludes/Lantern | ||
| ${NCT_PROJECTS}/DDKIncludes/OS600 | ||
| ${NCT_PROJECTS}/DDKIncludes/Packages | ||
| ${NCT_PROJECTS}/DDKIncludes/Power | ||
| ${NCT_PROJECTS}/DDKIncludes/QD | ||
| ${NCT_PROJECTS}/DDKIncludes/Toolbox | ||
| ${NCT_PROJECTS}/DDKIncludes/UtilityClasses | ||
| ${NCT_PROJECTS}/DDKIncludes/PCMCIA | ||
| ${NCT_PROJECTS}/Includes | ||
| ${NCT_PROJECTS}/Includes/CLibrary | ||
| ${NCT_PROJECTS}/Includes/Frames | ||
| ${NCT_PROJECTS}/Includes/Utilities | ||
| ${NCT_PROJECTS}/LanternDriver_DDK/Includes | ||
| ${NCT_PROJECTS}/NSandDDK | ||
| ${NCT_PROJECTS}) | ||
|
|
||
| file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/obj) | ||
|
|
||
| # -- Shared runtime, containing the NewtonOS APIs and additional glue code | ||
|
|
||
| project(Runtime) | ||
| add_library(Runtime | ||
| Glue.s UGlue.cpp NewtonRuntime/NewtonRuntime.cpp NewtonRuntime/NewtonPublicAPIs.s NativePrimitives.s) | ||
| target_include_directories(Runtime PRIVATE ${INCLUDE_DIRECTORIES}) | ||
| target_link_options(Runtime PRIVATE ${LINK_OPTIONS}) | ||
|
|
||
| # -- Drivers to interface with the Einstein emulator and host system | ||
|
|
||
| macro(define_driver DRIVER) | ||
| project(${DRIVER}) | ||
| add_executable(${DRIVER} ${ARGN}) | ||
| add_dependencies(${DRIVER} Runtime) | ||
| target_link_libraries(${DRIVER} Runtime) | ||
| target_include_directories(${DRIVER} PRIVATE ${INCLUDE_DIRECTORIES}) | ||
| target_link_options(${DRIVER} PRIVATE ${LINK_OPTIONS}) | ||
| add_custom_command(TARGET ${DRIVER} POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_SOURCE_DIR}/obj/$<TARGET_FILE_NAME:${DRIVER}>.pkg | ||
| COMMAND ELFtoPKG -o ${CMAKE_SOURCE_DIR}/obj/$<TARGET_FILE_NAME:${DRIVER}>.pkg $<TARGET_FILE_NAME:${DRIVER}>:Einstein -protocol | ||
| $<TARGET_FILE:${DRIVER}> -autoLoad -autoRemove) | ||
| endmacro() | ||
|
|
||
| define_driver(EinsteinBatteryDriver PMainBatteryDriver.cpp PMainBatteryDriver.impl.s PMainBatteryDriverPrims.s) | ||
| define_driver(EinsteinStartupDriver TMainStartupDriver.cpp TMainStartupDriver.impl.s) | ||
| define_driver(EinsteinPlatformDriver TMainPlatformDriver.cpp TMainPlatformDriver.impl.s TMainPlatformDriverPrims.s) | ||
| define_driver(EinsteinSoundDriver PMainSoundDriver.cpp PMainSoundDriver.impl.s PMainSoundDriverPrims.s) | ||
| define_driver(EinsteinScreenDriver TMainDisplayDriver.cpp TMainDisplayDriver.impl.s TMainDisplayDriverPrims.s) | ||
| define_driver(EinsteinTabletDriver TMainTabletDriver.cpp TMainTabletDriver.impl.s TMainTabletDriverPrims.s) | ||
| define_driver(EinsteinVersionString TMainVersionString.cpp TMainVersionString.impl.s) | ||
| define_driver(EinsteinSerialVoyager TSerialChipVoyager.cpp TSerialChipVoyager.impl.s TSerialChipVoyagerPrims.s) | ||
| define_driver(EinsteinInTranslator PEinsteinInTranslator.cpp PEinsteinInTranslator.impl.s PEinsteinInTranslatorPrims.s) | ||
| define_driver(EinsteinOutTranslator PEinsteinOutTranslator.cpp PEinsteinOutTranslator.impl.s PEinsteinOutTranslatorPrims.s) | ||
| define_driver(EinsteinNativeCalls TEinsteinNativeCalls.cpp TEinsteinNativeCalls.impl.s TEinsteinNativeCallsPrims.s) | ||
| define_driver(EinsteinSerialDriver TSerialChipEinstein.cpp TSerialChipEinstein.impl.s TSerialChipEinsteinPrims.s) | ||
| define_driver(EinsteinFlashDriver TEinsteinFlashDriver.cpp TEinsteinFlashDriver.impl.s TEinsteinFlashDriverPrims.s) | ||
| add_custom_command(TARGET EinsteinFlashDriver POST_BUILD | ||
| COMMAND ${OBJCOPY} -O binary $<TARGET_FILE:EinsteinFlashDriver> ${CMAKE_SOURCE_DIR}/obj/$<TARGET_FILE_NAME:EinsteinFlashDriver>.bin) | ||
|
|
||
| # -- Additional packages | ||
|
|
||
| add_subdirectory(EinsteinPortEnabler) | ||
|
|
||
| # -- Custom target to create the REx, will be always built and installed to the _Data_ directory | ||
|
|
||
| project(Einstein) | ||
| add_custom_target(Einstein ALL) | ||
| add_dependencies(Einstein | ||
| EinsteinBatteryDriver | ||
| EinsteinStartupDriver | ||
| EinsteinFlashDriver | ||
| EinsteinPlatformDriver | ||
| EinsteinSoundDriver | ||
| EinsteinScreenDriver | ||
| EinsteinTabletDriver | ||
| EinsteinVersionString | ||
| EinsteinSerialDriver | ||
| EinsteinSerialVoyager | ||
| EinsteinInTranslator | ||
| EinsteinOutTranslator | ||
| EinsteinNativeCalls | ||
| portenabler) | ||
| add_custom_command(TARGET Einstein | ||
| WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
| COMMAND ${CMAKE_COMMAND} -E rm -f Einstein.rex | ||
| COMMAND Rex -o Einstein.rex Einstein.rex.src) | ||
| install(FILES ${CMAKE_SOURCE_DIR}/Einstein.rex DESTINATION ${CMAKE_SOURCE_DIR}/../_Data_/) | ||
| cmake_minimum_required(VERSION 3.14) | ||
| project(EinsteinDrivers) | ||
|
|
||
| include(ExternalProject) | ||
| include(FetchContent) | ||
|
|
||
| # -- Check for ARM toolchain | ||
| find_program(ARM_GCC arm-none-eabi-gcc) | ||
| if (ARM_GCC) | ||
| get_filename_component(ARM_GCC_PATH ${ARM_GCC} DIRECTORY) | ||
| message(STATUS "Found ARM GCC at: ${ARM_GCC_PATH}") | ||
| message(STATUS "Newton drivers will be built.") | ||
|
|
||
| # -- Fetch NCT_Projects (Headers and platform file) | ||
| FetchContent_Declare( | ||
| nct_projects | ||
| GIT_REPOSITORY https://github.com/ekoeppen/NCT_Projects.git | ||
| GIT_TAG main | ||
| ) | ||
| FetchContent_MakeAvailable(nct_projects) | ||
| set(NCT_PROJECTS_DIR ${nct_projects_SOURCE_DIR}) | ||
|
|
||
| # -- Setup Host Tools (DCL tools and tntk) | ||
| add_subdirectory(host) | ||
|
|
||
| # -- Build REx | ||
| ExternalProject_Add(drivers_target | ||
| SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/target | ||
| BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/target-build | ||
| # We depend on the tools targets defined in the host sub-project | ||
| DEPENDS dcl_host tntk_host | ||
| CMAKE_ARGS | ||
| -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/newton-cross.cmake | ||
| -DREX_TOOL=${DCL_BIN_DIR}/Rex | ||
| -DELFTOPKG_TOOL=${DCL_BIN_DIR}/ELFtoPKG | ||
| -DELFTONTK_TOOL=${DCL_BIN_DIR}/ELFtoNTK | ||
| -DTNTK_TOOL=${TNTK_BIN_DIR}/tntk | ||
| -DNCT_PROJECTS=${NCT_PROJECTS_DIR} | ||
| -DEINSTEIN_ROOT=${CMAKE_CURRENT_SOURCE_DIR}/.. | ||
| INSTALL_COMMAND "" | ||
| BUILD_ALWAYS 1 | ||
| ) | ||
|
|
||
| # Expose the final artifact to the parent project | ||
| add_custom_target(EinsteinDrivers ALL) | ||
| add_dependencies(EinsteinDrivers drivers_target) | ||
|
|
||
| # Copy the finished REx to the build dir so the root can find it | ||
| add_custom_command(TARGET EinsteinDrivers POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Einstein.rex ${CMAKE_CURRENT_SOURCE_DIR}/../_Data_/Einstein.rex) | ||
| else() | ||
| message(STATUS "ARM toolchain NOT found. Skipping driver and host tool build.") | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,60 @@ | ||
| # Einstein ROM Extension | ||
|
|
||
| This directory contains the ROM extension (REx) for Einstein, which implements the protocols to interface with the | ||
| host OS. The REx is by default part of the Einstein application. The extension contains native parts which implement | ||
| NewtonOS protocols, as well as mixed NewtonScript/native extensions in the form of NewtonOS autoparts. | ||
| This directory contains the ROM extension (REx) for Einstein, which implements | ||
| the protocols to interface with the host OS. The REx is by default part of the | ||
| Einstein application. The extension contains native parts which implement | ||
| NewtonOS protocols, as well as mixed NewtonScript/native extensions in the | ||
| form of NewtonOS autoparts. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| The REx is a collection of NewtonOS binaries (wrapped into NewtonOS packages), and thus the sources need to be cross | ||
| compiled with a NewtonOS compatible tool chain. Compilation also requires NewtonOS specific tools. | ||
| The REx is a collection of NewtonOS binaries (wrapped into NewtonOS packages), | ||
| and thus the sources need to be cross-compiled with a NewtonOS-compatible tool | ||
| chain. Compilation also requires NewtonOS-specific tools. | ||
|
|
||
| CMake will fetch missing dependencies automatically except for GCC. If GCC is | ||
| not found, the build will be skipped. | ||
|
|
||
| ### GCC | ||
|
|
||
| GCC up to version 12.x as an ARM cross compiler, e.g. [gcc-arm-none-eabi](https://packages.ubuntu.com/search?keywords=gcc-arm-none-eabi&searchon=names) | ||
| GCC with support for `armv4` as an ARM cross compiler, e.g. [gcc-arm-none-eabi](https://packages.ubuntu.com/search?keywords=gcc-arm-none-eabi&searchon=names) | ||
| for an Ubuntu package, [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) | ||
| for the general ARM provided downloads, or a [brew tap](https://github.com/armmbed/homebrew-formulae) for installation | ||
| for the general ARM-provided downloads, or a | ||
| [brew tap](https://github.com/armmbed/homebrew-formulae) for installation | ||
| via Homebrew. | ||
|
|
||
| ### DCL | ||
|
|
||
| Conversion of the compiles binaries requires the `Rex` and `ELFtoPKG` tools. It can be installed by compiling and installing the [DCL](https://github.com/pguyot/DCL). | ||
| Conversion of the compiled binaries requires the `Rex` and `ELFtoPKG` tools | ||
| provided by [DCL](https://github.com/pguyot/DCL). | ||
|
|
||
| ### NCT and DDK Headers | ||
|
|
||
| The C++ headers can be obtained by cloning this [repository](https://github.com/ekoeppen/NCT_Projects). | ||
|
|
||
| The environment variable `NCT_PROJECTS` needs to point to the location of the directory containing the `Includes` and `DDKIncludes` directories. | ||
| The C++ headers and Newton Platform file are obtained by cloning this | ||
| [repository](https://github.com/ekoeppen/NCT_Projects). | ||
|
|
||
| ### tntk | ||
|
|
||
| [tntk](https://github.com/ekoeppen/tntk) is an optional prerequisite to compile NewtonScript packages. If it not installed, the precompiled | ||
| [tntk](https://github.com/ekoeppen/tntk) is an optional prerequisite to | ||
| compile NewtonScript packages. If it is not installed, the precompiled | ||
| packages are included in the REx. | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| ## Building | ||
|
|
||
| After installing GCC and the DCL tools, and setting `NCT_PROJECTS` correctly, the REx can be built with `cmake`: | ||
| The CMake script will pull in the dependencies and build first the DCL, then | ||
| tntk using the CMake file in `./host`, followed by compiling the REx using the | ||
| CMake file in `./target`. This is driven by the top level CMake file, e.g. | ||
| executing in the directory here: | ||
|
|
||
| cmake -S Drivers -B Drivers/build -DCMAKE_TOOLCHAIN_FILE=cmake/newton-cross.cmake | ||
| cmake --build Drivers/build | ||
| cmake --install Drivers/build | ||
| cmake -S . -B build | ||
| cmake --build build | ||
|
|
||
| ## Components | ||
|
|
||
| - Protocols: The NewtonOS to host implementation is provided as NewtonOS protocol implementations, which will either | ||
| handle the calls directly natively, or will invoke the Einstein drivers via coprocessor instructions | ||
| - Protocols: The NewtonOS to host implementation is provided as NewtonOS | ||
| protocol implementations, which will either handle the calls directly | ||
| natively, or will invoke the Einstein drivers via coprocessor instructions | ||
| - NSRuntime: Helper package | ||
| - EinsteinPortEnabler: Autopart which will initialize serial drivers when enabled via the Newton preferences app | ||
| - EinsteinPortEnabler: Autopart which will initialize serial drivers when | ||
| enabled via the Newton preferences app | ||
| - Additional packages in the `packages` directory can be included in the REx | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.