Skip to content

1. Setting Up Your Development Environment

takumi-ogata edited this page Aug 9, 2023 · 36 revisions

Steps

Follow along with the video guide!

1. Install the Toolchain

The "toolchain" is a combination of command line tools that are used within the Daisy ecosystem for building, flashing, and debugging firmware.

Follow the instructions below for installing the toolchain on your operating system:

2. Get the Source

Clone the DaisyExamples repository by pasting the following command into a terminal application:

git clone --recurse-submodules https://github.com/electro-smith/DaisyExamples ~/Desktop/DaisyExamples

3. VS Code

3a. Installation

Download and install the latest version of VS Code.

3b. Cortex Debug Extension

Note: this step is only necessary if you intend to debug your code with a debug probe.

To install the Cortex Debug extension in VS Code:

  • Go to the extensions tab View > Extensions
  • Search for Cortex Debug
  • Find the extension by marus25 and install, it should be the top result

3c. More Setup (Windows Only)

  • Open the terminal tab in the bottom of your VS Code window if not visible (Terminal -> New Terminal)
  • There should be a + button with a dropdown menu in the top right of the terminal window
  • In that dropdown select Select Default Profile, then choose Git Bash
  • Make sure to reset your USB driver before proceeding. Full instructions are on our Zadig Wiki Page.

If the git-bash terminal is not being used, you may get an error:

mkdir build
process_begin: CreateProcess(NULL, mkdir build, ...) failed.

If so, you can change your terminal to git-bash, or create the build/ folder manually.

4. Run the Blink Example

Now that we have a functioning build environment, let's run a "Blink" example on the Daisy.
A Blink program is the "Hello, World" of embedded programming and consists of toggling the state of an onboard LED.

There are two common ways to do this:

4a. Flashing the Daisy via USB

  • Open the Blink example's folder in VS Code by clicking File > Open Folder, then navigating to ~/Desktop/DaisyExamples/seed/Blink
  • Connect the Daisy Seed via USB
  • Put the Daisy into bootloader mode by holding the BOOT button down, and then pressing the RESET button. Once you release the RESET button, you can also let go of the BOOT button. This sequence is demonstrated above.
  • If this is a new install, or you have upgraded DaisyExamples, DaisySP, or libDaisy:
    • Launch the command palette with Ctrl+P on Windows or ⌘+P on macOS
    • Type task build_all. This will build the libraries, and the current example.
    • This step only has to be done on a new install, or when the source code has been updated inside of one of the libraries
  • Launch the command palette with Ctrl+P on Windows or ⌘+P on macOS
  • Run task build_and_program_dfu

This will build the example, and then flash the Daisy via dfu-util.

The Daisy Seed's onboard red led should be blinking.

In VS Code's Terminal, you'll see the following "errors" even though you succeeded in making the onboard LED blink. This message is normal and can be ignored in general.

dfu-util: Error during download get_status
make: *** [program-dfu] Error 74

4b. Flashing the Daisy via Debug probe

Connect the Debug Probe

We recommend using the ST-link V3 mini as your debug probe.

  • Connect the debug probe to the Daisy Seed as indicated below, making sure the red stripe is facing the correct direction
    Note: Make sure to center the debug probe on the Daisy's headers so that there are an even number of pins on either side of the connector
  • Power the device as usual

For the Daisy Seed:

For The Daisy Patch Submodule:

Flash the Example

  • Open VS Code
  • Open the Blink example's folder by clicking File > Open Folder, then navigating to ~/Desktop/DaisyExamples/seed/Blink
  • If this is a new install, or you have upgraded DaisyExamples, DaisySP, or libDaisy:
    • Launch the control palette with Ctrl+p on Windows or ⌘+P on macOS
    • Run task build_all. This will build the libraries
    • This step only has to be done on a new install, or when the source code has been updated
  • Launch the control palette with Ctrl+p on Windows or Shift+⌘+P on macOS
  • Run task build_and_program

This will build all libraries, build your example, and flash the Daisy via the debug probe.
The Daisy Seed's onboard red LED should be blinking.

To make your own Daisy project, checkout the Create a New Project wiki page.

5. Debugging

To debug your Daisy code:

  • Open the folder of the example you would like to debug as explained above
  • Attach your Daisy to the debug probe
  • Press F5, to enter debug mode, and flash your Daisy
  • VS Code will launch into the debugger, and halt at the default breakpoint
  • Press the continue arrow in the small debug menu to continue running the example

Under the hood, this command builds all libraries, builds your example, flashes via openocd, then connects the debug environment.

Refer to this tutorial for a good intro to debugging in VS Code.
While this tutorial is for debugging Node.js, the same principals apply.

6. Troubleshooting

Please refer to the troubleshooting page.