2.3 Configure and Build the Linux Kernel

  1. Enter the Linux directory.

    $ cd linux/

  2. Create a configuration file (.config) with default configuration.

    $ make sama5_defconfig

  3. Open the sama5d29_curiosity EV07R15A SAMA5D29 Curiosity Development Board’s dts file.
  4. Add the two nodes: “&macb0” and “&pioA”.

    $ vim arch/arm/boot/dts/microchip/at91-sama5d29_curiosity.dts

      &macb0 { 
        pinctrl-names = "default"; 
        pinctrl-0 = <&pinctrl_macb0_default>; 
        #address-cells = <1>; 
        #size-cells = <0>; 
        phy-mode = "rmii"; 
        status = "okay"; 
    
        ethernet-phy@0 { 
          reg = <0x0>;
          // Wake In pin feature is supported only in devices of Rev. D0 
          wakein-gpios = <&pioA PIN_PA27 GPIO_ACTIVE_HIGH>;
        }; 
      }; 
      &pioA { 
        pinctrl_macb0_default: macb0-default {
          pinmux = <PIN_PB14__GTXCK>, 
            <PIN_PB15__GTXEN>, 
            <PIN_PB16__GRXDV>, 
            <PIN_PB17__GRXER>, 
            <PIN_PB18__GRX0>, 
            <PIN_PB19__GRX1>, 
            <PIN_PB20__GTX0>, 
            <PIN_PB21__GTX1>, 
            <PIN_PB22__GMDC>, 
            <PIN_PB23__GMDIO>; 
          bias-disable; 
        }; 
      };
    After adding the above nodes, the .dts file should look like this:

  5. Download the latest LAN8670 PHY driver file from the net-next Linux kernel repository.

    $ wget -qO- "https://kernel.googlesource.com/pub/scm/linux/kernel/git/netdev/net-next/+/refs/heads/main/drivers/… | base64 --decode > microchip_t1s.c

    : The basic init settings and Link Status Feature support for the LAN8670 Rev. D0 PHY driver patch have been reviewed and accepted by the Linux mainline maintainers. The patch is currently available in the net-next repository and will be merged into the main Linux kernel repository (torvalds/linux.git) during the next merge window.
    : Development of advanced feature support for the LAN8670 Rev. D0 PHY driver is currently in progress for upstream integration. So, if you require Advanced Features Support you can obtain the latest LAN8670 Rev. D0 PHY driver source file from the Microchip product website until these features are included into the mainline kernel.
    : For LAN8670 Rev. D0 revision chips with advanced features support, follow steps 5.a - 5.d below. Subsequently, skip step number 6 and proceed with step number 7.
    1. Come out of the Linux directory and download the LAN867x Linux driver package file from the microchip product site.

      $ cd ..

      $ wget https://ww1.microchip.com/downloads/aemDocuments/documents/AIS/ProductDocuments/CodeExamples/EVB-LAN8670-USB_Linux_Driver_4v1.zip

    2. Extract the downloaded software package into your local directory.

      $ unzip EVB-LAN8670-USB_Linux_Driver_4v1.zip

    3. Get the LAN867x PHY driver file from the below directory.

      $ cd EVB-LAN8670-USB_Linux_Driver_4v1/lan867x-linux-driver-4v1/src/evb-lan8670-rmii/

    4. Copy the microchip_t1s.c file into linux/drivers/net/phy/ directory.

      $ cp microchip_t1s.c ../../../linux/drivers/net/phy/

  6. Replace the existing LAN8670 PHY driver file in the Linux kernel source code directory by copying the latest version of the LAN8670 PHY driver file that you have downloaded.

    $ cp microchip_t1s.c drivers/net/phy/

    Important: The git clone command downloads the kernel source code corresponding to Linux kernel version 6.12. However, support for the latest LAN8670 PHY revisions C1 and C2 is available only from Linux kernel version 6.13 onwards. Therefore, you need to download the latest LAN8670 PHY driver file from the main kernel source code and copy it into your current directory, which is “linux-6.12-mchp”. If you are using LAN8670 Rev B1, you may skip steps 5 and 6 above and proceed with the subsequent instructions.
  7. Configure LAN8670 support in the kernel.

    $ make menuconfig

    The kernel configuration window opens.

  8. Enable PHY driver support.

    Select “Device Drivers >> Network device support >> PHY Device support and infrastructure >> Microchip 10BASE-T1S Ethernet PHYs”

    Important: Make sure there is a “*” next to “Microchip 10BASE-T1S Ethernet PHYs”. If not, select the entry and press the space bar to cycle through the options. The “*” means the drivers will be built into the kernel.
  9. Save the configuration.
  10. Build the Linux kernel image.

    $ make -j8

  11. Create a uImage.
    $ make uImage LOADADDR=0x20008000
    Tip: Install u-boot-tools if you get the following error: "mkimage" command not found - U-Boot images will not be built.

    $ sudo apt-get install u-boot-tools

  12. Compile device tree source file.

    $ make dtbs

    If the building process is successful, the final images can be found in the arch/arm/boot/ directory.

  13. Come out of the Linux directory to create device tree overlay blob files. Run the following commands:

    $ cd ..

    $ git clone https://github.com/linux4microchip/dt-overlay-mchp.git

    $ cd dt-overlay-mchp/

    $ make sama5d29_curiosity_dtbos

    $ make sama5d29_curiosity.itb

  14. Replace the generated .itb file into the SD card’s below location (boot partition).

  15. Close the terminal window.