.. _how-to_build_code: How build code ============== .. toctree:: :maxdepth: 3 :caption: Contents: Platform support ---------------- Framework: - Arduino This code is made to be used with: - All (with Standard Library c++11 support) .. attention:: Code will not compile on boards without standard library c++11 support. Assembling dependencies ----------------------- The SYSROX code uses repo to synchronize all necessary repositories. The app_ins can not work without the necessary libraries and it is recommended to use repo or a zip file containing all dependencies. Using repo ---------- The repo system is a tool made by google to manage multiple git repositories. With a file (manifest) containing all the repositories links, it is possible to clone et keep synchronized all project dependencies with a single command. .. tip:: The idea is to repo sync the code the first time, do modifications in one or multiple repositories. When the base code is updated, all repositories can be update to the latest version with repo sync. Custom modification can then be rebased on top of the new code! Install repo ~~~~~~~~~~~~ .. code-block:: bash sudo apt-get install repo If your distribution does not have a repo package, you can do: .. code-block:: bash mkdir -p ~/.bin PATH="${HOME}/.bin:${PATH}" curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo chmod a+rx ~/.bin/repo Create a folder of your choice to place the project and go to it. Repo sync code with SSH key ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash repo init -u ssh://git@git.sysrox.com:2224/code/manifests/manifest_ins_minimal.git repo sync Repo sync code with HTTPS ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: bash repo init -u https://git.sysrox.com/code/manifests/manifest_ins_minimal.git repo sync Using platformio ---------------- The easiest way to use the code is to use platformio. It includes many tools to build, test and upload the code to the board. If you use vscode, you can install the extension and juste source the environment. Sourcing the environment or using the cli is not mandatory as you can just repo sync the code and use platformio extension (on windows for example), but it simplifies the process as you just need to copy paste the following commands. If you can not do it, you can just use the platformio extension and install Expressif32 platform. Platformio cli ~~~~~~~~~~~~~~ .. code-block:: bash pip install -U platformio Platformio with vscode IDE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If vscode extension is installed, you can just source the env: .. code-block:: bash source ~/.platformio/penv/bin/activate Build full code --------------- The configuration file for the build is a conf.ini located in conf folder. We want to create a symbolic link or copy this file to the root of the project in order to be able to build: .. code-block:: bash ln -s src/appDM_ins_minimal/conf/conf.ini platformio.ini Now we can build the code with: .. code-block:: bash pio run -e your_env .. admonition:: Example .. code-block:: bash pio run -e lolin_s3 and build+flash with: .. code-block:: bash pio run -e your_env --target upload .. admonition:: Example .. code-block:: bash pio run -e lolin_s3 --target upload The **your_env** is the name of the environment you want to build for. You can find examples in **platformio.ini** file (ie the configuration file located in **conf/conf.ini**) Depending on the microcontroller you use, you can add any environment you want with modifying this file, following Platformio syntax. .. admonition:: Example .. code-block:: ini :linenos: [env:lolin_s3] platform = espressif32 monitor_filters = esp32_exception_decoder board = lolin_s3 framework = arduino upload_speed = 921600 build_unflags = -Os board_build.f_cpu = 240000000L board_build.f_flash = 80000000L board_build.partitions = default_16MB.csv board_build.filesystem = spiffs build_flags = -O2 -DBOARD_HAS_PSRAM -I lib/libDM_ctrl/src/ -I lib/libDM_no_dep_abstract_sensors/src/ -I lib/libDM_no_dep_icm42688/src/ -I lib/libMM_no_dep_lps_22hb/src/ -I lib/libDM_no_dep_mmc5983ma/src/ -I lib/libDM_SRX_INS_10_DOF/src/ -I lib/libDM_SRX_INS_10_DOF/src/model -I src/appDM_ins_minimal # Model static libs -L lib/libDM_SRX_INS_10_DOF/src/static_libs -l Srx10Dof_esp32s3.a lib_deps = SPI [env:teensy41] platform = teensy@4.17 board = teensy41 framework = arduino board_build.f_cpu = 600000000L ; extra_scripts = pre:src/correct_clone.py build_flags = -D TEENSY_OPT_FASTER ; -D TEENSY_OPT_SMALLEST_CODE can be faster -I lib/libDM_ctrl/src/ -I lib/libDM_no_dep_abstract_sensors/src/ -I lib/libDM_no_dep_icm42688/src/ -I lib/libMM_no_dep_lps_22hb/src/ -I lib/libDM_no_dep_mmc5983ma/src/ -I lib/libDM_SRX_INS_10_DOF/src/ -I lib/libDM_SRX_INS_10_DOF/src/model -I src/appDM_ins_minimal # Model static libs -L lib/libDM_SRX_INS_10_DOF/src/static_libs -l Srx10Dof_teensy41.a lib_deps = SPI [env:teensy4] platform = teensy board = teensy40 framework = arduino board_build.f_cpu = 600000000L ; extra_scripts = pre:src/correct_clone.py build_flags = -D TEENSY_OPT_FASTER ; -D TEENSY_OPT_SMALLEST_CODE can be faster ; -g -I lib/libDM_ctrl/src/ -I lib/libDM_no_dep_abstract_sensors/src/ -I lib/libDM_no_dep_icm42688/src/ -I lib/libMM_no_dep_lps_22hb/src/ -I lib/libDM_no_dep_mmc5983ma/src/ -I lib/libDM_SRX_INS_10_DOF/src/ -I lib/libDM_SRX_INS_10_DOF/src/model -I src/appDM_ins_minimal # Model static libs -L lib/libDM_SRX_INS_10_DOF/src/static_libs -l Srx10Dof_teensy40.a lib_deps = SPI