FIX: [uboot] fix defaultconsole if comio shield is available
BugzId: 48404 SVN commit 25481@trunk
This commit is contained in:
parent
d6a24f1fe4
commit
d8fd5953c0
|
|
@ -80,6 +80,10 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
|
||||||
|
|
||||||
static BD_Context bdctx[3]; /* The descriptor context */
|
static BD_Context bdctx[3]; /* The descriptor context */
|
||||||
|
|
||||||
|
|
||||||
|
#define SHIELD_COM_IO 0
|
||||||
|
#define SHIELD_DUALCAN 1
|
||||||
|
|
||||||
static int _bd_init(void)
|
static int _bd_init(void)
|
||||||
{
|
{
|
||||||
if (bd_get_context(&bdctx[0], BD_EEPROM_ADDR, BD_ADDRESS) != 0) {
|
if (bd_get_context(&bdctx[0], BD_EEPROM_ADDR, BD_ADDRESS) != 0) {
|
||||||
|
|
@ -482,6 +486,35 @@ static void enable_wlan_clock(void)
|
||||||
|
|
||||||
#if !defined(CONFIG_SPL_BUILD)
|
#if !defined(CONFIG_SPL_BUILD)
|
||||||
|
|
||||||
|
void set_console(void)
|
||||||
|
{
|
||||||
|
char buf[8];
|
||||||
|
char *defaultconsole = getenv("defaultconsole");
|
||||||
|
int shield_id = bd_get_shield(0);
|
||||||
|
|
||||||
|
if (defaultconsole == 0) {
|
||||||
|
/* Use the default console */
|
||||||
|
setenv("defaultconsole", "ttyS1\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't allow changing to ttyS0 because ttyS0 is not available in the
|
||||||
|
* kernel if no comio shield is available */
|
||||||
|
if (shield_id != SHIELD_COM_IO) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If consoldev is set take this as productive conosle instead of default console */
|
||||||
|
if (read_file("/root/boot/consoledev", buf, 5) != 5) {
|
||||||
|
puts("Invalid file consoledev\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strstr(buf, "tty")==buf) {
|
||||||
|
buf[5] = 0;
|
||||||
|
setenv("defaultconsole", buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void set_devicetree_name(void)
|
static void set_devicetree_name(void)
|
||||||
{
|
{
|
||||||
char devicetreename[64];
|
char devicetreename[64];
|
||||||
|
|
@ -531,9 +564,6 @@ struct shield_command {
|
||||||
void (*init)(void);
|
void (*init)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SHIELD_COM_IO 0
|
|
||||||
#define SHIELD_DUALCAN 1
|
|
||||||
|
|
||||||
static struct shield_command known_shield_commands[] = {
|
static struct shield_command known_shield_commands[] = {
|
||||||
{
|
{
|
||||||
SHIELD_COM_IO,
|
SHIELD_COM_IO,
|
||||||
|
|
@ -629,13 +659,14 @@ int board_late_init(void)
|
||||||
|
|
||||||
/* mmcblk0p1 => root0, mmcblk0p2 => root1 so +1 */
|
/* mmcblk0p1 => root0, mmcblk0p2 => root1 so +1 */
|
||||||
setenv_ulong("root_part", boot_partition + 1);
|
setenv_ulong("root_part", boot_partition + 1);
|
||||||
fs_set_console();
|
|
||||||
|
|
||||||
check_reset_button();
|
check_reset_button();
|
||||||
|
|
||||||
get_hw_version();
|
get_hw_version();
|
||||||
|
|
||||||
set_devicetree_name();
|
set_devicetree_name();
|
||||||
|
|
||||||
|
set_console();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ int read_file(const char* filename, char *buf, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* File does not exist, do not print an error message */
|
/* File does not exist, do not print an error message */
|
||||||
if (fs_size(filename, &filesize)) {
|
if (fs_size(filename, &filesize)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -36,36 +36,8 @@ int read_file(const char* filename, char *buf, int size)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fs_set_console(void)
|
|
||||||
{
|
|
||||||
loff_t len;
|
|
||||||
char buf[50] = "\n";
|
|
||||||
char *defaultconsole = getenv("defaultconsole");
|
|
||||||
|
|
||||||
if (defaultconsole == 0) {
|
|
||||||
/* This is the default console that should be used for e.g. recovery boot */
|
|
||||||
sprintf(buf, "ttyS1");
|
|
||||||
setenv("defaultconsole", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* If consoldev is set take this as productive conosle instead of default console */
|
|
||||||
if (fs_set_blk_dev("mmc", OVERLAY_PART, FS_TYPE_EXT) != 0) {
|
|
||||||
puts("Error, can not set blk device\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs_read("/root/boot/consoledev", (ulong)buf, 0, 5, &len);
|
|
||||||
if ((len != 5) || (strstr(buf, "tty")!=buf) || ((buf[4]<'0') && (buf[4]>'1'))) {
|
|
||||||
puts("Using default console\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setenv("defaultconsoel", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue