Making an embedded system boot up properly can be quite a hurdle sometimes. Among the various problems you might encounter, those related to your root filesystem are some of the most common ones I have seen and among those a very frequent problem is not being akle to acquire an initial console/terminal.
These boot problems usually manifest themselves with the following two messages:
[1] Warning: unable to open an initial console.
[2] can’t open /dev/
If you see any of these errors this means that a device node which the init process needs in order to open a an initial termnial (console) is missing.
Let’s first deal with
[1] Warning: unable to open an initial console.
To solve this problem (unable to open an initial console) check the /dev directory on your rootfs. It has to have the following files and dirs:
/dev/console - a character device
/dev/pts - a directory
/dev/pts/0 - - a character device
The permissions and the major/minor device numbers of the devices are as follows:
drwxr-xr-x 2 root root 4096 Aug 14 10:34 pts
crwxrwxrwx 1 root root 5, 1 Aug 14 10:30 console
...
crw-r--r-- 1 root root 136, 0 Aug 14 10:34 0
The easiest way to find out the major and minor number of a device is to look in the If either of these is missing you’ll have to create it manually. Create the pts directory with mkdir and then to create the ‘console’ special file do
# sudo mknod console c 5 1
# sudo chmod 777 console
# cd pts
# sudo mknod 0 c 136 0
Rebooting the system now should not show the ‘unable to open an initial console’ error anymore. Let’s move on to the next one:
[2] can’t open /dev/ttyS0: No such file or directory
This problem is very similar to the first one and also happens quite often. Again, a dev node is missing. Let’s create it.
# sudo mknod ttyS0 c 204 40
# sudo chmod 664 ttyS0
Other devices such as null, zero, random, urandom could also be missing, the problems manifesting themselves with messages like:
can't open '/dev/null'
Create the nodes for the missing devices to fix this.
The next thing that I encountered was missing libs:
-sh: can't load library 'libgcc_s.
-sh: can't load library 'libc.so'
The files were indeed missing, not only in /lib directory of the root fs but they were not to be found anywhere in the root filesystem tree.
The libgcc so I simply copied from my buildroot output to lib and then created a symlink for it as well:
# ln -s libgcc_s.so.1 libgcc_s.so
The libc so was not really missing – I built my system with uClibc and the uclibc so was there, in /lib but it also wanted a libc.so symlink to it so all I had to do was:
# ln -s libuClibc-0.9.33.2.so libc.so
# ln -s libuClibc-0.9.33.2.so libc.so.0