LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - ARM
User Name
Password
Slackware - ARM This forum is for the discussion of Slackware ARM.

Notices


Reply
  Search this Thread
Old 10-20-2014, 04:19 PM   #16
justwantin
Member
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Slackware, Slackwarearm
Posts: 752

Rep: Reputation: 92

I'm a little out of my league but maybe this will give you some ideas. What does ls /dev/i2* give you, e.g.
Code:
root@shed-2:/home/rick# ls /dev/i2c*
/dev/i2c-0  /dev/i2c-1
then try i2cdetect on the devices to and see what happens
Code:
root@shed-2:/home/rick# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@shed-2:/home/rick# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
I use /dev/i2c-1 to connect to my owserver
Code:
root@shed-2:/home/rick# owserver --i2c=/dev/i2c-1:18
There is one pin on this Pi used for i2c interface. Maybe dmesg might give you an irq you can access somehow
Code:
root@shed-2:/home/rick# dmesg | grep i2c
[    3.155053] bcm2708_i2c_init_pinmode(0,0)
[    3.171234] bcm2708_i2c_init_pinmode(0,1)
[    3.172996] bcm2708_i2c bcm2708_i2c.0: BSC0 Controller at 0x20205000 (irq 79) (baudrate 100000)
[    3.215892] bcm2708_i2c_init_pinmode(1,2)
[    3.217481] bcm2708_i2c_init_pinmode(1,3)
[    3.231001] bcm2708_i2c bcm2708_i2c.1: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)
[    5.643216] i2c /dev entries driver
 
Old 10-21-2014, 02:29 AM   #17
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 487

Original Poster
Blog Entries: 13

Rep: Reputation: 47
On your device the PMU may be on a different bus/address you need to have a look at the fex after having converted it from the binary version script.bin
What are these values in your pmu_para section in the fex ?
Code:
[pmu_para]
pmu_used = 1
pmu_twi_addr = 52
pmu_twi_id = 0
On bus 0 address 52 (0x34) I get UU which means that the thing is in use ... dmesg reports something about PMU being ok while kernel is coming up.
Maybe that's why i2cdetect says it's busy and i2cdump fails to dump regisres.

Not sure that this route is good for me ... I had success on using GPIO last night ... maybe that's a faster route for me.

Last edited by louigi600; 10-21-2014 at 02:41 AM.
 
Old 10-21-2014, 06:02 AM   #18
justwantin
Member
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Slackware, Slackwarearm
Posts: 752

Rep: Reputation: 92
Not familiar with fex and script.bin Aren't they just for sunxi boards?
 
Old 10-21-2014, 06:10 AM   #19
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 487

Original Poster
Blog Entries: 13

Rep: Reputation: 47
As far as I know it's a Allwinner thing ... I thought you had an Axx based board too
 
Old 10-21-2014, 12:37 PM   #20
justwantin
Member
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Slackware, Slackwarearm
Posts: 752

Rep: Reputation: 92
Sorry I can't help, I like solving problems and also would like to learn more about interfacing with hardware
 
Old 10-21-2014, 01:38 PM   #21
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 487

Original Poster
Blog Entries: 13

Rep: Reputation: 47
Would this be any help to you:
Accessing_the_GPIO_pins_through_sysfs_with_mainline_kernel
That's how I got the GPIO working on my A13 by stitching information form various other places.
Now I've only to figure out how to efficiently monitor the pins status where I connect my custom button.
 
Old 10-22-2014, 01:08 AM   #22
justwantin
Member
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Slackware, Slackwarearm
Posts: 752

Rep: Reputation: 92
Thanks very much for that link. It's been on my mind to explore gpio interface in general but its not on the top of the list yet.

Here's what I run from /etc/rc.d/rc.local to shut down from a push button. "1" sets the pin high when I short the pin against earth via a push button it will go low "0". Any pin that is earth can be used on the other side of the switch. Be sure you are earthing the pin you monitor and not using another pin on the positive rail. There's not much overhead in the loop. Below is a png attachment png of what I do on my pi's. I use salvage connectors from old PC cases, solder to a push button switch and use a litle heat shrink to cover the bare wire/connections. Maybe it'll give you an idea or two.

Cheers
Code:
#!/bin/bash
##################################################################################
# /usr/local/bin/pi-stop.sh RM20140629
# monitor GPIO pin 17 (GPIO pin 11) for shutdown signal
##################################################################################
LED_GPIO_PIN="22" # This corresponds to GPIO header pin 15.

echo "$LED_GPIO_PIN" > /sys/class/gpio/export 2> /dev/null
echo "out" > /sys/class/gpio/gpio$LED_GPIO_PIN/direction 
echo "1" > /sys/class/gpio/gpio$LED_GPIO_PIN/value

while [ true ]
do
    if [ "$(cat /sys/class/gpio/gpio$LED_GPIO_PIN/value)" == '0' ]
    then
        shutdown -h now
    fi
    sleep 1
done

Last edited by justwantin; 07-15-2015 at 11:39 PM.
 
Old 10-22-2014, 03:37 AM   #23
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 487

Original Poster
Blog Entries: 13

Rep: Reputation: 47
On the pi it's easy ... there's a gpio pin connector all ready for use ... on my rt713 I've to remap either CSI or LVDS to gpio and then make a custom flect cable to be able to connect something there.
I was able to salvage something with the correct contact spacing from some old hardware but it does not span the entire CSI connector so I cannot use all the pins ... but some is better then none.
Actually my first attempt was for the UART on the CSI connector ... I'll haveto make another one for GPIO.
Click image for larger version

Name:	custom_flectcable_male.jpg
Views:	19
Size:	227.5 KB
ID:	16721

As to monitoring the pin status I'll have a go at something with inotify first if that fails (like the stuff on /proc) I'll probably resort to looking on the pin status itself.

Last edited by louigi600; 10-23-2014 at 12:18 AM.
 
Old 10-25-2014, 01:44 AM   #24
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 487

Original Poster
Blog Entries: 13

Rep: Reputation: 47
Reading kernel gpio sysfs documentation gave me good ideas:
I can trigger events detected by poll on rising or failing edges ... but that requires me writing C code.
I've set the fex to activate pullup on PE0 so the button just shorts to ground.

Could not get inotify to work so while waiting for the desire to write C code to rise I wrote a simple script:
Code:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
BUTTON=/sys/class/gpio/gpio1_pe0/value
ACTION="shutdown -h now"
while /usr/bin/grep -q 1 $BUTTON 2>&1 
do
  sleep 0.2
done

$ACTION
Sleeping 1/5 of a second before regrepping is a little aggressive but allows for detecting short button presses.
I run that code in background from rc.ocal right after having exported the buttons.

Here's the final hardware arrangement

I've made a further update: with the one button and 2 extra 1N4148 diodes I can also power up the device.

Last edited by louigi600; 10-27-2014 at 05:28 PM.
 
Old 10-28-2014, 05:28 AM   #25
justwantin
Member
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Slackware, Slackwarearm
Posts: 752

Rep: Reputation: 92
Neat!
 
Old 10-29-2014, 02:08 AM   #26
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 487

Original Poster
Blog Entries: 13

Rep: Reputation: 47
Quote:
Originally Posted by justwantin View Post
Cheers
Code:
#!/bin/bash
##################################################################################
# /usr/local/bin/pi-stop.sh RM20140629
# monitor GPIO pin 17 (GPIO pin 11) for shutdown signal
##################################################################################
LED_GPIO_PIN="22" # This corresponds to GPIO header pin 15.

echo "$LED_GPIO_PIN" > /sys/class/gpio/export 2> /dev/null
echo "out" > /sys/class/gpio/gpio$LED_GPIO_PIN/direction 
echo "1" > /sys/class/gpio/gpio$LED_GPIO_PIN/value

