Skip to content

tools: Add cpboard.py #893

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

Merged
merged 2 commits into from
Jun 5, 2018
Merged

tools: Add cpboard.py #893

merged 2 commits into from
Jun 5, 2018

Conversation

notro
Copy link

@notro notro commented Jun 2, 2018

I needed a simple way to upload firmware, attach to repl over network and a way to run tests.
@tannewt encouraged me to make a PR of my attempt.

Show some board info:

$ ./cpboard.py feather_m0_express
Device: 239a:8023 on /dev/ttyACM0
Serial number: 9B81BE1A8413D405A413E263903150FF
os.uname:
  sysname: samd21
  nodename: samd21
  release: 6479cb080-dirty
  version: patchbase-dirty on 2018-06-01
  machine: Adafruit Feather M0 Express with samd21g18

$ ./cpboard.py 239a:8023
Device: 239a:8023 on /dev/ttyACM0
Serial number: 9B81BE1A8413D405A413E263903150FF
<...>

$ ./cpboard.py /dev/ttyACM0
Device: /dev/ttyACM0
Serial number: 9B81BE1A8413D405A413E263903150FF
<...>

Upload firmware:

$ ./cpboard.py -v feather_m0_express --firmware /tmp/firmware.uf2
Serial number : 9B81BE1A8413D405A413E263903150FF
Current version: patchbase-dirty on 2018-06-01
Reset to bootloader...done
Bootloader: {'header': 'UF2 Bootloader v1.21.0 SFHR', 'Board-ID': 'SAMD21G18A-Feather-v0', 'Model': 'Feather M0'}
Upload firmware...done
Wait for board...done
New version: patchbase-dirty on 2018-06-01

Run tests through the repl:

$ python3 run-tests --target=pyboard --device=feather_m0_express -d basics circuitpython
<...>

406 tests performed (12312 individual testcases)
401 tests passed
31 tests skipped: array_micropython async_await async_await2 async_def async_for async_for2 async_with async_with2 builtin_compile builtin_delattr builtin_pow3 builtin_pow3_intbig class_delattr_setattr class_descriptor class_new class_notimpl class_reverse_op class_store_class class_super_object exception_chain fun_name namedtuple1_cpython_compat nvm_not_present nvm_present object_dict object_new ordereddict1 ordereddict_eq parser struct_micropython subclass_classmethod
5 tests failed: blinky enumerate memoryview_gc struct1 struct2

Run tests through code.py:

$ CPBOARD_EXEC_MODE=disk python3 run-tests --target=pyboard --device=feather_m0_express -d basics circuitpython
<...>

### Expected
b'RuntimeError\n'
### Actual
b'CRASH'
FAIL  basics/gen_stack_overflow.py
Traceback (most recent call last):
<...>
sh.TimeoutException

I couldn't get the test run to finish. The board locks up so hard I have to flash-erase it. The tests did run yesterday, but not one week ago. Not sure what's going on here.

Removing the gen_stack_overflow test:

$ CPBOARD_EXEC_MODE=disk python3 run-tests --target=pyboard --device=feather_m0_express -d basics circuitpython
<...>

412 tests performed (12422 individual testcases)
400 tests passed
25 tests skipped: array_micropython builtin_compile builtin_delattr builtin_pow3 builtin_pow3_intbig class_delattr_setattr class_descriptor class_new class_notimpl class_reverse_op class_store_class class_super_object exception_chain fun_name gen_stack_overflow namedtuple1_cpython_compat nvm_not_present nvm_present object_dict object_new ordereddict1 ordereddict_eq parser struct_micropython subclass_classmethod
12 tests failed: async_await async_await2 async_def async_for async_for2 async_with async_with2 blinky enumerate memoryview_gc struct1 struct2

Attach to REPL over ssh:

ssh -t pi@cp.home 'screen $(./cpboard.py feather_m0_express --tty)'

Ref: adafruit/rosie-ci#2

notro added 2 commits June 2, 2018 19:09
This is a variant of pyboard.py aimed at Circuit Python boards.
It can emulate pyboard.py enough so it works with tests/run-tests.
This makes it possible to run-tests on the board itself.
@notro
Copy link
Author

notro commented Jun 2, 2018

Version 2

I accidentally commited my hack to remove execution of basics/gen_stack_overflow.py.

@notro
Copy link
Author

notro commented Jun 3, 2018

Lesson learned from #894 is that running tests using code.py can lock the board up so a flash erase or custom firmware is the only way out.

@dhalbert:

So perhaps we should have some way of forcing safe mode in case of really broken main.py/code.py or boot.py.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Very cool! Thank you so much for this!

@tannewt tannewt merged commit 52cc3ed into adafruit:master Jun 5, 2018
@notro notro deleted the cpboard branch February 14, 2019 21:21
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