Gpio + uart (not the debug-port)


(Frank W.) #3

thanks for your answer

  1. https://github.com/BPI-SINOVOIP/BPI-R2-bsp/blob/89982c49b6266d4c8bd1311f6f14c4ebbd0567bb/linux-mt/arch/arm/boot/dts/mt7623.dtsi

There is only uart2 active (as i understand the dsi). How do i get params for uart 0/1?

  1. the reset-option ist last backup.
  • first call script (via uart) to enable internet-connection if that hangs (maybe also restart full network)
  • reboot-command via uart
  • last (if no success,no response on uart) do hard-reset via transistor-circuit over reset-switch

(dorabmon) #4

please refer http://elixir.free-electrons.com/linux/v4.13-rc7/source/arch/arm/boot/dts/mt7623.dtsi and add the missing uart nodes to the dtsi BPI providing. and also notes it is better to send pull request back to BPI. :slight_smile: sharing is the force and helps the next one person doesn’t make the same mistake again and concentrate what we need to care.

maybe is it required to add hardware link to your arduino with SYSRSTB_MT6323 to imitate manual operation as long press X second to reset.


(Frank W.) #5

UART0=Con1 Pin 8/10,UART1=Con1 Pin 11/13 (TX/RX)?

https://bananapi.gitbooks.io/banana-pi-bpi-r2-open-source-smart-router/content/bpi-r2-gpio-pin-define.html

in schematics it looks like uart0/1 are swapped (8/10=UTXD1 and 11/13 UTXD0)

where is uart3 (is it connected or only available in chip)?


(gary) #6

Hi Frank,

Looks like the serial port isn’t connected a header, if you need it, I will let hardware engineer to find where the TP47 and TP48 are.


(Frank W.) #7

This is just for info :slight_smile: additionally (to serial console) 2 uart are enough for me. are my pin-infos correct (and uart-correlation 0 vs. 1)?


(gary) #8

The UCTS2 and URTS2 can be routed to UART3,

.

Yes, the pin information for UART0 and UART1 is correct.


(Frank W.) #9

@garywang which dts will be used (where do i have to add uart0/1)?

i have: mt7623a-evb.dts mt7623.dtsi mt7623n-bpi-r2.dts / dtb <<< maybe this dts mt7623n-evb.dts

i assume that only bpi-r2.dts will be used (dtb is compiled), but maybe uart should be added to mt7623n.dts (where uart 2 is defined)…in bpi-r2.dts it seems uart2 is only enabled via

&uart2{status=“okay”;}

did i need such line also for uart0/1?

what does that mean: chosen {stdout-path=&uart2;} i think thats the definition of debug-console (which port is used for serial-console)


(gary) #10

You can change both mt7623.dtsi and mt7623n-bpi-r2.dts to add the devices you need,


(Frank W.) #11

how is the correct way to replace the kernel (debian jessie lite)? is it needed to replace uboot?


(gary) #12

Please follow above steps to update kernel


(Frank W.) #13

I’ve read that, i asked because there may be an easier way doing manually without the script (replace zimage+dtb and copy modules).

i tried to found out, what the script does, but no luck till now


(gary) #14

Hi Frank

