Reputation: 1547
My system (ARM32) is booting Linux via U-Boot.
The kernel gets console=ttymxc1,115200
as an argument from u-boot.
Then it uses a shell script with switch_root
(interpreted by busybox
) inside a initramfs for initializing the root filesystem.
Furthermore this initramfs script parses the kernel commandline to get the correct console
.
The problem is that switch_root
is printing to tty1
. Nonetheless the kernel uses the correct console, specified in its arguments.
If I pass no -c
argument to switch_root
it also uses /dev/tty1
, which is the display in my case.
Does anybody of you have an idea how I could get init
(sysvinit) to use the console specified in the kernel arguments?
Here's the initramfs script source:
#!/bin/sh
echo "init: rootfs setup"
# mount temporary filesystems
mount -n -t devtmpfs devtmpfs /dev
mount -n -t proc proc /proc
mount -n -t sysfs sysfs /sys
mount -n -t tmpfs tmpfs /run
read -r cmdline < /proc/cmdline
# define filesystems
ROOT_DEV="/dev/mydev"
ROOT="/newroot"
# mount rootfs
mkdir -p ${ROOT}
mount ${ROOT_DEV} ${ROOT}
# get & create console
CONSOLE=$(echo $cmdline) | sed 's/.*console=\(.*\),.*/\1/'
mknod -m 644 ${ROOT}/dev/${CONSOLE} c 5 1
# switch to new rootfs and exec init
echo "init: rootfs successful mounted (${ROOT})"
cd ${ROOT}
exec switch_root -c /dev/${CONSOLE} . "/sbin/init" "$@"
And here's the initramfs config.cfg
dir /bin 755 1000 1000
dir /dev 755 0 0
dir /mnt 755 0 0
dir /proc 755 0 0
dir /run 755 0 0
dir /sys 755 0 0
file /bin/busybox initramfs/busybox 755 0 0
file /init initramfs/init 755 0 0
nod /dev/console 644 0 0 c 5 1
nod /dev/ttymxc1 644 0 0 c 5 1
slink /bin/chroot busybox 777 0 0
slink /bin/find busybox 777 0 0
slink /bin/grep busybox 777 0 0
slink /bin/mkdir busybox 777 0 0
slink /bin/mknod busybox 777 0 0
slink /bin/mount busybox 777 0 0
slink /bin/sed busybox 777 0 0
slink /bin/sh busybox 777 0 0
Upvotes: 2
Views: 2896
Reputation: 1547
Finally I found the solution (and the mistake I made)!
The console device was created with the wrong major/minor numbers. Creating it with the same as the kernel assigns to ttymxc* it works:
mknod -m 644 ${ROOT}/dev/${CONSOLE} c 207 17
Upvotes: 2