Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Cannot change MAC in SAM7X256-EK iwIP demo

Posted by John Q. Publick on April 6, 2006
I quickly and easily compiled and loaded the iwIP demo for the sam7x using crossworks. However, when I attemted to show off to my friends, I found that the demo webserver was not available outside my gateway, although it worked completely within. After some sniffing I discovered that the SAM7X was still using the default MAC of 01:02:03:03:01:00. My thinking is that this is the problem.

Even though I have set a different set of values for the MAC in SAM7_EMAC.h, and the the function prvSetupMACAddress is getting passed the correct values, apparently they don't actually get used by the PHY.

Anyone understand a bit more about this? I have no problem altering the IP, gateway or mask.


RE: Cannot change MAC in SAM7X256-EK iwIP dem

Posted by David Williams on April 7, 2006
Please excuse the question, but presumably you have given the board an IP address that is relevant to the world outside the gateway? A private IP address like 192.168.x.x will not be visible outside the gateway, you need a public one.

I'm about to try some of this stuff too, so keep us posted.

RE: Cannot change MAC in SAM7X256-EK iwIP dem

Posted by Kenneth Trussell on April 7, 2006
Or either you have to have a router (your gateway) that has port mapping capability to map a specific outside IP address and port to an internal IP and port.

RE: Cannot change MAC in SAM7X256-EK iwIP demo

Posted by Richard on April 7, 2006
Here are a few pointers, most of which I think you already know.

+ The MAC address you have set has since been changed in the FreeRTOS download. It was found that this MAC address (having a 1 in the first octet) was not let through by some of the more intelligent routers. The download now includes the following:

#define emacETHADDR0 0
#define emacETHADDR1 0xbd
#define emacETHADDR2 0x33
#define emacETHADDR3 0x06
#define emacETHADDR4 0x68
#define emacETHADDR5 0x22

as a random address with 0 in the first octet. This does not explain why you are not able to change it however.

+ Changing the MAC address should be as simple as changing the header, doing a rebuild, then reprogramming the flash. I have done this many times with no problem. Is it possible that there is an ARP cache somewhere in your network that needs flushing?

+ Being able to access your demo from the internet needs a bit of infrastructure setup. I don't know how your internet is setup, but normally there will be an internal (LAN) that has a local IP configuration (172.25.218.nnn, 192.168.nnn.nnn, 10.10.10.nnn, I think from memory), and an external (WAN) that has a public address which is either fixed or dynamically allocated by your ISP. If your SAM7X is on your LAN with a private address you need to setup the LAN/WAN gateway to direct traffic from the public address to the correct private address and port.

Normally an HTTP request will go to port 80. I have three live demo's running on my private network so they cannot all use port 80 for external access, and I therefore use non standard port numbers externally and use the router to distinguish direct the incoming packets accordingly.

If you just have one board running then its much easier, assuming your SAM7X is using IP address

1) Set your SAM7X to listen on port 80 (this may be the default in the download).

2) Find out what your internet IP address is. An easy way of doing this is to go to www.whatismyip.com. Lets say for example you find it is

3) Setup your router/gateway to direct all port 80 traffic originating from the internet side of the router to local address (NOTE: if you have any other WEB servers on your local network this will stop them working and you will have to switch to a nonstandard port number instead!)

Now when you are on the internet to access the board you type The request will find its way to your router, which will see it is a request on port 80, and direct the request to your LAN IP address The SAM7X will reply (hopefully) back to the gateway, which will then redirect the traffic back to the request source on the internet.

Easy in theory, can be tricky in practice.

One thing to watch out for is if you are doing this from a residential internet account then some ISP's don't let you run a WEB server at home at will block port 80 traffic. If this is the case you are again going to have to switch to a non standard port number to get around it.

Also watch out for your WAN IP address changing. It might get reasigned each time you turn on the router.

Hope this is more helpful than confusing.


RE: Cannot change MAC in SAM7X256-EK iwIP demo

Posted by John Q. Publick on April 7, 2006
I did set the demo device to use a public IP address, and I placed it in our "DMZ" where I have our other public servers, including a web server. (We have a 3com firewall with WAN, DMZ, and LAN ports, with the WAN connected directly to the DSL gateway.) There should be no difficulty with routing or firewalls in this situation AFAIK. As I mentioned, I am able to access the demo server on the DMZ from within our private LAN segment through the firewall, but not from outside our gateway.

As far as an ARP cache, I was clearing it on the host.

In SAM7_EMAC.h I was originally using decimal values for the MAC. For sanity's sake, I tried again using 0x notation.

Lastly, I recompiled the whole project, instead of just doing an incremental build, and voila!, now it is reporting the correct MAC as entered, and the demo can be seen around the world.

I have no idea why that worked, but I assume it has to do with my inexperience with the TOOL! Strange that the IP address would be updated with a "build solution", but not the MAC, considering they are defined in the same header file. I will have to see if I can repeat this...

- J

RE: Cannot change MAC in SAM7X256-EK iwIP dem

Posted by Javier Davila on November 3, 2008

I tried the SAM7x Webserver using uIP, I am using WireShark to capture all the Ethernet traffic.
I could see that the MAC address from the webserver is always (00:00:00:00:00:00)

I have tried to change the MAC address in the FreeRTOSConfig.h but no success.

I have a switch connected to my WebServer and to two computers.. I can access the webserver from
those computers... then I have a router conected to the switch and from the router I have another
computer... From the computer connected to the router I cant access the webserver, I guess is because
my MAC address is not a valid one.

I have build, rebuild,, changed with many different values the MAC address but nothing happened.
Any Suggestions?

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists