Special Configuration Section of the EEPROM
|Top Previous Next|
All Tibbo devices have an EEPROM memory (accessible through the stor. object).
Bottom 28 bytes of the EEPROM form a so-called "special configuration section". This section includes:
•8 bytes for storing the MAC address of the device;
•20 bytes for storing the password of the device.
By default, the special configuration area is not accessible to your application- the stor.base property takes care of that. Unless you change it, this property specifies that your application's storage area starts at address 29. To see the MAC or password data, set the stor.base to 1. Reminder: EEPROM addresses are counted from 1.
Bytes 1-8 of the EEPROM store the MAC address of the device. On power-up, the MAC address is read out from the EEPROM and programmed into the Ethernet controller. You can always check the current MAC through the net.mac read-only property of the net. object but there is no direct way to change it. Instead, you can change the MAC address data in the EEPROM itself. Next time the device boots up, it will start using this new address.
MAC address data in the EEPROM has a special format — you have to follow it if you want the MAC to be recognized by the firmware (TiOS). Here is this format:
The byte at address 1 must be set to 6- this means that 6 bytes of data follow (MAC address consists of 6 bytes). Addresses from 2 to 7 carry the MAC address itself. Address 8 stores the checksum, which is calculated like this:
Here is a sample code that stores new MAC address into the EEPROM and then reboots the device:
There are limitations on what MAC address you can set. When loading the MAC into the Ethernet controller, the device always resets the first byte of this address to 0. For example, if you set the MAC to 18.104.22.168.5.6 then the actual MAC used by the device will be 0.2.3.4.5.6.
Bytes 9-28 store device password. The password is stored in the following format:
The byte at address 9 indicates the length of the password (16 bytes max). This is followed by the password itself, followed by 3 check bytes. These bytes are first 3 bytes of the md5 hash calculated over the combined length and password data bytes.
TiOS itself can accept any binary password with 0-16 bytes length (zero means "no password protection"). TIDE software, however, always sets 16-byte passwords. These are MD5 hashes of the actual passwords you type into Enter Device Password and Change Device Password dialogs.
Here is a code snippet that verifies if the password set for the device is really DEVICE_PASSWORD ("Tibbo" in the example below). If the EEPROM data is incorrect, the code sets the right data and reboots the device. By using this sort of code in your project you can make your devices self-protect themselves. This will spare you from manually setting the password for each device through TIDE.