September 21, 2019, 07:33:04 am

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


GPIO and LED

Started by @lex, April 20, 2015, 09:04:36 pm

Previous topic - Next topic

@lex

Hi,

I started working on GPIO today and i think i burned the blue LED somehow.

I have GPIO and LEDS as a module and had the heartbeat running on blue LED but after i played with GPIO on blue LED it stopped lighting, no more sign of life for this LED.

I cannot remember the exact sequence of commands i typed, but i think i set it to input and later to output and vice-versa, just to experiment if was working.

The odd thing is that i cannot use the same GPIO port when the LEDS are set on FEX in Android, kernel complains and warn the port is already in use. This does not happen in linux when both are loaded as modules.

What are the chances to burn the LEDs using GPIO?

@lex



Jojo

Hi,

look at the schematic and you will see, that it is almost impossible to burn the LED. LED and processor are some kind of "decoupled" with a transistor. So you just can switch the transistor on or off by the GPIO. That does not effekt the circuit of the LED.

Please have a look at the schematic page 2 and 8.
Don't think that anyone will take more pains for his answer, as you took for your question.

@lex

Thanks Jojo for the reassurance.

The LED's gone for some other reason.
I get weird things happening while driving a big panel, sometimes i get sdcard reading sector errors randomly while booting  and the sdcard is not corrupted.

The board boots fine from nand. PSU is 5A.

@lex

@lex

Hi Jojo,

Have you seen this kind of error:

Quote[    3.582732] Find HDMI Vendor Specific DataBlock
[    3.593093] PCLK=74250000 X 1920 2008 2052 2200 Y 540 542 547 562 fr 60 PP
[    3.605790] PCLK=74250000 X 1280 1390 1430 1650 Y 720 725 730 750 fr 60 PP
[    3.618922] PCLK=148500000 X 1920 2008 2052 2200 Y 1080 1084 1089 1125 fr 60 PP
[    3.632055] PCLK=74250000 X 1280 1720 1760 1980 Y 720 725 730 750 fr 50 PP
[    3.645091] asoc: sndhdmi <-> sunxi-hdmiaudio.0 mapping ok
[    3.654038] input: USB+PS/2 Optical Mouse as /devices/platform/sw-ehci.2/usb4/4-1/4-1.4/4-1.4:1.0/input/input3
[    3.680150] generic-usb 0003:04F3:0230.0003: input,hidraw2: USB HID v1.11 Mouse [USB+PS/2 Optical Mouse] on usb-sw-ehci-1.4/input0
[    3.695440] waited 0 ms for EDID info
[    3.705668] disp clks: lcd 148500000 pre_scale 1 hdmi 148500000 pll 297000000 2x 0
[    3.709588] [mmc-msg] mmc 0 detect change, present 1
[    4.212651] [mmc-msg] sdc0 set ios: clk 0Hz bm PP pm UP vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.237161] [mmc-msg] sdc0 power on
[    4.263065] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.289612] [mmc-msg] sdc0 set round clock 400000, src 24000000
[    4.390385] [mmc-err] smc 0 err, cmd 52,  RTO
[    4.398874] [mmc-err] smc 0 err, cmd 52,  RTO
[    4.411576] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.431799] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.446594] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.454899] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.463206] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.471511] [mmc-err] smc 0 err, cmd 5,  RTO
[    4.484767] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.502499] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.522709] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing LEGACY(SDR12) dt B
[    4.565812] [mmc-msg] sdc0 set ios: clk 400000Hz bm PP pm ON vdd 3.3V width 1 timing SD-HS(SDR25) dt B
[    4.583545] [mmc-msg] sdc0 set ios: clk 50000000Hz bm PP pm ON vdd 3.3V width 1 timing SD-HS(SDR25) dt B
[    4.598176] [mmc-msg] sdc0 set round clock 42857143, src 600000000
[    4.667861] [mmc-msg] sdc0 set ios: clk 50000000Hz bm PP pm ON vdd 3.3V width 4 timing SD-HS(SDR25) dt B
[    4.681785] mmc0: new high speed SDHC card at address 0007
[    4.691192] mmcblk0: mmc0:0007 SD16G 14.9 GiB
[    4.699237]  mmcblk0: p1 p2



Card is not corrupted, any idea?


@lex

@lex

oops, never mind, that seems harmless.
Quote
sudo fsck.ext4 -v /dev/sdc2
e2fsck 1.42 (29-Nov-2011)
rootfs was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

  241729 inodes used (24.80%)
      40 non-contiguous files (0.0%)
      26 non-contiguous directories (0.0%)
         # of inodes with ind/dind/tind blocks: 0/0/0
         Extent depth histogram: 185283/3
1529960 blocks used (39.31%)
       0 bad blocks
       1 large file

  160798 regular files
   15892 directories
     110 character device files
      50 block device files
       0 fifos
      50 links
   64870 symbolic links (56274 fast symbolic links)
       0 sockets
--------
  241770 files

Jojo

Hi,

about the error: sorry, I can not help. My knowledge in deep dark linux things is quite limited yet :( . I just wanted to help with the LED thing. And I still don't believe, that the LED blew up. It has a resistor in series. From my experiances I can say, that a LED with a 3,3V series resistor will work for some time even at 5V (maximum voltage that you have in your system). You can mach more easily blow up the driver stage of the I/O or the transistor at the I/O pin.

What kind of "panel" are you talking about? External LCD panel? have you coupled the GNDs of the CB and the panel? Maybe you have trouble with EMI or ground loops.

Greetings
Don't think that anyone will take more pains for his answer, as you took for your question.

@lex

Hi Jojo,
I was finishing a distro to have GPIO and LEDS as module, and driving a lcd panel that draws much current. i played with GPIO to turn ON,OFF the LEDs and for some reason cb2 started to act very strange. In short, the blue LED is really dead ( could be a coincidence when played with GPIO ), i get lots of sector error during boot, some times it boots (from sd), some times not. The SD card is not corrupted nor has bad sector, if it boots normally and i issue a sudo reboot without removing the sd card, i get randomly sector errors and it can't boot until i remove the card many times and get a proper boot.
I could see in the forum that this error [4.446594] [mmc-err] smc 0 err, cmd 5,  RTO is harmless.
If i set FEX to boot with HDMI it boots fine from SD card, no sectors errors.
This must be a hardware issue and i am not a hardware guy also, i can only guess.

Can you check if you get this msg on your boot and what is your kernel version?

Thank you anyways.
@lex

jwzumwalt

All mini unprotected motherboards are pretty easy to fry. I have never used a static strap in my 35+ years of electronic work but I have fried a board from static about every 10 years. I always touch something such as the usb shell in the hopes of not cooking something.

About four years ago I touch the MB of my current desktop and about 1hr later the motherboard gave a puff of smoke and my sound never worked again - I figured I was off easy since my MB and CPU combo are about $500.

You probably cooked it but it goes with the territory for experimenters and I would consider it bragging rights :)

jwzumwalt

July 24, 2015, 12:23:47 am #8 Last Edit: July 24, 2015, 12:28:02 am by jwzumwalt
Here is a test I use...

#!/bin/bash

echo ' . ----------------------------------------------------. '
echo ' | status_led.sh     by: Jan Zumwalt     Ver: 07/2016  | '
echo ' |-----------------------------------------------------| '
echo ' |                                                     | '
echo ' | This program excersises control over the  blue      |'
echo ' | and green onboard status led's                      | '
echo ' |                                                     | '
echo ' .-----------------------------------------------------. '
echo ''

# The following needs to be in the script.bin file
# Debian  /media/zero/script.bin
# Cubian  /boot/script.bin
#
# [leds_para]
# leds_used = 1
# leds_num = 2
# leds_pin_1 = port:PH20<1><default><default><0>
# leds_name_1 = "green:ph20:led1"
# leds_pin_2 = port:PH21<1><default><default><0>
# leds_name_2 = "blue:ph21:led2"

# a module may be needed. To load...
# modprobe leds-sunxi
#
# To auto load the module just add a line with the name of the module....
# edit /etc/modules.
# or execute the following line in the /etc/modules directory
# echo leds-sunxi >>/etc/modules

# setup
echo off
clear
echo -e "\n\n"
echo -e "  BOTH off\n"
echo 0 > /sys/class/leds/blu
e\:ph21\:led2/brightness # Blue led off
echo 0 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led off

# blue on
echo "  BLUE on"
echo 255 > /sys/class/leds/blue\:ph21\:led2/brightness # Blue led on
sleep 3
echo 0 > /sys/class/leds/blue\:ph21\:led2/brightness # Blue led off

# green on
echo "  GREEN on"
echo 255 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led on
sleep 3
echo 0 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led off

#blue blink
echo "  BLUE blink"
echo timer > /sys/class/leds/blue\:ph21\:led2/trigger # BLUE led blink
sleep 3
echo 0 > /sys/class/leds/blue\:ph21\:led2/brightness # Blue led off

# green blink
echo "  GREEN blink"
echo timer > /sys/class/leds/green\:ph20\:led1/trigger # GREEN led blink
sleep 3
echo 0 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led off

echo "  BLUE LED sd card status"
echo mmc0 > /sys/class/leds/blue\:ph21\:led2/trigger # blue sd card status

echo "  GREEN off"
echo 0 > /sys/class/leds/green\:ph20\:led1/brightness # GREEN led off

# list triggers
echo -e "\n  LED triggers"
cat /sys/class/leds/blue\:ph21\:led2/trigger

[/font]