Skip to content

Conversation

@deanm1278
Copy link
Contributor

this adds support for samd51 devices without modifying cmsis files of other devices

@cmaglie
Copy link
Member

cmaglie commented Aug 23, 2017

Hi @deanm1278 !

may I ask you where these files comes from? is there a source archive from Atmel somewhere?

@deanm1278
Copy link
Contributor Author

The SAMD51 CMSIS files are from the SAMD51 DFP distributed through Atmel Studio. The sam.h and samd.h files were modified by me instead of replacing entirely to ensure everything that already works using these files continues to work.

@ghost
Copy link

ghost commented Sep 19, 2017

I'm currently using the SAMD51 CMSIS files with the Arduino IDE, but they're causing compiler warnings.

I noticed that in the SAMD51 Atmel CMSIS files, they've chosen to define _U(x), _L(x) and _UL(x) macros, instead of the simple "ul" (unsigned long) suffix that they previously used for the SAMD21. However, this naming appears rather unfortunate, as the _U and _L macros are have been already defined in the ARM GCC toolchain file "ctype.h". This double definition is causing the warnings.

@ghost
Copy link

ghost commented Sep 20, 2017

I amended the _U and _L macro names in the SAMD51 Atmel CMSIS to _UI (unsigned int) and _SL (signed long) respectively.

The blank sketch now compiles without warnings or errors.

@deanm1278
Copy link
Contributor Author

hi Martin, I'm not seeing those warnings when using this with the most recent version of the core in this branch:
https://github.com/adafruit/ArduinoCore-samd/tree/samd51

would you be able to post the code you are using?

@deanm1278
Copy link
Contributor Author

hi @cmaglie, is there any update on whether or not this could be merged? We at Adafruit are getting ready to launch our SAMD51 based line soon :)

@ghost
Copy link

ghost commented Sep 20, 2017

Hi @deanm1278

would you be able to post the code you are using?

I'm just compiling a blank sketch, using the code from your most recent branch, https://github.com/adafruit/ArduinoCore-samd/tree/samd51. I'm using version 1.8.4 of the Arduino IDE, with compiler warnings set to default.

I'm also using the SAMD51, Atmel CMSIS files "sam.h", "samd.h" and the directory "samd51" taken from https://github.com/adafruit/ArduinoModule-CMSIS-Atmel. They're stored in my .../Arduino15/packages/arduino/tools/CMSIS-Atmel/1.1.0/CMSIS/Device/ATMEL directory.

The compiler warnings I'm getting are due to the fact that the ARM toolchain file, "ctype.h" defines the macros _U and _L:

#define	_U	01
#define	_L	02

(that's file "ctype.h" in the directory .../Arduino15/packages/arduino/tools/arm-non-eabi-gcc/4.8.3-2014q1/arm-none-eabi/include/...).

...but these macros are also defined in the SAMD51 Atmel CMSIS:

#if !defined(_UL)
#define _U(x)          x ## U            /**< C code: Unsigned integer literal constant value */
#define _L(x)          x ## L            /**< C code: Long integer literal constant value */
#define _UL(x)         x ## UL           /**< C code: Unsigned Long integer literal constant value */
#endif

By removing the additional _U, _L and _UL macro definitions added to bottom of "Arduino.h" for this (SAMD51) branch and replacing the SAMD51 Atmel CMSIS _U and _L macros with unique names, (_UI and _SL), removes the compiler warnings.

In addition, if I uncomment the _U, _L and _UL macros at the bottom of "Arduino.h" and compile for the Feather M0, I also get compiler warnings, again because "Arduino.h" is trying to redefine the macros already defined in "ctype.h".

@ghost
Copy link

ghost commented Sep 20, 2017

Furthermore, if I just cut and paste the _U, _L and _UL macros at the bottom of the SAMD51 branch's "Arduino.h" and paste them into the Arduino Zero's "Arduino.h", I get the same warnings.

@ghost
Copy link

ghost commented Sep 21, 2017

Hi @deanm1278

My compiler's also generating warnings for the FPU support code.

It's warning about the double definition of the __FPU_USED flag, that's first defined in the "boards.txt" file for the compiler command line flags:

adafruit_metro_m4.build.extra_flags=-D__SAMD51J20A__ -D__SAMD51__ {build.usb_flags} -D__FPU_USED

...and then later on line 151 of the "core_cm4.h" file:

#define __FPU_USED 1U

The "core_cm4.h" file is located in the directory .../Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/...

Removing the __FPU_USED flag from the compiler command line, allows it to compile without warnings or errors.

@deanm1278
Copy link
Contributor Author

ok silly me, I had accidentally turned off the compiler warnings. They are fixed now.

@ghost
Copy link

ghost commented Sep 22, 2017

Hi @deanm1278

I'd just like to say thank you for the work that you and Adafruit are doing to bring the SAMD51 to the Arduino IDE, much appreciated.

@ghost
Copy link

ghost commented Sep 25, 2017

Hi @deanm1278

I attempted to burn the SAMD51's bootloader using the Arduino IDE and an Atmel-ICE.

The attempt failed, (although it could be my hardware). However, I noticed that OpenOCD is saying that the target is a SAMD21J18A. Please could you tell me if you're also using OpenOCD's SAMD21 configuration to upload the SAM51's bootloader?

@deanm1278
Copy link
Contributor Author

hey @martinl1 I'd like to move other issues unrelated to CMSIS files to the issues section on the SAMD51 core repo here if you don't mind:
https://github.com/adafruit/ArduinoCore-samd/tree/samd51

Thanks!

@ptorrone
Copy link

ptorrone commented Apr 2, 2018

hi @cmaglie we emailed the team and did not hear back, this is a pull request that 1) does not break anything 2) makes things better 3) shows arduino WANTSS pull requests to make the IDE better for makers. what is the status of merging pull requests? 4) does arduino still accept pulled requests? 5) if not, why? if there a new policy you can link to? about pull requests?

thanks,
pt

@cmaglie cmaglie merged commit c6fc946 into arduino:master Apr 3, 2018
@cmaglie
Copy link
Member

cmaglie commented Apr 3, 2018

Thank you! It's now available as version 1.2.0 in the package manager. 👍

@ptorrone
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants