Skip to content

Move atmel-samd to tinyusb and support nRF flash. #1321

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 5 commits into from
Nov 9, 2018

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Nov 9, 2018

This started while adding USB MIDI support (and descriptor support is
in this change.) When seeing that I'd have to implement the MIDI class
logic twice, once for atmel-samd and once for nrf, I decided to refactor
the USB stack so its shared across ports. This has led to a number of
changes that remove items from the ports folder and move them into
supervisor.

Furthermore, we had external SPI flash support for nrf pending so I
factored out the connection between the usb stack and the flash API as
well. This PR also includes the QSPI support for nRF.

I'm using my own fork of tinyusb until I can land the changes upstream.

This started while adding USB MIDI support (and descriptor support is
in this change.) When seeing that I'd have to implement the MIDI class
logic twice, once for atmel-samd and once for nrf, I decided to refactor
the USB stack so its shared across ports. This has led to a number of
changes that remove items from the ports folder and move them into
supervisor.

Furthermore, we had external SPI flash support for nrf pending so I
factored out the connection between the usb stack and the flash API as
well. This PR also includes the QSPI support for nRF.
@siddacious
Copy link

Awesome work! 👍

@ladyada
Copy link
Member

ladyada commented Nov 9, 2018

i dont think i'd be good for code reviewing this opus, but i could do hardware testing for sure :) just let me know!

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Very impressive refactoring! In some ways, there are fewer changes than I would have expected due to tinyusb. There are many more cleanup changes, which are really welcome!

@tannewt
Copy link
Member Author

tannewt commented Nov 9, 2018

Thanks for the quick review! I'll get back to you tomorrow. Trying to run down the last few things to get the build green now.

* Clean up board defines.
* Add flush on eject and stay ejected.
* Swith back to NONE protocol for CDC.
@tannewt
Copy link
Member Author

tannewt commented Nov 9, 2018

@dhalbert This is ready for another look. Thanks!

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Fantastic! This is a huge step forward: tinyusb, and getting rid of a lot of technical debt.

@dhalbert dhalbert merged commit 97bc951 into adafruit:master Nov 9, 2018
@notro
Copy link

notro commented Nov 15, 2018

This PR is causing problems for me.
I use a tool similar to ampy to copy files through the REPL to the board.
It is now broken and I get timeout/disconnect after a few files are copied.
The commit before this PR is fine (I've tried the latest master, same problem).

The board is connected to a Raspberry Pi.
Sometimes the /dev device name stays the same and sometime I get a new one like here:

pi@cp:~/work/circuitpython/projects/fs.repl/fs $ python3 -u stdlib_copy.py -vvv /dev/ttyACM1 --delete-lib

board Board('/dev/ttyACM1')
uname: posix.uname_result(sysname='samd51', nodename='samd51', release='4.0.0', version='4.0.0-alpha.2-144-g50f5d27c4-dirty on 2018-11-15', machine='Adafruit Metro M4 Express with samd51j19')
board time time.struct_time(tm_year=2018, tm_mon=11, tm_mday=15, tm_hour=17, tm_min=14, tm_sec=38, tm_wday=3, tm_yday=319, tm_isdst=-1)
board time time.struct_time(tm_year=2018, tm_mon=11, tm_mday=15, tm_hour=17, tm_min=14, tm_sec=39, tm_wday=3, tm_yday=319, tm_isdst=-1)

<replfs '/dev/ttyACM1'>
Deleting /lib ...
Source: <osfs '/home/pi/work/circuitpython/tmp_CircuitPython_stdlib/lib'>
Destination: <replfs '/dev/ttyACM1'>/lib
new: /contextlib.mpy
new: /copy.mpy
new: /copyreg.mpy
new: /datetime.mpy
RETRY
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/serial/serialposix.py", line 537, in write
    n = os.write(self.fd, d)
OSError: [Errno 5] Input/output error

<snip>

cpboard.CPboardError: read error

pi@cp:~/work/circuitpython/projects/fs.repl/fs $ dmesg
[80063.522775] usb 1-1.4: reset full-speed USB device number 81 using dwc_otg
[80063.655651] cdc_acm 1-1.4:1.0: ttyACM2: USB ACM device
[80063.664710] sd 1:0:0:0: [sdc] 4089 512-byte logical blocks: (2.09 MB/2.00 MiB)
[80063.682308]  sdc: sdc1

The same problem is also experienced when trying out libraries in the REPL. Suddenly the connection closes down. In this case I can just reconnect, but loading a library and trying a few things, leads to disconnect again.
I've tried just keeping the REPL open without doing anything, and it stays connected.

Anything I can do to diagnose this further?

@tannewt
Copy link
Member Author

tannewt commented Nov 15, 2018

@notro have you tried the tip of master? Some fixes went in yesterday.

@notro
Copy link

notro commented Nov 15, 2018

Yes, I've tried the latest master.

@tannewt
Copy link
Member Author

tannewt commented Nov 15, 2018

@notro Please file a new issue with instructions to reproduce. For that issue:

  • Beagle or wireshark traces are extra helpful.
  • What is the status LED doing as it does this? One of the first things is to rule out a hardfault.
  • Which board are you using?

@notro
Copy link

notro commented Nov 15, 2018

To be precise, this PR didn't work at all (looked like something was corrupted in the transfer), I needed the overrun fix in order to copy anything at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants