However, I thought it would be "fun" to challenge myself and see if I could get something up and running in pure C/CPP. I had plenty of experience with CPP and related languages (Makefiles) in university but it's been years since I've regularly used the language.
My setup is a Windows box running WSL2 (Ubuntu) which has been working great for Arduino / Circuit Python. The CPP project uses the Atmel software libraries from start.atmel.com, and the toolchain is basically:
arm-none-eabi-gcc/g++ -> uf2conv.py the resulting .bin (from the Microsoft UF2 repo) -> drag the .uf2 onto the FEATHERBOOT drive.
It's at this point I've hit a brick wall. The project builds into its various binaries and when I drag the uf2 file onto FEATHERBOOT, it appears as though the MCU has gone to the program. When rebooting, the pin 13 LED briefly lights up before going dark -- I have not been able to get an actual blink out of it.
Has anyone had success with such a project, or have any suggestions on how to proceed from here?
If at all possible, I'd like to keep this toolchain as-is. I just love how simple (in concept!) the whole deal is. No bulky IDEs or Flashing tools needed. Just vscode, gcc, and uf2.
I put the entire project with all its gory details on github if anyone is interested: https://github.com/IrisAmp/FeatherC
Here's a bunch of troubleshooting steps I've already tried:
- - I've ruled out any hardware issue, since this particular Feather has been working a treat when using Arduino and CircuitPy.
- Different combinations of gcc/g++, -x c vs -x c++, and -std args. The only thing this really serves to do is make the resulting binary way bigger than it needs to be, if given the wrong parameters.
- Different configurations of software libraries. I have tried a couple of different configurations from start.atmel.com, as well as Adafruit's mirror of the libraries at https://github.com/adafruit/asf4, as well as a "mix" of the two (ie: using the config files from adafruit/asf4, with the newest code from Atmel). No configuration I tried has worked.
- Different arguments to uf2conv.py. I always pass -f SAMD51, but I have also tried varying -b as 0x0, 0x2000 and 0x4000.
- The linker option -Wl,--section-start=.text=0x4000. I learned that either this OR -b must be passed to uf2conv.py to avoid overlapping the bootloader section (otherwise the uf2 will get ignored, and you'll be kicked back into the bootloader)
- Different pinout mappings. I studied the pinouts provided in Adafruit's learning articles and conveniently the underlying pinouts are shown (ie: pin 13 is on Port A, Pin 23). When this didn't work, I also tried setting all pins to HIGH but still with no success.
- Feeding a .bin, .hex, and .elf into uf2conf.py. They all produce the same result.
Code: Select all
UF2 Bootloader 3.12.0 SFHWRO
Model: Feather M4 Express
Board-ID: SAMD51J19A-FeatherM4-v0