CMSIS Support for Sodaq Boards


#1

I am working on the Sodaq ExpLoRer and Sodaq ONE boards I wish to remove the Arduino framework entirely. I thought that I could use CMSIS instead (seeing as its an SAMD21 w/ARM processor) and program with the registers directly, however, when changing the framework to CMSIS it says it’s not supported by this board.

I know that the Arduino framwork loads the CMSIS layer as part of its abstraction, and I know that all ARM processors can use it so therefore it should work, but its not able to be selected, and when manually changing the platformio.ini file it throws an error on compilation. I would like to use it but I cant, and I dont want to go to another IDE that does support it.

Is it possible to unlock this option for those who wish to code without the Arduino framework?


#2

Sure, just add cmsis to https://github.com/platformio/platform-atmelsam/blob/develop/boards/sodaq_autonomo.json#L23


#3

Hi Ivankravets,

Unfortunately, simply changing the .json file is not working. Firstly, the include paths in VisualStudio Code were not configured but after installing CMSIS manually, and putting the include path to /.platformio/packages/framework-cmsis, I still was not able to compile the project.

This is the error message which occurs when trying to compile:

AssertionError: :
File "/home/brendan/.platformio/penv/local/lib/python2.7/site-packages/platformio/builder/main.py", line 158:
env.SConscript("$BUILD_SCRIPT")
File "/home/brendan/.platformio/packages/tool-scons/script/../engine/SCons/Script/SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
File "/home/brendan/.platformio/packages/tool-scons/script/../engine/SCons/Script/SConscript.py", line 250:
exec _file_ in call_stack[-1].globals
File "/home/brendan/.platformio/platforms/atmelsam/builder/main.py", line 232:
target_elf = env.BuildProgram()
File "/home/brendan/.platformio/packages/tool-scons/script/../engine/SCons/Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "/home/brendan/.platformio/penv/local/lib/python2.7/site-packages/platformio/builder/tools/platformio.py", line 60:
env.BuildFrameworks(env.get("PIOFRAMEWORK"))
File "/home/brendan/.platformio/packages/tool-scons/script/../engine/SCons/Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "/home/brendan/.platformio/penv/local/lib/python2.7/site-packages/platformio/builder/tools/platformio.py", line 261:
SConscript(env.GetFrameworkScript(f))
File "/home/brendan/.platformio/packages/tool-scons/script/../engine/SCons/Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "/home/brendan/.platformio/penv/local/lib/python2.7/site-packages/platformio/builder/tools/pioplatform.py", line 54:
assert p.frameworks and framework in p.frameworks

Perhaps I didnt install CMSIS properly, or left out some includePaths.
If you have any information at all on how to get this working it would be awesome, thank you.


#4

Please share the content of this file.


#5

Thanks for your quick reply.

sodaq_autonomo.json:

{
  "build": {
"core": "sodaq",
"system": "samd",
"cpu": "cortex-m0plus",
"extra_flags": "-D__SAMD21J18A__ -DARDUINO_ARCH_SAMD -DARDUINO_SODAQ_AUTONOMO",
"f_cpu": "48000000L",
"hwids": [
  [
    "0x2341",
    "0x804d"
  ],
  [
    "0x2341",
    "0x004d"
  ]
],
"ldscript": "flash_with_bootloader.ld",
"mcu": "samd21j18a",
"usb_product": "SODAQ Autonomo",
"variant": "sodaq_autonomo"
  },
  "frameworks": [
"arduino",
"cmsis"
  ],
  "name": "SODAQ Autonomo",
  "upload": {
"disable_flushing": true,
"maximum_ram_size": 32768,
"maximum_size": 262144,
"native_usb": true,
"protocol": "sam-ba",
"require_upload_port": true,
"use_1200bps_touch": true,
"wait_for_upload_port": true
  },
  "url": "http://support.sodaq.com/sodaq-one/autonomo/getting-started-autonomo/",
  "vendor": "SODAQ"
}

I may actually just be able to include only the header files I need in the project directory, rather than using the include path to all SAMD boards with the ‘samd.h’ include which is what I’m currently doing.

I just realsied that I am using a sodaq ONE board, and the MCU on here is the samd21G18A, not the J. Perhaps thats causing the issue.
Here is the contents of the sodaq_one.json file though:

