Adafruit Trinket M0: west flash > How to? #flash #west


@yasokada
 
Edited

My environment:
Ubuntu 18.04 LTS
board: Adafruit Trinket M0
RTOS: Zephyr 2.1.0-rc1

I was trying to use Adafruit Trinket M0.

### connections

https://docs.zephyrproject.org/latest/boards/arm/adafruit_trinket_m0/doc/index.html

> Flash
> ...
> 2. Connect the Trinket M0 to your host computer using USB
> 3. 
Connect a 3.3 V USB to serial adapter to the board and to the host. See the Serial Port section above for the board’s pin connections.

With the above step 2, the device is '/dev/ttyACM0'.
With the above step 3, the device may depends on the used "USB to serial adapter". For example, I use some FTDI adapter, which becomes '/dev/ttyUSB0'.

When I try "west flash", the Zephyr will use "/dev/ttyACM0'. 
This is defined at 'scripts/west_commands/runners/bossac.py' as 
DEFAULT_BOSSAC_PORT = '/dev/ttyACM0'.

So, my understanding is that :

> 2. Connect the Trinket M0 to your host computer using USB
is for west flash.

> 3. Connect a 3.3 V USB to serial adapter to the board and to the host. See the Serial Port section above for the board’s pin connections.
is not clear what to use.

With these information, I thought I can flash by using USB connected at the above step 2.

### west flash

I tried to west flash for Trinket M0.

1. connect USB to Trinket M0
2. sudo chmod +777 /dev/ttyACM0 (to add permission to write flash)
3. west flash

I have following error. What is wrong?

```
$ west flash
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner bossac
bossac: invalid option -- 'o'
Try 'bossac -h' or 'bossac --help' for more information
```

Q1. I do not understand why step 3 is necessary.
Q2. If the step 3 is used for west flash, how can I change /dev/ttyACM0 to /dev/ttyUSB0 for west flash?
Q3. If step 3 is not relevant to west flash, what is wrong with the above procedure?



Bolivar, Marti
 

Hello,

"yasokada via Lists.Zephyrproject.Org"
<yasokada=gmail.com@lists.zephyrproject.org> writes:

Q1. I do not understand why step 3 is necessary.
Q2. If the step 2 is used for flash, how can I change /dev/ttyACM0 to /dev/ttyUSB0 for west flash?
Q3. If step 3 is not relevant to west flash, what is wrong with the above procedure?

I don't have this board, and I can't help you with Q1 or Q3, but for Q2:
you can always run this command to get help on options that are
available to you:

$ west flash --context -d <YOUR_BUILD_DIR>

In this case, you are looking for the --bossac-port option.

Best,
Marti


William Fish
 

Not completely sure i understand your question but hopefully this will help.

Step 3: west flash
This builds your application then flash your device.

So steps to flash your application are:
Step 1: Identify port

Find port on Linux
  1. Open terminal and type: ls /dev/tty*.

  2. Note the port number listed for /dev/ttyUSB* or /dev/ttyACM*. The port number is represented with * here.

  3. Use the listed port as the serial port. For example: /dev/ttyUSB0.

Step 2: Update the standard config file
This is defined at 'scripts/west_commands/runners/bossac.py' as 
DEFAULT_BOSSAC_PORT = '/dev/ttyACM0'.
Update the port identified in Step 1

Step 3: Build and Flash Board
Run West Flash

If configured correctly West will build and write application to board.

Billy..
 


@yasokada
 
Edited

Dear Marti and William

Thank you for your reply.

I tried using "--bossac-port", but still have problem about "-o" option.

I checked my bossac option by
```
$ ~/Zephyr_191116/zephyr-sdk-0.10.3/sysroots/x86_64-pokysdk-linux/usr/bin/bossac --help
```

```
Usage: bossac [OPTION...] [FILE]
Basic Open Source SAM-BA Application (BOSSA) Version 1.7.0
Flash programmer for Atmel SAM devices.
...
```

There is no "-o" option for my bossac.
My environment is Ubuntu 18.04 LTS.

I have found this.
Adafruit Trinket M0 Bossac Offset is Wrong #16052
https://github.com/zephyrproject-rtos/zephyr/issues/16052

For Adafruit Trinket M0, the address is specified using "-o 0x2000". However, because my bossac does not have "-o" option, the problem occurs.
It seems that I have to update my environment to have newer? bossac version.


Bolivar, Marti
 

Hi Yas,

"yasokada via Lists.Zephyrproject.Org"
<yasokada=gmail.com@lists.zephyrproject.org> writes:

