weAut_01 / weAutSys    R 2.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
individEEP.c

weAutSys (weAut_01) template to initialise EEPROM This file contains the basic MAC and default IP settings for an individual weAut_01 device. The compilation result goes to the EEPROM. The EEPROM content is the only non-volatile storage to individualize a device surviving re-programming with complete flash erasure, besides the fact that flash content should be type specific.

The individualization is provided here by a small serial number (0..20). To get the result into a boards EEPROM do something like:

       avr-gcc -c -mmcu=atmega1284p -Wl,--section-start=.eeprom=0x0080 -I.  -I ./include individEEP.c -DserNo=1
       avr-objcopy -j .eeprom --change-section-lma .eeprom=128 --no-change-warnings -O ihex individEEP.o  individEEP.hex
       avrdude -p atmega1284p -c avrisp2  -P com4   -U eeprom:w:individEEP.hex:i

Change settings according to programming interface and needs.

This file is part of weAutSys   <weinert-automation.de>

  Copyright © 2013 Albrecht Weinert, Bochum

Author:
Albrecht Weinert   <a-weinert.de>
Revision:
2
Date:
2017-01-25 17:49:03 +0100 (Mi, 25 Jan 2017)
//  SVN last change by $Author: albrecht $


#include "pt/pt.h"
#include "we-aut_sys/common.h"
#include "we-aut_sys/network.h"
#include "we-aut_sys/persist.h"

#ifndef serNo
#warning No (small) serializion number defined. Using 0.
#  define serNo 0x00
#endif

/*  The device's basic default configuration individualized for EEPROM
 *
 *  This structure holds basic configuration data specific to the individual
 *  device. These values typically put starting 0x80 in EEPROM.
 *
 *  Hint: The real address used is found by two step indirection in the EEPROM
 *  itself; see persist.h/c.
 *  Change settings according to programming interface and needs.
 */
INEEPROM (conf_data_t defaultTypeConfData) = {
      {0x40, 0x1B, 0x50, 0xCA, 0xFE, serNo}, // MAC

      0xA1,  // magic number

      /* The default IP configuration */
      {IP_ADD(192, 168, 89, 190+serNo), // IP address
       IP_ADD(255, 255, 255,  0), // net mask
       IP_ADD(192, 168, 89,  11), // default router
       IP_ADD(192, 168, 89,  11), // DNS
       IP_ADD(0, 0, 0,  0), // DNS 2
       IP_ADD(192, 168, 89,  2), // NTP
       IP_ADD(192, 168, 89,  3), // NTP 2
       604800, // lease time (one week)
       0,        // set time (unused)
       DNS1_MSK, // consider only DNS set
       DNS1_MSK | DHCP_MSK  // use DHCP and NTP if possible
      }
};
// As of this writing (April 2013) the magic number is A1 and the EEPROM
// configuration address is 0x80=128. This as well as the structure type used
// may change.
INEEPROM(uint8_t endMarker[3]) = {0x77, 0xFF, 0xDD}; // test end marker example