Uclinux-2008r1-rc8 (bf561) to VDSP5 Transplant (MB): Unable to open an initial console blog.
Encountered a depressed problem, prompted "Unable to open a initial console" after no later.
The location where this error occurred is searched, in the Init_post function:
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
printk(KERN_WARNING "Warning: unable to open an initial console./n");
Just started to think that is not the reason for the correct establishment of/dev/console, but after tracking in to find not so,/dev/console has been correctly created, the problem appears in the Tty_open function.
In this function, it first obtains the tty_driver of the console:
if (device == MKDEV(TTYAUX_MAJOR,1)) {
driver = console_device(&index);
if (driver) {
/* Don't let /dev/console block */
filp->f_flags |= O_NONBLOCK;
noctty = 1;
goto got_driver;
}
mutex_unlock(&tty_mutex);
return -ENODEV;
}
Look at the implementation of the Console_device:
/*
* Return the console tty driver structure and its associated index
*/
struct tty_driver *console_device(int *index)
{
struct console *c;
struct tty_driver *driver = NULL;
acquire_console_sem();
for (c = console_drivers; c != NULL; c = c->next) {
if (!c->device)
continue;
driver = c->device(c, index);
if (driver)
break;
}
release_console_sem();
return driver;
}
It looks for all available console, finds a console that provides Tty_driver, and returns. In the kernel, the actual console used is described by the global variable Bfin_serial_console (DRIVERS/SERIAL/BFIN_5XX.C). The device callback function is provided in this structure to obtain the tty_driver used by this console:
static struct console bfin_serial_console = {
.name = BFIN_SERIAL_NAME,
.write = bfin_serial_console_write,
.device = uart_console_device,
.setup = bfin_serial_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &bfin_serial_reg,
};