天天看點

嵌入式Linux關閉序列槽列印-屏蔽序列槽列印

公司某些産品可能涉及一些敏感資訊,如晶片選型,參數配置,調試資訊.不想讓客戶或者競争對手看到.需要将序列槽列印資訊屏蔽掉.最後以關閉核心和序列槽列印的方案最合适,稍加改動就可以實作.筆記記錄如下:

以hi3518ev200為例,其他平台可參考配置.

bootargs修改
修改前:

setenv bootargs 'mem=64M console=ttyAMA0,115200 root=/dev/sda1 rootwait rw mtdparts=hi_sfc:256k(boot),64k(env),4M(kernel),7M(rootfs)'
修改後:
setenv bootargs 'mem=64M  root=/dev/sda1 rootwait rw mtdparts=hi_sfc:256k(boot),64k(env),4M(kernel),7M(rootfs)'

将console去掉

檔案系統修改
在檔案系統 /etc/inittab

#::askfirst:-/bin/sh
# Start an "askfirst" shell on /dev/tty2-4
# tty2::askfirst:-/bin/sh
# tty3::askfirst:-/bin/sh
# tty4::askfirst:-/bin/sh

# /sbin/getty invocations for selected ttys
# tty4::respawn:/sbin/getty 38400 tty5
# tty5::respawn:/sbin/getty 38400 tty6

# Example of how to put a getty on a serial line (for a terminal)
::respawn:/sbin/getty -L ttyS000 115200 vt100 -n root -I "Auto login as root ..."
#::respawn:/sbin/getty -L ttyS1 9600 vt100
#
# Example how to put a getty on a modem line.
#::respawn:/sbin/getty 57600 ttyS2

# Stuff to do when restarting the init process
::restart:/sbin/init

# Stuff to do before rebooting
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a

#::askfirst:-/bin/sh
# Start an "askfirst" shell on /dev/tty2-4
# tty2::askfirst:-/bin/sh
# tty3::askfirst:-/bin/sh
# tty4::askfirst:-/bin/sh

# /sbin/getty invocations for selected ttys
# tty4::respawn:/sbin/getty 38400 tty5
# tty5::respawn:/sbin/getty 38400 tty6

# Example of how to put a getty on a serial line (for a terminal)
#::respawn:/sbin/getty -L ttyS000 115200 vt100 -n root -I "Auto login as root ..."
#::respawn:/sbin/getty -L ttyS1 9600 vt100
#
# Example how to put a getty on a modem line.
#::respawn:/sbin/getty 57600 ttyS2

# Stuff to do when restarting the init process
::restart:/sbin/init

# Stuff to do before rebooting
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a

~

注釋掉::respawn:/sbin/getty -L ttyS000 115200 vt100 -n root -I "Auto login as root ..."




重新開機,

hi3516cv300 System startup


U-Boot 2010.06 (Apr 20 2017 - 15:46:32)

Check Flash Memory Controller v100 ... Found
SPI Nor(cs 0) ID: 0xc2 0x20 0x18
Block:64KB Chip:16MB Name:"MX25L128XX"
SPI Nor total size: 16MB
In:    serial
Out:   serial
Err:   serial
Press Ctrl+C to stop autoboot
16384 KiB hi_fmc at 0:0 is now current device

## Booting kernel from Legacy Image at 82000000 ...
   Image Name:   Linux-3.18.20
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1939151 Bytes = 1.8 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Loading Kernel Image ... OK
OK

Starting kernel ...

之後所有的列印都沒有了.

特意打開了telnet跟蹤下,app有沒有在運作.

hi3516c login: 
hi3516c login: 
hi3516c login: root
Password: 
profile echoing
PATH= /usr/bin:/usr/sbin:/bin:/sbin
LIBRARY= /usr/local/lib:/usr/lib
1234567--->hi3516cv300
profile ending 
PATH= /usr/bin:/usr/sbin:/bin:/sbin:/app/bin
LIBRARY= /usr/local/lib:/usr/lib:/app/lib
Welcome to HiLinux.
Mount: 192.168.5.172:/home/hecong/work/tcpip/7203/trunk/platform/pub/rootfs_glibc on / type nfs (rw,relatime,vers=2,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=udp,timeo=11,retrans=3,sec=sys,mountaddr=192.168.5.172,mountvers=1,mountproto=udp,local_lock=all,addr=192.168.5.172)
chroot: can't execute '/usr/bin/env': No such file or directory
~ # ps
PID   USER     TIME   COMMAND
    1 root       0:00 init
    2 root       0:00 [kthreadd]
    3 root       0:00 [ksoftirqd/0]
    4 root       0:00 [kworker/0:0]
    5 root       0:00 [kworker/0:0H]
    6 root       0:00 [kworker/u2:0]
    7 root       0:00 [khelper]
    8 root       0:00 [kdevtmpfs]
    9 root       0:00 [netns]
   10 root       0:00 [writeback]
   11 root       0:00 [crypto]
   12 root       0:00 [bioset]
   13 root       0:00 [kblockd]
   14 root       0:00 [spi0]
   15 root       0:00 [kworker/u2:1]
   18 root       0:00 [rpciod]
   19 root       0:00 [kworker/0:1]
   20 root       0:00 [kswapd0]
   21 root       0:00 [fsnotify_mark]
   22 root       0:00 [nfsiod]
   23 root       0:00 [cifsiod]
   40 root       0:00 [ipv6_addrconf]
   41 root       0:00 [deferwq]
   42 root       0:00 [kworker/u2:2]
   43 root       0:00 [kworker/0:2]
   57 root       0:00 udevd --daemon
   69 root       0:00 udevd --daemon
   71 root       0:00 udevd --daemon
  129 root       0:00 ./test1
  130 root       0:00 telnetd
  131 root       0:00 -sh
  143 root       0:00 ps
~ # 
           

測試程式test1正常背景運作,功能實作.