Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Mar 2020 10:16:49 -0700
From:      Mark Millard <marklmi@yahoo.com>
To:        Toomas Soome <tsoome@me.com>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: head -r538966 on OrangePi+ 2ed: boot loader crashes when USB drive is present at power-on/boot: its a misaligned access by code from -r354746
Message-ID:  <541CAE86-B6DA-4BCA-B6B2-D0B0A13DBE1A@yahoo.com>
In-Reply-To: <26DEEA3C-C880-410C-BCB4-CE1314EAFA02@me.com>
References:  <863312E1-4216-49BA-A623-CAC85F123655@yahoo.com> <30A666F0-8773-41B7-AD37-7E319AA510CA@yahoo.com> <26DEEA3C-C880-410C-BCB4-CE1314EAFA02@me.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On 2020-Mar-19, at 02:00, Toomas Soome <tsoome@me.com> wrote:

> I think this should fix it. We need to create copy of dos partition =
array, so we will get proper alignment.=20
>=20
>=20
> tsoome@freebsd-2:/usr/src % svn diff stand/common/part.c
> Index: stand/common/part.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
> --- stand/common/part.c	(revision 359099)
> +++ stand/common/part.c	(working copy)
> @@ -654,6 +654,7 @@
>  	int has_ext;
>  #endif
>  	table =3D NULL;
> +	dp =3D NULL;
>  	buf =3D malloc(sectorsize);
>  	if (buf =3D=3D NULL)
>  		return (NULL);
> @@ -708,7 +709,11 @@
>  		goto out;
>  	}
>  	/* Check that we have PMBR. Also do some validation. */
> -	dp =3D (struct dos_partition *)(buf + DOSPARTOFF);
> +	dp =3D malloc(NDOSPART * sizeof(struct dos_partition));
> +	if (dp =3D=3D NULL)
> +		goto out;
> +	bcopy(buf + DOSPARTOFF, dp, NDOSPART * sizeof(struct =
dos_partition));
> +
>  	/*
>  	 * In mac we can have PMBR partition in hybrid MBR;
>  	 * that is, MBR partition which has DOSPTYP_PMBR entry defined =
as
> @@ -770,6 +775,7 @@
>  #endif /* LOADER_MBR_SUPPORT */
>  #endif /* LOADER_MBR_SUPPORT || LOADER_GPT_SUPPORT */
>  out:
> +	free(dp);
>  	free(buf);
>  	return (table);
>  }
> tsoome@freebsd-2:/usr/src %

That is working for me: the OPi+2e now boots with the
USB drive plugged in ahead of time, without manual
intervention to assign loaderdev :

FreeBSD/armv7 U-Boot loader, Revision 1.3

DRAM: 2048MB
Number of U-Boot devices: 2
U-Boot env: loaderdev not set, will probe all devices.
Found U-Boot device: disk
  Probing all <unknown> devices...
  Checking unit=3D0 slice=3D<auto> partition=3D<auto>... good.
Booting from disk0p1:
Loading /boot/defaults/loader.conf
Loading /boot/device.hints
Loading /boot/loader.conf
Loading /boot/loader.conf.local
Loading kernel...
/boot/kernel/kernel text=3D0x90b3fc data=3D0xa85a8 data=3D0x0+0x200000 =
syms=3D[0x4+0xa1660+0x4+0x113e7c]
Loading configured modules...
/boot/kernel/umodem.ko text=3D0x1520 text=3D0xf10 data=3D0x234+0x4 =
syms=3D[0x4+0xe70+0x4+0xa74]
loading required module 'ucom'
/boot/kernel/ucom.ko text=3D0x1714 text=3D0x2c7c data=3D0x484+0x838 =
syms=3D[0x4+0x13e0+0x4+0xbac]
/boot/entropy size=3D0x1000

Hit [Enter] to boot immediately, or any other key for command prompt.
. . .

Thanks!

> . . .


=3D=3D=3D
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?541CAE86-B6DA-4BCA-B6B2-D0B0A13DBE1A>