新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > /bin/sh: can‘t access tty; job control turned off

        /bin/sh: can‘t access tty; job control turned off

        作者: 時間:2016-11-22 來源:網絡 收藏

        問題

        最近在做嵌入式文件系統時使用了如下的inittab文件
        #/etc/inittab
        ::sysinit:/etc/init.d/rcS
        ::respawn:-/bin/sh
        s3c2410_serial0::askfirst:-/bin/sh
        ::ctrlaltdel:/sbin/reboot
        ::shutdown:/bin/umount -a -r
        結果出現了:/bin/sh: cant access tty; job control turned off

        分析

        BusyBox通過系統控制臺來做些工作, 如果我們的shell啟動在 /dev/console(5,1)上, tty_io.c 函數open中noctty就被設置成1,導致這個問題,具體原因還不知道。總之要啟動在一個真實的串口就沒有關系。
        Job control will be turned off since your shell can not obtain a controlling terminal. This typically happens when you run your shell on /dev/console. The kernel will not provide a controlling terminal on the /dev/console device. Your should run your shell on a normal tty such as tty1 or ttyS0 and everything will work perfectly. If you REALLY want your shell to run on /dev/console, then you can hack your kernel (if you are into that sortof thing) by changing drivers/char/tty_io.c to change the lines where it sets "noctty = 1;" to instead set it to "0". I recommend you instead run your shell on a real console...

        解決方法

        可以通過BusyBox的init指定shell的設備, 注意, S3C2410上, 串口0是s3c2410_serial0。也就是說去掉::respawn:-/bin/sh就可以啦~~

        串口名稱

        串口名稱可以是s3c2410_serialx、ttySACx和ttySx等,但底層使用的是設備的主設備號和次設備號來定位具體設備的。所以不管是串口的名稱是什么
        ,只要主設備號和次設備號對了就可以。此外,通過mdev生成設備節點時,串口的名稱是s3c2410_serialx。
        S3C2410的串口驅動文件drivers/serial/s3c2410.c中,有如下數據結構:

        本文引用地址:http://www.104case.com/article/201611/319982.htm
        [plain] view plain copy
        print?
        1. staticstructuart_drivers3c24xx_uart_drv={
        2. .owner=THIS_MODULE,
        3. .dev_name="s3c2410_serial",
        4. .nr=3,
        5. .cons=S3C24XX_SERIAL_CONSOLE,
        6. .driver_name=S3C24XX_SERIAL_NAME,
        7. .major=S3C24XX_SERIAL_MAJOR,//主設備號為204
        8. .minor=S3C24XX_SERIAL_MINOR,//次設備號為64,這指第1個串口;第2個為65
        9. };

        通過這個結構體就可以確定串口設備的主設備號和次設備號。


        關鍵詞: s3c2410inittab文

        評論


        技術專區

        關閉
        主站蜘蛛池模板: 遂川县| 山西省| 青州市| 墨竹工卡县| 新宾| 吉安县| 乌鲁木齐县| 攀枝花市| 沂南县| 卢龙县| 临湘市| 上虞市| 会昌县| 广饶县| 平远县| 雷山县| 岳普湖县| 泰宁县| 信宜市| 林西县| 仁布县| 凯里市| 宁德市| 合肥市| 尤溪县| 木兰县| 潞城市| 沛县| 外汇| 尚志市| 西安市| 泗洪县| 永胜县| 青阳县| 神池县| 绥棱县| 福贡县| 盘锦市| 天全县| 广安市| 新野县|