stdout on ttySX for the first userspace program

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hello,

I'm working on an embedded kernel for PowerPC 460 (board like amcc
canyonland).
I'm compiling for ARCH=powerpc and I'm using the DTS methode (not the
kernel wrapper, uboot is in powerpc with lib_of)

My serial terminal is connected to ttyS2

Under uboot, no problem; ttyS2 work, I have my uboot console.

my kernel command line have console=ttyS2,115200
and my DTS
    chosen {
        linux,stdout-path = "/plb/opb/serial@ef600500";
    };
which serial@ef600500 is the TTYS2 name

When my kernel start, before serial driver init, all is working
After, this is the same:
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0x4ef600300 (irq = 20) is a 16550A
serial8250.0: ttyS1 at MMIO 0x4ef600400 (irq = 21) is a 16550A
serial8250.0: ttyS2 at MMIO 0x4ef600500 (irq = 29) is a 16550A
console [ttyS2] enabled, bootconsole disabled
console [ttyS2] enabled, bootconsole disabled
serial8250.0: ttyS3 at MMIO 0x4ef600600 (irq = 22) is a 16550A
4ef600300.serial: ttyS0 at MMIO 0x4ef600300 (irq = 20) is a 16550
4ef600400.serial: ttyS1 at MMIO 0x4ef600400 (irq = 21) is a 16550
4ef600500.serial: ttyS2 at MMIO 0x4ef600500 (irq = 29) is a 16550
4ef600600.serial: ttyS3 at MMIO 0x4ef600600 (irq = 22) is a 16550

The latest line I see is:
Freeing unused kernel memory: 148k init


I boot a nfs filesystem, if I add traces (printk) under nfs driver, I
can see my kernel run init (busybox or an openembedded angstrom) is
running, udev is start, login also... all is working well BUT, I can't
see anything on the serial console...

I wrote a small C program
int main(int argc, char *argv[], char *envp[]){
    int i ;
    struct stat stdin_stats, stdout_stats, stderr_stats ;
    printf("Toto\n");
    FILE* f = fopen("wtest.txt","w");
    fwrite("toto\n",strlen("toto\n"),1,f);
    fclose(f);
    return 0;
}
I start it by add to kernel command line "init=/myprog"

I can see on my nfs filesystem the file wtest.txt with "toto" inside,
so, my program is runing, but nothing from the printf on my console...

All printk works (kernel space) but no printf work (userspace).

Anybody have an idea about my problem ?
Or a way to debug this type of problem...
Where I must search ?

Thanks,
Fabien

Re: stdout on ttySX for the first userspace program
This might fix your problem:

In the Linux Kernel section of the Linux Forums at
http://www.linuxforums.org/forum/linux-kernel/88751-redirecting-stdout-stderr-pty0.html
rostfrei says

"console=ttyS0,115200 only implies for the Kernel printouts. If you
want your application printouts on the serial port you have to start
the application in such a way that controlling terminal for that
application is ttyS0.

In my embedded system (Busybox, Init, inittab) I added a line to the /
etc/inittab

ttyS0::respawn:-/bin/sh

Which basically means that shell is started with ttyS0 as it's
controlling terminal. Now every program you start within this shell
also has ttyS0 as controlling terminal."

Site Timeline