title: How to change a mac address using the command line parameters in the linux kernel
body: <p>I want to change a mac address at the u-boot level like the following.</p>
  
  <pre><code># setenv bootargs 'console=ttyAMA0,115200n8 root=/dev/ram0 rw initrd=0x40000000 ethaddr=${ethaddr}'
  # setenv ethaddr 11:22:33:44:55:66
  # saveenv
  </code></pre>
  
  <p>And at the driver,</p>
  
  <pre><code>static unsigned char my_ethaddr[MAX_ADDR_LEN];
  
  /* need to get the ether addr from armboot */
  static int __init ethaddr_setup(char *line)
  {
          char *ep;
          int i;
  
          printk("command line : %s\n", line);
  
          memset(my_ethaddr, 0, MAX_ADDR_LEN);
          /* there should really be routines to do this stuff */
          for (i = 0; i &lt; 6; i++)
          {
                  my_ethaddr[i] = line ? simple_strtoul(line, &amp;ep, 16) : 0;
                  if (line)
                          line = (*ep) ? ep+1 : ep;
                  printk("mac[%d] = 0x%02Xn", i, my_ethaddr[i]);
          }
          return 0;
  }
  __setup("ethaddr=", ethaddr_setup);
  </code></pre>
  
  <p>When booting, the log message is like following.</p>
  
  <pre><code>[    0.000000] Kernel command line: console=ttyAMA0,115200n8 root=/dev/ram0 rw initrd=0x40000000 ethaddr=${ethaddr}
  [    0.000000] command line : ${ethaddr}
  [    0.000000] mac[0] = 0x00, mac[1] = 0x00, mac[2] = 0x0E, mac[3] = 0x00, mac[4] = 0xDD, mac[5] = 0x00
  </code></pre>
  
  <p>The command line message is ${ethaddr}, is it right?
  The mac address isn't correct.</p>
  
  <p>How can I fix it?</p>