Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Feb 2013 10:03:20 +0100
From:      Nick Hibma <nick@van-laarhoven.org>
To:        =?windows-1252?Q?=93FreeBSD_Current_Mailing_List=94?= <freebsd-current@freebsd.org>
Subject:   Re: No console, not even serial, does not work (init fails)
Message-ID:  <D8863C8D-9BF3-440B-AB70-4237B1A32779@van-laarhoven.org>
In-Reply-To: <96A2B40B-4191-4C4F-8AA5-39526E252D40@van-laarhoven.org>
References:  <96A2B40B-4191-4C4F-8AA5-39526E252D40@van-laarhoven.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Ed sent me a answer to my ramblings:

"It is indeed true that init(8) is a bit picky when you don't have a
console. If /dev/console cannot be opened, init(8) will just break
completely. This has been fixed in FreeBSD -HEAD, where I've extended
init(8) to handle this gracefully, specifically for cases where you
have hardware without a console or potentially want to run init(8) in
a jail (though we're not there yet)."

http://svnweb.freebsd.org/base?view=3Drevision&revision=3D232977

I'll try that, and will follow up here.

Nick Hibma
nick@van-laarhoven.org

Collect, process, organize, review and do. - GTD

On 18 Feb 2013, at 20:30, Nick Hibma <nick@van-laarhoven.org> wrote:

> 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.
>=20
> The problem is that FreeBSD does not handle well the case where there =
is no console at all:
>=20
> 1) http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dbin/102515
>=20
> 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'.
>=20
> 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.
>=20
>=20
> As far as I can see this is still a problem in CURRENT.
>=20
>=20
> 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.
>=20
>=20
> Any pointers as to who/how to resolve this issue? Any reason why the =
null console approach does not work?
>=20
> Nick Hibma
> nick@van-laarhoven.org
>=20
> GTD: Time management for chaotic people.
>=20
> 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)
> +{
> +}
>=20




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D8863C8D-9BF3-440B-AB70-4237B1A32779>