Go Down

Topic: Floating Point Unit support (Read 393 times) previous topic - next topic

dlabun

I am looking at porting the Zero core to support the SAMD5x chip as I specifically want the FPU. Does the Arduino core "care" if there's an FPU or not? I know I have to change the compiler flags to tell it there's a hardware FPU.

westfw

There could be impact on interrupts.  The ARM has an option not to stack FP registers if they haven't been used, or won't be used in the ISR, I think.   Otherwise, interrupts are going to get slower.

dlabun

Fortunately for my application getting an accurate calculation result is more important than the speed of an ISR... But on the flip side running at 120MHz means the whole thing is just faster in general.

westfw

Have you checked out the stuff that Adafruit has on Github.  They seem very excited about SAMD5x, and apparently have made a bunch of progress already.  I'm not sure whether that includes floating point considerations.

(It looks like a really promising set of chips.  I like that it goes from Uno-sized to Mega-sized without major changes (unlike Zero vs Due.))

(Or "will", anyway.  Atmel has never been particularly trustworthy in the "delivery schedule for new chips" department, and I doubt whether Microchip has fixed everything.  There are currently a fair number of people upset about the Atmega328PB becoming "unobtainium.")


MartinL

#4
Sep 14, 2017, 10:34 am Last Edit: Sep 14, 2017, 01:09 pm by MartinL
Thanks for the information about the SAMD5x. A 120MHz microcontroller with an ARM Cortex M4F core, huge memory (up to 1MB flash, 256KB RAM) and comes in a variety of small TQFP and QFN packages, it certainly looks interesting.

Adafruit have prototype on an Uno-sized PCB: https://www.adafruit.com/product/3382, but like you say it could be used for Mega-sized boards as well.

dlabun

Mouser does have the SAMD51G19A in stock, it's the 512KB Flash 48 Pin QFN variant. I am going to give the Adafruit core a look to see if they're supporting the FPU.

MartinL

#6
Sep 15, 2017, 12:19 pm Last Edit: Sep 15, 2017, 04:19 pm by MartinL
Looks like Adafruit will be using the SAMD51J20A (1MB flash, 256KB RAM in a 64 pin QFN package) for their Metro M4 Express board.