{
  "build": {
"core": "sodaq",
"system": "samd",
"cpu": "cortex-m0plus",
"extra_flags": "-D__SAMD21G18A__ -DARDUINO_ARCH_SAMD -DARDUINO_SODAQ_ONE",
"f_cpu": "48000000L",
"hwids": [
  [
    "0x2341",
    "0x804d"
  ],
  [
    "0x2341",
    "0x004d"
  ]
],
"ldscript": "flash_with_bootloader.ld",
"mcu": "samd21g18a",
"usb_product": "SODAQ ONE",
"variant": "sodaq_one"
  },
  "debug": {
"tools": {
  "jlink": {
    "server": [
      {
        "arguments": [
          "-singlerun",
          "-if", "SWD",
          "-select", "USB",
          "-device", "ATSAMD21G18",
          "-port", "2331"
        ],
        "executable": "JLinkGDBServerCL.exe",
        "system": [
          "windows",
          "windows_amd64",
          "windows_x86"
        ]
      },
      {
        "arguments": [
          "-singlerun",
          "-if", "SWD",
          "-select", "USB",
          "-device", "ATSAMD21G18",
          "-port", "2331"
        ],
        "executable": "JLinkGDBServer",
        "system": [
          "darwin_x86_64",
          "linux_i686",
          "linux_x86_64"
        ]
      }
    ]
  }
}
  },
  "frameworks": [
"arduino",
"cmsis"
  ],
  "name": "SODAQ ONE",
  "upload": {
"disable_flushing": true,
"maximum_ram_size": 32768,
"maximum_size": 262144,
"native_usb": true,
"protocol": "sam-ba",
"require_upload_port": true,
"use_1200bps_touch": true,
"wait_for_upload_port": true
  },
  "url": "http://support.sodaq.com/sodaq-one/",
  "vendor": "SODAQ"
}

#6

How does look your platformio.ini? Where do you edit this board’s JSON file? It seems that PIO does not see your modifications.


#7

Thats what I was thinking too…

The platform.ini file:

[env:sodaq_one]
platform = atmelsam
board = sodaq_one
framework = cmsis

I created the project by using the “New Project” from PIO home page. CMSIS was in the drop down box after I added it to the board’s JSON file.

The board’s JSON file that I modified is located at:
/home/brendan/.platformio/platforms/atmelsam/boards/sodaq_one.json
/home/brendan/.platformio/platforms/atmelsam/boards/sodaq_autonomo.json
I am on an ubuntu system runing Elementary OS - Loki build

Something that is interesting to note:
In the project directory (/home/brendan/Documents/PlatformIO/Projects/Exercises/CMSIS_Ex1/) the .pionvs folder does not contain the “sodaq_one” folder with the “fimware.elf” or framwork directoryies that are created when using the Arduino framework. In fact, this directory only contains two files:

  1. “do-not-modify-files-here.url”
  2. “structure.hash”

I assume the reason why it will not compile is because there is no firmware in this directory.


#8

Any more ideas how I can get PIO to see my modifications and how I can get the correct firmware.elf in the .pionvs folder?

Thanks again,

Brendan


#9

Oh… Now I understand your problem. The problem here is linked with missing cmsis declaration for Atmel SAM dev/platform. See https://github.com/platformio/platform-atmelsam/blob/develop/platform.json#L21

You have to provide build script for cmsis framework. It should look like:

...
  "frameworks": {
    "arduino": {
      "package": "framework-arduinosam",
      "script": "builder/frameworks/arduino.py"
    },
    "mbed": {
      "package": "framework-mbed",
      "script": "builder/frameworks/mbed/mbed.py"
    },
    "simba": {
      "package": "framework-simba",
      "script": "builder/frameworks/simba.py"
    },
    "cmsis": {
      "package": "framework-cmsis",
      "script": "builder/frameworks/cmsis.py"
    }
  },
...

But… that is long story. Why you don’t want to use CMSIS directly with framework = arduino? If you don’t use Arduino API, linker will not link it to the final firmware.


#10

I’m already doing that in my code already, programming using CMSIS and C. But its not technically bare metal if I’m still loading all the Arduino abstraction layers.

What is the point of loading/compiling the thousands of lines of code included in the Arduino framework if I’m not using, nor require it. Its just adding additional overhead to my program.

I was hoping that CMSIS could provide the solution here, which is why I initially asked if it was possible for PlatformIO to provide CMSIS support, so I could use CMSIS without the Arduino framework.

Is it not possible to compile a program with CMSIS and not Arduino? Or is possible but a lot of work to set up and get working?


#11

Yes, you need to make some changes to dev/platform.


#12

Can you run me through how I can get this working? Or is it a lot of work to do? I get the feeling it might be something that’s easier to do that to explain to me.

Thanks again for all your time on this.