while [ true ]
do
    if [ "$(cat /sys/class/gpio/gpio$LED_GPIO_PIN/value)" == '0' ]
    then
        shutdown -h now
    fi
    sleep 1
done
I had a better look at your code and I think you're doing something potentially harmfull to the output drivers on the pin:
You are setting the pin to output (which enables the gpio pin output diver circuitry), then setting the output status to high and lastly you bare reading the status which in theory should now be always high as log as you stay within the output driver's max current specification.
When you push the button you are shorting to ground, pushing the output circuitry beyond specification and forcing it to low.
Now the PI evidently has output over-current protection or you would have blown the output driver in other circumstances.

The correct way to do this would have been to set the gpio pin to input and enable internal pullup, if it is available else use an external pullup resistor (10K would probabbly work fine) connected to a logic level 1 compatible voltage.

Altough this may be safe on the PI it may damage permanently some other device without internal over-current protection.
You should correct your post or at least warn people that this may be unsafe on devices different form the PI.

Now on the Allwinner SOC's the pullup thing can be done via script.bin: here's the corresponding clear text fex section of my gpio pins setup:
Code:
[gpio_para]
gpio_used = 1
gpio_num = 12
gpio_pin_1 = port:PE00<1><1><default><default>
gpio_pin_2 = port:PE01<1><1><default><default>
gpio_pin_3 = port:PE02<1><1><default><default>
gpio_pin_4 = port:PE03<1><default><default><default>
gpio_pin_5 = port:PE04<1><default><default><default>
gpio_pin_6 = port:PE05<1><default><default><default>
gpio_pin_7 = port:PE06<1><default><default><default>
gpio_pin_8 = port:PE07<1><default><default><default>
gpio_pin_9 = port:PE08<1><default><default><default>
gpio_pin_10 = port:PE09<1><default><default><default>
gpio_pin_11 = port:PE10<1><default><default><default>
gpio_pin_12 = port:PE11<1><default><default><default>
The first 3 pins have an extra <1> which enables the internal pullup circuitry only if the pin is set to input. On the A13 those 3 pins are input only so I just export them via sys and that's it.
Although I've a PI I'm not sure myself if the PI's gpio pins have selectable/fixed pullup/down or if they are left floating when the pins are in input mode.

Last edited by louigi600; 10-29-2014 at 02:30 AM.
 
Old 10-30-2014, 04:36 AM   #27
justwantin
Member
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Slackware, Slackwarearm
Posts: 752

Rep: Reputation: 92
Ta, I'll look closer at this whern I have the time, but I'm really pressed right now
 
Old 01-10-2016, 10:53 AM   #28
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 487

Original Poster
Blog Entries: 13

Rep: Reputation: 47
I've pushed the thing a bit further on my RPi 1 and 2: 5 buttons and 5 leds indicating whether the button press has been caught by the monitor script.
One does the shutdown thing while the other 4 prepare any NIC that is plugged into the respective usb port for unplugging.
If anyone is interested I'll post the script.
 
Old 01-11-2016, 07:28 AM   #29
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Arch/Slackware/Knoppix
Posts: 1,799
Blog Entries: 14

Rep: Reputation: 280Reputation: 280Reputation: 280
It appears to me that it always is a good thing to post something that may be useful to someone in the future.
 
Old 01-11-2016, 12:58 PM   #30
justwantin
Member
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Slackware, Slackwarearm
Posts: 752

Rep: Reputation: 92
Yes, please thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning Xlib: Get next Button Press on the display hydraMax Programming 3 01-10-2012 10:14 AM
Turn the power button into a key press? jsteel Linux - General 2 04-21-2011 01:47 AM
i hv to manually press the power button on shutdown after all daemons have been stopp alice_neo Linux - Software 6 09-12-2007 02:55 PM
disable shutdown by press the power button nickraj General 8 03-02-2007 11:16 PM
I want my Controller to output text with button press timrs Linux - Games 9 01-08-2007 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - ARM

All times are GMT -5. The time now is 03:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration