cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to read GPIO registers using devmem2 under Linux? (on DK2)

ABora.1
Associate II

On DK2, using devmem2 on linux I read that GPIOH->MODER/ODR (0x50009000/0x50009014) are all zeroes. The same for GPIOA. OTOH some other things can be read out like RTC clock settings. Is there a way to read the GPIO registers?

1 ACCEPTED SOLUTION

Accepted Solutions
Olivier GALLIEN
ST Employee

Hi @ABora.1​ ,

Please have a look to How to read or write peripheral registers - stm32mpu

You probably miss the step to enable the GPIO clock.

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
Olivier GALLIEN
ST Employee

Hi @ABora.1​ ,

Please have a look to How to read or write peripheral registers - stm32mpu

You probably miss the step to enable the GPIO clock.

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

I don't quite understand why those GPIO clocks are apparently off by default under Linux. U-Boot enables a bunch of them, does Linux turn them off again? How is the WiFi able to operate without GPIOH? To my understanding PH4 is used to drive the on/off wire for the WiFi module.

Hi @ABora.1​ ,

Linux Clock framework manage clock dynamically and enable it only when required by drivers.

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

It must be a power saving feature. If I enable the GPIOH clock with devmem2, I am able to see the correct bit for PH4 on GPIOH->ODR. So I suppose the GPIOs hold their state without the clock enabled and Linux shuts off the clock if there are no needed changes to the GPIO state.