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>; 
        }; 
      }; 
      &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 mainline kernel source code.

    $ wget raw.githubusercontent.com/torvalds/linux/refs/heads/master/drivers/net/phy/microchip_t1s.c

  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.