-
Notifications
You must be signed in to change notification settings - Fork 423
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
fel: Introduce 'sid-dump' #189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Qianfan,
thanks for the patch, looks like a useful addition!
Can you please add some more text to the commit message, maybe including a part of the pull request message?
And we would need the new command mentioned in the internal help text, ideally also in the manpage.
Some comments inside.
fel.c
Outdated
for (const sid_section *s = soc_info->sid_sections; s->name; s++) { | ||
uint32_t count = s->size_bits / 32; | ||
|
||
if (count > sizeof(buffer) / sizeof(buffer[0])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In common.h we have ARRAY_SIZE() for this. But in general this looks a bit odd to check this at all, since there is an upper limit (the 2KB SID storage size) and the input size comes from an internal struct, so we don't need to defend against user input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fel_lib.c
Outdated
bool fel_get_sid(feldev_handle *dev, uint32_t *result, uint32_t offset, | ||
size_t count) | ||
{ | ||
if (!dev->soc_info->sid_base) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check looks unnecessary, since we check this before calling this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, removed
fel_lib.c
Outdated
{ | ||
if (!dev->soc_info->sid_base) { | ||
for (unsigned i = 0; i < count; i++) | ||
result[i] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First this would be a job for memset(). But why would we want to clear the result before we bail out? In fact I would expect a function to not touch a result buffer in case of an early error. Also the caller doesn't seem to need this, so remove that clearing part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the check for sid_base and the clear function are removed now.
soc_info.c
Outdated
@@ -507,3 +521,4 @@ void get_soc_name_from_id(soc_name_t buffer, uint32_t soc_id) | |||
/* unknown SoC (or name string missing), use the hexadecimal ID */ | |||
snprintf(buffer, sizeof(soc_name_t) - 1, "0x%04X", soc_id); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stray extra line
74b273d
to
65192d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick changes, looks alright now. Tested on a Bananapi M2 Berry. I also tested with some A64 and H6 maps, will send them later.
I will let this sit for a few more days, in case people have comments.
size_t count) | ||
{ | ||
fel_readl_n(dev, dev->soc_info->sid_base | ||
+ dev->soc_info->sid_offset + offset, result, count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use the register readout method on SoCs where that is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the better. I've considered it, but it's too hard to write assembly code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it looks like fel_get_sid_registers()
can be easily extended to read registers from offset instead of 4 registers from offset 0. Then we could just extend fel_get_sid_root_key()
to allow parameters, and use that for both sid-dump and for aw_fel_print_sid()
, avoiding a new function.
@qianfan-Zhao do you want to do this? If not, I can do it in a follow up patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apritzel It is hard to me. Could you please submit some patchs after this pr merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two minor things I noticed about the output formatting.
fel.c
Outdated
for (uint32_t i = 0; i < count; i++) { | ||
if (i > 0 && ((i % 8) == 0)) { | ||
putchar('\n'); | ||
printf("%-16s", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw this on a final inspection: can you merge those two into one line:
printf("\n%-16s", "");
Then you can get rid of the brackets as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fel.c
Outdated
putchar('\n'); | ||
printf("%-16s", ""); | ||
} | ||
printf("%08x ", buffer[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you decrease the indent from 16 to 15 in the tow lines above, you can put the space here first, before the number, and avoid a trailing space on the last word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
The sid memory maps are copied from allwinner 3.10 bsp. Next is a sample output from allwinner T3: $ sunxi-fel sid-dump chipid 1300000c 02c04700 79350400 30791acc in 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ssk 00000000 00000000 00000000 00000000 thermal 0823081c ft_zone 00000000 00000000 tvout 00ff02ad 00f8029e 00f0028d 00f902a2 rssk 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 hdcp_hash 00000000 00000000 00000000 00000000 reserved 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Signed-off-by: qianfan Zhao <[email protected]>
65192d1
to
23bb103
Compare
A sample output from allwinner T3: