am335x 更改調試串口


/*********************************************************************
 *                  am335x 更改調試串口
 *  
 *  am335x的調試串口是uart0,uart硬件連接上與其他功能出現了沖突。
 *  打算將其更改為uart1。本文並沒有全部更改成功。
 *  記錄其過程,方便以后繼續嘗試。
 *
 *                              Tony Liu, 2016-4-47, Shenzhen
 *********************************************************************/
本文主要內容:
        1. kernel調試串口更改
        2. rootfs調試串口更改
        3. uboot調試串口更改
參考鏈接:
        http://bbs.ednchina.com/BLOG_ARTICLE_3003157.HTM        
        http://www.cnblogs.com/zym0805/archive/2011/07/17/2108573.html

1. kernel
1.1 更改kernel調試串口
    通過uboot傳參數,更改內核的uart端口,默認是ttyO0,更改為ttyO1
    uboot/include/configs/ok335x.h
#define CON     \
    "console=ttyO1,115200n8\0" \
    "optargs=\0" \
    "mmcroot=/dev/mmcblk0p2 ro\0" \
    "mmcrootfstype=ext3 rootwait\0" \
    "nandroot=ubi0:rootfs rw ubi.mtd=7,2048\0" \
    "nandrootfstype=ubifs rootwait=1\0" 
#endif
1.2 關閉kernel的調試串口
    include/configs/ok335x.h
    通過uboot傳參數,更改內核的uart端口,默認是ttyO0,更改為ttynull
#define CON     \
    "console=ttynull,115200n8\0" \
    "optargs=\0" \
    "mmcroot=/dev/mmcblk0p2 ro\0" \
    "mmcrootfstype=ext3 rootwait\0" \
    "nandroot=ubi0:rootfs rw ubi.mtd=7,2048\0" \
    "nandrootfstype=ubifs rootwait=1\0" 
#endif

2. rootfs
2.1  更改文件系統的調試端口
    更改為ttyO1, getty命令用於設置uart的參數 
    /etc/inittab
    0:2345:respawn:/sbin/getty 115200 ttyO1 

2.2 關閉rootfs調試串口  
    將對應的行注釋即可
    /etc/inittab
    #0:2345:respawn:/sbin/getty 115200 ttyO0 

3. uboot
    uboot中更改沒有成功,但也把過程記錄,方便之后查看。
    uboot/include/configs/ok335x.h

    更改下面的宏,注釋的時候使用"/* */"進行注釋,用“//”注釋,編譯會出現問題。
/* tony */
/*#define CONFIG_SERIAL2            1       
#define CONFIG_CONS_INDEX        2       
*/
#define CONFIG_SERIAL1            1
#define CONFIG_CONS_INDEX        1    

//並添加下面兩個宏, 定義UART1,UART2的寄存器地址
/* tony */
#define CONFIG_SYS_NS16550_COM2        0x48022000    /* UART1 */
#define CONFIG_SYS_NS16550_COM3        0x48024000    /* UART2 */
/*******/

board/forlinx/ok335x/pll.c
添加使能uart1
static void per_clocks_enable(void)
{
    ......
    /* UART0 */
    __raw_writel(PRCM_MOD_EN, CM_WKUP_UART0_CLKCTRL);
    while (__raw_readl(CM_WKUP_UART0_CLKCTRL) != PRCM_MOD_EN);

    /* UART1, add by Tony */
    __raw_writel(PRCM_MOD_EN, CM_PER_UART1_CLKCTRL);
    while (__raw_readl(CM_PER_UART1_CLKCTRL) != PRCM_MOD_EN);

    /* UART3 */
    __raw_writel(PRCM_MOD_EN, CM_PER_UART3_CLKCTRL);
    while (__raw_readl(CM_PER_UART3_CLKCTRL) != PRCM_MOD_EN);
    ......
}

//添加uart1的時能
board/forlinx/ok335x/mux.c
void enable_uart1_pin_mux(void)
{
    configure_module_pin_mux(uart1_pin_mux);
}

添加調用
board/forlinx/ok335x/evm.c
void s_init(void)
{
    ......
    enable_uart0_pin_mux();
    enable_uart1_pin_mux();
    ......
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM