macOS C++ IDE

Hey @adam_f, still working on getting all that working together nicely and plan on writing a full tutorial about it when I’m done.

The goal is to be able to use VS Code + Platform IO for all development tasks, with the ability to flash directly to the seed within the IDE, and have full hardware debugging support and all full features of PIO available.

Here’s how far I’ve gotten and what remains to be done:

What Works

  • I can run make clean; make; make program-dfu while in the DaisyExamples folder and it’ll build/push to the seed if it’s in DFU mode just fine. This is all from terminal after git cloning the DaisyExamples repo and cd’ing to it.

  • I bought a SEGGER J-LINK EDU and connected it to the seed, I was able to start the GDB server for debugging.

  • I created a new project using Platform IO in VS Code called “Hello World”, my platformio.ini file looks like this:

      [env:electrosmith_daisy]
      platform = ststm32
      board = electrosmith_daisy
      framework = cmsis
      debug_tool = jlink
      upload_protocol = jlink-jtag
      debug_port = :2331
      debug_server =
        /Applications/SEGGER/JLink/JLinkGDBServerCL
        -singlerun
        -if
        SWD
        -select
        USB
        -port
        2331
        -device
        STM32H750IB
    

What Doesn’t Work

  • The biggest issue I’m having at the moment is getting VS Code to work with the DaisyExamples repo by recognizing the source code as valid. When attempting to compile source directly within VS Code, I get the following errors:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/flavius/repos/DaisyExamples/pod/SynthVoice/SynthVoice.cpp).

cannot open source file “daisysp.h”

cannot open source file “daisy_pod.h”

For some reason VS Code doesn’t find the source valid, and attempting to upload/debug SynthVoice.cpp results in this mess:

> Executing task in folder DaisyExamples: platformio debug <

Processing electrosmith_daisy (platform: ststm32; board: electrosmith_daisy; framework: cmsis)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/electrosmith_daisy.html
PLATFORM: ST STM32 7.0.0 > Electrosmith Daisy
HARDWARE: STM32H750IBK6 400MHz, 128KB RAM, 512KB Flash
DEBUG: Current (jlink) External (blackmagic, jlink, stlink)
PACKAGES: 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 - framework-cmsis-stm32h7 1.8.0 
 - tool-ldscripts-ststm32 0.1.0 
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Linking .pio/build/electrosmith_daisy/firmware.elf
.pio/build/electrosmith_daisy/FrameworkCMSIS/gcc/startup_stm32h750xx.o: In function `LoopFillZerobss':
/Users/flavius/.platformio/packages/framework-cmsis-stm32h7/Source/Templates/gcc/startup_stm32h750xx.S:97: undefined reference to `main'
collect2: error: ld returned 1 exit status
*** [.pio/build/electrosmith_daisy/firmware.elf] Error 1
  • I currently cannot get VS Code to play nicely with the hardware debugger either, and I’m guessing this is because the source isn’t cooperating. Hopefully once I figure that out I can get debugging working too.

  • I tried following instructions for getting the Cortex Debugger working but that was it’s own can of worms. Will revisit once basic Platform IO functionality works.

If anybody has time to help, I’d greatly appreciate it!

Hey Flavius, thanks for your reply!

Where are your daisy libraries located? I don’t get the include error when I use
lib_extra_dirs = (library path) in platformio.ini. Also I found that you have to run the project task ‘Rebuild Intellisense Index’ to get platformio to register the new folder. Let me know if that works!

Also I have a ST-LINK/V2 programmer, do you know if that would work for flashing and debugging? It’s what I’ve used to flash STM32 MCUs on MI modules in the past.

The ST-link is used on boards that can’t be flashed directly through USB.

I don’t have any answers for the issues related yet, but I’ve just recently started migrating to VS Code (with the Cortex-Debug extension) as well. I got debugging working for a non-daisy stm32 board fairly quickly without seeing build errors. I’ll be digging in a lot more over the few days and might have some insight.

I’m pretty unfamiliar with platformIO, but the general interest here has piqued my interest. I’m going to try to get something running with it sometime this week.

2 Likes

Made some more progress today! The daisy libraries are located in the DaisyExamples root directory, cloned from the electrosmith github repo directly. As it has both libDaisy, DaisySP, and working examples, I wanted this to be my primary working dir. I set lib_extra_dirs to the absolute path of the DaisyExamples repo, rebuilt the intellisense index, and no longer have build errors!

The bad news is I still can’t build/upload/debug from within VS Code, lol. Despite everything looking very right, I still get the following error when trying to run Verbose Build:

> Executing task in folder DaisyExamples: platformio run --verbose <

Processing electrosmith_daisy (platform: ststm32; board: electrosmith_daisy; framework: cmsis; debug_tool: jlink; upload_protocol: jlink-jtag; debug_port: :2331; debug_server: /Applications/SEGGER/JLink/JLinkGDBServerCLExe -select USB -device STM32H750IB -endian little -if JTAG -speed 4000 -noir -noLocalhostOnly; lib_extra_dirs: /Users/flavius/repos/DaisyExamples)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/electrosmith_daisy.html
PLATFORM: ST STM32 7.0.0 > Electrosmith Daisy
HARDWARE: STM32H750IBK6 400MHz, 128KB RAM, 512KB Flash
DEBUG: Current (jlink) External (blackmagic, jlink, stlink)
PACKAGES: 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 - framework-cmsis-stm32h7 1.8.0 
 - tool-ldscripts-ststm32 0.1.0 
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 15 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
arm-none-eabi-gcc -o .pio/build/electrosmith_daisy/firmware.elf -T /Users/flavius/.platformio/packages/tool-ldscripts-ststm32/stm32h7/STM32H750IBTX_FLASH.ld -Os -Wl,--gc-sections,--relax -mthumb -mcpu=cortex-m7 --specs=nano.specs --specs=nosys.specs .pio/build/electrosmith_daisy/FrameworkCMSIS/gcc/startup_stm32h750xx.o .pio/build/electrosmith_daisy/FrameworkCMSIS/system_stm32h7xx.o -L/Users/flavius/.platformio/platforms/ststm32/ldscripts -L.pio/build/electrosmith_daisy -Wl,--start-group -lc -lgcc -lm -lstdc++ -Wl,--end-group
.pio/build/electrosmith_daisy/FrameworkCMSIS/gcc/startup_stm32h750xx.o: In function `LoopFillZerobss':
(.text.Reset_Handler+0x32): undefined reference to `main'
collect2: error: ld returned 1 exit status
*** [.pio/build/electrosmith_daisy/firmware.elf] Error 1

Something about that .pio/build/electrosmith_daisy/FrameworkCMSIS/gcc/startup_stm32h750xx.o: In function LoopFillZerobss’:` file doesn’t seem to want to work. I tried changing the platform from cmsis to arduino and even stm32cube with no luck. Something seems wrong with the default configuration but I can’t tell what…

I’ve had a play around with it, but couldn’t get lib_extra_dirs to work propertly as it doesn’t seem to find the .h and .c files in subdirectories. I managed to get to the same error as you by manually adding include flags:

build_flags = 
	-I./lib/libDaisy/Drivers/STM32H7xx_HAL_Driver/Inc
	-I./lib/libDaisy/Middlewares/ST/STM32_USB_Device_Library/Core/Inc
	-I./lib/libDaisy/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc
	-I./lib/libDaisy/Middlewares/Third_Party/FatFs/src

Then fixed the undefined reference to `main’ by adding an empty main() function.
It compiles fine while it’s empty but as soon as you copy a real example there are loads of linking errors becasue it can’t find the functions defined in the includes.

Seems like it might work if the structure of libdaisy was ‘flattened’, or maybe these libraries should be being brought in by the PlatformIO framework itself, rather than from libdaisy?

1 Like

@pigatron FWIW you can get the FatFs to work with lib_extra_dirs if you give it the full path up to and in culding the folder “FatFs” (but leaving out the /src).

I set the DaisyExamples root dir as my lib_extra_dirs param (lib_extra_dirs = /Users/flavius/repos/DaisyExamples) and then ran the Rebuild IntelliSense Index project tasks before the files and subdirectories were recognized.

@flavius Intellisense is a Visual Studio thing, right? PlatformIO on Atom doesn’t seem to have that.

Ah! Yes, it indeed is a VS Code thing, I assumed it was apart of PIO. It’s the last option in the list when you click the alien head in the side bar.

image

1 Like

So, IntelliSense does seem to work for me. It can resolve includes such as daisy_seed.h but when I compile it gives me an error like this:

In file included from lib/libDaisy/src/dev_codec_pcm3060.c:2:0:
lib/libDaisy/src/util_hal_map.h:4:10: fatal error: stm32h7xx_hal.h: No such file or directory

It seems to be seeing some includes but not all of them. Not sure what could be different between our setups. Could it be becasue I used the lib folder inside the project? I’ll try moving it tomrrow.

OK, I’ve managed to get the Blink example compiling and was able to flash it to the daisy over USB.

I cloned libDaisy into the lib folder of the project (if it’s inside lib there is no need to add lib_extra_dirs) then added the following library.json file into the root of the library:

{
    "build": {
        "flags": [
            "-I Drivers/STM32H7xx_HAL_Driver/Inc",
            "-I Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
            "-I Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc",
            "-I Middlewares/Third_Party/FatFs/src"
        ],
        "srcFilter": [
            "+<*>", 
            "+<../Drivers/STM32H7xx_HAL_Driver/Src>",
            "+<../Middlewares/ST/STM32_USB_Device_Library/Core/Src>",
            "+<../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src",
            "+<../Middlewares/Third_Party/FatFs/src>"
        ]
    }
}

This is needed to tell platformio where all the source and include files are located.

Then copied the Blink.cpp example into the project’s src folder.

My platformio.ini is:

    [env:electrosmith_daisy]
    platform = ststm32
    board = electrosmith_daisy
    framework = cmsis
    upload_protocol = dfu

For some reason I get an error after uploading to the daisy, but it still works anyway because the LED started to flash.

Next step is to do a similar thing for DaisySP library, and get an example with audio working.

2 Likes

Just a thought. If you’re cloning libraries into multiple locations, symbolic links might be better.

I’m switching over from PlatformIO on Atom to PlatformIO in VSCode so that we don’t have any editor based peculiarities / differences to deal with … It will take some time to install now but I’ll try the solution @pigatron found and see if I can successfully compile blink as well.

The only thing I had to add to the DaisySP library was this in library.json:

{
    "build": {
        "srcDir": ""
    }
}

That’s because, by default, PlatformIO looks in the src directory for the source files, but the main include file daisysp.h is in the root directory, so using an empty string makes it look in root. After adding that all the examples I tried are compiling fine.

All this would probably work in Atom as well, but after having made the switch myself I think VSCode is probably better for all the extra features.

Of course, you don’t have to have the libraries in the lib folder, you can put them wherever you want and reference them using lib_extra_dirs and this should should still work.

Ideally we’d get these or similar library.json files checked into the git repos for the libraries, then we would only need to reference the library names in the ini file and they would be brought in automatically.

1 Like

Just tried the solution you suggested @pigatron and using both library.json snippets, I can get both libDaisy and DaisyDSP to work. I can also flash the chip both via USB (DFU) and STlinkV2.

However, if I upload one of the simple examples, e.g. ADenv or ADSR I end up with a static saw-toothish signal on the outs.

The Arduino counterpart of these examples run fine which leads me to believe something is going wrong in the init of the peripherals … maybe blocksize or samplerate is wrong … again more detective work for another day. Still need to try the “official” toolchain.

PS Blink now works as intented

Yeah you’re right @MakingSoundMachines.

Just uploaded the oscillator example from the web uploader and got a perfect sine wave on my scope.

Uploaded the same example using PlatformIO and got something quite random:

So yeah, something is not right.

OK, completely different approach…

Grab the DaisyDuino library, stick it in lib folder, use the arduino framework.

Tested with the oscillator example in the main.cpp and it works perfectly!

No messing around with json files at all.

1 Like

@pigatron yes that would work. the other thing I’ve been trying yesterday that also works well, is editing the code from one of the example files in VSC and then compiling and uploading with the make / command line toolchain.

You have to adjust filenames in the makefile for new projects.

It’s still C++ (so is Arduino), and you get the synthax highliting etc. you just compile somewhere else.

This is kind of what I am doing - using VSCode and using modified make files. Running those from the terminal in VSCode means don’t have to jump around. Seems to work well. The only thing I haven’t decided yet is whether to just copy the libdaisy and daisysp libraries into the same folder and point to those, or whether to add them as git submodules so I can keep them up to date (which I haven’t tried yet).

What are you guys/girls doing for debug? I don’t have an ST-Link (and I’m not sure I would know what to do with one). Is there a way to print back to USB connected term like there is in Arduino?