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

Enable Arduino Nano 33 BLE #55

Merged
merged 13 commits into from
Oct 16, 2022
Merged

Conversation

multiplemonomials
Copy link
Collaborator

@multiplemonomials multiplemonomials commented Sep 22, 2022

Summary of changes

Even though Mbed OS is used to power the Arduino Nano 33 BLE, mainline Mbed doesn't actually support this board out of the box. The Arduino board uses a custom bootloader with a different memory layout, as well as an upload method that does not align with Mbed's tooling. ARM evidently didn't want to deal with this, so Arduino people had to develop their own tooling on top of Mbed, and the ARDUINO_NANO33BLE target was left in an odd half-working state. Until now!

This PR:

  • Adds new linker script configuration to the ARDUINO_NANO33BLE target to make it play nice with the Arduino bootloader
  • Fixes a bug where some config defines (that went into mbed-target-config.h) were not passed to the linker script
  • Adds a new ARDUINO_NANO33BLE_SWD target for using the Nano 33 BLE with no bootloader and an SWD debugger soldered on (this config will be needed for CI testing)
  • Adds infrastructure for a target to request USB serial instead of a serial port as its standard input/output. This is needed for the Nano 33 BLE because it does not have an interface chip and relies on USB for communication with the host PC.
  • Adds a new ArduinoBossac upload method for the bossac program used to talk to the Nano 33 BLE bootloader
  • Modifies the OpenOCD upload method co include a configuration option for which debug adapter is used (so that the CI can work with multiple CMSIS-DAP devices plugged into the same machine)

Impact of changes

Arduino Nano 33 supported out of the box by Mbed

Migration actions required

Documentation

Still need to do this


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[X] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@jay-sridharan
@JohnK1987


JohnK1987
JohnK1987 previously approved these changes Sep 22, 2022
Copy link
Member

@JohnK1987 JohnK1987 left a comment

Choose a reason for hiding this comment

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

Looks OK

@multiplemonomials
Copy link
Collaborator Author

UploadMethods page updated https://github.com/mbed-ce/mbed-os/wiki/Upload-Methods

@multiplemonomials
Copy link
Collaborator Author

Finally got around to hooking up SWD to my Arduino and adding it to my test setup! Test results:

95% tests passed, 4 tests failed out of 73

Total Test time (real) = 945.67 sec

The following tests did not run:
	  8 - mbed-hal-crc (Skipped)
	 13 - mbed-hal-mpu (Skipped)
	 14 - mbed-hal-ospi (Skipped)
	 16 - mbed-hal-qspi (Skipped)
	 17 - mbed-hal-reset-reason (Skipped)
	 18 - mbed-hal-rtc (Skipped)
	 19 - mbed-hal-rtc-reset (Skipped)
	 20 - mbed-hal-rtc-time (Skipped)
	 21 - mbed-hal-rtc-time-conv (Skipped)
	 29 - mbed-hal-watchdog (Skipped)
	 30 - mbed-hal-watchdog-reset (Skipped)
	 31 - mbed-hal-watchdog-timing (Skipped)
	 32 - mbed-hal-verify-arduino-pinmap (Skipped)
	 43 - mbed-platform-crash-reporting (Skipped)
	 53 - mbed-platform-stats-cpu (Skipped)
	 54 - mbed-platform-stats-heap (Skipped)
	 55 - mbed-platform-stats-sys (Skipped)
	 56 - mbed-platform-stats-thread (Skipped)
	 71 - mbed-connectivity-nfc-eeprom (Skipped)
	 73 - mbed-connectivity-ble-cordio-hci-transport (Skipped)

The following tests FAILED:
	  2 - mbed-usb-device-basic (Failed)
	  4 - mbed-usb-device-msd (Failed)
	  5 - mbed-usb-device-serial (Failed)
	 61 - mbed-rtos-kernel-tick-count (Failed)
Errors while running CTest
Build step 'Execute shell' marked build as failure
  • mbed-usb-device-basic also failing due to endpoint abort test:
