Skip to content

brilliantlabsAR/monocle-micropython

Repository files navigation

MicroPython for Monocle

A custom deployment of MicroPython designed specifically for Monocle. Check out the user docs here.

For those of you who want to modify the standard firmware, keep on reading.

Getting started with development

  1. Ensure you have the ARM GCC Toolchain installed.

  2. Ensure you have the nRF Command Line Tools installed.

  3. Clone this repository along with submodules and build the mpy-cross toolchain:

    git clone https://github.com/brilliantlabsAR/monocle-micropython.git
    cd monocle-micropython
    
    git submodule update --init
    git -C micropython submodule update --init lib/micropython-lib
    
    make -C micropython/mpy-cross
  4. You should now be able to build the project by calling make from the monocle-micropython folder.

    make
  5. Before flashing an nRF5340, you may need to unlock the chip first.

    nrfjprog --recover
  6. You should then be able to flash the device.

    make flash

Debugging

  1. Open the project in VSCode.

    There are some build tasks already configured within .vscode/tasks.json. Access them by pressing Ctrl-Shift-P (Cmd-Shift-P on MacOS) → Tasks: Run Task.

    1. Build
    2. Build & Flash Chip
    3. Erase & Unlock Chip
    4. Clean
  2. Connect your debugger as described here.

  3. You many need to unlock the device by using the Erase Chip task before programming or debugging.

  4. To enable IntelliSense, be sure to select the correct compiler from within VSCode. Ctrl-Shift-P (Cmd-Shift-P on MacOS) → C/C++: Select IntelliSense ConfigurationUse arm-none-eabi-gcc.

  5. Install the Cortex-Debug extension for VSCode in order to enable debugging.

  6. A debugging launch is already configured within .vscode/launch.json. Run the J-Link launch configuration from the Run and Debug panel, or press F5. The project will automatically build and flash before launching.

  7. To monitor the logs, run the task RTT Console and ensure the J-Link launch configuration is running.

Generating final release .hex and DFU .zip files

  1. Download and install nrfutil including the nrf5sdk-tools package:

    chmod +x nrfutil
    # Make sure to add nrfutil to your path
    nrfutil install nrf5sdk-tools
  2. Generate a settings file:

    nrfutil settings generate --family NRF52 --application build/application.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 build/settings.hex
  3. Download and install the mergehex tool which is a part of the nRF Command Line Tools.

  4. Merge the settings, bootloader, softdevice and application hex files:

    mergehex -m build/settings.hex build/application.hex softdevice/s132_nrf52_7.3.0_softdevice.hex bootloader/build/nrf52832_xxaa_s132.hex -o build/release.hex
  5. Create the DFU zip package using the command:

    nrfutil pkg generate --hw-version 52 --application-version 0 --application build/application.hex --sd-req 0x0124 --key-file bootloader/published_privkey.pem build/release.zip

FPGA

For information on developing and flashing the FPGA binary. Check the Monocle FPGA repository.