Subject: Raspberrypi CM3, u-boot console and kernel patch #raspberrypi #rpi #cm3 #dunfell #kernel #yocto #uboot To: yocto@lists.yoctoproject.org From: "Romain Crausaz" X-Originating-Location: St. Gallen, Saint Gallen, CH (83.150.5.145) X-Originating-Platform: Linux Firefox 82 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Wed, 25 Nov 2020 07:04:13 -0800 Message-ID: <5ExN.1606316653500514733.778K@lists.yoctoproject.org> Content-Type: multipart/alternative; boundary="ekLEeDpvx1LDPHuJ5fh7" --ekLEeDpvx1LDPHuJ5fh7 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Dear all, I have 4 different topics on which I can't find a correct answer on intern= et. I am developing a new system base on the Raspberrypi CM3+ with our custom = board. I am using Yocto with the meta-raspberrypi and the dunfell branch (f= or LTS) Here is what I would like to achieve: * Get UART0 or UART1 as the standard console for u-boot and the linux kern= el on pins 32 and 33 * Make u-boot pass my device tree (stored in the boot partition) to the ke= rnel and not the device tree generated by the first stage bootloader * U-boot message ? * Patch kernel which sources are in work-shared --------------------------------------------------------------------------= ------------------------------------------------------------ Regarding the first point, I already created a new device tree within u-bo= ot and set it as the default bootloader in my default config. I have some t= roubles to understand how everything works between the first stage bootload= er, u-boot, u-boot internal device tree and the kernel device tree. Here is the different things I tried: * Use UART0 on pins 32 and 33 * In the u-boot device tree: >=20 > chosen { > stdout-path =3D "serial0:115200n8"; > } > ... > &uart0 { > pinctrl-names=3D "default"; > pinctrl-0 =3D <&uart0_gpio32>; > status =3D "okay"; > } >=20 * In the config.txt: >=20 > enable_uart=3D1 >=20 > dtoverlay=3Duart0,txd0_pin=3D32,rxd0_pin=3D33,pin_func=3D7 * This works but only for the kernel, I don't get any output from u-boot a= nd can't stop the boot process. * Use UART1 on pins 32 and 33: more or less the same modification but with= different values (uart1_gpio32, serial1, etc..) and same results I would like to know if there is an other file I should modify to get this= working. When I use the uart0 or uart1 on pin 14 and 15 everything works p= erfectly. Here is my device tree patch for u-boot: >=20 > diff --git a/arch/arm/dts/bcm2837-rpi-cm3-digisens.dts > b/arch/arm/dts/bcm2837-rpi-cm3-digisens.dts > index e69de29bb2..f6c0efd18d 100644 > --- a/arch/arm/dts/bcm2837-rpi-cm3-digisens.dts > +++ b/arch/arm/dts/bcm2837-rpi-cm3-digisens.dts > @@ -0,0 +1,175 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/dts-v1/; > +#include "bcm2837.dtsi" > +#include "bcm2836-rpi.dtsi" > +#include "bcm283x-rpi-smsc9514.dtsi" > +#include "bcm283x-rpi-usb-host.dtsi" > + > +/ { > +=C2=A0 =C2=A0 =C2=A0compatible =3D "raspberrypi,3-compute-module", "brc= m,bcm2837"; > +=C2=A0 =C2=A0 =C2=A0model =3D "Raspberry Pi Compute Module 3 DIGI-SENS = baseboard"; > + > +=C2=A0 =C2=A0 =C2=A0memory@0 { > +=C2=A0 =C2=A0 =C2=A0reg =3D <0 0x40000000>; > + }; > + > + leds { > +=C2=A0 =C2=A0 =C2=A0act { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0gpios =3D <&expgpio 2 GPIO_ACTIVE_HIG= H>; > +=C2=A0 =C2=A0 =C2=A0}; > + }; > + > + chosen { > +=C2=A0 =C2=A0 =C2=A0/* 8250 auxiliary UART instead of pl011 */ > +=C2=A0 =C2=A0 =C2=A0stdout-path =3D "serial1:115200n8"; > + }; > + > + reg_3v3: fixed-regulator { > +=C2=A0 =C2=A0 =C2=A0compatible =3D "regulator-fixed"; > +=C2=A0 =C2=A0 =C2=A0regulator-name =3D "3V3"; > +=C2=A0 =C2=A0 =C2=A0regulator-min-microvolt =3D <3300000>; > +=C2=A0 =C2=A0 =C2=A0regulator-max-microvolt =3D <3300000>; > +=C2=A0 =C2=A0 =C2=A0regulator-always-on; > + }; > + > + reg_1v8: fixed-regulator { > +=C2=A0 =C2=A0 =C2=A0compatible =3D "regulator-fixed"; > +=C2=A0 =C2=A0 =C2=A0regulator-name =3D "1V8"; > +=C2=A0 =C2=A0 =C2=A0regulator-min-microvolt =3D <1800000>; > +=C2=A0 =C2=A0 =C2=A0regulator-max-microvolt =3D <1800000>; > +=C2=A0 =C2=A0 =C2=A0regulator-always-on; > +=C2=A0 =C2=A0 =C2=A0}; > +}; > + > +&firmware { > +=C2=A0 =C2=A0 =C2=A0expgpio: gpio { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0compatible =3D "raspberrypi,firmware-= gpio"; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0gpio-controller; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0#gpio-cells =3D <2>; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0gpio-line-names =3D "HDMI_HPD_N", > + "EMMC_EN_N", > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"NC", > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"NC", > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"NC", > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"NC", > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"NC", > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"NC"; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0status =3D "okay"; > + }; > +}; > + > +&hdmi { > +=C2=A0 =C2=A0 =C2=A0hpd-gpios =3D <&expgpio 1 GPIO_ACTIVE_LOW>; > +}; > + > +&uart1 { > +=C2=A0 =C2=A0 =C2=A0pinctrl-names =3D "default"; > +=C2=A0 =C2=A0 =C2=A0pinctrl-0 =3D <&uart0_gpio32>; > +=C2=A0 =C2=A0 =C2=A0status =3D "okay"; > +}; > + > + > +&sdhost { > +=C2=A0 =C2=A0 =C2=A0pinctrl-names =3D "default"; > +=C2=A0 =C2=A0 =C2=A0pinctrl-0 =3D <&sdhost_gpio48>; > +=C2=A0 =C2=A0 =C2=A0bus-width =3D <4>; > +=C2=A0 =C2=A0 =C2=A0vmmc-supply =3D <®_3v3>; > +=C2=A0 =C2=A0 =C2=A0vqmmc-supply =3D <®_1v8>; > +=C2=A0 =C2=A0 =C2=A0status =3D "okay"; > +}; >=20 (in my defconfig for u-boot I have the following default device tree param= eter:=C2=A0+CONFIG_DEFAULT_DEVICE_TREE=3D"bcm2837-rpi-cm3-digisens") --------------------------------------------------------------------------= ------------------------------------------------------------ The second point seems pretty clear to me. I will change the bootscript an= d load the file with the fatload command and pass it to the kernel. However= I wonder if it might create some problems if the first stage bootloader ha= s already reserved the pins. --------------------------------------------------------------------------= ------------------------------------------------------------ When u-boot is starting correctly (for the moment only on pin 14 and 15) I= have the following warning and I was not able to find any explanation abou= t it: >=20 > U-Boot 2020.01 (Jan 06 2020 - 20:56:31 +0000) >=20 > DRAM: =C2=A0948 MiB > RPI Compute Module 3+ (0xa02100) > MMC: =C2=A0 mmc@7e202000: 0 > Loading Environment from FAT... WARNING at > drivers/mmc/bcm2835_sdhost.c:410/bcm2835_send_command()! > *WARNING at drivers/mmc/bcm2835_sdhost.c:410/bcm2835_send_command()!* > *** Warning - bad CRC, using default environment >=20 > In: =C2=A0 =C2=A0serial > Out: =C2=A0 vidconsole > Err: =C2=A0 vidconsole > Net: =C2=A0 No ethernet found. > starting USB... > Bus usb@7e980000: scanning bus usb@7e980000 for devices... 1 USB Device(= s) > found > scanning usb for storage devices... 0 Storage Device(s) found > Hit any key to stop autoboot: =C2=A00 > *WARNING at drivers/mmc/bcm2835_sdhost.c:410/bcm2835_send_command()!* > *WARNING at drivers/mmc/bcm2835_sdhost.c:410/bcm2835_send_command()!* > switch to partitions #0, OK > mmc0(part 0) is current device > Scanning mmc 0:1... > Found U-Boot script /boot.scr >=20 Should I simply ignore it ? --------------------------------------------------------------------------= ------------------------------------------------------------ Finally I have some troubles when I try to patch the kernel. I have always= been working with IMX SOC and (Karo-electronics bsp). With the meta-raspbe= rry, the kernel sources are in the work-shared directory. When I create a p= atch with for example this command: >=20 > git diff arch/arm/boot/dts/overlays/uart0-cm3-overlay.dts > > /.../0001-uart0.patch >=20 I have the following error when I run bitbake: "Patch failures can be reso= lved in the linux source directory" --------------------------------------------------------------------------= ------------------------------------------------------------ Thank you in advance for your time. Let me know if you need more informati= on. Best regards Romain --ekLEeDpvx1LDPHuJ5fh7 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Dear all,
 
I have 4 different topics on whic= h I can't find a correct answer on internet.

I am developing a new syste= m base on the Raspberrypi CM3+ with our custom board. I am using Yocto with= the meta-raspberrypi and the dunfell branch (for LTS)
 
Here is what I would like to achi= eve:
  1. Get UART0 or UART1 as the standard console for u-boot and the linux ke= rnel on pins 32 and 33
  2. Make u-boot pass my device tree (stored in the boot partition) to the = kernel and not the device tree generated by the first stage bootloader
  3. U-boot message ?
  4. Patch kernel which sources are in work-shared
-------------------------------------= ---------------------------------------------------------------------------= ----------------------
Regarding the first point, I already = created a new device tree within u-boot and set it as the default bootloade= r in my default config. I have some troubles to understand how everything works between the first stage bootloader, u-boo= t, u-boot internal device tree and the kernel device tree.
 <= /div>
Here is the different things I tried:=
  • Use UART0 on pins 32 and 33
    • In the u-boot device tree:
chosen {
    stdout-path =3D "serial0:115200n8";
}
...
&uart0 {
    pinctrl-names=3D "default";
    pinctrl-0 =3D <&uart0_gpio32>;
    status =3D "okay";
}
    • In the config.txt:
enable_uart=3D1
dtoverlay=3Duart0,= txd0_pin=3D32,rxd0_pin=3D33,pin_func=3D7
    • This works but only for the kernel, I don't get any output from u-boot= and can't stop the boot process.
  • Use UART1 on pins 32 and 33: more or less the same modification but wi= th different values (uart1_gpio32, serial1, etc..) and same results
I would like to know if there is an o= ther file I should modify to get this working. When I use the uart0 or uart= 1 on pin 14 and 15 everything works perfectly.
 
Here is my device tree patch for u-bo= ot:
diff --git a/arch/arm/dts/bcm2837-rpi-cm3-digisens.dts b/arch/arm= /dts/bcm2837-rpi-cm3-digisens.dts
index e69de29bb2..f6c0efd18d 100644
--- a/arch/arm/dts/bcm2837-rpi-cm3-digisens.dts
+++ b/arch/arm/dts/bcm2837-rpi-cm3-digisens.dts
@@ -0,0 +1,175 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+#include "bcm2837.dtsi"
+#include "bcm2836-rpi.dtsi"
+#include "bcm283x-rpi-smsc9514.dtsi"
+#include "bcm283x-rpi-usb-host.dtsi"
+
+/ {
+     compatible =3D "raspberrypi,3-compute-module= ", "brcm,bcm2837";
+     model =3D "Raspberry Pi Compute Module 3 DIG= I-SENS baseboard";
+
+     memory@0 {
+     reg =3D <0 0x40000000>;
+ };
+
+ leds {
+     act {
+         gpios =3D <&expgpio 2 G= PIO_ACTIVE_HIGH>;
+     };
+ };
+
+ chosen {
+     /* 8250 auxiliary UART instead of pl011 */
+     stdout-path =3D "serial1:115200n8";
+ };
+
+ reg_3v3: fixed-regulator {
+     compatible =3D "regulator-fixed";
+     regulator-name =3D "3V3";
+     regulator-min-microvolt =3D <3300000>;=
+     regulator-max-microvolt =3D <3300000>;=
+     regulator-always-on;
+ };
+
+ reg_1v8: fixed-regulator {
+     compatible =3D "regulator-fixed";
+     regulator-name =3D "1V8";
+     regulator-min-microvolt =3D <1800000>;=
+     regulator-max-microvolt =3D <1800000>;=
+     regulator-always-on;
+     };
+};
+
+&firmware {
+     expgpio: gpio {
+         compatible =3D "raspberrypi,fi= rmware-gpio";
+         gpio-controller;
+         #gpio-cells =3D <2>;
+         gpio-line-names =3D "HDMI_HPD_= N",
+             "EMMC_EN_N",
+             "NC",
+             "NC",
+             "NC",
+             "NC",
+             "NC",
+             "NC";
+         status =3D "okay";
+ };
+};
+
+&hdmi {
+     hpd-gpios =3D <&expgpio 1 GPIO_ACTIVE= _LOW>;
+};
+
+&uart1 {
+     pinctrl-names =3D "default";
+     pinctrl-0 =3D <&uart0_gpio32>;
+     status =3D "okay";
+};
+
+
+&sdhost {
+     pinctrl-names =3D "default";
+     pinctrl-0 =3D <&sdhost_gpio48>;
+     bus-width =3D <4>;
+     vmmc-supply =3D <&reg_3v3>;=
+     vqmmc-supply =3D <&reg_1v8>;
+     status =3D "okay";
+};
(in my defconfig for u-boot I have th= e following default device tree parameter: +CONFIG_DEFAULT_DEVICE_TREE= = =3D"bcm2837-rpi-cm3-digisens")
 
-------------------------------------= ---------------------------------------------------------------------------= ----------------------
The second point seems pretty clear t= o me. I will change the bootscript and load the file with the fatload comma= nd and pass it to the kernel. However I wonder if it might create some prob= lems if the first stage bootloader has already reserved the pins.
 
-------------------= ---------------------------------------------------------------------------= ----------------------------------------
When u-boot is starting correctly (fo= r the moment only on pin 14 and 15) I have the following warning and I was = not able to find any explanation about it:
U-Boot 2020.01 (Ja= n 06 2020 - 20:56:31 +0000)
 
DRAM:  948 MiB
RPI Compute Module 3+ (0xa02100)
MMC:   mmc@7e202000: 0
Loading Environment from FAT... WARNING at drivers/mmc/bcm2835_sd= host.c:410/bcm2835_send_command()!
WARNING at drivers/mmc/bcm2835_sdhost.c:410/bcm2835_send_= command()!
*** Warning - bad CRC, using default environment
 
In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   No ethernet found.
starting USB...
Bus usb@7e980000: scanning bus usb@7e980000 for devices... 1 USB = Device(s) found
       scanning usb for storage devices... 0 = Storage Device(s) found
Hit any key to stop autoboot:  0
WARNING at drivers/mmc/bcm2835_sdhost.c:410/bcm2835_send_= command()!
WARNING at drivers/mmc/bcm2835_sdhost.c:410/bcm2835_send_= command()!
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
Should I simply ignore it ?
 
-------------------= ---------------------------------------------------------------------------= ----------------------------------------
Finally I have some troubles when I t= ry to patch the kernel. I have always been working with IMX SOC and (Karo-e= lectronics bsp). With the meta-raspberry, the kernel sources are in the wor= k-shared directory. When I create a patch with for example this command:&nb= sp;
 
git diff arch/arm/boot/dts/overlays/uart0-cm3-overlay.dts > /.= ../0001-uart0.patch
I have the following error when I run= bitbake: "Patch failures can be resolved in the linux source directory"
-------------------------------------------------------------------= -------------------------------------------------------------------<= /div>
 
Thank you in advance for your time. L= et me know if you need more information.
 
Best regards
Romain
--ekLEeDpvx1LDPHuJ5fh7--