SJFOM / StepUp-Pico

Portable stepper motor magic - on a RPi Pico board 🥧
MIT License
0 stars 0 forks source link

Alt Text

StepUp! - A simple tool for instant stepper motor testing

Hits Badge Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors License Badge

Project Structure

/StepUp-Pico
|
|___/App-StepUp             // StepUp! Application source code (C++)
|   |___CMakeLists.txt      // Application-level CMake config file
|
|___/Config
|   |___FreeRTOSConfig.h    // FreeRTOS project config file
|
|___/FreeRTOS-Kernel        // FreeRTOS kernel files, included as a submodule
|___/pico-sdk               // Raspberry Pi Pico SDK, included as a submodule
|
|___CMakeLists.txt          // Top-level project CMake config file
|___pico_sdk_import.cmake   // Raspberry Pi Pico SDK CMake import script
|
|___deploy.sh               // Build-and-deploy shell script (Windows)
|___deploy.py               // Build-and-deploy shell script (OS Agnostic - WIP)
|___program.sh              // Program Pico using a connected debugger tool
|___program_and_monitor.sh  // Program and monitor the Pico using a connected debugger tool
|___build_and_program.sh    // Build and then program the Pico using a connected debugger tool
|
|___rp2040.code-workspace   // Visual Studio Code workspace
|
|___README.md
|___LICENSE.md

Prerequisites

To use the code in this repo, your system must be set up for RP2040 C/C++ development.

VS Code extensions

Windows

The Raspberry Pi foundation offer a simple installer script for Windows users which downloads and configures the following:

Once installed, you will be presented with a version of VS Code pre-pended with the work "Pico" as shown in the image below.

VS Code Pico IDE

Use this version of the VSCode IDE from now on whenever developing for the Pico.

Once selected and VS code opens, you will likely be prompted with a choice of "Kit" - you should choose the arm-none-eabi

VS Code Kit selection

NOTE: If an existing build folder exists, it is recommended that you delete it before attempting to configure CMake to build your project.

Mac

(TBD)...

Linux (WIP)

Run bin/setup_pico.sh to configure a Linux machine for programming the Pico

NOTE: This guide is a modified version of a setup guide for the Raspberry Pi as offered by the Pi foundation - exercise caution when using!

Additional project setup info

Additionally, this blog post offers additional details on how Pico project setup works and explains how to add new libraries and Pico functionality (e.g. I2C).

Hardware

This project makes use of the very handy Raspberry Pi Debug Probe although this is only one of several ways of uploading code to and debugging the Pico microcontroller found on the StepUp! circuit board.

Alt Text

Debugging on MacOS

To get openocd to play ball, you must install the following libraries as described in the openocd/README.macOS file:

brew install libtool automake libusb libusb-compat hidapi libftdi

Debugging in Linux

1. Enable arm-none-eabi-gdb

To debug in Linux, you need to ensure you have arm-none-eabi-gdb installed. If you can build firmware for the Pico, odds are this is already installed on your PC but not symlinked correctly. To link this, run the following with elevated priveleges (sudo)

ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb

You should now see that running arm-none-eabi-gdb works as expected.

2. Configure Linux to recognise device

By following the very useful steps outlined here, you can configure your udev rules to recognise the Pico plugged in as a CMSIS-DAP interface.

The relevant steps in the linked guide are as follows:

  1. Create a file 10-my-usb.rules in /etc/udev/rules.d containing
    SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000c", MODE="666", GROUP="plugdev"
  2. Now, restart the udev service using
    sudo udevadm control --reload
    sudo udevadm trigger

Note on debugging (all platforms)

Ensure that both cortex-debug.openocdPath in settings.json and configFiles and searchDir key values in launch.json refer to the current Pico SDK v1.5.X version at time of install.

The environment variable PICO_SDK_VERSION should represent what SDK is being used by the development environment - query this environment variable from within your preferred terminal in VS Code to get this value.

Usage

  1. Clone (recursively) the repo: git clone --recursive https://github.com/SJFOM/StepUp-Pico.git.
  2. Enter the repo: StepUp-Pico.
  3. Optionally, edit CMakeLists.txt and /App-StepUp/CMakeLists.txt to configure the project.
  4. Optionally, manually configure the build process: cmake -S . -B build/.
  5. Optionally, manually build the app: cmake --build build.
  6. Connect your device so it’s ready for file transfer.
  7. Copy the StepUp.uf2 file from the build/App-StepUp folder to the drive which represents the attached Pico device hardware.

IDEs

Workspace files are included for Visual Studio Code.

Credits

This work makes heavy usage of Tony Smith's (a.k.a smittytone) wonderful RP2040-FreeRTOS Template which forms the basic structure for most of this project. Kudos to his work on creating a simple platform to get started with FreeRTOS on the Pi Pico hardware.

Copyright and Licences

StepUp! application source © 2023, Sam O'Mahony (a.k.a SJFOM) and licensed under the terms of the MIT Licence.

Original template source code © 2022, Tony Smith (a.k.a. smittytone) and licensed under the terms of the MIT Licence.

FreeRTOS © 2021, Amazon Web Services, Inc. It is also licensed under the terms of the MIT Licence.

The Raspberry Pi Pico SDK is © 2020, Raspberry Pi (Trading) Ltd. It is licensed under the terms of the BSD 3-Clause "New" or "Revised" Licence.