|
| 1 | + |
| 2 | +# Building CircuitPython |
| 3 | + |
| 4 | +Welcome to CircuitPython! |
| 5 | + |
| 6 | +This document is a quick-start guide only. |
| 7 | + |
| 8 | +Detailed guides on how to build CircuitPython can be found in the Adafruit Learn system at |
| 9 | +https://learn.adafruit.com/building-circuitpython/ |
| 10 | + |
| 11 | +## Setup |
| 12 | + |
| 13 | +Please ensure you setup your build environment appropriately, as per the guide. You will need: |
| 14 | + |
| 15 | +* Linux: https://learn.adafruit.com/building-circuitpython/linux |
| 16 | +* MacOS: https://learn.adafruit.com/building-circuitpython/macos |
| 17 | +* Windows Subsystem for Linux (WSL): https://learn.adafruit.com/building-circuitpython/windows-subsystem-for-linux |
| 18 | + |
| 19 | +### Submodules |
| 20 | + |
| 21 | +This project has a bunch of git submodules. You will need to update them regularly. |
| 22 | + |
| 23 | + git submodule sync |
| 24 | + git submodule update --init |
| 25 | + |
| 26 | +### mpy-cross |
| 27 | + |
| 28 | +As part of the build process, mpy-cross is needed to compile .py files into .mpy files. |
| 29 | +To compile (or recompile) mpy-cross: |
| 30 | + |
| 31 | + make -C mpy-cross |
| 32 | + |
| 33 | +# Building |
| 34 | + |
| 35 | +There a number of ports of CircuitPython! To build for your board, change to the appropriate ports directory and build. |
| 36 | + |
| 37 | +Examples: |
| 38 | + |
| 39 | + cd ports/atmel-samd |
| 40 | + make BOARD=circuitplayground_express |
| 41 | + |
| 42 | + cd ports/nrf |
| 43 | + make BOARD=circuitplayground_bluefruit |
| 44 | + |
| 45 | +If you aren't sure what boards exist, have a peek in the boards subdirectory of your port. |
| 46 | +If you have a fast computer with many cores, consider adding `-j` to your build flags, such as `-j17` on |
| 47 | +a 6-core 12-thread machine. |
| 48 | + |
| 49 | +# Testing |
| 50 | + |
| 51 | +If you are working on changes to the core language, you might find it useful to run the test suite. |
| 52 | +The test suite in the top level `tests` directory. It needs the unix port to run. |
| 53 | + |
| 54 | + cd ports/unix |
| 55 | + make axtls |
| 56 | + make micropython |
| 57 | + |
| 58 | +Then you can run the test suite: |
| 59 | + |
| 60 | + cd ../../tests |
| 61 | + ./run-tests |
| 62 | + |
| 63 | +A successful run will say something like |
| 64 | + |
| 65 | + 676 tests performed (19129 individual testcases) |
| 66 | + 676 tests passed |
| 67 | + 30 tests skipped: buffered_writer builtin_help builtin_range_binop class_delattr_setattr cmd_parsetree extra_coverage framebuf1 framebuf16 framebuf2 framebuf4 framebuf8 framebuf_subclass mpy_invalid namedtuple_asdict non_compliant resource_stream schedule sys_getsizeof urandom_extra ure_groups ure_span ure_sub ure_sub_unmatched vfs_basic vfs_fat_fileio1 vfs_fat_fileio2 vfs_fat_more vfs_fat_oldproto vfs_fat_ramdisk vfs_userfs |
| 68 | + |
| 69 | +# Debugging |
| 70 | + |
| 71 | +The easiest way to debug CircuitPython on hardware is with a JLink device, JLinkGDBServer, and an appropriate GDB. |
| 72 | +Instructions can be found at https://learn.adafruit.com/debugging-the-samd21-with-gdb |
| 73 | + |
| 74 | +If using JLink, you'll need both the `JLinkGDBServer` and `arm-none-eabi-gdb` running. |
| 75 | + |
| 76 | +Example: |
| 77 | + |
| 78 | + JLinkGDBServer -if SWD -device ATSAMD51J19 |
| 79 | + arm-none-eabi-gdb build-metro_m4_express/firmware.elf -iex "target extended-remote :2331" |
| 80 | + |
| 81 | +If your port/build includes `arm-none-eabi-gdb-py`, consider using it instead, as it can be used for better register |
| 82 | +debugging with https://github.com/bnahill/PyCortexMDebug |
0 commit comments