Adafruit NeoTrellis M4

This addition seems important nevertheless, so keep it in there.

Since I don’t have the hardware to reproduce this fault at hand, and $40 is quiet hefty, I’d like to rely on someone who has the hardware. (BTW @valeros, do you have such a board?)

Do you have a SWD programmer at hand, such as as ST-Link V2, JLink or a STM32 Nucleo board of any kind?

To be able to debug such low-level errors where we can’t even print stuff and don’t know where it hangs / crashes, you would need to attach a SWD probe to the SWD signals of the board (SWDIO + SWCLK), which enables line-by-line debugging of the code and startup routines.

Copper pads to these signals are located left to the main chip (SAMD51J19A) and you would need to solder cables to them and connect them to the probe (along with GND)

(refer Downloads | Adafruit NeoTrellis M4 Express | Adafruit Learning System)

Unfortunately not. Hopefully someone else is able to assist with this.

Sorry been away from here for a while …
I will have some time to look at this again middle of next week and I do have a J-LINK.

In the end I managed to deliver a demo unit coded in micro python.
Works OK for a demo but there are many time critical parts that will need to be looked at for the full version which I am pretty sure need to be coded in C … so this is becoming critical again for me soon !!

1 Like

Well actually from this post you can see a second error I’ve overlooked yesterday: The target chip is wrong in PIO. The schematics say SAMD51G(19A), Adafruit’s board.txt says SAMD51G19A, PIO says SAMD51J19A.

Can you create a folder boards in your project and put the following file in it

adafruit_trellis_m4_fixed.json

{
  "build": {
    "arduino": {
        "ldscript": "flash_with_bootloader.ld"
    },
    "core": "adafruit",
    "cpu": "cortex-m4",
    "extra_flags": [
      "-DARDUINO_ARCH_SAMD",
      "-DARDUINO_TRELLIS_M4",
      "-DADAFRUIT_TRELLIS_M4_EXPRESS",
      "-D__SAMD51G19A__",
      "-D__SAMD51__",
      "-D__FPU_PRESENT",
      "-DARM_MATH_CM4",
      "-DCRYSTALLESS",
      "-DENABLE_CACHE",
      "-DVARIANT_QSPI_BAUD_DEFAULT=50000000"
    ],
    "f_cpu": "120000000L",
    "hwids": [
      [
        "0x239A",
        "0x802F"
      ],
      [
        "0x239A",
        "0x002F"
      ],
      [
        "0x239A",
        "0x0030"
      ]
    ],
    "mcu": "samd51g19a",
    "system": "samd",
    "usb_product": "Adafruit Trellis M4",
    "variant": "trellis_m4"
  },
  "debug": {
    "jlink_device": "ATSAMD51G19",
    "openocd_chipname": "at91samd51G19",
    "openocd_target": "atsame5x",
    "svd_path": "ATSAMD51G19A.svd"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "Adafruit Trellis M4",
  "upload": {
    "disable_flushing": true,
    "maximum_ram_size": 196608,
    "maximum_size": 524288,
    "native_usb": true,
    "offset_address": "0x4000",
    "protocol": "sam-ba",
    "protocols": [
      "sam-ba",
      "jlink",
      "atmel-ice"
    ],
    "require_upload_port": true,
    "use_1200bps_touch": true,
    "wait_for_upload_port": true
  },
  "url": "https://www.adafruit.com/product/4064",
  "vendor": "Adafruit"
}

And then in your platformio.ini change the board = .. line to

board = adafruit_trellis_m4_fixed

Clean the project, recompile and reupload. Does the simple Serial.println() firmware work now?

So, some progress… With the new fixed board it doesn’t work BUT when I press reset on the device whilst monitoring the serial output it will print a few lines before it loses the connection. This does not happen without the new adafruit_trellis_m4_fixed.json file.

What does it print there? Loosing the serial connection upon reset is expected though, since it’s a USB-CDC serial and microcontroller reset also resets the USB peripheral setup.

Can you use a different serial monitor program like CoolTerm (Mac version) to try and connect to the board after it has been reset? You should then catch it in the middle of the execution.

it prints the result of the code:

Test 1
Test 2
Test 3
...

so for some reason, between resetting, the code runs briefly and prints the expected string to the serial monitor.

Ok so on reflection

Adding this seems to fix things. As @maxgerhardt suspected I was incorrectly connecting to the serial monitor.

Thanks again for all you help.

When you use the fixed board json this is now automatically included. Does the board now run the initially wanted sketch?

Yes as long as I include the development version of atmelsam in platform.ini:

platform = https://github.com/platformio/platform-atmelsam.git

It will run the following example provided by adafruit (once it has been refactored into c++):

Do you know when this will hit the stable version?

Also I have two other questions that you might be able to help with (no worries if not):

  1. I am trying to view PlatformIO’s serial device monitor using the menu item found in ‘Tools > PlatformIO > Monitor’. When I try and run ‘Monitor’ it shows this error:

    /usr/local/bin/platformio -c clion device monitor -e adafruit_trellis_m4
    ...
    Error: (25, 'Inappropriate ioctl for device')
    

    Any ideas what is happening here? When I type the same command into the terminal in CLion it
    works as expected. Do you think this is a CLion bug or something to do with my Platformio setup?

  2. I would like to buy a device that will help me debug my code on the board (i.e breakpoints etc…). Do you have any recommendations on what I should buy to connect to the SWD port on the this board. On the adafruit site Board Tour | Adafruit NeoTrellis M4 Express | Adafruit Learning System it highlights the 10 pin connector pitch connector that can be soldered on to the board. And on the platformio site Adafruit Trellis M4 — PlatformIO latest documentation it suggests that the two compatible devices are Atmel-ICE (defualt) or JLink. What device would you recommend and is the ten pin connector a standard cable or one that I would have to buy separately?