Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jul 2022 15:33:02 -0700
From:      Mark Millard <marklmi@yahoo.com>
To:        "Dr. Rolf Jansen" <freebsd-rj@cyclaero.com>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>, John Kennedy <warlock@phouka.net>
Subject:   Re: Failed to execute custom kernels which where build on a RPi 4 operated by 13.1-RELEASE
Message-ID:  <DE77E564-3D5A-43A5-B68D-408237D623FA@yahoo.com>
In-Reply-To: <E1353A37-4AC5-48FB-9209-358C245963C0@cyclaero.com>
References:  <B1296677-558F-49F3-B7B7-2784ACA6612B@cyclaero.com> <YsOU/Gzxnrq6H2sJ@phouka1.phouka.net> <D523159F-CEF5-4F98-92E8-11C79F5C6419@cyclaero.com> <YsRB9uOlUNOoDBVu@phouka1.phouka.net> <71D4E84B-5D80-43A5-BE22-8E4F6486B7E4@cyclaero.com> <DD01DB57-7E6D-496F-9D31-762964F52388@yahoo.com> <E1353A37-4AC5-48FB-9209-358C245963C0@cyclaero.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2022-Jul-8, at 14:34, Dr. Rolf Jansen <freebsd-rj@cyclaero.com> =
wrote:
>=20
>> Am 06.07.2022 um 02:01 schrieb Mark Millard <marklmi@yahoo.com>:
>>=20
>> On 2022-Jul-5, at 08:09, Dr. Rolf Jansen <freebsd-rj@cyclaero.com> =
wrote:
>>=20
>>>> . . .
>>>=20
>>> That would be the second step. The first step would be that somebody =
else confirms my finding that building and running a custom kernel on a =
stock FreeBSD 13.1-RELEASE on RPi 4 does not work out. And actually that =
was my initial question.
>>>=20
>>> (1) In case somebody raises her/his hand telling, that this worked =
flawlessly on their system,
>>> then I would have a more in deep look, what might have gone wrong =
here.
>>>=20
>>> (2) In case the issue would be confirmed, then I would submit a bug =
report, and the discussion
>>> may continue in a more productive way on bugs.freebsd.org.
>>=20
>> Summary of the later material:
>>=20
>> It would appear that if building any kernels are
>> broken, it is specific to some custom kernel(s)
>> in question, not to building kernels in general.
>> 13.1-RELEASE's install is able to build, install,
>> and boot its own generic kernel on a 8GiByte
>> RPi4B Rev. 1.4.
>=20
> So we are talking about case (1 - works flawlessly as expected), and =
as I promised, I will look more in deep on what might have gone wrong =
here. For those who want to reproduce building of kernels completely =
from the scratch on the RPi 4 in the shortest possible way, I leave a =
transcript of the procedure at the very bottom of this message (see: *** =
Installing FreeBSD on a microSD card and building a (custom) kernel =
****).
>=20
> Results with the thus builded kernels:
>=20
> 13.1-GENERIC does work
> 13.1-GENERIC-MMCCAM does boot from the microSD, but USB does not work

But for use of sys/arm64/conf/GENERIC-MMCCAM . . .
For my example context, booting via a USB3 port with USB3
media attached booted just fine. I reported this in a
later message. But it was an older "BOT" (3 GiByte DMA
limitation) SOC Rev 1.4 board RPi4B (8 GiByte).

(I did not even test booting from microsd media at
all.)

> 13.1-GNNERIC-RPi4 stalls when booting.
> cat /usr/src/sys/arm64/conf/GENERIC-RPi4
>   include	GENERIC
>   ident	GENERIC-RPi4
>   nooptions	SOC_NVIDIA_TEGRA210
>=20
> In the serial console:
>   ...
>   mmcsd0: Error indicated: 1 Timeout
>   mountroot: waiting for device /dev/ufs/rootfs...
>   bcm_dma0: DMA error 4 on CH5
>   Mounting from ufs:/dev/ufs/rootfs failed with error 19.

I will note that there are DMA related differences in
our contexts. An example that I know of is:

A) The "B0T" SOC's have limitations, such as the restriction
   to the lower 3 GiByte range.

B) The "C0T" SOC's do not have that limitation.

Normally (A) vs. (B) only matters for the 4 GiByte and 8
GiByte RPi4B variants, if I understand right.

My understanding is that the device tree handed over by
the RPi* firmware has differences for (A) vs. (B) via
dynamic adjustments to the .dtb content after it is
loaded. But I've no clue if such might have contributed
to what you observed.

> My conclusion is that we may not completely disable NVIDIA Tegra 210. =
And after all, my goal was not exactly to disable the Tegra, but to =
mitigate the egoistic behaviour of its internal RTC driver for the =
MAX77620 (all i2c-addr 68 is mine). I achieved that goal by replacing in =
the source file /usr/src/sys/arm64/nvidia/tegra210/max77620_rtc.c (of =
13.1-RELEASE) the I2C address from 0x68 to 0x7F. Nothing uses 0x7F and =
so the MAX77620 driver may claim it for itself without harm to other =
devices.
>=20
> sed -e "s/#define MAX77620_RTC_I2C_ADDR.0x68/#define =
MAX77620_RTC_I2C_ADDR   0x7F/" \
>    -i "" /usr/src/sys/arm64/nvidia/tegra210/max77620_rtc.c=20
>=20
> 13.1-GENERIC (patched) does work, including the DS3231 RTC on i2c1 =
address 0x68.
>=20
>   ...
>   iicbus0: <OFW I2C bus> on iichb0
>   iic0: <I2C generic I/O> on iicbus0
>   ds32310: <Maxim DS3231 RTC> at addr 0xd0 on iicbus0
>   ...
>   ...
>   mmcsd0: 16GB <SDHC SL16G 8.0 SN 399D0D61 MFG 09/2016 by 3 SD> at =
mmc1 50.0MHz/4bit/65535-block
>   bcm2835_cpufreq0: ARM 1500MHz, Core 500MHz, SDRAM 400MHz, Turbo ON
>   ds32310: registered as a time-of-day clock, resolution 1.000000s
>   ...
>=20
> Many thanks for all your inputs and efforts.

Glad to hear that you got it going.

> Best regards
>=20
> Rolf
>=20
>=20
> *** Installing FreeBSD on a microSD card and building a (custom) =
kernel ****
>=20
> 1. Fetch the image and write it to a pristine microSD card:
>=20
>   # fetch =
https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/13.1/FreeBS=
D-13.1-RELEASE-arm64-aarch64-RPI.img.xz
>   # xz -d FreeBSD-13.1-RELEASE-arm64-aarch64-RPI.img.xz
>   # dd if=3DFreeBSD-13.1-RELEASE-arm64-aarch64-RPI.img of=3D/dev/da0 =
bs=3D1m conv=3Dsync
>=20
>=20
> 2. Preparation before the first start which automatically would max. =
out the UFS partition.
>   Hovever, I want to reserve space for a 2 GB swap partition
>   (omit this step, in case you don't want a swap p.):
>=20
>   # gpart resize -i 2 da0
>   # gpart show da0 da0s2
>   =3D>      63  31116225  da0  MBR  (15G)
>           63      2016       - free -  (1.0M)
>         2079    102312    1  fat32lba  [active]  (50M)
>       104391  31011897    2  freebsd  (15G)
>=20
>   =3D>       0  31011897  da0s2  BSD  (15G)
>            0        57         - free -  (29K)
>           57   6186880      1  freebsd-ufs  (2.9G)
>      6186937  24824960         - free -  (12G)
>=20
>   Calculate the base (start) of the swap partition, e.g. here: 6186937 =
+ 24824960 - 4*1024*1024 =3D 26817593
>   # gpart add -b 26817593 -t freebsd-swap da0s2
>   # gpart show da0s2
>   =3D>       0  31011897  da0s2  BSD  (15G)
>            0        57         - free -  (29K)
>           57   6186880      1  freebsd-ufs  (2.9G)
>      6186937  20630656         - free -  (9.8G)
>     26817593   4194304      2  freebsd-swap  (2.0G)
>=20
>=20
> 3. Start the RPi 4 with the SD card and enter via serial console as =
root:
>=20
>   login: root
>   Password:
>   May 12 08:46:57 generic login[1206]: ROOT LOGIN (root) ON ttyu0
>   FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC
>=20
>   Welcome to FreeBSD!
>=20
>   Release Notes, Errata: https://www.FreeBSD.org/releases/
>   Security Advisories:   https://www.FreeBSD.org/security/
>   FreeBSD Handbook:      https://www.FreeBSD.org/handbook/
>   FreeBSD FAQ:           https://www.FreeBSD.org/faq/
>   Questions List:        =
https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/
>   FreeBSD Forums:        https://forums.FreeBSD.org/
>=20
>   Documents installed with the system are in the =
/usr/local/share/doc/freebsd/
>   directory, or can be installed later with:  pkg install =
en-freebsd-doc
>   For other languages, replace "en" with a language code like de or =
fr.
>=20
>   Show the version of FreeBSD installed:  freebsd-version ; uname -a
>   Please include that output and any error messages when posting =
questions.
>   Introduction to manual pages:  man man
>   FreeBSD directory layout:      man hier
>=20
>   To change this login announcement, see motd(5).
>=20
>   root@generic:~ # gpart show
>   =3D>      63  31116225  mmcsd0  MBR  (15G)
>           63      2016          - free -  (1.0M)
>         2079    102312       1  fat32lba  [active]  (50M)
>       104391  31011897       2  freebsd  (15G)
>=20
>   =3D>       0  31011897  mmcsd0s2  BSD  (15G)
>            0        57            - free -  (29K)
>           57  26814464         1  freebsd-ufs  (13G)
>     26814521      3072            - free -  (1.5M)
>     26817593   4194304         2  freebsd-swap  (2.0G)
>=20
>=20
> 4. Donwload and install the sources:
>=20
>   # cd /
>   # fetch --no-verify-peer =
https://download.freebsd.org/releases/arm64/aarch64/13.1-RELEASE/src.txz
>   # tar -xzf src.txz
>=20
>=20
> 5. Build and install the GENERIC kernel
>=20
>   # cd /usr/src
>   # make -j4 buildkernel KERNCONF=3DGENERIC
>   # make installkernel KERNCONF=3DGENERIC
>=20
>=20
> 6. Restart the RPi 4


=3D=3D=3D
Mark Millard
marklmi at yahoo.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DE77E564-3D5A-43A5-B68D-408237D623FA>