[1664677047.99][CONN][RXD] >>> Running case #9: 'endpoint test halt'...
[1664677048.04][CONN][INF] found KV pair in stream: {{__testcase_start;endpoint test halt}}, queued...
[1664677048.72][CONN][INF] found KV pair in stream: {{ep_test_halt;0123456789}}, queued...
interface 0, alt 0 -- skipping the default AlternateSetting
interface 0, alt 1 -- running tests
interface 0, alt 2 -- running tests
interface 0, alt 3 -- running tests
interface 0, alt 4 -- running tests
interface 0, alt 0 -- skipping the default AlternateSetting
interface 0, alt 1 -- running tests
interface 0, alt 2 -- running tests
interface 0, alt 3 -- running tests
Endpoint 0x81 halt failed (USBError(32, 'Pipe error')).
[1664677053.39][HTST][INF] TEST FAILED: [/home/jenkins/workspace/mbed-os-ce/drivers/usb/tests/TESTS/host_tests/pyusb_basic.py]:970, Endpoints must NOT be halted at the start of this test
[1664677053.40][SERI][TXD] {{fail;0}}
[1664677053.48][CONN][RXD] <greentea test suite>:275::FAIL: Expected 'pass' Was 'fail'
[1664677053.52][CONN][INF] found KV pair in stream: {{__testcase_finish;endpoint test halt;0;1}}, queued...
[1664677053.60][CONN][RXD] >>> 'endpoint test halt': 0 passed, 1 failed with reason 'Assertion Failed'
[1664677053.60][CONN][RXD] 
[1664677053.61][CONN][RXD] 
[1664677053.67][CONN][RXD] >>> Test cases: 8 passed, 1 failed with reason 'Assertion Failed'
[1664677053.69][CONN][RXD] >>> TESTS FAILED!
[1664677053.69][CONN][RXD] 
[1664677053.71][CONN][RXD] -----------------------
[1664677053.74][CONN][RXD] 0 Tests 1 Failures 0 Ignored 
[1664677053.75][CONN][RXD] FAIL

Looks similar to #53 ?

  • mbed-usb-device-msd DOES pass on my Windows desktop, but failed on Linux with:
[1664677106.86][CONN][RXD] >>> Running case #2: 'mount/unmount test - Heap block device'...
[1664677106.93][CONN][INF] found KV pair in stream: {{__testcase_start;mount/unmount test - Heap block device}}, queued...
[1664677107.95][CONN][INF] found KV pair in stream: {{check_if_mounted;0}}, queued...
[1664677134.18][HTST][INF] mount check failed !!!
[1664677134.18][SERI][TXD] {{failed;0}}
[1664677134.28][CONN][RXD] <greentea test suite>:303::FAIL: expected passed was failed (loop index: 1)
[1664677134.35][CONN][INF] found KV pair in stream: {{__testcase_finish;mount/unmount test - Heap block device;0;1}}, queued...
[1664677134.45][CONN][RXD] >>> 'mount/unmount test - Heap block device': 0 passed, 1 failed with reason 'Assertion Failed'
[1664677134.48][CONN][RXD] <greentea test suite>:0::PASS
[1664677134.48][CONN][RXD] 
[1664677134.55][CONN][RXD] >>> Test cases: 1 passed, 1 failed with reason 'Assertion Failed'
[1664677134.56][CONN][RXD] >>> TESTS FAILED!

Maybe this is some sort of udev related issue.

  • mbed-usb-device-serial seems like maybe a Python related error? I'll investigate.
  • mbed-rtos-kernel-tick-count looks like maybe a transient timing error? It was only off by a small fraction

@JohnK1987 JohnK1987 self-requested a review October 2, 2022 05:54
JohnK1987
JohnK1987 previously approved these changes Oct 2, 2022
@multiplemonomials
Copy link
Collaborator Author

Made another fix just now that allows the usb-device-serial test to pass 50% of the time. Still seems to randomly fail the other half of the time though.

JohnK1987
JohnK1987 previously approved these changes Oct 5, 2022
JohnK1987
JohnK1987 previously approved these changes Oct 9, 2022
@multiplemonomials
Copy link
Collaborator Author

I'm so close to being able to merge this... finally fixed the linker script issue after hours and hours of work. How I just need to:

  • Fix the OpenOCD upload method so it can distinguish between multiple CMSIS-DAP probes (this is causing problems on the Jenkins server)
  • Write a wiki page about this MCU

Hopefully I can get this done in the next 1-2 weeks.

@multiplemonomials
Copy link
Collaborator Author

@multiplemonomials multiplemonomials changed the title [WIP] Enable Arduino Nano 33 BLE Enable Arduino Nano 33 BLE Oct 16, 2022
@multiplemonomials
Copy link
Collaborator Author

OK, I think my latest commit has resolved the flashing issues in CI. Now, I can connect all three devices I have (LPC1768, Nano 33 BLE, NUCLEO_F429ZI) to the host at the same time and I verified that code gets flashed to the correct ones.

@JohnK1987 Once you approve, should be good to merge!

JohnK1987
JohnK1987 previously approved these changes Oct 16, 2022
…e weak implementation can simply be removed, because there's no legitimate case where it is used.
@multiplemonomials
Copy link
Collaborator Author

multiplemonomials commented Oct 16, 2022

@JohnK1987 OK last one for real, tests showed a bluetooth failure after rebasing due to a weak symbol issue. Should be fixed now.

@multiplemonomials multiplemonomials merged commit 32a9080 into master Oct 16, 2022
@multiplemonomials multiplemonomials deleted the dev/enable-arduino-nano-33-ble branch October 16, 2022 17:32
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.

2 participants