This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: Systemd start permission issue

Part Number: AM5728

Tool/software: Linux

Hello,
I am using AM5728 PLSDK 04.00.00.04.

We changed the console path from tty02 to tty09.

I changed the console information as shown below.
(include/configs/am57xx_evm.h)
#define CONSOLEDEV     "ttyO9"
#define CONFIG_SYS_NS16550_COM10 UART10_BASE /* UART10 */
#define CONFIG_SYS_NS16550_COM1  UART1_BASE /* Base EVM has UART0 */
#define CONFIG_SYS_NS16550_COM2  UART2_BASE /* UART2 */
#define CONFIG_SYS_NS16550_COM3  UART3_BASE /* UART3 */
#define CONFIG_BAUDRATE    115200

Kernel change
I changed stdout-path to &uart10 from am57xx-beagle-x15-common.dtsi
I removed uart3 part from dra7.dtsi.
I Add to tty09 from /etc/securetty.

This work was a success, and we can use the console terminal.

>>_____                    _____           _         _  
>>|  _  |___ ___ ___ ___   |  _  |___ ___  |_|___ ___| |_
>>|     |  _| .'| . | . |  |   __|  _| . | | | -_|  _|  _|
>>|__|__|_| |__,|_  |___|  |__|  |_| |___|_| |___|___|_| 
>>          |___|                    |___|           

>>Arago Project http://arago-project.org am57xx-evm ttyS9
>>Arago 2017.05 am57xx-evm ttyS9
>>am57xx-evm login:


We modified the changed console information to systemd service.

systemctl stop serial-getty@ttyS2.service => serial-getty@ttyS9.service
I tried executing the program in systemd.

>> root@am57xx-evm:~#systemctl start run.service
======================================================
run.service

[Unit]
Description=run service

[Service]
Type=simple

User=root
Group=root

ExecStart=/home/root/run.sh
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target
--------------------------
run.sh

#!/bin/sh
systemctl stop serial-getty@ttyS9.service
/home/root/run_exe
======================================================

But, The program failed to start.
The error occurred without getting information about the console.

=========code===========
ret = tcgetattr(STDIN_FILENO, &m_tio_save);
if ( ret < 0 )
{
 printf("DBG::ret= %d\n", ret);
 assert(0);
}
The error number from tcgetattr() was -1, which was a permission issue.

If ttyS9 is not disable, systemd will work normally.

However, we must run our program from the console after the automatic start up.

For this reason, the console must be prevented.

Please help me with this error.

Small information may be acceptable.

Thank you.

  • The software team have been notified. They will respond here.
  • Hello aupers,

    You are killing the console which you are going to logg in. If you connect to that board with ssh you will see that the program is actually executed.

    Best regards,
    Kemal
  • Hello, Kemal

    It was no problem when using ttyS2.

    After changing the tty, start the program using systemd File Disruption I have a problem accessing STDIN_FILENO.

    I want to be helped with things we are missing.

    H/W or S/W Any advice is recommended.

    Best regards,

    aupers

  • You have added tty09 to /etc/securetty but the leter is "O" not "zero" as you wrote. Can you change this to ttyO9 and also add ttyS9 to /etc/securetty. I do not see any other ttyS2 usage which is supposed to be changed in rootfs.

  • I confirmed ttyS9, ttyO9 of / etc / securetty.

    I still can not access 'STDIN_FILENO'.

    We made access to tty in other ways.

    Share the solution here.

    if (( fd = open("/dev/ttyS9", O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK )) < 0 )
    {
        printf("DBG:: Device Open Fail /dev/ttyS9 \n");
        assert(0);
    }

    if (( ret = tcgetattr( fd, &m_tio_save )) < 0 )
    {
        printf("DBG:: tcgetattr() Fail \n");
        assert(0);
    }

    This code did what we wanted, like tcgetattr (STDIN_FILENO, & m_tio_save).

    I still understand why you can not access "STDIN_FILENO".

    Please let me know if you know.

    Thank you for your support.

    Best regards,

    aupers

  • I will ask the serial interface expert to comment. He will reply here.
  • Hi aupers,

    I will have to test this out on a BeagleBone to see what issues I run into - I'm not a systemd expert unfortunately, so will need to do some experiementation to figure out what's wrong.

    I do not think this is strictly a permissions issue- from what I've read, EPERM could be due to some other process locking STDIN_FILENO, or perhaps TTYS9 has not been fully configured to be your console, from systemd's perspective.

    If you need a definitive answer, I can look deeper into this when I return on 11/20.

    Thank you in advance for your patience!
    Mike