Feather M4 Express & a C/CPP Project

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
BYuey
 
Posts: 2
Joined: Sat Oct 02, 2021 2:32 am

Feather M4 Express & a C/CPP Project

Post by BYuey »

Hey all, I've been playing around with a Feather M4 express using both Arduino and Circuit Python and things have been working great. The UF2 bootloader is magic and I love it.

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.
My INFO_UF2.TXT is as follows:

Code: Select all

UF2 Bootloader 3.12.0 SFHWRO
Model: Feather M4 Express
Board-ID: SAMD51J19A-FeatherM4-v0

User avatar
dastels
 
Posts: 15655
Joined: Tue Oct 20, 2015 3:22 pm

Re: Feather M4 Express & a C/CPP Project

Post by dastels »

Have you looked at platform.io? https://platformio.org/

Dave

User avatar
BYuey
 
Posts: 2
Joined: Sat Oct 02, 2021 2:32 am

Re: Feather M4 Express & a C/CPP Project

Post by BYuey »

dastels wrote:Have you looked at platform.io? https://platformio.org/
Hmmm, I've never heard of this. I was hoping to avoid downloading any additional software but I'll give it a try in any case when I get the chance and report back. Thank you!

User avatar
gertvb
 
Posts: 26
Joined: Fri Jan 16, 2015 3:35 am

Re: Feather M4 Express & a C/CPP Project

Post by gertvb »

Have a look at the following stuff Ive dumped on github a while ago

Basically an Atmel Studio 7 project I created to do C development on the Feather M4

I didnt use the uf2 format, rather I used bossac to download the bin file to the chip as far as I remember

Havent worked on it recently, so you are on your own. But it should provide a few pointers

https://github.com/gertvb/Feather_M4_Atmel_Studio

Kind regards

Gert

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”