platformio / platform-atmelsam

Atmel SAM: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelsam
Apache License 2.0
79 stars 105 forks source link

No board support for Macchina M2 #127

Open rfrowe opened 3 years ago

rfrowe commented 3 years ago

Support for the Macchina M2 was added in platformio/platformio-core#1198, however it was later removed by the commit that moved Atmel SAM boards to this repo.

I tried messing around with this repo, adding a new framework-arduino-sam-macchina and copying boards/dueUSB.json to boards/macchina_m2.json, but I can't get my code to compile.

Here is the Arduino framework it should reference: https://github.com/macchina/arduino-boards-sam

rfrowe commented 3 years ago

I managed to get this working locally, but it requires some hacking. I hope that we can get this added to this repo. I tried to do it myself but the change seems like it's going to be pretty complex, requiring reworking the SAM python code.

What I've done is create a macchina_m2.json in by local boards directory which contains:

{
  "build": {
    "arduino": {
      "ldscript": "flash.ld"
    },
    "core": "arduino",
    "cpu": "cortex-m3",
    "extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_M2 -DMACCHINA_M2",
    "f_cpu": "84000000L",
    "hwids": [
      [
        "0x2341",
        "0x003E"
      ],
      [
        "0x2A03",
        "0x003E"
      ]
    ],
    "mcu": "at91sam3x8e",
    "usb_product": "Arduino Due",
    "variant": "m2"
  },
  "connectivity": [
    "can"
  ],
  "debug": {
    "jlink_device": "ATSAM3X8E",
    "openocd_chipname": "at91sam3X8E",
    "openocd_target": "at91sam3ax_8x",
    "svd_path": "ATSAM3X8E.svd"
  },
  "frameworks": [
    "arduino",
    "simba"
  ],
  "name": "Macchina M2",
  "upload": {
    "disable_flushing": true,
    "maximum_ram_size": 98304,
    "maximum_size": 524288,
    "native_usb": true,
    "protocol": "sam-ba",
    "protocols": [
      "sam-ba",
      "jlink",
      "blackmagic",
      "atmel-ice",
      "stlink"
    ],
    "require_upload_port": true,
    "use_1200bps_touch": true,
    "wait_for_upload_port": true
  },
  "url": "https://docs.macchina.cc/m2-docs",
  "vendor": "Macchina"
}

Then I cloned https://github.com/macchina/arduino-boards-sam into platforms/macchina. Then, I use these parameters in my platformio.ini:

platform = atmelsam
board = macchina_m2
board_build.variants_dir = ./platforms/macchina/sam/variants