Temat: br6104k i wysterowanie przekaźników

W jaki sposób za pomocą gpio mogę wysterować przekaźniki w w/w routerze
Ma to cacko takie oto gpio
gpio0 = power-led
gpio1 = unused  ( used with i2c yet )
gpio2 = Reset-switch
gpio3 = unused  ( used with i2c yet !! used with 4MB-flash mod also !! )
gpio4 .. gpio7 not available because of PLCC-chip

GPIO 8: LINK_ACT    \
GPIO 9: SPEED        > switch port 0 (wan)
GPIO 10: DUPLEX_COL /
GPIO 11: LINK_ACT   \
GPIO 12: SPEED       >  switch port 1 (lan)
GPIO 13: DUPLEX_COL /
GPIO 14: LINK_ACT   \
GPIO 15: SPEED       >  switch port 2 (lan)
GPIO 16: DUPLEX_COL /
GPIO 17: LINK_ACT   \
GPIO 18: SPEED       >  switch port 3 (lan)
GPIO 19: DUPLEX_COL /
GPIO 20: LINK_ACT   \
GPIO 21: SPEED       >  switch port 4 (lan)
GPIO 22: DUPLEX_COL /

poprzez wpisywanie różnych komend typu
<code>
echo "led on" > /dev/gpio0
echo "led off" > /dev/gpio0
</code>
można zapalać/gasić diodę ale działa mi to tylko na diodzie power, na pozostałych niestety nie. Nie ma różnicy napięć pomiędzy diodą załączoną i wyłączoną.

2

Odp: br6104k i wysterowanie przekaźników

Bo reszta jest wykorzystywana przez system?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

3

Odp: br6104k i wysterowanie przekaźników

Bazuję na starej dystrubcji midge i nie ma żadnego komunikatu że te diody / piny są zajęte

Mam taką rozpiskę

Pin kernel name    pin ID  Board marking
ADM5120_GPIO_PIN0       0      D13   (Power)
ADM5120_GPIO_PIN1       1      D15   (USB)
ADM5120_GPIO_PIN2       2
ADM5120_GPIO_PIN3       3      D16   (USB)
ADM5120_GPIO_PIN4       4
ADM5120_GPIO_PIN5       5
ADM5120_GPIO_PIN6       6
ADM5120_GPIO_PIN7       7
ADM5120_GPIO_P0L0       8      D3
ADM5120_GPIO_P0L1       9      D4
ADM5120_GPIO_P0L2       10
ADM5120_GPIO_P1L0       11     D5
ADM5120_GPIO_P1L1       12     D6
ADM5120_GPIO_P1L2       13
ADM5120_GPIO_P2L0       14     D7
ADM5120_GPIO_P2L1       15     D8
ADM5120_GPIO_P2L2       16
ADM5120_GPIO_P3L0       17     D9
ADM5120_GPIO_P3L1       18     D10
ADM5120_GPIO_P3L2       19
ADM5120_GPIO_P4L0       20     D11
ADM5120_GPIO_P4L1       21     D12
ADM5120_GPIO_P4L2       22

i przykładowo jak wyślę polecenie
echo "led on" > /dev/gpio21 to nie ma napięcia pomiędzy + i - od diody D12, tak samo jest z led off

Może jakoś to inaczej trzeba zrobić ?

4

Odp: br6104k i wysterowanie przekaźników

Doszedłem co i jak według tej rozpiski

01/Feb/2007

This ist the new and overworked version of a the driver for all GPIO an LED.
Now we have 8 GPIO (BGA-case) or 4 GPIO with the PLCC-case.
Also now all 15 ports from the Ethernet-switch are possible as
input, output or as all modes described in the datasheed.

The driver IS limited compatible with the old driver.
The needed ioctl-call for led on/off are vailable.
Now also ioctl-calls to get and set the mode and value for the leds/gpios
are ready for use.
The biggest differenz to the old driver is the device-id and the led-numbering.
This driver use only the major device-id 167 with minor number 0 to 22.
For example "mknod /dev/gpio0 c 167 0".
For old programs you have to symlink the name /dev/led0 to this /dev/gpio0.
Please modify your start-scripts.

To make the dev entries you can use this code :
-----------------------------------------------
i=0
while [ $i != 23 ]
 do
   mknod /dev/gpio$i c 167 $((i++))
done
-----------------------------------------------

The numbering for Edimax BR6104k is:
gpio0 = power-led
gpio1 = unused  ( used with i2c yet )
gpio2 = Reset-switch 
gpio3 = unused  ( used with i2c yet !! used with 4MB-flash mod also !! )
gpio4 .. gpio7 not available because of PLCC-chip

GPIO 8: LINK_ACT    \
GPIO 9: SPEED        > switch port 0 (wan)
GPIO 10: DUPLEX_COL /
GPIO 11: LINK_ACT   \
GPIO 12: SPEED       >  switch port 1 (lan)
GPIO 13: DUPLEX_COL /
GPIO 14: LINK_ACT   \
GPIO 15: SPEED       >  switch port 2 (lan)
GPIO 16: DUPLEX_COL /
GPIO 17: LINK_ACT   \
GPIO 18: SPEED       >  switch port 3 (lan)
GPIO 19: DUPLEX_COL /
GPIO 20: LINK_ACT   \
GPIO 21: SPEED       >  switch port 4 (lan)
GPIO 22: DUPLEX_COL /

On Edimax "BR6104K(P)" the DUPLEX_COL led are not connected !

This version do not initialize the gpio or led ! The setting above are 
from the hardware reset.
This is to prevent conficts with other driver they use the gpios.
You can change any mode in init scripts or in programs.
You do not need any tool for config.
The current status can you see with "cat /proc/driver/led".
To set a gpio you can send a string to the device /dev/gpioX or you can 
use the ioctl-call via /dev/gpio0 (see led_set.c and gpiodemo.c for example).
String commands are :
"led on"    :    power on the led
"led off"    :    power off the led
"led invert"    :    change the assignment on/off to low/high-level
"led switch x" :    set the mode to x (x = 0..1 for gpio0..7 , 0..13 for gpio8..22)
"led blink n" :      blink the led with n ms

For understanding the funktion:
- the gpio0 .. gpio7 can only set to input or output
  example: echo "led switch 0" > /dev/gpio1      set gpio1 to input
           echo "led switch 1" > /dev/gpio2      set gpio2 to output
- only if in output mode you can set the led on or off
           echo "led on" > /dev/gpio2            set the led on
- in both modes you can change the assignment between "on" and "off" to
  the physical high or low level with the "invert" statement.
           echo "led invert" > /dev/gpio2
  normal : on = high-level (3.3V) on the pin, LED is wired between GPIO and GND
       used on Edimax Power-LED
  invert : on = low-level (0V) on the pin , LED is wired between GPIO an +3.3V
       used on Edimax Switch-LEDs

- the gpio8 .. gpio22 can set to 11 modes (with 14 mode-numbers).
  for compatibily the modes 0 and 1 are identical to gpio0 .. gpio7.
- the other modes are from the datasheed
  the mode "1" (flash) from the datasheet is moved to mode number 13.
          echo "led switch 0" > /dev/gpio8       set gpio8 to input
          echo "led switch 1" > /dev/gpio10      set gpio10 to output
          echo "led switch 9" > /dev/gpio9       set gpio8 to LINK_ACT
          echo "led switch 13" > /dev/gpio17     set gpio8 to FLASH, the hardware-blink-mode 
- all gpio's can set to the software blink if in output mode with
          echo "led blink 1000" > /dev/gpio12    blinks gpio12 with 1s pulse
 
If you read from the device for example with  "cat /dev/gpio8" you can see the current mode 
(the real settings of the register) if not in input mode.
If you have set the gpio with "led on","led off" or "led blink xxx" you see this entry.
If in input mode you see the value 0 or 1 from the input, conditioned from the "invert" state.
 
known bugs:
- on the led lines are a small low level puls if you switch from input to output_1.
  The leds have 2 seperate modes for output, called output_0 and output_1 in 
  datasheet. output_1 set the line to high level, output_0 to low level.
  If the line is switched from input to this high level output a low level pulse with
  35..45ns is occur.
  I think its a hardware bug or the C compiler generate bad code.


The lcd_out_4x20.c is a example how to drive a standart lcd over this driver.


For questions or suggestion please mail to dl4huf@darc.de.
 

5

Odp: br6104k i wysterowanie przekaźników

ja mam przekaźniki na backfire, jeśli sie przesiądziesz to z checią pomogę;)

6 (edytowany przez viper_lasser 2013-04-21 12:38:55)

Odp: br6104k i wysterowanie przekaźników

Na backfire kiedyś leciałem ale założyłem sobie za cel żeby to zmieściło się w 2mb flasha a pendrive'y są zawodne.

Chyba ze masz skompilowany obraz na backfire który się mieści w 2mb flasha to daj znać smile

7

Odp: br6104k i wysterowanie przekaźników

Ja mam również na backfire zrobione. wszystkie diody można sterować. Mam wyrzuconego nata, iptables i jeszcze parę drobiazgów, bo się nie mieściłem.

8 (edytowany przez viper_lasser 2013-04-21 15:28:29)

Odp: br6104k i wysterowanie przekaźników

Spróbuję przekompilować pod backfire obraz żeby zmieścił się w 2mb flasha. Była by możliwość udostępnienia działającego configa ?
W jaki sposób pod backfire ustawia się diody jako wejściowe lub wyjściowe ?
Midge szybko mi wstawało ale minus taki że teraz mam 2 dystrybucje linuxa smile

Edit:
Ustawianie wejść i wyjść jest tutaj smile
http://openrouter.info/index.php?option … ;Itemid=61

9

Odp: br6104k i wysterowanie przekaźników

Chciałem zpowrotem zmienić w make kernel_menuconfig->Kernel hacking bootowanie na normlane

Zmieniłem na takie

console=ttyS0,115200 rootfstype=squashfs,yaffs2,jffs2

Przekompilowałem ale dalej router uparcie twierdzi że chce bootować z /dev/sda1


Co jeszcze trzeba zmienić ?