Hello!
Now we're trying to controll GPIO ports from Android.
Let's say we have connected LED to GPIO1[7].
What we've done till now:
1. Added MX6Q_PAD_GPIO7__GPIO_1_7 to mx6q_var_som_pads array in /kernel_imx/arch/arm/mach-mx6/board-mx6q_var_som.h
2. Builded kernel (step 6.7 from http://variwiki.com/index.php?title=VAR-SOM-MX6_Android_GS_R21)
3. Builded boot.img (step 6.4 from VAR-SOM-MX6 Android GS R21 - Variscite Wiki)
(nexts steps were made on android root console)
4. Checked if GPIO are available in FS (we have gpiochipxx available in /sys/class/gpio) and exported GPIO7 (echo 7 > /sys/class/gpio/export)
5. Changed direction to out for GPIO7 (echo out > /sys/class/gpio7/direction)
6. Tried to drive the LED connected to this GPIO, but with no luck (echo 1 > /sys/class/gpio7/value or echo 0 > /sys/class/gpio7/value)
Have we missed some steps?
Solved! Go to Solution.
Hi Igor! Just want to let you know that I'va managed to control GPIO, for now output only, but it's going right direction.
Main problem was with IOMUX in board-mx6q_var_som.h. I've muxed some of them to be GPIO but didn't check that below they were used as other lines :smileyhappy: No I'm testing GPIO3[22] and exporting this as a GPIO86 works fine. Thanks! Now I'm also trying to access UART3, but this is other story...
Hi Krzysztof
I think it should be like (/gpio/gpio7) :
echo out > /sys/class/gpio/gpio7/direction
as described in
Best regards
igor
You're right, but it was mistake only in creating post on forum :smileyhappy: Thanks for pointing this out.
Of course we use /sys/class/gpio/gpio7/ not /sys/class/gpio7/ - so this wasn't couse of the problem.
One can try other pins to check if this works on this board or check GPIO/IOMUX registers with
memtool
Re: How to confirm a Register value on AndroidKK4.4.2 for MX6-SABRE-SD
~igor
Will this patch also work for Android 4.2.2?
I think yes.
Well, maybe I've made some mistake but:
- I've copied this patch file to jb_422_110_build/external/linux-test/
- git apply this path (success)
- checked, that Android.mk was added to test/memtool
- rebuild all sources (make from jb_422_110_build directory)
- reflashed SOM
But memtool wasn't found as android command?
root@android:/ # memtool
/system/bin/sh: memtool: not found
what is about test/memtool folder ?
Are you asking what's inside jb_422_110_build/external/linux-test/test/memtool folder?
If so:
- Android.mk
- Makefile
- memtool.c
- memtools_register_info.h
- mx6dl_modules.c
- mx6q_modules.c
- mx6sl_modules.c
after compilation there should be executable
Hello igorpadykov
I've finally added memtool to my android compilation.
Let's say I want to test switch connected to GPIO3[23]/UART3_CTS - how can I do it?
First I check address of GPIO3.PSR2 (memtool GPIO3.PSR23):
GPIO3 Addr:0x20a4000
Then I call memtool -32 0x20a4000 1
Reading 0x1 count starting at address 0x20a4000
0x20a4000: 4C1F2080
I push switch, call once again the same and... result is the same.
Hi Krzysztof
one can set GPIO direction register (GPIOx_GDIR)
as input, for PSR check below
Is gpio_get_value() working correctly?
~igor
Hi Igor, thanks for suggestion.
First I've checked base addr of GPIO3 direction register:
root@android:/ # memtool GPIO3.GDIR
SOC is mx6q
GPIO3 Addr:0x20a4000
GPIO3.GDIR Addr:0x020A4004 Value:0x10002000 - GPIO_GDIR functions as direction control when the IOMUXC is in GPIO mode.
GPIO3.GDIR.GDIR(0..31) :0x10002000
GPIO direction bits.
I've changed GPIO3.23 direction to input:
root@android:/ # memtool -32 0x020A4004=0x189E50
Writing 32-bit value 0x189E50 to address 0x020A4004
Then I've checked if it has written:
root@android:/ # memtool GPIO3.GDIR
SOC is mx6q
GPIO3 Addr:0x20a4000
GPIO3.GDIR Addr:0x020A4004 Value:0x00189E50 - GPIO_GDIR functions as direction control when the IOMUXC is in GPIO mode.
GPIO3.GDIR.GDIR(0..31) :0x189e50
GPIO direction bits.
Get value from GPIO3:
root@android:/ # memtool GPIO3.DR
SOC is mx6q
GPIO3 Addr:0x20a4000
GPIO3.DR Addr:0x020A4000 Value:0x4C1F0080 - The 32-bit GPIO_DR register stores data that is ready to be driven to the output lines.
GPIO3.DR.DR(0..31) :0x4c1f0080
Data bits.
Push button, check the same - still the same value (0x4c1f0080).
Maybe I'm refereing to wrong IO port? I've connected button to GPIO3[23]/UART3_CTS. Button is shorting IO line to GND. Should I setup a pullup somehow?
Hi Krzysztof
I would suggest to attach jtag debugger and
try to check this GPIO. Also one can check all register settings.
~igor
Oh, this is something new for me as I'm rather software developer :smileyhappy: Can you suggest some software? And we have JTAG J-Link Ultra+ - will it be sufficient?
Yes, J-Link jtag will support i.MX6.
Also IAR Embedded Workbench 7.0 has i.MX6 examples (led blink)
and you can easily simulate your settings. Then
you can printf Android settings and compare them.
~igor
Hi Igor! Just want to let you know that I'va managed to control GPIO, for now output only, but it's going right direction.
Main problem was with IOMUX in board-mx6q_var_som.h. I've muxed some of them to be GPIO but didn't check that below they were used as other lines :smileyhappy: No I'm testing GPIO3[22] and exporting this as a GPIO86 works fine. Thanks! Now I'm also trying to access UART3, but this is other story...