Skip to content

About

A playground for learning about microcontroller programming

Topics

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Microcontroller Playground

Tests Documentation License Raspberry Pi Apache NuttX


This is a playground for my microcontroller projects and experiments.


Quickstart

1. Clone the repository

git clone https://github.com/habedi/microcontroller-playground
cd microcontroller-playground
make submodules

2. Enter the development environment

make shell

Important

The first make shell builds the RISC-V cross-compiler toolchain from source, which can take some time. When the first build is done, run make shell-pin, so a Nix garbage collection does not discard the build results. The Espressif boards also need make install, which installs esptool. Note that the Raspberry Pi Pico 2 does not need it.

3. Build and run on the Pico 2

make nuttx-configure BOARD=raspberrypi-pico-2:usbnsh
make nuttx-build
make flash-pico-uf2             # Hold the BOOTSEL button pressed down while plugging the board in
make console TTY=/dev/ttyACM0   # Picocom at 115200 baud; quit with C-a C-x

Press Enter twice after the console opens to get the nsh> prompt. The first Enter only echoes, and the session starts on the second one.

NuttShell

The usbnsh configuration puts the NuttShell on the USB cable, so no extra hardware is needed. The nsh configuration puts it on UART0 (at GP0 and GP1 pins), which needs a USB to UART adapter.

Both flash targets need the board in BOOTSEL mode. make flash-pico-uf2 copies the image to the drive that the board exposes, and needs no special permissions. make flash-pico uses picotool, which needs the udev rules that make setup-udev installs once.

4. Build and run on the ESP32-P4

make nuttx-distclean            # Run this whenever you switch boards
make nuttx-configure BOARD=esp32p4-function-ev-board:nsh
make nuttx-build
make nuttx-flash-esp PORT=/dev/ttyACM0
make console TTY=/dev/ttyACM0

The board's USB-C port connects to an onboard WCH CH343 USB to UART bridge on UART0 (GPIO 37 and GPIO 38), appearing as /dev/ttyACM0 with USB vendor 1a86.

Note

An ESP32-P4 with a silicon revision below v3.0 halts in the revision check that the stock configuration compiles in. Configure such a chip from the saved configuration instead, with make nuttx-configure-saved SAVED_CONFIG=configs/nuttx/esp32p4-function-ev-board/nsh-rev1. It sets CONFIG_ESP32P4_SELECTS_REV_LESS_V3 and CONFIG_ESP32P4_REV_MIN_100 and boots to an interactive NuttShell on UART0.

Note

Serial access needs membership in the dialout group. Run sudo usermod -aG dialout $USER, then log in again. If you are not a member of the group, you will not have permission to access the serial port.


Contributing

See CONTRIBUTING.md for details on how to make a contribution.

License

The content of this repository is licensed under the Apache License, Version 2.0 (see LICENSE).

About

A playground for learning about microcontroller programming

Topics

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Sponsor this project

Used by

Contributors

Languages