It doesn't look like they're supporting the FPU at the moment, (at least I couldn't find any reference to the -mfpu or -mfloat-abi flags on the compiler command line in the "platform.txt" file), but I'm sure they'll add this in due course.

At 120MHz it'll still go pretty quick though, with or without the FPU enabled.

MartinL

#7
Sep 16, 2017, 07:04 pm Last Edit: Sep 16, 2017, 07:09 pm by MartinL
I've just ordered some SAMD51J20As in both 64-pin TQFP and QFN packages.

Checking the SAMD51 datasheet it appears that, while it isn't quite a drop in replacement for SAMD21, it's very close. The power, debug, crystal and sercom port pin placement look the same. The main difference being the substitution of a pin called VSW for port pin PA28 (USB_HOST_ENABLE on the Arduino Zero), but this pin can remain unconnected, if powering the microcontroller's core using its internal linear regulator. The TCC and TC timer outputs have moved to other pins, but this can be worked around and hopefully won't be too much of an issue.

I'll use the TQFP devices as a drop in replacement on one of my SAMD21J18A (Arduino Zero) based custom boards for the purposes of evaluation. I'll try to get it going using Adafruit's new Metro M4 core code with the Arduino IDE.

I'll let you know how it goes...

AloyseTech

Hey guys,
if you start working with the D51, you might want to take a look to the 21 pages of errata here (PDF).

dlabun

How do you release a chip with the internal pull up for the reset line being broken?? Hopefully the get their act together as this chip shows promise with both Ethernet and CAN capabilities on the E51 version.

MartinL

#10
Sep 18, 2017, 05:14 pm Last Edit: Sep 18, 2017, 05:28 pm by MartinL
I'm making steady progress on modifying the Arduino IDE, in order to integrate the SAMD51.

There are three main issues:

1. Arduino IDE Boards Manager

The standard way to add new boards to the Arduino IDE, is to provide the web address (or URL) of a JSON file. The Arduino IDE uses this to configure its Boards Manager.

I couldn't find a JSON file in the Adafruit code and rasied the issue with them on Github. It turns out that they're currently not providing any JSON file support, so I'm currently in the process of writing my own.

I'll also eventually modify the "variant.cpp" file that defines the board's pin functions, as my SAMD51 target board pinout is closer to the Arduino Zero than Adafruit's Metro M4.

2. Atmel CMSIS

The Atmel CMSIS includes the register definitions for the microcontrollers.

The Arduino IDE also currently lacks the SAMD51 register definitions, so I've included them. These are the "samd51" directory, as well as modified "sam.h" and "samd.h" files.

3. Adafruit's Modified Bossa 1.7.0

Bossa is a program used by Arduino IDE to upload the code on to their boards using the native USB port.

Adafruit have also forked and modified Bossa Version 1.7.0, to make it compatible with the SAMD51. The bossac executable files are located in the "Tools" directory of their Metro M4 code. I've replaced the Arduino IDE's current "bossac.exe" file with the modified one. It appears to work OK with the SAMD21.

dlabun

Did you see the pull request to add the SAMD51 CMSIS to Arduino CMSIS repository?

https://github.com/arduino/ArduinoModule-CMSIS-Atmel/pull/8

MartinL

#12
Sep 18, 2017, 06:28 pm Last Edit: Sep 18, 2017, 07:04 pm by MartinL
Hi dlabun,

Quote
Did you see the pull request to add the SAMD51 CMSIS to Arduino CMSIS repository?

https://github.com/arduino/ArduinoModule-CMSIS-Atmel/pull/8
Yes I did. I guess it's likely that SAMD51 CMSIS files will be supported in the next version of the Arduino IDE, or maybe already are with the hourly builds.

For now I just got the SAMD51 files from the Adafruit's "ArduinoModule-CMSIS-Atmel" repo on Github.

By the way, I've got the boards manager going...


westfw

Have you figured out the differences between the SAMD5x and the SAME5x?  They seem to have the same datasheet - I guess D5x is supposed to be an upgrade of D2x, while E5x is a cheaper E7x?

There's a development board for the E54...  https://www.digikey.com/product-detail/en/microchip-technology/ATSAME54-XPRO/ATSAME54-XPRO-ND/7354381


MartinL

#14
Sep 19, 2017, 12:26 pm Last Edit: Sep 19, 2017, 10:54 pm by MartinL
Sketches on the Arduino IDE now compile for the SAMD51 without errors, but with warnings.

The warnings stem from the fact that Atmel rather than using the simple "ul" (unsigned long) suffix, as in their previous CMSIS register definitions, for example the SAMD21, they have decided instead to use _U(x), _L(x) and _UL(x) macros.

The macros themselves just use the ## preprocessor directive to move the parameter 'x' to the front and "UL" to the back:

Code: [Select]
_UL(x) x ## UL
However, the use of _U and _L naming is unfortunate, as these have already been defined in the ARM GCC Toolchain file "ctype.h", leading to a double definition that's causing the compiler warnings.

It appears that others are having the same issue:

Quote
...there is one more issue with the new header files we've just found. Chip header files like same70q21.h define _U, _L, _UL macros in the following manner

#if !defined(_UL)
#define _U(x) x ## U
#define _L(x) x ## L
#define _UL(x) x ## UL
#endif /* !defined(UL) */

However, some toolchains define _U but not _UL. That leads to a double definition of _U, _L macros.
It begs the question, why is Atmel using macro names that conflict with their own microcontoller's C++ code?

I'm trying to figure out if there's a simple workaround?

Go Up