The uImage(with dtb) is in partition 1 and modules of kernel is in partition 2 of SD card, there is a script for you reference. mount /dev/mmcblk0p1 /mnt/ cp SD/BPI-BOOT/bananapi/bpi-r2/linux/* /mnt/bananapi/bpi-r2/linux/ umount /mnt

mount /dev/mmcblk0p2 /mnt/ cp SD/BPI-ROOT/* /mnt/ -rf umount /mnt


(Frank W.) #15

copied uimage to boot and modules to root-partition seems not to work:

Filesystem: FAT16 "BPI-BOOT   "                                                 
Boot from SD                                                                    
reading bananapi/bpi-r2/linux/uEnv.txt                                          
771 bytes read in 10 ms (75.2 KiB/s)                                            
Loaded environment from uEnv.txt                                                
Banana Pi bpi-r2 chip: mt7623n Service: linux                                   
reading bananapi/bpi-r2/linux/uImage                                            
8132578 bytes read in 1062 ms (7.3 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-4.4.70-BPI-R2-Kernel                                     
   Image Type:   ARM Linux Kernel Image (uncompressed)                          
   Data Size:    8132514 Bytes = 7.8 MiB                                        
   Load Address: 80008000                                                       
   Entry Point:  80008000                                                       
   Verifying Checksum ... OK                                                    
   Loading Kernel Image ... OK                                                  
                                                                               
Starting kernel ...                                                             

then it stops…no more messages

do i have to change uboot, too? had kernel 4.4.43 before (default for jessie-lite-image).

full log attached: uart_kernel.log (18.0 KB)


(gary) #16

Did you change the code of BPI-R2-bsp, if yes, can you please share me the differences?

And I assume you’re using the latest code of BPI-R2-bsp from github.


(Frank W.) #17

only added block for uart0/1 to dtsi and set them to “&uart2{status=“okay”;}” in bpi-r2.dts

have run “git pull” before build…maybe that’s enough

enabled_uart0 1.zip (14.7 KB)


(gary) #18

Can you please try to change the order of uart controller in mt7623.dtsi: uart2 uart0 uart1 uart3


(Frank W.) #19

seems that fixed that:

root@bpi-iot-ros-ai:~# uname -r

4.4.70-BPI-R2-Kernel

now i must enable uart0/1 in debian…currently i have no ttyAMAx

root@bpi-iot-ros-ai:~# find /sys/ -name 'serial*'
  /sys/fs/cgroup/systemd/system.slice/system-serial\x2dgetty.slice/serial-getty@ttyS0.service

  /sys/bus/pci/drivers/serial

  /sys/bus/platform/devices/serial8250

  /sys/bus/platform/drivers/serial8250

  /sys/bus/platform/drivers/serial8250/serial8250

  /sys/devices/platform/11230000.mmc/mmc_host/mmc1/mmc1:0001/serial

  /sys/devices/platform/1a1c0000.usb/usb1/serial

  /sys/devices/platform/1a1c0000.usb/usb2/serial

  /sys/devices/platform/serial8250

  /sys/devices/platform/1a240000.usb/usb3/serial

  /sys/devices/platform/1a240000.usb/usb4/serial

  /sys/devices/platform/11240000.mmc/mmc_host/mmc0/mmc0:0007/serial

  /sys/firmware/devicetree/base/serial@11002000

  /sys/firmware/devicetree/base/serial@11003000

  /sys/firmware/devicetree/base/serial@11004000

i assume that the last 3 devices are my serial ports (remember such numbers from dtsi…)

uart0: serial@11002000 { };

uart1: serial@11003000 { };

From bootlog:

[ 4.737895] 11002000.serial: ttyS1 at MMIO 0x11002000 (irq = 31, base_baud = 1625000) is a ST16650V2

[ 4.767828] 11003000.serial: ttyS2 at MMIO 0x11003000 (irq = 32, base_baud = 1625000) is a ST16650V2

on that kernel net is not working right ;( interface exists, but no transmission possible (only own ip-stack),

=> found out that eth0 and eth1 are swapped with kernel-upgrade (eth0=lan-switch, eth1=wan-port)

also poweroff is not working

=> found nothing related in kernel-config

how can i set kernel-parameters (modules, build-in) like “make menuconfig” with the right config-file?

=> option 4 in build.sh, needs “libncurses-dev” to be installed


(Frank W.) #20

connected an arduino (with levelshifter) to GPIO Pin 8/10 (should be uart0=11002000=ttyS1)

set speed via stty -F /dev/ttyS1 9600 raw

cat /dev/ttyS1

nothing happens

now using minicom (9600 8n1,flow:off) with ttys2 and i’ve got the input from arduino (keepalives every 60 seconds), why ttyS2??

seems that i have an error in my notes…looked in schematics again.

summary:

pin 8/10 = uart1 (tx/rx) = 11003000 = ttyS2
pin 11/13 = uart0 (tx/rx) = 11002000 = ttyS1

read works, but i can not send via minicom/bash

#!/bin/bash
DEV=/dev/ttyS2
while read line; do
    echo "["$(date "+%Y-%m-%d %H:%M:%S")"] from Arduino: "$line
done < <(cat $DEV)

here i see my keepalives…if i try to send via

echo "AT" >/dev/ttyS2

i get no response (my arduino sends back “AT”-Strings)…arduino is connected also via usb to my workstation, if i send same string via ardiono-console, i see the response in the console and my script-output…so there is a problem with sending to the device (same construction works with raspi [script+send on another terminal via echo])

seems gpio (also uart) are not set to high-level…further debug here: https://github.com/BPI-SINOVOIP/BPI-R2-bsp/issues/17


(Frank W.) #21

got GPIO working, infos here

no idea currently about uart-tx, can anybody confirm, that is not working (maybe i doing something wrong)


(Frank W.) #22

is it enough to add the uart0/1 blocks to mt7623.dtsi and set the status to ok in bpi dts? anything needded for sending, because tx is not working?