如题,如何把自定义服务的日志log默认输出到debug口ttyLP0?
即,CPU启动后,自定义服务的日志log(printf输出)直接输出到debug口上。
测试service(位置:/lib/systemd/system):
root@imx8qxpmek:~# cat /lib/systemd/system/printftest.service
[Unit]
Description=printftest
After=rc-local.service
After=syslog.target network.target
[Service]
#Type=forking
RemainAfterExit=yes
ExecStart=/opt/test/testsh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
User=root
[Install]
WantedBy=multi-user.target
测试脚本testsh
#!/bin/sh
echo "printf test"
cd /opt/test
./printftest
printftest源码:
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <fcntl.h>
#include <time.h>
#include <sys/ioctl.h>
#include <linux/ioctl.h>
#include <sys/stat.h>
#include <linux/types.h>
void main(void)
{
while(1)
{
printf("printf test\n");
sleep(1);
}
}