Custom board similar to MKRZERO bossac problems

Hi,

I'm an engineer not a programmer so out of my comfort zone beyond simple c type programming.

I designed a custom PCB similar to MKRZERO, initially I used the same part SAMD21G18. I wrote a fairly extensive program based on a custom board variant and had the whole thing working tickety-boo.

Fast forward to Covid and supply line disruptions and chip shortages I could not get the SAMD21G18 parts so I moved to the SAMD21G17. i built one of my custom boards with the 17 variation and the problem I have is that when Arduino attempts to load the main program via the bootloader (using bossac), bossac does not recognize the G17 chip ID 0x10010093.

I know for a fact my code compiles and works because as a work around I compiled a no bootloader version and loaded it using a atmel studio and a Segger programmer. The problem is I need to do further development and would like to simply do it using Arduino do update the board using the normal bootloader.

I tried contacting bossac, but they have not responded. I'm not aware of any "Arduino" boards that use the G17 that I could pretend to be instead of the custom board.

So I'm looking for help,

  1. I see the source code for BOSSA is available but I have no idea how to compile a change. Is it possible to modify bossac to include the chip ID for the G17?
  2. I think for some boards OPENOCD is used for programming , so I'm not sure if that's an option or how I would do it?
  3. Perhaps someone else has another approach, if so I'm all ears???

Thanks
J

At six minutes in, Sayanee Basu's video shows using the Segger J-Flash Lite and app to flash the Arduino Zero bootloader on SAMD21-G/custom PCB.

Basu YouTube.com video w/arduino bootloader

You can install this nice 3rd party Arduino boards platform to add ATSAMD21G17A support to the Arduino IDE:

borland,
In my post I stated

Thanks though

in0,

I was looking at the mattairtech stuff on github yesterday. I could be wrong but when I look at the source code for bossac, although it lists the SAMD21G17A in the source code for bossac, the chip ID's that is uses is not the same as the chip ID of the SAMD21G17's I'm able to source from Digi-Key.

In the mattairtech source device.cpp they list 4 variations of the G17A, see below, however none of the chip ID's match the chip ID of the part I'm able to get from Digi-Key which is chipId=0x10010093

If i had the knowledge to recompile a branch of bossac with an extra line for chip ID 0x10010093, I would think that bossac would work for the SAMD21g17a that I'm trying to use. Unfortunately I think you need to compile bossac on a linux machine? Which I don't have, I only have Win7

I think it just needs the following line added at about line 456 (see bold text):

    case 0x10010001: // J17A
    case 0x10010006: // G17A
    **case 0x10010093: // G17A    128KB FLASH 48TQFP**
    case 0x1001000b: // E17A
    case 0x10010010: // G17A WLCSP
            _family = FAMILY_SAMD21;
            flashPtr = new D2xNvmFlash(_samba, "ATSAMD21x17", 2048, 64, 0x20002000, 0x20004000) ;
            break;

The following is a partial listing of device.cpp

Am I correct in assuming I would need a Linux machine to tweak bossac.exe for win7

///////////////////////////////////////////////////////////////////////////////
// BOSSA
//
// Copyright (c) 2011-2018, ShumaTech
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of the <organization> nor the
//       names of its contributors may be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///////////////////////////////////////////////////////////////////////////////

**** note partial file about 300 lines deleted above !!!!!!!!!!!!!


        case 0x10010001: // J17A
        **case 0x10010006: // G17A**
        case 0x1001000b: // E17A
        **case 0x10010010: // G17A WLCSP**
            _family = FAMILY_SAMD21;
            flashPtr = new D2xNvmFlash(_samba, "ATSAMD21x17", 2048, 64, 0x20002000, 0x20004000) ;
            break;

**** note partial file about 300 lines deleted !!!!

        case 0x1001001d: // E17A
        **case 0x1001001a: // G17A**
            _family = FAMILY_SAMR21;
            flashPtr = new D2xNvmFlash(_samba, "ATSAMR21x17", 2048, 64, 0x20002000, 0x20004000) ;
            break;

        case 0x1001001c: // E18A
        case 0x10010019: // G18A
            _family = FAMILY_SAMR21;
            flashPtr = new D2xNvmFlash(_samba, "ATSAMR21x18", 4096, 64, 0x20004000, 0x20008000) ;
            break;

  
        case 0x10810001: // J17A
        **case 0x10810006: // G17A**
        case 0x1081000b: // E17A
        case 0x10810010: // J17B
        case 0x10810015: // G17B
        case 0x1081001a: // E17B
            _family = FAMILY_SAML21;
            flashPtr = new D2xNvmFlash(_samba, "ATSAML21x17", 2048, 64, 0x20002000, 0x20004000) ;
            break;


**** note partial file about 300 lines deleted !!!!


Hi @JesterJ

There are two issues:

  1. The bootloader needs to be modified to account for the smaller memory footprint, since the double tap reset fuctionality relies on a "magic number" variable stored in the last 4 bytes in RAM. It's also necessary to specify if the board is crystalless or not.

  2. The bossac.exe file might need replacing if the variant isn't supported by Arduino's version. Bossac is somewhat fussy, as it checks the variant's chip ID.

This topic was discussed here: https://forum.arduino.cc/t/how-to-write-programs-for-a-custom-samd21-board-using-arduino-ide/914110

1 Like

I have already updated the bootloader and programmed the G17A with it, I just need an updated bossac with the correct chip ID.

Am I correct that bossac needs to be compiled on a Linux machine. I only have a Win7 machine.

Hi @JesterJ

I faced the same issue, while trying solve this on a previous thread. It certainly seems as though compiling for on a Windows machine is much more complex and involved.

I found the path of least resistance was to simply download a precompiled fork of bossac on Github that supported more SAMD21 variants than the standard Arduino one. Here's a link to the instructions to do that: https://forum.arduino.cc/t/lower-memory-samd21-variant/890009/37.

You'll also need to change the available memory in your Arduino core code's "boards.txt" file and linker script: https://forum.arduino.cc/t/how-to-write-programs-for-a-custom-samd21-board-using-arduino-ide/914110/11.

1 Like