问题:
在老内核2.6.24.3的目标板上,/dev下能看到ttyS0,ttyS1和ttyS2;没有ttys*文件;
但是,内核升级到2.6.30后,在/dev下只能看到ttyS0和ttyS2,有ttys0~ttysf共16个文件;
并且,不能通过open命令打开ttyS1设备。
解决办法:
1. 进入到内核所在目录linux-2.6.30,运行命令:
make menuconfig
使用/来查找serial字符,看到这么一行,
Symbol: SERIAL_ATMEL_CONSOLE [=n] │
│ Prompt: Support for console on AT91 / AT32 serial port │
│ Defined at drivers/serial/Kconfig:370 │
│ Depends on: HAS_IOMEM && SERIAL_ATMEL │
│ Location: │
│ -> Device Drivers │
│ -> Character devices │
│ -> Serial drivers │
│ -> AT91 / AT32 on-chip serial port support (SERIAL_ATMEL [=n]) │
│ Selects: SERIAL_CORE_CONSOLE
从SERIAL_ATMEL_CONSOLE = n,本来以为是内核配置有误,但是,查了一下.config文件,有这么几行:
# Non-8250 serial port support
#
CONFIG_SERIAL_ATMEL=y
CONFIG_SERIAL_ATMEL_CONSOLE=y
CONFIG_SERIAL_ATMEL_PDC=y
# CONFIG_SERIAL_ATMEL_TTYAT is not set
看来在.config文件中已经设定好了,那为什么make menuconfig看不到AT91 / AT32 on-chip serila port support呢?
原来,是make命令用错了,不只是要指定交叉编译名称,也要指定目标处理器的体系结构,应该使用命令:
make ARCH=arm CROSS_COMPILE=arm-ilnux- menuconfig
这样,就能看到Device Drivers -> Serial drivers -> AT91 / AT32 on-chip serial port support的选择界面了。
2. 既然内核的选项中已经把所有的开关都打开了,ttyS1还是不能显示,那真正影响到ttyS1显示的是这个文件:
arch/arm/mach-at91/board-sam9260ek.c
在函数ek_map_io()中,注册ttyS1的串口被屏蔽掉了。
static void __init ek_map_io(void)
{
/* Initialize processor: 18.432 MHz crystal */
at91sam9260_initialize(18432000);
/* DGBU on ttyS0. (Rx & Tx only) */
at91_register_uart(0, 0, 0);
/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
/*
at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD | ATMEL_UART_RI);
*/
/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
// at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
at91_register_uart(AT91SAM9260_ID_US1, 2, 0);
/* set serial console to ttyS0 (ie, DBGU) */
at91_set_serial_console(0);
}
将屏蔽语句去除,改为:
static void __init ek_map_io(void)
{
/* Initialize processor: 18.432 MHz crystal */
at91sam9260_initialize(18432000);
/* DGBU on ttyS0. (Rx & Tx only) */
at91_register_uart(0, 0, 0);
/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
| ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
| ATMEL_UART_RI);
/*
*/
/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
// at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
at91_register_uart(AT91SAM9260_ID_US1, 2, 0);
/* set serial console to ttyS0 (ie, DBGU) */
at91_set_serial_console(0);
}