-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
up_squared: samples/boards/up_squared/gpio_counter failed. #28551
Comments
Have you set up the BIOS according to README and |
yes, I have configured BIOS accroding to README in main.c file. |
git bisect and found the first bad commit is 9f84637 . |
I can reproduce this issue. Thanks @chen-png for bisecting to |
I'm looking into the device mapping here. A few notes about this GPIO/HAT Pin (37), it is 3rd of 4 GPIOs listed as OUT in https://github.com/zephyrproject-rtos/zephyr/blob/master/samples/boards/up_squared/gpio_counter/src/main.c, and it is the only of those 4 GPIOs that does not have a function-mode associated (see https://wiki.up-community.org/Pinout_UP2) toggled in the BIOS. Also, looking at recent patch that might be related #31274. |
^that patch #31274 is EHL and UART driver, not UP2 and GPIO driver. Might not help here. |
Perhaps it is -EINVAL: Invalid argument GPIO, which is consistent with linux error codes... |
The error values are defined in |
It get's through the
so something is happening with the arguments, for only HAT Pin 37, to
|
Interesting, this seems to effect OUT and IN pins, depending on something TBD. If I remove HAT pin 37 from the structure
I'll try printk in the gpio driver ( |
building on that, also interesting if I avoid HAT pin 37 and 16, and instead use HAT pin 38 as IN not OUT, I can progress to the first counter value but does not advance:
|
did you short the related pins after you changed the input pin number? |
Yes, thanks for checking. Counter does not increment. Curious. |
Ok, the driver gets the -EINVAL error at the failed permission check for the pin (HAT pin 37). Wonder what might cause this to start failing. Looking into this. Here are my debug prints in the driver (sample is unchanged):
which gave this output (each gpio device has an iteration of the driver, see the error in the 2nd gpio in the array)
|
I think a PR to add LOG_ERR() statements to all failed runtime checks in the driver might be useful for debugging issues like this in the future |
Great suggestion! I can work on that. I started with printk but doesn't help long term like logging statements. |
A bit more on the printk study from earlier...here is the output from when the sample works. Interesting that the 2 pins (HAT Pin 37 and HAT Pin 16) which give us trouble as we move up the tree, both have an offset of 32:
|
Ok, since the permission check failed for the pin (HAT pin 37), diving into
|
I suspect we are reading the incorrect address, but still investigating. The offset seems to have something to do with it based on testing above (both pins with 32-bit offset encounter issue.) |
Indeed this looks to be an address issue. I narrowed it down to this change from 9f84637
Couple of observations are the now-inconsistent value of Adding printk to show
results in this for the code after 9f84637 (see lines starting with gpio init pad_base below):
The
|
I'm looking into why the |
This is still on my radar. Sorry for the delay. |
Discussed this with Spoorthy offline and we are looking into possible issues with data types, as mentioned earlier about the struct member changing from a uint32_t to a struct with different size. This may have introduced some overflow or undefined behavior. |
Hardcoding Reviewing the prints in previous comments, I saw another difference in addition to pad_base:
After/Error
|
I'm digging around this part for
where
|
Noticed a couple things when I was looking at this alongside the tests for
|
Worked backward on the mapping, leading to |
This issue still present after move to unified gpio driver for Intel SoC #34719 |
On Apollo Lake, each GPIO controller has more than 32 pins. But Zephyr API can only manipulate 32 pins per controller. So the workaround is to divide each hardware GPIO controller into 32-pin blocks so each block has a GPIO driver instance. Compounding to the issue is that there cannot be two device tree nodes with same register address. So another workaround is to increment the register addresses by 1 for each block. So when mapping the address, the lowest 8-bit needs to be masked to get the actual hardware address. Fixes zephyrproject-rtos#28551 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
On Apollo Lake, each GPIO controller has more than 32 pins. But Zephyr API can only manipulate 32 pins per controller. So the workaround is to divide each hardware GPIO controller into 32-pin blocks so each block has a GPIO driver instance. Compounding to the issue is that there cannot be two device tree nodes with same register address. So another workaround is to increment the register addresses by 1 for each block. So when mapping the address, the lowest 8-bit needs to be masked to get the actual hardware address. Fixes #28551 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Describe the bug
when running samples/boards/up_squared/gpio_counter on up_squared board, have configured the GPIO pins according to readme file, but it reported an error "ERROR: cannot set HAT pin 37 to OUT (-22)".
To Reproduce
Steps to reproduce the behavior:
Logs and console output
*** Booting Zephyr OS build v2.4.0-rc2 ***
ERROR: cannot set HAT pin 37 to OUT (-22)
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: