Date: Mon, 18 Feb 2013 20:30:11 +0100 From: Nick Hibma <nick@van-laarhoven.org> To: =?windows-1252?Q?=93FreeBSD_Current_Mailing_List=94?= <freebsd-current@freebsd.org> Subject: No console, not even serial, does not work (init fails) Message-ID: <96A2B40B-4191-4C4F-8AA5-39526E252D40@van-laarhoven.org>
next in thread | raw e-mail | index | archive | help
We run our NanoBSD images on Soekris and ALIX hardware. In some cases we = need all available serial ports for other hardware like GPS, and modems. = The boards have no video, so with all serial ports unavailable as a = console no other console is available. The problem is that FreeBSD does not handle well the case where there is = no console at all: 1) http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dbin/102515 fsck_ufs crashes (6.1-STABLE). Because of the unitialised console libc = somehow gets corrupted and crashes fsck_ufs. This problem can be = circumvented by replacing 'fsck -p' with 'fsck < /dev/null > /dev/null'. 2) In 8.3-RELEASE init exits prematurely because it cannot open = /dev/console for reading and writing in setctty(). Removing the calls to = _exit(1) in that function makes the boot complete. I haven't checked = whether the fsck_ufs problem still appears as our builds run with a = patched rc.d script. As far as I can see this is still a problem in CURRENT. My attempt at resolving this was to create a null terminal in = dev/null/null.c, see the patch below, but that did not work as expected. = After booting the system with a modified init the response to 'echo > = /dev/console' was 'Device not configured'. I've added another CN_* = priority to make sure a null console does not take precedence over for = example gdb console. Any pointers as to who/how to resolve this issue? Any reason why the = null console approach does not work? Nick Hibma nick@van-laarhoven.org GTD: Time management for chaotic people. Index: /usr/src/sys/sys/cons.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /usr/src/sys/sys/cons.h (revision 242660) +++ /usr/src/sys/sys/cons.h (working copy) @@ -69,10 +69,11 @@ =20 /* values for cn_pri - reflect our policy for console selection */ #define CN_DEAD 0 /* device doesn't exist */ -#define CN_LOW 1 /* device is a last restort only */ -#define CN_NORMAL 2 /* device exists but is nothing special = */ -#define CN_INTERNAL 3 /* "internal" bit-mapped display */ -#define CN_REMOTE 4 /* serial interface with remote bit set = */ +#define CN_NULL 1 /* no console at all */ +#define CN_LOW 2 /* device is a last restort only */ +#define CN_NORMAL 3 /* device exists but is nothing special = */ +#define CN_INTERNAL 4 /* "internal" bit-mapped display */ +#define CN_REMOTE 5 /* serial interface with remote bit set = */ =20 /* Values for cn_flags. */ #define CN_FLAG_NODEBUG 0x00000001 /* Not supported with = debugger. */ Index: /usr/src/sys/dev/null/null.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /usr/src/sys/dev/null/null.c (revision 242660) +++ /usr/src/sys/dev/null/null.c (working copy) @@ -41,6 +41,9 @@ #include <sys/bus.h> #include <sys/filio.h> =20 +#include <sys/cons.h> +#include <sys/consio.h> + #include <machine/bus.h> =20 /* For use with destroy_dev(9). */ @@ -173,3 +176,45 @@ =20 DEV_MODULE(null, null_modevent, NULL); MODULE_VERSION(null, 1); + +static cn_probe_t null_cnprobe; +static cn_init_t null_cninit; +static cn_term_t null_cnterm; +static cn_getc_t null_cngetc; +static cn_putc_t null_cnputc; + +CONSOLE_DRIVER(null); + +static void +null_cnprobe(struct consdev *cp) +{ + sprintf(cp->cn_name, "null"); + cp->cn_pri =3D CN_NULL; +} + +static void +null_cninit(struct consdev *cp) +{ +} + + +static void +null_cnputc(struct consdev *cp, int c) +{ + (void) cp; + + (void) c; +} + +static int +null_cngetc(struct consdev * cp) +{ + (void) cp; +=09 + return -1; +} + +static void +null_cnterm(struct consdev * cp) +{ +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?96A2B40B-4191-4C4F-8AA5-39526E252D40>