This repository was archived by the owner on Apr 14, 2023. It is now read-only.
Improvements to the atsha204 driver#14
Open
jrbyrne wants to merge 4 commits intocryptotronix:masterfrom
Open
Conversation
added 4 commits
May 29, 2015 11:16
Fix assignment that caused an "initialization from incompatible pointer type" warning.
This commit makes a number of improvements to the Makefile: - Test KERNELRELEASE to separate the parts used by kbuild from the parts used when invoked normally. - Use standard aliases for $(MAKE) and $(CC) instead of using them explicitly. - Separate the building of the test program, give it a proper dependency and simplify the recipe. - Add a KOPTIONS variable that can be used to allow cross-compilation.
The call to hwrng_register() can cause an immediate callback to atsha204_i2c_get_random(). Since the global_chip variable is NULL at this point, this causes a crash. Fix this by setting global_chip before the call.
The atsha204_i2c_wakeup() function did not work reliably. To wake the chip it is necessary to hold SDA low for at least tWLO (60us), then delay for tWHI (500us for ATECC108A; 2.5ms for ATSHA204). There is no way to explicitly hold the SDA line low in Linux, so instead attempt to send 0 to address 0; this will hold SDA low for 8 clock cycles (sending the address), which will be more than 60us if the I2C clock speed is less than 133kHz. The limitation this imposes on the clock speed is restrictive, but this logic does at least work reliably when the clock speed is under this threshold. This commit also tidies up the debug so that dev_dbg() is used throughout, and reorders some of the messages so that they come out in a logical order that makes debugging easier.
Member
|
Hey this great, thanks! Probably next week I'll have a chance to try it out on the full range of 204a/108a/508 and it should work on all of them. re: wakeup, I know... it's annoying. On a MCU I disable the i2c controller and then toggle SDA in GPIO mode but yeah, I don't think that can be done (generically) on Linux. There could be a dependency on another module or a callback or something... perhaps... |
Member
|
I've merged this but it's on the 0.2 branch at the moment. I've also added some other changes (mainly formatting results from a review I had from a kernel dev). Once I test the 0.2 branch, I'll move it to master. Thanks again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have been working on a design using the ATECC108A chip, and have found the atsha204 driver very useful for communicating with this chip, but encountered a number of issues. I hope you will find these commits to be useful general improvements to the code.
I am not entirely happy with the method used to wake the chip up, as described in the commit comments, but I can't currently think of a better solution.
Note that I have not tested with ATSHA204, only ATECC108A, but these changes should work with both chips.