How to set a fixed MAC address in a LeopardBoard DM36x

From RidgeRun Developer Connection

Jump to:navigation, search



This whitepaper explains how to modify and set the MAC address on a LeopardBoard DM36x. LeopardBoard boards have two independent MAC address: u-boot's MAC address used on u-boot start up and kernel's MAC address used once the Ethernet interface is set up on kernel space.

Modifying U-Boot's MAC address

U-Boot's MAC address on the LeopardBoard DM36x (not applicable to all systems) is wired in software on the file $DEVDIR/bootloader/u-boot-2010.12-rc2-psp03.01.01.39/src/include/configs/davinci_dm36xleopard.h with a line similar to the following:

#define CONFIG_ETHADDR          "00:0C:0C:A0:02:b5"

Since the only way to change the u-boot's MAC address is on code, you need to change this value to the desired MAC address for U-Boot and rebuild it with the following command:

make bootloader

Once your bootloader has been built with the new MAC address just install it in your board by running the following command

make install

This way a new bootloader with a new MAC address will be flashed to the board.

Setting a fixed MAC address for the kernel

By default the kernel will start up with a random and different MAC address each time you reboot your board, sometimes this is not a desired behavior if you need to work with several boards with network connection since the existence of two or more devices with the same MAC address could cause conflicts in the network. The following sections shows how to set a fixed MAC address for the Kernel.

Setting a user defined MAC address

It is possible to set a user defined MAC address for the Kernel. In order to do that we just need to add the following extra kernel parameter

davinci_emac.ethaddr=<MAC address> 


-> Kernel configuration
   -> Extra kernel arguments

where <MAC address> is the desired MAC address in the form: xx:xx:xx:xx:xx:xx

After that you just need to rebuild your cmdline with the following command

make cmdline

and install the SDK on your board

make install

Setting the same MAC address used for u-boot

We also can set a fixed MAC address for the Kernel using the same MAC address that was set for the U-Boot, in order to do that we need to modify the bootcmd parameter in the U-Boot environment. We can find this environment variable either in the u-boot's prompt if we are using NAND booting or in the uEnv.txt file if we are using SD card booting.

In order to set the kernel's MAC address to the u-boot's MAC address follow the next steps:

1. Get into your minicom/termnet session and stop your board on the u-boot's prompt.

2. Type


3. Look for the bootcmd variable, you should see something like this

bootcmd=nboot 0x82000000 0 ${kerneloffset}

4. We need to specify the board to set the MAC address on the bootargs on booting to the same value of the u-boot's ethaddr environment variable, in order to do that we modify the bootcmd as is shown below:

bootcmd=setenv bootargs ${bootargs} davinci_emac.ethaddr=${ethaddr}; nboot 0x82000000 0 ${kerneloffset}

the setenv bootargs ${bootargs} davinci_emac.ethaddr=${ethaddr} command will set as bootargs the old bootargs and will add the MAC address which is set to the same value of the ethaddr variable.

5. Set the new value for the boot command

setenv bootcmd 'setenv bootargs \${bootargs} davinci_emac.ethaddr=\${ethaddr}; nboot 0x82000000 0 \${kerneloffset}'

6. Save the new environment


7. Now your board will boot using the same MAC address in u-boot and kernel.

When you are booting from SD Card you need to modify the uEnv.txt command on it to set the fixed MAC address since is on this file where you will find the bootcmd variable. In order to do that follow the next steps:

1. Insert your SD card in your computer.

2. Open the boot partition.

3. Open the uEnv.txt file, you will find something like this:

bootargs= davinci_enc_mngr.ch0_output=COMPONENT davinci_enc_mngr.ch0_mode=720P-60  davinci_display.cont2_bufsize=6291456 
vpfe_capture.cont_bufoffset=6291456 vpfe_capture.cont_bufsize=12582912 video=davincifb:osd1=0x0x8:osd0=1280x720x16,1800K@0,0:vid0=off:vid1=off  
console=ttyS0,115200n8  dm365_imp.oper_mode=0  vpfe_capture.interface=1  mem=78M root=/dev/mmcblk0p2 rootdelay=2 rootfstype=ext3   
uenvcmd=echo Running uenvcmd ...; run loaduimage;bootm 0x82000000

the bootcmd command is defined at:

uenvcmd=echo Running uenvcmd ...; run loaduimage;bootm 0x82000000

4. We need to modify this command the same way we did on previous section like this

uenvcmd=echo Running uenvcmd ...; setenv bootargs ${bootargs} davinci_emac.ethaddr=${ethaddr}; run loaduimage;bootm 0x82000000

If you are using perl to generate your uEnv.txt file (such as using the RidgeRun installer at $DEVDIR/installer/u-boot-installer/methods/sd_card/installer), you can do something like:

    open (CMD, ">$IMAGEDIR/uEnv.txt");
    print CMD "bootargs=$BOOTARGS\n";
    print CMD "uenvcmd=echo Running uenvcmd ...; ";
    print CMD 'setenv bootargs ${bootargs} davinci_emac.ethaddr=${ethaddr}; ';
    print CMD "run loaduimage;bootm $CONFIG_INSTALLER_LOAD_ADDRS\n";

5. Save the file and boot from your SD card, this time it will boot using the u-boot's MAC address for the kernel.