[Edited Message Follows]

Dear Marti and William

Thank you for your reply.

I tried using " --bossac-port", but still have problem about "-o" option.

I checked my bossac option by
```
$ ~/Zephyr_191116/zephyr-sdk-0.10.3/sysroots/x86_64-pokysdk-linux/usr/bin/bossac --help
```

```
Usage: bossac [OPTION...] [FILE]
Basic Open Source SAM-BA Application (BOSSA) Version 1.7.0
Flash programmer for Atmel SAM devices.
...
```

There is no "-o" option for my bossac.
My environment is Ubuntu 18.04 LTS.
I checked the bossac source code and the option seems to be available,
so it doesn't look like there's a problem with the bossac.py code in the
zephyr repository that is using --offset:

https://github.com/shumatech/BOSSA/blob/master/src/bossac.cpp#L185

I'm not sure why the bossac that ships with the Zephyr SDK doesn't have
the --offset option. I checked the version that ships with bossa-cli on
Ubuntu 18.04 and it doesn't seem to have it either, as you say.

I would try compiling bossac from source trying that version. Please
consider filing a bug against the Zephyr SDK about the missing option if
that solves your issue.


I have found this.
Adafruit Trinket M0 Bossac Offset is Wrong #16052
https://github.com/zephyrproject-rtos/zephyr/issues/16052

For Adafruit Trinket M0, the address is specified using "-o 0x2000". However, because my bossac does not have "-o" option, the problem occurs.
It seems that I have to update my environment to have newer? bossac
version.
By the way, it looks like the person who added this board in commit
4f9864b15b263dcf7d6e204ac79f3d96a8a30e64 is no longer active on Zephyr
(the last contribution they made is from March 2018), so it's possible
that this board is unmaintained.

Hope you figure out your issue.

Thanks,
Marti



@yasokada
 

Dear Marti


Thank you very much for taking your time for this.
From your information, it seems the bossac has "-o" options in source code, but does not have in binary execution code.

> I would try compiling bossac from source trying that version. Please
> consider filing a bug against the Zephyr SDK about the missing option if
> that solves your issue.

I will see.

From your information again, it seems the Adafruit Trinket M0 is unmaintained. Updating the SDK somehow broke the condition to compile and flash the Trinket M0 in current SDK version.

I will check how to solve this.


Bolivar, Marti
 

Hi Yas,

"yasokada via Lists.Zephyrproject.Org"
<yasokada=gmail.com@lists.zephyrproject.org> writes:

Dear Marti

Thank you very much for taking your time for this.
From your information, it seems the bossac has "-o" options in source
code, but does not have in binary execution code.
Correct -- where the binary in question is the one provided with the
SDK.


I would try compiling bossac from source trying that version. Please
consider filing a bug against the Zephyr SDK about the missing option if
that solves your issue.
I will see.

From your information again, it seems the Adafruit Trinket M0 is
unmaintained.
It may be unmaintained. I am not sure :).

Updating the SDK somehow broke the condition to compile
and flash the Trinket M0 in current SDK version.
This I'm not sure about either. I don't know if anybody was actively
testing this with the SDK in previous versions. I just meant by this
that if nobody is actively maintaining this, you may have to figure this
issue out for yourself, unfortunately.

Best,
Marti


I will check how to solve this.


@yasokada
 

I have checked old SDKs.

SDK v0.9.2 (20 Oct 2017): no "-o" option for bossac.
SDK v0.9.1 (20 May 2017): no "-o" option for bossac.

The "-o" for bossac.py is added on 9 Jul 2018
https://github.com/zephyrproject-rtos/zephyr/commit/bde3224c911176a6af4fa60a067c7492dfc76fe4

I just wonder which environment they did check.

It may be possible to replace bossac binary with "-o" option, but I am not sure whether it is best way for Zephyr.
I will just check further information myself, but for a while, I give up using Adafruit Trinket M0 and will use other boards.


William Fish
 

I have downloaded the Arduino IDE and that includes a version of BOSSAC that may be useful. That may be a quickest method to find a working replacement version.

My interest in the use of bossac comes from the release of the Arduino Nano 33 BLE (Sense) as they are based on nRF52840 with a special boot-loader designed to work in the arduino environment.

I am looking to see if it is possible to use zephyr on these boards without having to replace the boot-loader which may not be possible. I do know that the boot-loader can easily be replacement via the debug interface pins on the underside of these board but that's not that useful for most people.

Billy..