How does it all come together? Daisy c++, making, flashing etc

Hi everyone,

I’m new to Daisy / C++ / dev environments / embedded programming (though experienced with Pd). Whilst there’s various tutorials on getting the most basic blink patches working with things like VS Code (see the Electro-Smith YouTube channel), when one runs into problems it feels almost impossible to know what is going on and what to look for for help online.

This is focusing on developing for Daisy in C++, right at the most basic level of how to get from C++ code in a .cpp file to a flashed Daisy (seed, patch etc), in this instance using Mac Terminal.

So say we have the DaisyExamples folder freshly downloaded onto our computer. This contains various examples for different Daisy boards, but also libraries (libdaisy and daisysp - are there others?). From here I can open terminal and change the working directory to an example such as Blink in DaisyExamples/seed. As there is already a makefile file, I can type ‘make’ into the terminal, which will do it’s thing a create a new directory called ‘build’. Within this directory we have a bunch of new files:

Blink.d
Blink.lst
Blink.map
Blink.o
startup_stm32h750xx.d
startup_stm32h750xx.lst
startup_stm32h750xx.o

What are these files and what do we do with them?

In my brief experience with VS Code, I could run the ‘task build_and_program_dfu’, so curious as to what the process is outside of VS Code from the terminal. I’ve seen dfu-util mentioned in places, but didn’t get very far trying to tie it all together!

(As a side note, I first tried flashing the seed with the examples with VS Code, but ran into a wall when using examples where the .cpp file had #include “daisy_seed.h” and #include “daisysp.h” at the top.

You’ve apparently been able to build from the command line - so the command line equivalent to VSC ‘task build_and_program_dfu’ is ‘make’ followed by ‘make program-dfu’.

The files you listed are intermediate products of the build process, and mostly are ignored, though they can be useful for debugging.

Daisy isn’t well suited for those without some basic knowledge about programming. Still, some succeed, more or less.

Thanks for your response @tele_player. That’s helpful getting a better insight into the equivalent processes between VS Code and the Mac Terminal and the files generated with the ‘make’ command.

I’ve had more success with VS Code writing out the cpp of one of the examples line-by-line and dealing with the errors as they come up. I’ll add it here in case anyone else finds themselves in a similar position – no prior experience of VSC or C++ and trying to get the DaisyExamples working with a Daisy Seed.

I started by creating a new folder on my desktop called DaisyProject and from VSC created a new file called DaisyProject.cpp and saved this to that folder. I then copied the libDaisy and DaisySP folders into the new DaisyProject folder so the libraries were in one place.

Back to the blank cpp file, I started by adding

#include "libDaisy/src/daisy_seed.h"

to the top to first make sure that VSC could see the library. With no errors, I then added the next library underneath:

#include "libDaisy/src/daisy_seed.h"
#include "DaisySP/Source/daisysp.h"

When I went to define DaisySeed hw, VSC threw an error. It turns out you need to add the namespaces! This was added below:

using namespace daisy;
using namespace daisysp;

The rest went pretty smoothly, just copying out the cpp file from the whitenoise example. I found it helped typing out the text to get an idea of how things were connecting together – it was satisfying seeing the auto-complete popping up as I was typing.

With the cpp file written out and no errors coming up, I found that the commands ‘task build_and_program_dfu’ was not coming up. It turns out there are hidden folders called .vscode in each of the example folders, and I think these are part of what allows VSCode to do all the build and flashing for the Daisy. There’s a Mac terminal command that unhides hidden files in the Finder:

defaults write com.apple.Finder AppleShowAllFiles TRUE
killall Finder

Then I copied one of these unhidden .vscode folders over to my new DaisyProject folder, and the commands started working in VS Code.

The DaisyExamples (seed, patch etc) each already have a makefile file in them. Looking at one of these makefile files there isn’t much going on – it seems to be pointing the compiler towards to right libraries and source files. Here’s a makefile that was only edited so that the project name and cpp matched my folder, likewise just having the folder names for libDaisy and DaisySP:

# Project Name

TARGET = DaisyProject

# Sources

CPP_SOURCES = DaisyProject.cpp

# Library Locations

LIBDAISY_DIR ?= libDaisy

DAISYSP_DIR ?= DaisySP

# Core location, and generic Makefile.

SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core

include $(SYSTEM_FILES_DIR)/Makefile

After this I ran the ‘task build_and_program_dfu’ command and the noise demo was coming out of the audio out pins!