AlcoFarm
Posts: 2
Joined: Thu Aug 16, 2018 8:46 am

CM3L can`t use ttyS0 like console on ubuntu mate

Thu Aug 16, 2018 9:11 am

Hi guys.
I've been working with rpi3 for several years and now I'm starting to work with CM3L. My problem is that I can not output the console to the port ttyS0 (serial1).
1) I'm using ubuntu mate 16.04.2 LTS 4.1.19. X-server disabled.
2) I compiled uart0-overlay.dtb and uart1-overlay.dtb:

Code: Select all

/dts-v1/;
/plugin/;

/{
        compatible = "brcm,bcm2708";

        [email protected] {
                target = <&uart0>;
                __overlay__ {
                        pinctrl-names = "default";
                        pinctrl-0 = <&uart0_pins>;
                        status = "okay";
                };
        };

        [email protected] {
                target = <&gpio>;
                __overlay__ {
                        uart0_pins: uart0_pins {
                                brcm,pins = <14 15>;
                                brcm,function = <2>; /* alt5 */
                                brcm,pull = <0 2>;
                        };
                };
        };

        [email protected] {
                target-path = "/chosen";
                __overlay__ {
                        bootargs = "8250.nr_uarts=1";
                };
        };

        __overrides__ {
                txd0_pin = <&uart0_pins>,"brcm,pins:0";
                rxd0_pin = <&uart0_pins>,"brcm,pins:4";
        };
};

Code: Select all

/dts-v1/;
/plugin/;

/{
        compatible = "brcm,bcm2708";

        [email protected] {
                target = <&uart1>;
                __overlay__ {
                        pinctrl-names = "default";
                        pinctrl-0 = <&uart1_pins>;
                        status = "okay";
                };
        };

        [email protected] {
                target = <&gpio>;
                __overlay__ {
                        uart1_pins: uart1_pins {
                                brcm,pins = <32 33>;
                                brcm,function = <4>; /* alt0 */
                                brcm,pull = <0 2>;
                        };
                };
        };

        [email protected] {
                target-path = "/chosen";
                __overlay__ {
                        bootargs = "8250.nr_uarts=1";
                };
        };

        __overrides__ {
                txd1_pin = <&uart1_pins>,"brcm,pins:0";
                rxd1_pin = <&uart1_pins>,"brcm,pins:4";
        };
};
3) I changed /boot/config.txt to add:

Code: Select all

#enable_uart=1

#Ignore the HDMI cable hotplug (to avoid the delay at startup)
hdmi_ignore_hotplug=1

# Set the debug port on GPIO32, GPIO33 pins
force_turbo=1
dtoverlay=uart1,txd1_pin=32,rxd1_pin=33
dtoverlay=uart0,txd0_pin=14,rxd0_pin=15

# Enable the 1-wire bus
dtoverlay=w1-gpio,gpiopin=16

# Set the audio lines on GPIO40 and GPIO41 pins
dtoverlay=pwm-2chan,pin=40,func=4,pin2=41,func2=4

# Disable the Bluetooth
dtoverlay=pi3-disable-bt

# Set the I2C1 on GPIO 44 and GPIO 45 pins
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=100000
dtoverlay=i2c1-bcm2708,sda1_pin=44,scl1_pin=45,pin_func=6

#Enable the IR Linux driver
dtoverlay=gpio-ir,gpio_pin=20
#core_freq=250
I tried comment/uncomment all this parametrs and their variatons, but no results. I see ttyS0 in dev, but can use it like console or configure like uart to transmit data.
4) I changed /boot/cmdline.txt:

Code: Select all

dwc_otg.lpm_enable=0 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=120 elevator=deadline noatime nodiratime rootwait quiet splash
Also i tried use serial0/serial1 and /dev/ttyS0, but haven`t results.
Have you any ideas to help?

P.S When i use RASPBIAN STRETCH LITE all work fine with this parametrs:
/boot/config.txt:

Code: Select all

# Enable audio (loads snd_bcm2835)
dtparam=audio=on


#Ignore the HDMI cable hotplug (to avoid the delay at startup)
hdmi_ignore_hotplug=1

# Set the debug port on GPIO32, GPIO33 pins
force_turbo=1
dtoverlay=uart1,txd1_pin=32,rxd1_pin=33

# Enable the 1-wire bus
dtoverlay=w1-gpio,gpiopin=16

# Set the audio lines on GPIO40 and GPIO41 pins
dtoverlay=pwm-2chan,pin=40,func=4,pin2=41,func2=4

# Disable the Bluetooth
dtoverlay=pi3-disable-bt

# Set the I2C1 on GPIO 44 and GPIO 45 pins
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=100000
dtoverlay=i2c1-bcm2708,sda1_pin=44,scl1_pin=45,pin_func=6

#Enable the IR Linux driver
dtoverlay=gpio-ir,gpio_pin=20
/boot/cmdline.txt:

Code: Select all

dwc_otg.lpm_enable=0 console=serial1,115200 console=tty1 root=PARTUUID=051c85e3-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1829
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM3L can`t use ttyS0 like console on ubuntu mate

Thu Aug 16, 2018 10:39 am

You have number of problems here:
1) You've hacked the standard uart0 and uart1 overlays to change the default pins and Alt functions. The existing standard overlays have parameters to allow you to achieve what you want to, so use them.
2) You appear to have the alternate function selections confused. Read page 102 of the BCM2835 ARM Peripherals pdf to understand which Alt functions you need - Alt0 (selector 4) for UART0 on 14&15, Alt5 (selector 2) for UART1 on 32&33.
3) Don't combine pi3-disable-bt and uart0 and uart1 - it will only complicate matters.
4) If you want to use UART1 you'll need to uncomment that "core_freq=250" otherwise the baud rate will change with CPU load.

AlcoFarm
Posts: 2
Joined: Thu Aug 16, 2018 8:46 am

Re: CM3L can`t use ttyS0 like console on ubuntu mate

Thu Aug 16, 2018 11:50 am

Thanks for reply. I was confused by developers of devboard for CM3(They write this pins for uarts).
So, now all working fine)). ttyS0 work like console and ttyAMA0 work like uart(I connect GPS module and receive data). The config files:
/boot/config.txt:

Code: Select all

# Set the debug port on GPIO32, GPIO33 pins
force_turbo=1
dtoverlay=uart1,txd1_pin=14,rxd1_pin=15
dtoverlay=uart0,txd0_pin=32,rxd0_pin=33

core_freq=250
/boot/cmdline.txt:

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=120 elevator=deadline noatime nodiratime rootwait quiet splash
uart1-overlay.dts:

Code: Select all

/dts-v1/;
/plugin/;

/{
        compatible = "brcm,bcm2708";

        [email protected] {
                target = <&uart1>;
                __overlay__ {
                        pinctrl-names = "default";
                        pinctrl-0 = <&uart1_pins>;
                        status = "okay";
                };
        };

        [email protected] {
                target = <&gpio>;
                __overlay__ {
                        uart1_pins: uart1_pins {
                                brcm,pins = <14 15>;
                                brcm,function = <4>; /* alt0 */
                                brcm,pull = <0 2>;
                        };
                };
        };

        [email protected] {
                target-path = "/chosen";
                __overlay__ {
                        bootargs = "8250.nr_uarts=1";
                };
        };

        __overrides__ {
                txd1_pin = <&uart1_pins>,"brcm,pins:0";
                rxd1_pin = <&uart1_pins>,"brcm,pins:4";
        };
};
uart0-overlay.dts:

Code: Select all

/dts-v1/;
/plugin/;

/{
        compatible = "brcm,bcm2708";

        [email protected] {
                target = <&uart0>;
                __overlay__ {
                        pinctrl-names = "default";
                        pinctrl-0 = <&uart0_pins>;
                        status = "okay";
                };
        };

        [email protected] {
                target = <&gpio>;
                __overlay__ {
                        uart0_pins: uart0_pins {
                                brcm,pins = <32 33>;
                                brcm,function = <2>; /* alt5 */
                                brcm,pull = <0 2>;
                        };
                };
        };

        [email protected] {
                target-path = "/chosen";
                __overlay__ {
                        bootargs = "8250.nr_uarts=1";
                };
        };

        __overrides__ {
                txd0_pin = <&uart0_pins>,"brcm,pins:0";
                rxd0_pin = <&uart0_pins>,"brcm,pins:4";
        };
};
To compile dts:

Code: Select all

dtc -O dtb -o uart0-overlay.dtb uart0-overlay.dts
dtc -O dtb -o uart1-overlay.dtb uart1-overlay.dts
After compile copy uart0-overlay.dtb and uart1-overlay.dtb to /boot/overlays/

dtc from apt-get not compile(invalid syntax of this files). I use this script to install dtc(overlay.sh):

Code: Select all

#!/bin/sh -e

check_dpkg () {
        LC_ALL=C dpkg --list | awk '{print $2}' | grep "^${pkg}" >/dev/null || deb_pkgs="${deb_pkgs}${pkg} "
}

unset deb_pkgs
pkg="bison"
check_dpkg
pkg="build-essential"
check_dpkg
pkg="flex"
check_dpkg
pkg="git-core"
check_dpkg

if [ "${deb_pkgs}" ] ; then
        echo "Installing: ${deb_pkgs}"
        sudo apt-get update
        sudo apt-get -y install ${deb_pkgs}
        sudo apt-get clean
fi

#git_sha="origin/master"
git_sha="origin/dtc-v1.4.4"
project="dtc"
#server="https://git.kernel.org/pub/scm/utils/dtc"
server="https://github.com/RobertCNelson"

if [ ! -f ${HOME}/git/bb.org-${project}/.git/config ] ; then
        git clone ${server}/${project}.git ${HOME}/git/bb.org-${project}/
fi

if [ ! -f ${HOME}/git/bb.org-${project}/.git/config ] ; then
        rm -rf ${HOME}/git/bb.org-${project}/ || true
        echo "error: git failure, try re-runing"
        exit
fi

cd ${HOME}/git/bb.org-${project}/
make clean
git checkout master -f
git pull || true

test_for_branch=$(git branch --list ${git_sha}-build)
if [ "x${test_for_branch}" != "x" ] ; then
        git branch ${git_sha}-build -D
fi

git checkout ${git_sha} -b ${git_sha}-build

make clean
make PREFIX=/usr/local/ CC=gcc CROSS_COMPILE= all
echo "Installing into: /usr/local/bin/"
sudo make PREFIX=/usr/local/ install
sudo ln -sf /usr/local/bin/dtc /usr/bin/dtc
echo "dtc: `/usr/bin/dtc --version`"
This all working for me. I hope that this information will be useful to someone.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1829
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM3L can`t use ttyS0 like console on ubuntu mate

Thu Aug 16, 2018 12:32 pm

I'm happy that your setup is working for you, but there are still a few things I'm not happy about.

* "name-overlay.dts" should be compiled to "name.dtbo", not "name-overlay.dtb". The latter will work, but will take slightly longer and produce warnings in the (normally invisible) logs. It also leads to the possibility of loading and an older "name.dtbo", ignoring a newer "name-overlay.dtb".

* Your "uart1-overlay.dts" actually maps UART0 onto GPIOs 14 and 15. You also use the parameters to explicitly set the pins to 14 and 15, which are the defaults.

* Your "uart0-overlay.dts" puts UART1 on GPIOs 32 and 33, and once again replicates the defaults as explicit parameters.

From what I can see this configuration is equivalent to:

Code: Select all

dtoverlay=uart0,txd0_pin=14,rxd0_pin=15 # Parameters are optional here, as these are the defaults
dtoverlay=uart1,txd1_pin=32,rxd1_pin=33
using standard, unmodified overlays. Notice how "uart0" and "uart1" have swapped places, so now the names accurately reflect the roles they are performing.

* Your overlays can be compiled with the standard Pi dtc without errors. You will see some warnings, but these are because the tool still isn't very overlay-aware:

Code: Select all

[email protected]:~ $ dtc [email protected] -I dts -O dtb -o uart1.dtbo uart1-overlay.dts 
uart1.dtbo: Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property
uart1.dtbo: Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property
uart1.dtbo: Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property
[email protected]:~ $ dtc [email protected] -I dts -O dtb -o uart0.dtbo uart0-overlay.dts 
uart0.dtbo: Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property
uart0.dtbo: Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property
uart0.dtbo: Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property

Return to “Compute Module”

Who is online

Users browsing this forum: No registered users and 5 guests