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

Added support for SAM C21 J18A #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

ka-long
Copy link

@ka-long ka-long commented Jan 31, 2020

  • Device.cpp and Device.h adapted to know Sam C21
  • Added sleep after command executing which is specified in Sam C2x/D2x datasheet

…or writing a page.

More info:
 SAM x20/21 needs a couple of ms to execute some commands
 EP: 6ms, WP: 2,5ms
 During this time SAM cant receive serial data reliable

 Earlier implementation dont wait and sent the next command which
 results in incomplete command and no response
@shumatech
Copy link
Owner

Using sleep to control program flow is almost always a bad idea and leads to brittle and difficult to maintain code. How were the sleep times determined and proven to be correct? How do the sleeps impact other devices in the D2xNvm family? Was this tested with all other devices in the D2xNvm family? What if the next device down the road needs a longer sleep?

If this device drops serial communication for some time after the command, then you should implement a retry loop in waitReady() instead of using sleep. I'm assuming the problem is that Samba::readWord is timing out and throwing an error. You should catch the error in waitReady() and retry the readWord a sane number of times before throwing an error. This type of implementation doesn't impact existing devices and is likely to work with devices down the road.

@ka-long
Copy link
Author

ka-long commented Feb 2, 2020

I got your point. I want to answer your questions anyway:

Sleep times: I have checked all supported device datasheets (D20/D21/R21/L20/L21/C20/C21) to make sure that they have all the same timings (NVM characteristics tFPP and tFRE)

Other devices and next devices: Currently all supported devices have the same characteristics. Only impact is that throwing the error will be delayed by 6ms (for supported and unsupported devices when failing)

Testing: Physically tested on C21 /D21 and D20 explained boards with SAM-BA firmware from ASF3 / SAM-BA windows PC application and BOSSA under linux.

I need to figure out if the SAM-BA firmware wont stuck when implementing a retry loop.
Your assumption is right regarding waitReady.

But: From my point of view (3 explained boards / just using vanilla code) the current implementation wont work anyway (at least on todays fast PCs, might be working on a very slow one).

All-in-all one question is:
How current code was proofen to be working when the problem is a systematic one (NVM page programming time and row erase time) ?
Just want to understand why my setup fails without these modifications...

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