Skip to contentSkip to conversation

sh-sci: Extend sh-sci driver with early console V2

PATCH Applied Magnus Damm 4 participants 14 messages Dec 14, 2009 – Apr 26, 2010 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh-sci: Extend sh-sci driver with early console V2

From: Magnus Damm <[email protected]>

This is V2 of early serial console support for the sh-sci driver. The early serial console is using early platform devices and "earlyprintk". To use this feature the early platform devices must be broken out to one device per port and the desired port should be selected on the kernel command line like: "earlyprintk=sh-sci.N[,baudrate][,keep]"

---

Depends on "Driver Core: Early platform driver buffer"

Changes since V1:
- Removed #ifdefs, only CONFIG_SERIAL_SH_SCI_CONSOLE now left

Platform device patches apply on top of this, a cleanup patch that removes the old duplicated serial port code will follow.

 arch/sh/kernel/early_printk.c |   10 -------
 arch/sh/kernel/setup.c        |    3 ++
 drivers/serial/sh-sci.c       |   54 ++++++++++++++++++++++++++++++++++-------
 3 files changed, 49 insertions(+), 18 deletions(-)
arch/sh/kernel/early_printk.c +1 -9
@@ -191,15 +191,7 @@ static void scif_sercon_init(char *s)
  * Setup a default console, if more than one is compiled in, rely on the
  * earlyprintk= parsing to give priority.
  */
-static struct console *early_console -#ifdef CONFIG_SH_STANDARD_BIOS
-	&bios_console
-#elif defined(CONFIG_EARLY_SCIF_CONSOLE)
-	&scif_console
-#else
-	NULL
-#endif
-	;
+static struct console *early_console;
 
 static int __init setup_early_printk(char *buf)
 {
--- 0001/arch/sh/kernel/setup.c

+++ work/arch/sh/kernel/setup.c 2009-12-14 15:58:45.000000000 +0900
@@ -423,6 +423,9 @@ void __init setup_arch(char **cmdline_p)

plat_early_device_setup();

+ /* Let earlyprintk output early console messages */
+ early_platform_driver_probe("earlyprintk", 1, 1);
+
sh_mv_setup();

/*

drivers/serial/sh-sci.c +45 -9

96 lines not on this page · raw message

Applied
#1 lore raw
Quoted 6 lines · Magnus Damm

This is V2 of early serial console support for the sh-sci driver. The early serial console is using early platform devices and "earlyprintk". To use this feature the early platform devices must be broken out to one device per port and the desired port should be selected on the kernel command line like: "earlyprintk=sh-sci.N[,baudrate][,keep]"

Quoted 9 lines · Magnus Damm

These patches break out the scif serial port platform data into one platform device per port.

With these patches and the early serial support in place it is possible to select the early serial console port with the kernel command line. For example, to enable early serial console on KFR2R09, simply add the following to the kernel command line:

"earlyprintk=sh-sci.1,115200".

Quoted 14 lines · Magnus Damm

Now when the sh-sci driver can do early serial output, get rid of the old duplicated code. This patch is V2 and removes support for "earlyprintk=serial" together with the following kconfig options:
CONFIG_EARLY_SCIF_CONSOLE CONFIG_EARLY_SCIF_CONSOLE_PORT CONFIG_EARLY_PRINTK

With this patch applied "earlyprintk=" support is always built-in the SuperH kernel. For this to work the serial driver must have early platform support and in the case of sh-sci the serial console needs to be enabled:
CONFIG_SERIAL_SH_SCI_CONSOLE=y

Quoted 7 lines

So after enabling the SuperH SCI console kconfig option you also need to point out port using the kernel command
line: "earlyprintk=sh-sci.N[,baudrate][,keep]"

Remember that clocks may be disabled by the boot loader so you may have to do some board specific static clock setup before earlyprintk will work on your platform.

Applied, thanks.

#2 lore raw
In reply to Magnus Damm

Hello Magnus,

I'm in trouble with qemu-sh serial console. Don't you have any guide on this trouble?

With the patch, qemu-sh serial console doesn't work. The emulated device is r2d+.

- no earlyprintk option
... Qemu carshes with assertion. No kernel boot log printed.
I guess it touches sh-sci.0 registers, which qemu doesn't support.
- earlyprintk=sh-sci.1
... Qemu boots up with kernel boot log output,
but the log message stops with
"turn off boot console early_ttySC0' message.
No login prompt appears.
- earlyprintk=sh-sci.1,115200,keep
... The message "turn off boots up ..." disappears, but no
login prompt appears.

Best Regards,
Shin-ichiro KAWASAKI

Quoted 165 lines · Magnus Damm

From: Magnus Damm<[email protected]>

This is V2 of early serial console support for the sh-sci driver. The early serial console is using early platform devices and "earlyprintk". To use this feature the early platform devices must be broken out to one device per port and the desired port should be selected on the kernel command line like: "earlyprintk=sh-sci.N[,baudrate][,keep]"

---

Depends on "Driver Core: Early platform driver buffer"

Changes since V1:
- Removed #ifdefs, only CONFIG_SERIAL_SH_SCI_CONSOLE now left

Platform device patches apply on top of this, a cleanup patch that removes the old duplicated serial port code will follow.

  arch/sh/kernel/early_printk.c |   10 -------
  arch/sh/kernel/setup.c        |    3 ++
  drivers/serial/sh-sci.c       |   54 ++++++++++++++++++++++++++++++++++-------
  3 files changed, 49 insertions(+), 18 deletions(-)
arch/sh/kernel/early_printk.c +1 -8
@@ -191,15 +191,7 @@ static void scif_sercon_init(char *s)
   * Setup a default console, if more than one is compiled in, rely on the
   * earlyprintk= parsing to give priority.
   */
-static struct console *early_console > -#ifdef CONFIG_SH_STANDARD_BIOS
-	&bios_console
-#elif defined(CONFIG_EARLY_SCIF_CONSOLE)
-	&scif_console
-#else
-	NULL
-#endif
-	;
+static struct console *early_console;
 
  static int __init setup_early_printk(char *buf)
  {
arch/sh/kernel/setup.c +3 -0
@@ -423,6 +423,9 @@ void __init setup_arch(char **cmdline_p)
 
  	plat_early_device_setup();
 
+	/* Let earlyprintk output early console messages */
+	early_platform_driver_probe("earlyprintk", 1, 1);
+
  	sh_mv_setup();
 
  	/*
drivers/serial/sh-sci.c +45 -10
@@ -1043,10 +1043,14 @@ static void __devinit sci_init_single(st
  	sci_port->port.iotype	= UPIO_MEM;
  	sci_port->port.line	= index;
  	sci_port->port.fifosize	= 1;
-	sci_port->iclk		= p->clk ? clk_get(&dev->dev, p->clk) : NULL;
-	sci_port->dclk		= clk_get(&dev->dev, "peripheral_clk");
-	sci_port->enable	= sci_clk_enable;
-	sci_port->disable	= sci_clk_disable;
+
+	if (dev) {
+		sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL;
+		sci_port->dclk = clk_get(&dev->dev, "peripheral_clk");
+		sci_port->enable = sci_clk_enable;
+		sci_port->disable = sci_clk_disable;
+		sci_port->port.dev =&dev->dev;
+	}
 
  	sci_port->break_timer.data = (unsigned long)sci_port;
  	sci_port->break_timer.function = sci_break_timer;
@@ -1057,7 +1061,6 @@ static void __devinit sci_init_single(st
 
  	sci_port->port.irq	= p->irqs[SCIx_TXI_IRQ];
  	sci_port->port.flags	= p->flags;
-	sci_port->port.dev	=&dev->dev;
  	sci_port->type		= sci_port->port.type = p->type;
 
  	memcpy(&sci_port->irqs,&p->irqs, sizeof(p->irqs));
@@ -1101,7 +1104,7 @@ static void serial_console_write(struct
  		sci_port->disable(port);
  }
 
-static int __init serial_console_setup(struct console *co, char *options)
+static int __devinit serial_console_setup(struct console *co, char *options)
  {
  	struct sci_port *sci_port;
  	struct uart_port *port;
@@ -1119,9 +1122,14 @@ static int __init serial_console_setup(s
  	if (co->index>= SCI_NPORTS)
  		co->index = 0;
 
-	sci_port =&sci_ports[co->index];
-	port =&sci_port->port;
-	co->data = port;
+	if (co->data) {
+		port = co->data;
+		sci_port = to_sci_port(port);
+	} else {
+		sci_port =&sci_ports[co->index];
+		port =&sci_port->port;
+		co->data = port;
+	}
 
  	/*
  	 * Also need to check port->type, we don't actually have any
@@ -1165,6 +1173,15 @@ static int __init sci_console_init(void)
  	return 0;
  }
  console_initcall(sci_console_init);
+
+static struct sci_port early_serial_port;
+static struct console early_serial_console = {
+	.name           = "early_ttySC",
+	.write          = serial_console_write,
+	.flags          = CON_PRINTBUFFER,
+};
+static char early_serial_buf[32];
+
  #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
 
  #if defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
@@ -1250,6 +1267,21 @@ static int __devinit sci_probe(struct pl
  	struct sh_sci_priv *priv;
  	int i, ret = -EINVAL;
 
+#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
+	if (is_early_platform_device(dev)) {
+		if (dev->id = -1)
+			return -ENOTSUPP;
+		early_serial_console.index = dev->id;
+		early_serial_console.data =&early_serial_port.port;
+		sci_init_single(NULL,&early_serial_port, dev->id, p);
+		serial_console_setup(&early_serial_console, early_serial_buf);
+		if (!strstr(early_serial_buf, "keep"))
+			early_serial_console.flags |= CON_BOOT;
+		register_console(&early_serial_console);
+		return 0;
+	}
+#endif
+
  	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  	if (!priv)
  		return -ENOMEM;
@@ -1349,6 +1381,10 @@ static void __exit sci_exit(void)
  	uart_unregister_driver(&sci_uart_driver);
  }
 
+#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
+early_platform_init_buffer("earlyprintk",&sci_driver,
+			   early_serial_buf, ARRAY_SIZE(early_serial_buf));
+#endif
  module_init(sci_init);
  module_exit(sci_exit);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Magnus Damm

Hey Kawasaki-san,

2010/4/11 Shin-ichiro KAWASAKI <[email protected]>:

Quoted 4 lines

Hello Magnus,

I'm in trouble with qemu-sh serial console.  Don't you have any guide on this trouble?

Yes, I think the defconfig is missing one thing. Please try setting CONFIG_SERIAL_SH_SCI_NR_UARTS=2. See below.

Quoted 6 lines

With the patch, qemu-sh serial console doesn't work. The emulated device is r2d+.

 - no earlyprintk option
 ... Qemu carshes with assertion. No kernel boot log printed. I guess it touches sh-sci.0 registers, which qemu doesn't support.

Hm, I'm not sure why this happens. Did you update the kernel command line to use ttySC1?

This commit in linux-2.6 git may be useful:

cd5f107628ab89c5dec5ad923f1c27f4cba41972

Quoted 8 lines

 - earlyprintk=sh-sci.1
 ... Qemu boots up with kernel boot log output, but the log message stops with
     "turn off boot console early_ttySC0' message. No login prompt appears.
 - earlyprintk=sh-sci.1,115200,keep
 ... The message "turn off boots up ..." disappears, but no login prompt appears.

I think this is because CONFIG_SERIAL_SH_SCI_NR_UARTS is set to 1. Or perhaps is your user space still using ttySC0 instead of ttySC1?

Does updating CONFIG_SERIAL_SH_SCI_NR_UARTS to 2 solve your issue?

Thanks for the report and sorry about the breakage.

/ magnus

#4 lore raw
In reply to Magnus Damm

Hello everybody,

Quoted 5 lines
Quoted 2 lines

I'm in trouble with qemu-sh serial console.  Don't you have any guide on this trouble?

Yes, I think the defconfig is missing one thing. Please try setting CONFIG_SERIAL_SH_SCI_NR_UARTS=2. See below.

Indeed, I ran into the same problem as Kawasaki-san and got it fixed by setting CONFIG_SERIAL_SH_SCI_NR_UARTS to 2 instead of 1. With this value, I am able to boot correctly by using the "earlyprintk=sh-sci.1 console=ttySC1" kernel parameters. FYI, my qemu command-line is:

qemu-system-sh4 -M r2d -kernel arch/sh/boot/zImage -serial null -serial stdio -append "earlyprintk=sh-sci.1 console=ttySC1"

Also, the r2dplus configuration file sets CONFIG_SERIAL_SH_SCI_NR_UARTS to 1 currently - here is a patch that fixes that. It is possible that other targets need this.

We are also trying to get the latest Linux to run on the SH2007 platform, and since the new serial driver boot fails during SCIF intialization. I have attached a boot log of what is sent to the serial line. The output gets cut right in the middle of displaying status for sh-sci.1. Any clue on that issue would be greatly appreciated.

Thanks,
Alex.

SH IPL+g version 1.30 Jun 21 2007, Copyright (C) 2001-2007 Free Software Foundation, Inc.

This software comes with ABSOLUTELY NO WARRANTY; for details type w'. This is free software, and you are welcome to redistribute it under certain conditions; type l' for details.

128Mbyte memory
PCI: Starting intialization.
pci device 00: VID=0x1033 DID=0x0035
Initializing uPD720101 USB Interface
DSW[1..8]=0001 1110

Booting from network!
SMSC LAN911x Driver (v1.12)
LAN9118(rev:1) at 0xb0800000 ADDR: 00:10:0c:00:50:f2
Searching for server (BOOTP/DHCP)...
IP Address: 192.168.1.100
Server: 192.168.1.1, Gateway 192.168.1.1
Kernel to load: "/nfs/sh2007/boot/vmlinuz.sh2007"
HOSTNAME: sh2007-mitake
ROOT PATH: /nfs/sh2007
Loading Kernel: /nfs/sh2007/boot/vmlinuz.sh2007 at 0x88210000 .........................................................a done
Setting GDB trap vector to 80000100
Linux version 2.6.34-rc2 (mitake@mitakei7) (gcc version 4.4.3 (Debian 4.4.3-3) ) #238 Thu Apr 15 17:31:45 JST 2010 Boot params:
... MOUNT_ROOT_RDONLY - 00000000

... RAMDISK_FLAGS     - 00000000
... ORIG_ROOT_DEV     - 00000000
... LOADER_TYPE       - 00000000
... INITRD_START      - 00000000
... INITRD_SIZE       - 00000000

bootconsole [bios0] enabled
Booting machvec: sh2007
Node 0: start_pfn = 0x8000, low = 0x10000
Zone PFN ranges:
Normal 0x00008000 -> 0x00010000
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
0: 0x00008000 -> 0x00010000
SH-2007 Setup...done.
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: console=ttySC1,115200 ip=dhcp root=/dev/nfs rw nfsroot=/nfs/sh2007,rsize=1024,wsize=1024 earlyprins PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
PVR=10200a00 CVR=73440010 PRR=00000920
I-cache : n_ways=4 n_sets=256 way_incr=8192
I-cache : entry_mask=0x00001fe0 alias_mask=0x00001000 n_aliases=2
D-cache : n_ways=4 n_sets=256 way_incr=8192
D-cache : entry_mask=0x00001fe0 alias_mask=0x00001000 n_aliases=2
Memory: 123392k/131072k available (3918k kernel code, 2323k data, 184k init)
virtual kernel memory layout:

   fixmap  : 0xdfff7000 - 0xdffff000   (  32 kB)
   vmalloc : 0xc0000000 - 0xdfff5000   ( 511 MB)
   lowmem  : 0x88000000 - 0x90000000   ( 128 MB) (cached)
           : 0xa0000000 - 0xc0000000   ( 512 MB) (uncached)
     .init : 0x8861a000 - 0x88648000   ( 184 kB)
     .data : 0x883d49e8 - 0x886199a0   (2323 kB)
     .text : 0x88001000 - 0x883d49e8   (3918 kB)

Hierarchical RCU implementation.
NR_IRQS:256 nr_irqs:256
Console: colour dummy device 80x25
sh_tmu.0: used for clock events
sh_tmu.0: used for periodic clock events
sh_tmu.1: used as clock source
Calibrating delay loop (skipped)... 600.00 BogoMIPS PRESET (lpj=3000000) Mount-cache hash table entries: 512
CPU: SH7780
NET: Registered protocol family 16
Performance Events: SH-4A support registered
HW Breakpoints: SH-4A UBC support registered
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
DMA: Registering sh_dmac handler (12 channels).
DMA: Registering DMA API.
Switching to clocksource sh_tmu.1
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes) platform sh_tmu.0: used for oneshot clock events
TCP established hash table entries: 4096 (order: 3, 32768 bytes) TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module. SH2007 PIO Driver v0.1
audit: initializing netlink socket (disabled)
type=2000 audit(946684800.170:1): initialized
msgmni has been set to 241
alg: No test for cipher_null (cipher_null-generic)
alg: No test for ecb(cipher_null) (ecb-cipher_null)
alg: No test for digest_null (digest_null-generic)
alg: No test for compress_null (compress_null-generic)
alg: No test for fcrypt (fcrypt-generic)
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Serial: 8250/16550 driver, 8 ports, IRQ sharing enabled SuperH SCI(F) driver initialized
sh-sci.0: ttySC0 at MMIO 0xffe00000 (irq = 40) is a scif sh-sci.1: ttySC1 at MMIO 0x

From 18885a76e31aaccbaf78c43b42cdaf9031b3c13f Mon Sep 17 00:00:00 2001
From: Alexandre Courbot <[email protected]>
Date: Mon, 19 Apr 2010 16:29:21 +0900
Subject: [PATCH] [SH] Fixed number of UARTs in r2dplus config

---
 arch/sh/configs/rts7751r2dplus_defconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/sh/configs/rts7751r2dplus_defconfig +1 -1
index a8d538f..6d511d0 100644
@@ -963,7 +963,7 @@ CONFIG_SERIAL_8250_RUNTIME_UARTS=4
 #
 # CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_SH_SCI=y
-CONFIG_SERIAL_SH_SCI_NR_UARTS=1
+CONFIG_SERIAL_SH_SCI_NR_UARTS=2
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
Signature · 1 line
1.7.0.5
#5 lore raw
In reply to Magnus Damm

Hi Alexandre,

Quoted 8 lines · Alexandre Courbot

Hello everybody,

Quoted 5 lines
Quoted 2 lines

I'm in trouble with qemu-sh serial console.  Don't you have any guide on this trouble?

Yes, I think the defconfig is missing one thing. Please try setting CONFIG_SERIAL_SH_SCI_NR_UARTS=2. See below.

Quoted 7 lines

Indeed, I ran into the same problem as Kawasaki-san and got it fixed by setting CONFIG_SERIAL_SH_SCI_NR_UARTS to 2 instead of 1. With this value, I am able to boot correctly by using the "earlyprintk=sh-sci.1 console=ttySC1" kernel parameters. FYI, my qemu command-line is:

qemu-system-sh4 -M r2d -kernel arch/sh/boot/zImage -serial null -serial stdio -append "earlyprintk=sh-sci.1 console=ttySC1"

Thanks for sharing this information.

Quoted 3 lines

Also, the r2dplus configuration file sets CONFIG_SERIAL_SH_SCI_NR_UARTS to 1 currently - here is a patch that fixes that. It is possible that other targets need this.

Cool, thanks. It's very similar to the patch I just posted. =)

Quoted 6 lines

We are also trying to get the latest Linux to run on the SH2007 platform, and since the new serial driver boot fails during SCIF intialization. I have attached a boot log of what is sent to the serial line. The output gets cut right in the middle of displaying status for sh-sci.1. Any clue on that issue would be greatly appreciated.

Is the SH2007 board based on sh7780? Perhaps it's a clock issue.

Cheers,

/ magnus

#6 lore raw
In reply to Magnus Damm
Quoted 5 lines
Quoted 3 lines

Also, the r2dplus configuration file sets CONFIG_SERIAL_SH_SCI_NR_UARTS to 1 currently - here is a patch that fixes that. It is possible that other targets need this.

Cool, thanks. It's very similar to the patch I just posted. =)

Indeed. :p

Quoted 8 lines
Quoted 6 lines

We are also trying to get the latest Linux to run on the SH2007 platform, and since the new serial driver boot fails during SCIF intialization. I have attached a boot log of what is sent to the serial line. The output gets cut right in the middle of displaying status for sh-sci.1. Any clue on that issue would be greatly appreciated.

Is the SH2007 board based on sh7780? Perhaps it's a clock issue.

It's a 7780 indeed. I'm not a specialist of the SH platform (still learning), but I'll try to look at this from a clock perspective. FYI, the early printk is done through the bios.

Thanks!
Alex.

#7 lore raw
In reply to Magnus Damm
Quoted 7 lines · Alexandre Courbot
Quoted 7 lines
Quoted 6 lines

We are also trying to get the latest Linux to run on the SH2007 platform, and since the new serial driver boot fails during SCIF intialization. I have attached a boot log of what is sent to the serial line. The output gets cut right in the middle of displaying status for sh-sci.1. Any clue on that issue would be greatly appreciated.

Quoted 5 lines
Quoted 1 line

Is the SH2007 board based on sh7780? Perhaps it's a clock issue.

It's a 7780 indeed. I'm not a specialist of the SH platform (still learning), but I'll try to look at this from a clock perspective. FYI, the early printk is done through the bios.

Your command line is word wrapped so it's not apparent what options you are using. One noticeable difference for sh-bios users in sh-sci is the detach callback via sh_bios_gdb_detach(), you might want to try commenting this out to make sure you're not trapping in to some bogus location. If the sh-bios earlyprintk is working for you then you might also try the 'keep' option to prevent the serial console from taking control away from it.

#8 lore raw
In reply to Magnus Damm
Quoted 7 lines · Alexandre Courbot
Quoted 7 lines
Quoted 6 lines

We are also trying to get the latest Linux to run on the SH2007 platform, and since the new serial driver boot fails during SCIF intialization. I have attached a boot log of what is sent to the serial line. The output gets cut right in the middle of displaying status for sh-sci.1. Any clue on that issue would be greatly appreciated.

Quoted 5 lines
Quoted 1 line

Is the SH2007 board based on sh7780? Perhaps it's a clock issue.

It's a 7780 indeed. I'm not a specialist of the SH platform (still learning), but I'll try to look at this from a clock perspective. FYI, the early printk is done through the bios.

Does the kernel commandline option "earlyprintk=sh-sci.1,115200" work?

/ magnus

#9 lore raw
In reply to Magnus Damm

Hello,

Quoted 1 line

Does the kernel commandline option "earlyprintk=sh-sci.1,115200" work?

It does not - nothing gets displayed at all by the kernel.

Quoted 2 lines

Your command line is word wrapped so it's not apparent what options you are using.

Sorry - the options I were using on sh2007 to get the log I attached previously are
"earlyprintk=bios console=ttySC1,115200"

Quoted 8 lines

One noticeable difference for sh-bios users in sh-sci is the detach callback via sh_bios_gdb_detach(), you might want to try commenting this out to make sure you're not trapping in to some bogus location.

If the sh-bios earlyprintk is working for you then you might also try the 'keep' option to prevent the serial console from taking control away from it.

Indeed, that workarounds the problem, but then I stop getting feedback from the kernel starting from when init is supposed to start:

VFS: Mounted root (nfs filesystem) on device 0:12. Freeing unused kernel memory: 184k freed

However, by monitoring the network activity (I use a NFS root FS), I can see that the init script executes normally as all the boot time invoked binaries and libraries are sent through the network. Therefore the kernel is starting normally, but it seems it just lacks a console that uses the same device as the kernel earlyprintk. Any idea about how I could create such an entry in /dev/ ? (major/minor numbers?)

Still, it would be nice to get the SCIF to work on that platform. I'm willing to investigate the problem (may be clock-related indeed), but could someone provide me some guidance about where in the driver I should look at?

Thanks again, looks like I'm close to having a working kernel again! Alex.

#10 lore raw
In reply to Magnus Damm
Quoted 9 lines · Alexandre Courbot
Quoted 8 lines

One noticeable difference for sh-bios users in sh-sci is the detach callback via sh_bios_gdb_detach(), you might want to try commenting this out to make sure you're not trapping in to some bogus location.

If the sh-bios earlyprintk is working for you then you might also try the 'keep' option to prevent the serial console from taking control away from it.

Quoted 6 lines

Indeed, that workarounds the problem, but then I stop getting feedback from the kernel starting from when init is supposed to start:

VFS: Mounted root (nfs filesystem) on device 0:12. Freeing unused kernel memory: 184k freed

That would be because the early consoles themselves are only meant for debugging aids, and have no input methods of their own. With no backing device userspace will also fail to bind /dev/console, so this is the expected behaviour.

Quoted 5 lines

Still, it would be nice to get the SCIF to work on that platform. I'm willing to investigate the problem (may be clock-related indeed), but could someone provide me some guidance about where in the driver I should look at?

I've dusted off the SH7780 Highlander to see if there were any immediate issues with the clock or serial code that would have broken the CPU, but that all worked out of the box.

Quoted 1 line

Thanks again, looks like I'm close to having a working kernel again!

The obvious remaining question would be are you sure that your serial port is really on ttySC1? Most of the SH7780 boards placed the console on ttySC0 by default, so make sure that you aren't just being bitten by a bogus defconfig setting.

If you have board support patches that you've applied to the kernel then you might also want to try backing those off and simply booting with the default machvec with SH7780 support enabled. Given that the serial port is an SoC property you shouldn't have any difficulty getting a console even if you have no other board support built in.

You may also want to disable sh-bios support in the off chance that this is clobbering something it shouldn't be (note that sh-bios support itself is almost never tested these days, and in the past it has always been a source of inconsistency).

If all else fails then we'll simply have to debug the init path, but I suspect you're being bitten by something completely unrelated given that none of the other SH7780's exhibit any sort of difficulty.

#11 lore raw
In reply to Magnus Damm
Quoted 4 lines

The obvious remaining question would be are you sure that your serial port is really on ttySC1? Most of the SH7780 boards placed the console on ttySC0 by default, so make sure that you aren't just being bitten by a bogus defconfig setting.

Yes, I checked this too, and with older versions of the kernel I was also using ttySC1.

Quoted 5 lines

If you have board support patches that you've applied to the kernel then you might also want to try backing those off and simply booting with the default machvec with SH7780 support enabled. Given that the serial port is an SoC property you shouldn't have any difficulty getting a console even if you have no other board support built in.

Just tried with the latest official branch, and unfortunately no luck. earlyprintk=bios,keep performs the same as our branch with respect to the SCI.

Quoted 4 lines

You may also want to disable sh-bios support in the off chance that this is clobbering something it shouldn't be (note that sh-bios support itself is almost never tested these days, and in the past it has always been a source of inconsistency).

Did that too, did not help with "earlyprintk=sh-sci.1" or "earlyprintk=sh-sci.0" at all. :( Nothing is displayed, but the NFS activity testifies that the kernel boots.

Quoted 3 lines

If all else fails then we'll simply have to debug the init path, but I suspect you're being bitten by something completely unrelated given that none of the other SH7780's exhibit any sort of difficulty.

Indeed, this looks very strange to me too. Sorry for being clueless, but I'm rather new to kernel programming and debugging - what would you recommend me to try next?

Thanks,
Alex.

#12 lore raw
In reply to Magnus Damm

Hi, Magnus-san, and Alex-san,

Thank you very much for your guides.
Setting "CONFIG_SERIAL_SH_SCI_NR_UARTS=2" solved my problem fully. I find no qemu crash, and happy to see login prompt again.

I tried out these two option with real R2D+ boards and recent sh-2.6 git.
CONFIG_SERIAL_SH_SCI_NR_UARTS=1 ... no serial output CONFIG_SERIAL_SH_SCI_NR_UARTS=2 ... kernel boot log printed in serial output

I hope the patch applied soon :)

Best Regards,
Shin-ichiro KAWASAKI

Quoted 43 lines · Magnus Damm

Hey Kawasaki-san,

2010/4/11 Shin-ichiro KAWASAKI<[email protected]>:

Quoted 4 lines

Hello Magnus,

I'm in trouble with qemu-sh serial console. Don't you have any guide on this trouble?

Yes, I think the defconfig is missing one thing. Please try setting CONFIG_SERIAL_SH_SCI_NR_UARTS=2. See below.

Quoted 6 lines

With the patch, qemu-sh serial console doesn't work. The emulated device is r2d+.

- no earlyprintk option
... Qemu carshes with assertion. No kernel boot log printed.
I guess it touches sh-sci.0 registers, which qemu doesn't support.

Hm, I'm not sure why this happens. Did you update the kernel command line to use ttySC1?

This commit in linux-2.6 git may be useful:

cd5f107628ab89c5dec5ad923f1c27f4cba41972

Quoted 8 lines

- earlyprintk=sh-sci.1
... Qemu boots up with kernel boot log output,
but the log message stops with
"turn off boot console early_ttySC0' message. No login prompt appears.
- earlyprintk=sh-sci.1,115200,keep
... The message "turn off boots up ..." disappears, but no
login prompt appears.

I think this is because CONFIG_SERIAL_SH_SCI_NR_UARTS is set to 1. Or perhaps is your user space still using ttySC0 instead of ttySC1?

Does updating CONFIG_SERIAL_SH_SCI_NR_UARTS to 2 solve your issue?

Thanks for the report and sorry about the breakage.

/ magnus

#13 lore raw
In reply to Magnus Damm
Quoted 6 lines · Shin-ichiro KAWASAKI

Hi, Magnus-san, and Alex-san,

Thank you very much for your guides.
Setting "CONFIG_SERIAL_SH_SCI_NR_UARTS=2" solved my problem fully. I find no qemu crash, and happy to see login prompt again.

Quoted 7 lines

I tried out these two option with real R2D+ boards and recent sh-2.6 git.
CONFIG_SERIAL_SH_SCI_NR_UARTS=1 ... no serial output CONFIG_SERIAL_SH_SCI_NR_UARTS=2 ... kernel boot log printed in serial output

I hope the patch applied soon :)

It's queued for 2.6.34 now, thanks for testing.