Should Due sketches run on the M2 where possible?

Is a desire or expectation that Due sketches should run on the M2?

I just tried verifying the Blink sketch in the Arduino IDE. With the board selection as Arduino Due, it verifies. With the selection as Macchina M2 (Beta), it fails because LED_BUILTIN is not defined. I recognize the M2 has many LEDs, but it so it would be possible to designate one of them as LED_BUILTIN (in addition to its more specific designation) so the sketch would work.

Well, where possible I’d say it is nice for Arduino Due sketches to work with the M2. However, it will never be possible for 100% of Arduino Due sketches to work out of the box with the M2. People shouldn’t expect it all to work perfectly and getting it too close might lead people to get a bit too comfortable. For one, the Due has a programming port where you can send text but the M2 doesn’t have that port, just native. Also other serial ports aren’t necessarily there on an M2.

I suppose it couldn’t hurt to support the blink sketch as it’s a nice way to verify that the hardware works. But, basically any example arduino sketch that uses a serial output will use Serial and not SerialUSB like you’d need to use for the M2. You could put a “#define Serial SerialUSB” line into the M2 board files such that it automatically redirects those calls to the right place.

There’s probably some benefit to making the two reasonably compatible but I personally wouldn’t spend a long time on it. The uses for the two are quite different. I doubt anyone is going to run Blink on an M2 for longer than 2 seconds. After that they’ll want a LIN capture sketch or a CAN sketch or something more geared toward automotive stuff. Once you get that fancy you’ve pretty well left the Due in the dust.

Hi Adam
Funny you should mention about the Builtin Led as i had already enable this for the next release of the Variant files. Apart from the builtin LED the only other similarities are I2c & SPI the similarities stop there. The next release will incorporate your changes plus the foopa correction i found i had made in the analog definitions plus a few other minor changes. I am currently thoroughly testing these changes before releasing.
Regards Tony