[BPI-R2] Control On-board LEDs

the other 2 (red/blue) go on (1) and off (0), no blinking

timing with delay-nodes ist strange anyway…hard to describe

i see no difference between red,blue and green: https://github.com/frank-w/BPI-R2-4.14/blob/b80a9345899842733507fe40decec0ab7f0ba3cd/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts#L72

btw. i have HW rev 1.1 (if it matters), running debian 8 on my test-system with kernel 4.14.34

LEDs in /sys/class/leds/bpi-r2:pio (next to gpio40-header) are also strange:

  • red cannot be set
  • blue and green are swapped
  • 0/1 is swapped (1 turnes off, 0 turns on)

it looks like gpio problem

it can be solved by change properties such as label and low or high-active in gpio leds nodes in dts. Could you help to try which one is good setting?

where are the pio-leds defined? i lokked in bananapi.dts and mt7623.dtsi…found only the isink leds

how about the blinking of green isink-led? any idea? which HW-revision/kernel do you use?

compatible string is gpio-led, see

https://elixir.bootlin.com/linux/v4.17-rc1/source/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts#L87

it looks like board issue, I am using v1.1 with v4.16 rc5 and code is almost same between 4.14 you used and 4.16.

1 Like

ok, found it, thank you…in dts the are defined as high-active…in shematics they look low-active (led between vcc and gpio)…thats the first problem…to bad that in shematics the colors are not described…so we can only swap green&blue but have no clue whats up with red

fixed green and blue: https://github.com/frank-w/BPI-R2-4.14/commit/5da2e20c279ae77f13ea92d11f2e4c8c17ab0ce2 working now as expected and do not light the entire time (only red is always on).

in shematics the leds are named

led0=239 (r)
led1=241 (b)
led2=240 (g)

as you see by reading gpio-order you get r-g-b, with led-numbers you get r-b-g…seems like thats the reason for swapped green/blue

1 Like

xbgmsharp tested also the green-led-behaviour: green light is only blinking

On my board, the resistors R303 and R239-R240 are not populated, so the red LED can not be controlled. It is used only as a power indicator.

then i need to disable blinking of green isink led

@frank-w I clonned your git repo for kernel 4.14-main, configure it to have built in SATA and RAID support and then compile it using your build.sh script: build.sh build and then build.sh pack. I got an archive bpi-r2_4.14.34_main.tar.gz which I extract to SDCard to root. Now, when I try to boot from this kernel, it hangs on “Starting kernel…”. How can I debug what is wrong?

Part    Start Sector    Num Sectors     UUID            Type
  1     204800          524288          03ecee97-01     0c
  2     729088          14211072        03ecee97-02     83
mmc0 is available
reading bananapi/bpi-r2/linux/uEnv.txt
811 bytes read in 5 ms (158.2 KiB/s)
Loaded environment from uEnv.txt
Banana Pi bpi-r2 chip: mt7623n Service: linux
reading bananapi/bpi-r2/linux/uImage
8895605 bytes read in 544 ms (15.6 MiB/s)
reading bananapi/berryboot.img
** Unable to read file bananapi/berryboot.img **
bootm flag=0, states=70f
## Booting kernel from Legacy Image at 84000000 ...
   Image Name:   Linux Kernel 4.14.34-main
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    8895541 Bytes = 8.5 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

in 4.14 the needed commands are:

  • ./build.sh importconfig
  • ./build.sh config to add raid-support
  • ./build.sh

The tar contains folders bpi-boot for uImage and bpi-root for modules…extract with same folders to the right partition

For debug you can use this Steps (done that for dma-debug):

To enable the earlyprintk :

-> make menuconfig -> kernel hacking -> early printk

options used to have the debugs on the serial port :

root=/dev/mmcblk0p2 rootfstype=ext4 rootwait console=ttyS0,115200 earlycon=uart8250,mmio32,0x11004000 earlyprintk=serial,ttyS0,115200 debug=7 loglevel=7 initcall_debug=1 ignore_loglevel=1 bootopts=vmalloc=496M

As I found a little free time I’m back to this task :slight_smile: After enabling debug I have: https://pastebin.com/BXXqwGMn So, I think I have not enabled some important options in kernel config, right?

@frank-w ./build.sh importconfig will be working only the system running from BPI-R2 motherboards, right? I’m compile this kernel on Virtual machine with Ubuntu 16.04 so, importconfig will be works on x86_64 arch too?

It maybe important: I use BPI-R2-EMMC-boot0-DDR1600-0k-0905.img.gz

bpi-bootsel BPI-R2-EMMC-boot0-DDR1600-0k-0905.img.gz /dev/mmcblk1boot0

build.sh from my repo works also with crosscompile…i also compile on x86_64.

You can look in my defconfig and compare with yours

Preloader has nothing to do with kernel…you do not need to change it

Try using an existing image and only replace uImage on boot-part and add modules folder to root…just to verify your kernel works

As for your log it seems pinctl-driver (mt2701) is missing

could not find pctldev for node /pinctrl@10005000/pcie_pin_default,

I’m update my local kernel source to 4.14.39 from your git repo. Run

./build.sh importconfig

and then

./build.sh config

to add RAID support. After that I compile the kernel using

./build.sh build

and then copy kernel image and modules to correct path on SDCard. When I have:

root=/dev/mmcblk0p2 rootfstype=ext4 rootwait console=ttyS0,115200 earlycon=uart8250,mmio32,0x11004000 earlyprintk=serial,ttyS0,115200 debug=7 loglevel=7 initcall_debug=1 ignore_loglevel=1 bootopts=vmalloc=496M

options for debug in uEnv.txt the boot process hangs on

[    4.289399] initcall exar_pci_driver_init+0x0/0x30 returned 0 after 30 usecs
[    4.296439] calling  mtk8250_platform_driver_init+0x0/0x28 @ 1
[    4.322980] 11004000.serial: ttyS0 at MMIO 0x11004000 (irq = 197, base_baud = 1625000) is a ST16650V2

If I’m back to default options in uEnv.txt file BPI finish booting and I can logon to OS but HDMI not works :confused:

In kernel 4.14.39 - it is possible to have old network interface name eth0 and eth1 instead wan@eth0 lanX@eth0 etc.?

Hdmi is not working in kernels != 4.4,

dual gmac only in 4.4 (without dsa) and 4.9 (with dsa).

In 4.9 maybe you can archive it by disabling dsa-driver.

Are you sure this is correct?

earlycon=uart8250,mmio32,0x11004000

./build.sh allone is enough to build 4.14 (no need for param)

Yes, I’m sure. Boot with:

console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200

But with

console=console=ttyS0,115200 earlycon=uart8250,mmio32,0x11004000 earlyprintk=serial,ttyS0,115200 debug=7 loglevel=7 ignore_loglevel=1

can’t boot.

In kernels != 4.4 for HDMI it is a problem with drivers or something other? It is possible to have/port LEDs support in/to kernel 4.4?

console ttyS0 is mapped via dts…a user from github gave me the line with adress…have not tried it yet …btw. you have “console=console=” at beginning…

HDMI is ported to current mainline-kernel 4.17, now this have to be backported to 4.14…hoping gary / jack are working on it

you can try to port the dts-nodes from 4.14 to 4.4 and add CONFIG_LED to your config

in my wiki there is an instruction for Access to GPIO also for 4.4…you have to search where the nodes in 4.4 for led…

The first “console=” in both lines is a variable in uEnv.txt file, so I think it is correct. I will try to find how to access LEDs in kernel 4.4 without any additional electronic elements (resistors etc.).

Rightt the first is correct,but not assigning console= to it

anyone know how to disable the blinking from green isink-led?

btw. the patch for pio-leds is included in linux-next:

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts?h=next-20180718&id=2ca48895ba984c9b1fa0e725064decfed527811b