Skip to end of metadata
Go to start of metadata

The following is an example of modifying barebox source code by appending the barebox recipe in meta-phytec. This example is based on the PD15.1.0 release for phyCORE-AM335x, and applies a patch to switch the serial console from UART0 to UART1.

In order to make porting to future releases more seamless, it is recommended that you create your own meta-layer when making changes to the BSP rather than modify the source code directly. For in-depth information on creating a new layer and using bbappend files, section 5.1 of the Yocto project Development Manual is a great reference: http://www.yoctoproject.org/docs/1.7.1/dev-manual/dev-manual.html#understanding-and-creating-layers

Step-by-step guide

  1. Follow Section 5.1.1 of the Yocto Project Development Manual to create your own layer.

  2. Create the following directories in your custom meta-layer to match the path to the barebox recipe in meta-phytec:

     

    mkdir recipes-bsp/
    mkdir recipes-bsp/barebox/
    mkdir recipes-bsp/barebox/files/
  3. The following patch modifies arch/arm/dts/am335x-phytec-phycore-som.dtsi. The UART1_rxd and UART1_txd pins are configured with the appropriate pads and the existing UART1 node is configured to have control over these pins. Once UART1 is configured, the standard output path is switched from UART0 to UART1. Download the patch and save it to your meta-layer under recipes-bsp/files/.

    From 9f49aed044075f438bb73c61912058801fb21eed Mon Sep 17 00:00:00 2001
    From: Anna Horstmann <ahorstmann@phytec.com>
    Date: Mon, 2 Mar 2015 10:35:13 -0800
    Subject: [PATCH] ARM: dts: am335x-phytec-phycore-som.dtsi: set console to UART1
    ---
     arch/arm/dts/am335x-phytec-phycore-som.dtsi | 15 ++++++++++++++-
     1 file changed, 14 insertions(+), 1 deletion(-)
    diff --git a/arch/arm/dts/am335x-phytec-phycore-som.dtsi b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
    index 8c40c06..379911d 100644
    --- a/arch/arm/dts/am335x-phytec-phycore-som.dtsi
    +++ b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
    @@ -1,6 +1,6 @@
     / {
     	chosen {
    -		linux,stdout-path = &uart0;
    +		linux,stdout-path = &uart1;
    
     		environment-spi {
     			compatible = "barebox,environment";
    @@ -39,6 +39,13 @@
     			0x174 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart0_txd.uart0_txd */
     		>;
     	};
    +	
    +	uart1_pins: pinmux_uart1_pins {
    +                pinctrl-single,pins = <
    +                        0x180 (PIN_INPUT_PULLUP | MUX_MODE0)    /* uart1_rxd.uart1_rxd */
    +                        0x184 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart1_txd.uart1_txd */
    +                >;
    +        };
    
     	mmc1_pins: pinmux_mmc1_pins {
     		pinctrl-single,pins = <
    @@ -173,6 +180,12 @@
     	status = "okay";
     };
    
    +&uart1 {
    +        pinctrl-names = "default";
    +        pinctrl-0 = <&uart1_pins>;
    +        status = "okay";
    +};
    +
     &davinci_mdio {
     	pinctrl-names = "default";
     	pinctrl-0 = <&davinci_mdio_default>;
    -- 
    1.9.1
  4. Create a file recipes-bsp/barebox/barebox_%.bbappend to append the barebox recipe that is in the meta-phyam335x meta layer. The following lines will include the patch in the build:

    FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
    
    SRC_URI += " \
        file://0001-ARM-dts-am335x-phytec-phycore-som.dtsi-set-console-to-UART1.patch \
    "


  5. Once the changes have been made, rebuild barebox with the following command (executed from the Yocto build directory):

     bitbake barebox -f -c compile && bitbake barebox
  6. Copy the images to your desired boot source. 

  7. For the kernel to use UART1 as the serial console instead of UART0, change the file /etc/inittab in the root filesystem. If booting from SD card, this can be done from your Host machine. Modify the line “O0:12345:respawn:/sbin/getty 115200 ttyO0” to:

    O1:12345:respawn:/sbin/getty -L 115200 ttyO1

The following is an example of modifying barebox source code by appending the barebox recipe in meta-phytec. This example is based on the PD15.1.0 release for phyCORE-AM335x, and applies a patch to switch the serial console from UART0 to UART1.

In order to make porting to future releases more seamless, it is recommended that you create your own meta-layer when making changes to the BSP rather than modify the source code directly. For in-depth information on creating a new layer and using bbappend files, section 5.1 of the Yocto project Development Manual is a great reference: http://www.yoctoproject.org/docs/1.7.1/dev-manual/dev-manual.html#understanding-and-creating-layers

Step-by-step guide

  1. Follow Section 5.1.1 of the Yocto Project Development Manual to create your own layer.

  2. Create the following directories in your custom meta-layer to match the path to the barebox recipe in meta-phytec:

     

    mkdir recipes-bsp/
    mkdir recipes-bsp/barebox/
    mkdir recipes-bsp/barebox/files/
  3. The following patch modifies arch/arm/dts/am335x-phytec-phycore-som.dtsi. The UART1_rxd and UART1_txd pins are configured with the appropriate pads and the existing UART1 node is configured to have control over these pins. Once UART1 is configured, the standard output path is switched from UART0 to UART1. Download the patch and save it to your meta-layer under recipes-bsp/files/.

    From 9f49aed044075f438bb73c61912058801fb21eed Mon Sep 17 00:00:00 2001
    From: Anna Horstmann <ahorstmann@phytec.com>
    Date: Mon, 2 Mar 2015 10:35:13 -0800
    Subject: [PATCH] ARM: dts: am335x-phytec-phycore-som.dtsi: set console to UART1
    ---
     arch/arm/dts/am335x-phytec-phycore-som.dtsi | 15 ++++++++++++++-
     1 file changed, 14 insertions(+), 1 deletion(-)
    diff --git a/arch/arm/dts/am335x-phytec-phycore-som.dtsi b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
    index 8c40c06..379911d 100644
    --- a/arch/arm/dts/am335x-phytec-phycore-som.dtsi
    +++ b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
    @@ -1,6 +1,6 @@
     / {
     	chosen {
    -		linux,stdout-path = &uart0;
    +		linux,stdout-path = &uart1;
    
     		environment-spi {
     			compatible = "barebox,environment";
    @@ -39,6 +39,13 @@
     			0x174 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart0_txd.uart0_txd */
     		>;
     	};
    +	
    +	uart1_pins: pinmux_uart1_pins {
    +                pinctrl-single,pins = <
    +                        0x180 (PIN_INPUT_PULLUP | MUX_MODE0)    /* uart1_rxd.uart1_rxd */
    +                        0x184 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart1_txd.uart1_txd */
    +                >;
    +        };
    
     	mmc1_pins: pinmux_mmc1_pins {
     		pinctrl-single,pins = <
    @@ -173,6 +180,12 @@
     	status = "okay";
     };
    
    +&uart1 {
    +        pinctrl-names = "default";
    +        pinctrl-0 = <&uart1_pins>;
    +        status = "okay";
    +};
    +
     &davinci_mdio {
     	pinctrl-names = "default";
     	pinctrl-0 = <&davinci_mdio_default>;
    -- 
    1.9.1
  4. Create a file recipes-bsp/barebox/barebox_%.bbappend to append the barebox recipe that is in the meta-phyam335x meta layer. The following lines will include the patch in the build:

    FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
    
    SRC_URI += " \
        file://0001-ARM-dts-am335x-phytec-phycore-som.dtsi-set-console-to-UART1.patch \
    "


  5. Once the changes have been made, rebuild barebox with the following command (executed from the Yocto build directory):

     bitbake barebox -f -c compile && bitbake barebox
  6. Copy the images to your desired boot source. 

  7. For the kernel to use UART1 as the serial console instead of UART0, change the file /etc/inittab in the root filesystem. If booting from SD card, this can be done from your Host machine. Modify the line “O0:12345:respawn:/sbin/getty 115200 ttyO0” to:

    O1:12345:respawn:/sbin/getty -L 115200 ttyO1

Related articles