KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\
        ALIASES=/proc/device-tree/aliases; \
        if [ $(cat $ALIASES/uart0) = $(cat $ALIASES/serial0) ]; then \
            echo 0;\
        elif [ $(cat $ALIASES/uart0) = $(cat $ALIASES/serial1) ]; then \
            echo 1; \
        else \
            exit 1; \
        fi\
    '", SYMLINK+="serial%c"

KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\
        ALIASES=/proc/device-tree/aliases; \
        if [ $(cat $ALIASES/uart1) = $(cat $ALIASES/serial0) ]; then \
            echo 0; \
        elif [ $(cat $ALIASES/uart1) = $(cat $ALIASES/serial1) ]; then \
            echo 1; \
        else \
            exit 1; \
        fi \
    '", SYMLINK+="serial%c"
