SetMacAddress.exe is a sample program that shows how to program the MAC address of the SMSC 91C111 ethernet chip on ADS PXA255 based devices.
USAGE
There are three ways to use SetMacAddress: Command line, ADSLOAD.MAC file, or interactively.
- Command Line:
Example: setmacaddress 11-22-33-44-55-66 If a valid MAC address is provided on the command line in the form shown above, it will be written to the chip. If an invalid parameter is given, the program will exit and print an error message on the debug port.
- ADSLOAD.MAC:
If no command line parameter is given, SetMacAddress will look for the file "ADSLOAD.MAC" in the current directory. If it is found, the next MAC address, as well as the lower and upper bound addresses will be read from the file. If the MAC address is valid and within the given constraints, it will be written to the chip, If an error occurs, the program will terminate and print an error message on the debug port. Otherwise, the current MAC address will be incremented by one and written back to the chip as the next MAC address to write.
File format:
11-22-33-00-cc-50 11-22-33-00-aa-00 11-22-33-00-ff-ff
Line 1 contains the next MAC address to be assigned. Line 2 contains the lower bound of the range of valid MAC addresses. Line 3 contains the upper bound of the range of valid MAC addresses.
- Interactive:
If no command line parameter is given and ADSLOAD.MAC cannot be found, SetMacAddress will prompt the user to enter a MAC address. Once a valid MAC address has been entered, the user will have the option of writing it to the chip or quitting without writing.
| Key APIs Used Virtual Alloc VirtualFree _wfopen fgets
Lines of Code: ~200
|