Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runners: bossa: fix support for the Arduino Due #26866

Merged
merged 2 commits into from
Oct 9, 2020

Conversation

nzmichaelh
Copy link
Collaborator

The bossac runner uses the absolute load address as the flash offset, where it should be the actual flash offset. This is fine on most boards as the flash starts at address zero but fails on the Arduino Due the flash starts at address +512 KiB.

Change to use the offset. Tested on the adafruit_trinket_m0, adafruit_itsybitsy_m4_express, and arduino_due.

Related: zephyrproject-rtos/sdk-ng#234.

Also support sniffing --help on the git versions of bossac.

@nzmichaelh nzmichaelh requested a review from galak July 14, 2020 17:57
@galak
Copy link
Collaborator

galak commented Jul 14, 2020

What command line are you now passing to bossac for arduino due?

@nzmichaelh
Copy link
Collaborator Author

What command line are you now passing to bossac for arduino due?

Using BOSSA 1.9.1+git:

$ west build -b arduino_due samples/basic/blinky
$ west -v flash
-- west flash: rebuilding
cmake version 3.16.3 is OK; minimum version is 3.13.1
-- west flash: using runner bossac
runners.bossac: /home/michaelh/.local/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/bossac --help
runners.bossac: /home/michaelh/.local/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/bossac -p /dev/ttyACM0 -R -e -w -v -b /home/michaelh/src/zephyr/zephyr/build/zephyr/zephyr.bin

This is with a symlink from poxysdk/.../bossac to the git build. The -o flag is skipped as the offset is zero.

@galak
Copy link
Collaborator

galak commented Jul 15, 2020

So it feels like there is some bug with bossa 1.9.x (tried both mainline - Version 1.9.1-14-g3532de8 Version 1.9.1). The both appear to flash, but than the board doesn't boot on Arduino Due. Works w/1.7.0 just fine.

@nzmichaelh
Copy link
Collaborator Author

Yip. patformio has the same issue with the Due: platformio/platform-atmelsam/issues/78

@nzmichaelh
Copy link
Collaborator Author

And shumatech/BOSSA/issues/125

@nzmichaelh
Copy link
Collaborator Author

@galak could you try patching in shumatech/BOSSA#111 and testing it against the Due?

@galak
Copy link
Collaborator

galak commented Jul 15, 2020

@galak could you try patching in shumatech/BOSSA#111 and testing it against the Due?

will Try.

@galak
Copy link
Collaborator

galak commented Jul 15, 2020

That seems to fix the issue. Worked up update to sdk w/latest bossa tree plus that patch:

zephyrproject-rtos/sdk-ng#247

@galak
Copy link
Collaborator

galak commented Jul 15, 2020

@nzmichaelh can you test this SDK version w/newer bossac + patch:

builds.zephyrproject.org/zephyrproject-rtos/sdk-ng/247/zephyr-sdk-0.11.4-pr-247-setup.run

@nzmichaelh
Copy link
Collaborator Author

Will test.

Note that this needs to land before zephyrproject-rtos/sdk-ng/pull/247 is released. Without this PR, BOSSA 1.9.1+git will use offset zero and overwrite the bootloader.

Also, fun fact: Arduino boards don't protect the bootloader.

What's the SDK vs Zephyr compatibility policy? Can a user pick a recent SDK with an older release of Zephyr? If so we might need to rethink the BOSSA 1.9.1+git update.

@galak
Copy link
Collaborator

galak commented Jul 16, 2020

Will test.

Note that this needs to land before zephyrproject-rtos/sdk-ng/pull/247 is released. Without this PR, BOSSA 1.9.1+git will use offset zero and overwrite the bootloader.

Also, fun fact: Arduino boards don't protect the bootloader.

What's the SDK vs Zephyr compatibility policy? Can a user pick a recent SDK with an older release of Zephyr? If so we might need to rethink the BOSSA 1.9.1+git update.

We have a version check w/regards to the SDK. I expect the SDK version that the newer bossa will be in is 0.12.0 and it will have other non-backward compatible changes in it. So we will require 0.12.0 as part of the zephyr 2.4 release is my expectation.

Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections to this PR, will leave it up to @galak / @nzmichaelh to sort out the details.

@nzmichaelh
Copy link
Collaborator Author

nzmichaelh commented Jul 23, 2020

@galak I've tested the SDK build combined with #26866 and it works fine on the Arduino Nano 33 IOT:

$ md5sum ~/Downloads/zephyr*run
574720fcee6e1478c58c42734ac942b5  /home/michaelh/Downloads/zephyr-sdk-0.11.4-pr-247-setup.1.run

$ west -v flash
ZEPHYR_BASE=/home/michaelh/src/zephyr/zephyr (origin: configfile)
-- west flash: rebuilding
cmake version 3.16.3 is OK; minimum version is 3.13.1
Running CMake: /usr/bin/cmake --build /home/michaelh/src/zephyr/zephyr/build --target west_flash_depends
[0/1] cd /home/michaelh/src/zephyr/zephyr/build/zephyr/cmake/flash && /usr/bin/cmake -E echo

-- west flash: using runner bossac
runners.bossac: stty -F /dev/ttyACM0 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
runners.bossac: /home/michaelh/.local/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/bossac --help
runners.bossac: /home/michaelh/.local/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/bossac -p /dev/ttyACM0 -R -e -w -v -b /home/michaelh/src/zephyr/zephyr/build/zephyr/zephyr.bin -o 8192
Erase flash

Done in 0.818 seconds
Write 30412 bytes to flash (476 pages)
[==============================] 100% (476/476 pages)
Done in 0.179 seconds
Verify 30412 bytes of flash
[==============================] 100% (476/476 pages)
Verify successful
Done in 0.113 seconds
Set boot flash true

$ /home/michaelh/.local/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/bossac -V
Basic Open Source SAM-BA Application (BOSSA) Version 1.9.1-14-g3532de8-dirty
Flash programmer for Atmel SAM devices.
Copyright (c) 2011-2018 ShumaTech (http://www.shumatech.com)

@nzmichaelh nzmichaelh marked this pull request as ready for review July 23, 2020 18:21
@nzmichaelh
Copy link
Collaborator Author

Also, I have a follow up PR that changes the runner to use the built-in reset support instead of calling stty. This fixes the re-enumeration problem.

BOSSA takes the offset within flash memory, not the absolute address.
This doesn't matter on most boards as the flash starts at zero but
does matter on the Due as the flash starts at +512 KiB.

Signed-off-by: Michael Hope <[email protected]>
BOSSA 1.9.1 and before an errror on `--help`, but the current git
version returns 0.  Handle both cases.

Signed-off-by: Michael Hope <[email protected]>
@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Sep 23, 2020
@mbolivar-nordic
Copy link
Contributor

I don't think this is stale -- @galak can you please take a look?

@galak galak merged commit bf04c29 into zephyrproject-rtos:master Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants