Open cederom opened 1 year ago
How about this one https://github.com/apache/nuttx/blob/master/drivers/efuse/efuse.c ?
Looks like a good starting point, thanks! I'll try and use this for a SAMA5 Secure Fuse driver and see how I get on.
On 25 Apr 2023, at 22:10, CeDeROM @.***> wrote:
How about this one https://github.com/apache/nuttx/blob/master/drivers/efuse/efuse.c ?
So... include/nuttx/efuse.h defines:
struct efuse_param { FAR const efuse_desc_t *field; size_t size; FAR uint8_t data; };
With the explanation:
/* The efuse_param is used by the application to inform which field(s)
There are no implementations that use this. Perhaps it's because it's the end of a long week, but I can't get my head around what I'm supposed to do with this.
Can some kind person explain how it is to be used, please?
Perhaps use the example of the SAMA5D2 that has 32 bit fuses (SFC_DR0 through SFC_DR23)? What should the "arch efuse table" look like, where would it be, and how is it to be referenced in a (new) header file?
Also, data is a uint8_t, but this arch has 32 bit "fields". Should I just stick with 8 bit "fields" and have 4 times as many? Or have I missed the point of "fields"?
Spent some time today, and it does seem likely this should do the job, bot specifically and generically. Even though the SAMA5D2 I'm working with has 32 bit fuse registers there's no need for me to worry about the 32 vs 8 bit fields, as we just need to return 4 bytes if a full 32 bit fuse read is wanted (with suitable checks that the data struct member is large enough for the requested size, for example) but in may cases read/writes will be of individual fuse bits.
Once I have something implemented I will submit as a draft PR for critique.
I see the efuse files were co-authored by @xiaoxiang781216 - any information you can add? For example is it based on Linux or Android methods that I can compare to?
I have found that the esp32 processors have efuse support that makes use of the efuse driver core that @cederom linked to. It does the job, although has a few style issues that I will fix on the way.
I now have a working driver for sama5d2 which I will submit as a PR after more testing next week.
Therefore, I would say that the issue here is actually already covered, although additional documentation would be useful and I'll see what I can add.
Thank you @TimJTi :-) Good documentation is always welcome :-) Please create a separate PR for that :-)