7 This target supports building Pigweed on a few Arduino cores.
10 There are a few caveats when running Pigweed on top of the Arduino API. See
11 :ref:`module-pw_arduino_build` for details.
16 Currently only Teensy 4.x and 3.x boards are supported.
18 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
19 | Core | Board Name | Compiling | Flashing | Test Runner |
20 +==================================================================+===================================================================+===========+==========+=============+
21 | `teensy <https://www.pjrc.com/teensy/td_download.html>`_ | `Teensy 4.1 <https://www.pjrc.com/store/teensy41.html>`_ | ✓ | ✓ | ✓ |
22 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
23 | `teensy <https://www.pjrc.com/teensy/td_download.html>`_ | `Teensy 4.0 <https://www.pjrc.com/store/teensy40.html>`_ | ✓ | ✓ | ✓ |
24 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
25 | `teensy <https://www.pjrc.com/teensy/td_download.html>`_ | `Teensy 3.6 <https://www.pjrc.com/store/teensy36.html>`_ | ✓ | ✓ | ✓ |
26 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
27 | `teensy <https://www.pjrc.com/teensy/td_download.html>`_ | `Teensy 3.5 <https://www.pjrc.com/store/teensy35.html>`_ | ✓ | ✓ | ✓ |
28 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
29 | `teensy <https://www.pjrc.com/teensy/td_download.html>`_ | `Teensy 3.2 <https://www.pjrc.com/store/teensy32.html>`_ | ✓ | ✓ | ✓ |
30 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
31 | `arduino-samd <https://github.com/arduino/ArduinoCore-samd>`_ | `Arduino Zero <https://store.arduino.cc/usa/arduino-zero>`_ | | | |
32 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
33 | `arduino-sam <https://github.com/arduino/ArduinoCore-sam>`_ | `Arduino Due <https://store.arduino.cc/usa/due>`_ | | | |
34 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
35 | `adafruit-samd <https://github.com/adafruit/ArduinoCore-samd>`_ | `Adafruit Feather M0 <https://www.adafruit.com/?q=feather+m0>`_ | | | |
36 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
37 | `adafruit-samd <https://github.com/adafruit/ArduinoCore-samd>`_ | `Adafruit SAMD51 Boards <https://www.adafruit.com/category/952>`_ | | | |
38 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
39 | `stm32duino <https://github.com/stm32duino/Arduino_Core_STM32>`_ | | | | |
40 +------------------------------------------------------------------+-------------------------------------------------------------------+-----------+----------+-------------+
45 You must first install an Arduino core or let Pigweed know where you have cores
46 installed using the ``pw_arduino_build_CORE_PATH`` build arg.
48 Installing Arduino Cores
49 ------------------------
51 The ``arduino_builder`` utility can install Arduino cores automatically. It's
52 recommended to install them to into ``third_party/arduino/cores/``.
56 # Setup pigweed environment.
58 # Install an arduino core
59 arduino_builder install-core --prefix ./third_party/arduino/cores/ --core-name teensy
63 To build for this Pigweed target, simply build the top-level "arduino" Ninja
64 target. You can set Arduino build options using ``gn args out`` or by running:
69 pw_arduino_build_CORE_PATH="//third_party/arduino/cores"
70 pw_arduino_build_CORE_NAME="teensy"
71 pw_arduino_build_PACKAGE_NAME="teensy/avr"
72 pw_arduino_build_BOARD="teensy40"
73 pw_arduino_build_MENU_OPTIONS=["menu.usb.serial", "menu.keys.en-us"]'
75 On a Windows machine it's easier to run:
81 That will open a text file where you can paste the args in:
85 pw_arduino_build_CORE_PATH = "//third_party/arduino/cores"
86 pw_arduino_build_CORE_NAME = "teensy"
87 pw_arduino_build_PACKAGE_NAME="teensy/avr"
88 pw_arduino_build_BOARD = "teensy40"
89 pw_arduino_build_MENU_OPTIONS = ["menu.usb.serial", "menu.keys.en-us"]
91 Save the file and close the text editor.
99 To see supported boards and Arduino menu options for a given core:
103 arduino_builder --arduino-package-path ./third_party/arduino/cores/teensy \
104 --arduino-package-name teensy/avr \
109 Board Name Description
114 teensy31 Teensy 3.2 / 3.1
116 You may wish to set different arduino build options in
117 ``pw_arduino_build_MENU_OPTIONS``. Run this to see what's available for your core:
121 arduino_builder --arduino-package-path ./third_party/arduino/cores/teensy \
122 --arduino-package-name teensy/avr \
123 list-menu-options --board teensy40
125 That will show all menu options that can be added to ``gn args out``.
130 ----------------------------------------------------------------
131 menu.usb.serial Serial
132 menu.usb.serial2 Dual Serial
133 menu.usb.serial3 Triple Serial
134 menu.usb.keyboard Keyboard
135 menu.usb.touch Keyboard + Touch Screen
136 menu.usb.hidtouch Keyboard + Mouse + Touch Screen
137 menu.usb.hid Keyboard + Mouse + Joystick
138 menu.usb.serialhid Serial + Keyboard + Mouse + Joystick
143 --------------------------------------
144 menu.usb.serial Serial
145 menu.speed.600 600 MHz
146 menu.opt.o2std Faster
147 menu.keys.en-us US English
151 When working in upstream Pigweed, building this target will build all Pigweed
152 modules' unit tests. These tests can be run on-device in a few different ways.
156 If using ``out`` as a build directory, tests will be located in
157 ``out/arduino_debug/obj/[module name]/[test_name].elf``.
159 Tests can be flashed and run using the `arduino_unit_test_runner` tool. Here is
160 a sample bash script to run all tests on a Linux machine.
165 gn gen out --export-compile-commands \
166 --args='pw_arduino_build_CORE_PATH="//third_party/arduino/cores"
167 pw_arduino_build_CORE_NAME="teensy"
168 pw_arduino_build_PACKAGE_NAME="teensy/avr"
169 pw_arduino_build_BOARD="teensy40"
170 pw_arduino_build_MENU_OPTIONS=["menu.usb.serial", "menu.keys.en-us"]' && \
173 for f in $(find out/arduino_debug/obj/ -iname "*.elf"); do
174 arduino_unit_test_runner --verbose \
175 --config-file ./out/arduino_debug/gen/arduino_builder_config.json \
176 --upload-tool teensyloader \
177 out/arduino_debug/obj/pw_string/test/format_test.elf
180 Using the test server
181 ---------------------
183 Tests may also be run using the `pw_arduino_use_test_server = true` GN arg.
184 The server must be run with an `arduino_builder` config file so it can locate
185 the correct Arduino core, compiler path, and Arduino board used.
189 arduino_test_server --verbose \
190 --config-file ./out/arduino_debug/gen/arduino_builder_config.json
192 .. TODO(tonymd): Flesh out this section similar to the stm32f429i target docs.
194 Flashing Known Issues
195 ---------------------
200 By default Teensyduino uses the `Teensy Loader Application
201 <https://www.pjrc.com/teensy/loader.html>`_ which has a couple limitations:
203 - Requires a GUI (or X11 on Linux).
204 - Can only flash one board at a time.
209 Here is an example `pw_executable` gn rule that includes some Teensyduino
214 import("//build_overrides/pigweed.gni")
215 import("$dir_pw_arduino_build/arduino.gni")
216 import("$dir_pw_build/target_types.gni")
220 rebase_path(arduino_core_library_path),
226 pw_executable("my_app") {
227 # All Library Sources
228 _library_c_files = exec_script(
229 arduino_builder_script,
230 arduino_show_command_args + _library_args + [
234 _library_cpp_files = exec_script(
235 arduino_builder_script,
236 arduino_show_command_args + _library_args + [
237 "--library-cpp-files"
241 sources = [ "main.cc" ] + _library_c_files + _library_cpp_files
249 include_dirs = exec_script(arduino_builder_script,
250 arduino_show_command_args + _library_args +
251 [ "--library-include-dirs" ],
254 # Required for using Arduino.h and any Arduino API functions
255 remove_configs = [ "$dir_pw_build:strict_warnings" ]
256 deps += [ "$dir_pw_third_party/arduino:arduino_core_sources" ]