I am using Buildroot to build an initramfs image for my IMX Board. On the board, I run a custom Linux 4.19.35 Linux kernel (4.19.35-gexxxxxx) and a custom U-Boot bootloader. Hence, do not require these from Buildroot. My use case is only the rootfs.cpio (initramfs) image that gets built.
I am able to load the above initramfs into memory and execute my custom init and post-init scripts. However, I am unable to spawn an interactive shell. On reaching the command /bin/sh in the init script, I am greeted with a shell prompt but it seems that the serial console is not registering any keyboard inputs. Note that all other shell utilities and commands are executed just fine, but only when they are run in a script. Since one of my objectives is to have a minimal image, I am using busybox (1.32.0).
This gets even more confusing when I run the same initramfs along with the kernel image that is generated by buildroot. In this case, I do get an interactive shell prompt and I am able to enter my input like in a regular terminal.
I am suspecting that this might happen because of the different kernels. The buildroot kernel image is 4.19.35 but the kernel I use is 4.19.35-gexxxxx. However, I am not sure how the initramfs might be dependent on the kernel version string.
Any directions on what might be going wrong would be very helpful.
Edit 1: Below is my init code:
#!/bin/sh
/bin/mount -t devtmpfs devtmpfs /dev
export PATH=/sbin:/usr/sbin:/bin:/usr/bin
[ -d /dev ] || mkdir -m 0755 /dev
[ -d /root ] || mkdir -m 0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
[ -d /run ] || mkdir /run
mkdir -p /dev/pts
mkdir -p /var/lock
/bin/mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
/bin/mount -t proc -o nodev,noexec,nosuid proc /proc
/bin/mknod -m 666 /dev/ttyS0 c 4 64
/bin/mknod -m 666 /dev/ttyS0 c 4 64
/bin/mknod -m 622 /dev/console c 5 1
/bin/mknod -m 666 /dev/null c 1 3
/bin/mknod -m 666 /dev/tty c 5 0
/bin/mknod -m 666 /dev/zero c 1 5
/bin/mknod -m 666 /dev/ttymxc3 c 5 1
/bin/sh # --------------------> Spawning a shell
Try using a 5v serial adapter instead of 3.3v - with the lower voltage, you can still see what it's sending, but your adapter doesn't get heard by the device.