-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
ADC: adc shell failure when mismatch with dts device label #27350
Comments
I'm not familiar with adc. Can you provide commands to reproduce the issue ? In
|
@erwango Let's assume we only have ADC_1 enabled. To clarify the issue, if we run the following command: |
@avigreen1978 Txs for feedback, I'll have a new look Also, can you tell me what sample you're using to reproduce the issue? |
Any sample (for example, hello_world) in which you set |
I'll have a look, but from what I understand we need a new SHELL DT dedicated command that should not stringify the "_syntax" argument. This might not be sufficient, but this is the first step. |
@jakub-uC, @nordic-krch, @mbolivar I've managed to make this working creating a new shell macro that doesn't stringify
So I think this kind of macro, that basically uses In a second step, this could be even combined with DT API macro to something like:
So my first step would be the brute force approach of defining this new EDIT: Pinged the wrong |
@erwango To be honest we can achieve what is needed with existing macros. It would require to rework existing commands a bit. |
I knew there were smarter ways :-), would you have time to do that ? |
I can do it but it will not be done in 1-2 days :) |
No rush (I guess). Is that ok if I assign the point to you ? |
sure |
@avigreen1978 , @erwango I've started working on my idea. It will be easy to fix the problem but I will need some support from people that are working on Device Tree. I need a function that will return a pointer to an array of strings with active ADC names. |
From
|
It is a solution but I think I need to assume that all ADCs have the same label |
Not sure to get your point, how the user could change an ADC label if not in device tree ? |
@avigreen1978 would you mind have a check on #28599 ? |
Describe the bug
using
adc
command forcesadc ADC_0
when ADC_1 is the first enabled ADC, causing any command to fail withdevice is not in device list
errorTo Reproduce
Try on any STM32 EVB
Expected behavior
The root cause for this bug is the ambiguous use of the sub command name, here "ADC_0", and the device label configured in the dts.
if "ADC_0" means "the first enabled ADC instance" in line 45: .device_name = DT_INST_LABEL(inst), sets the device_name field in the hdl struct as "ADC_1", the device label string defined in the dts.
But, in line 111 in function get_adc_from_list(char *name): if (!strcmp(name, adc_list[adc_idx].device_name)) { it is compared to the argv parameter given, which is "ADC_0". thus always failing the search.
Note: using "ADC_1" as shell parameter fails the shell core as this is not a valid subcommand.
This can happen in the following cases, which causes the enabled device under instance index x to no be labelled "ADC_x":
Solution:
I suggest avoiding the double use of ADC_x for both the subcommand syntax and the device label. using index only for the subcommand. using adc 0 read 15 for example.
If this "ADC_x" naming convention is necessary, using "ADC_0" for "first enabled instance" is wrong, and it should be "ADC_1" for the device label as defined in the dts. can be achieved by dynamically creating the subcommand syntax.
For now, this code is malfunctioning in every ST core we used.
The text was updated successfully, but these errors were encountered: