Using the Atmel AT24MAC402 on Acqua A5

Using the Atmel AT24MAC402 on Acqua A5

An Atmel AT24MAC402 chip is mounted by default on the Acqua A5 SoM. This chip is useful to have:

  • An embedded unique 128-bit serial bumber
  • A factory-programmed unique and valid EUI-48 address
  • An I2C-Compatible 2-Kbit Serial EEPROM

The chip is wired to the SAMA5D3x CPU followind this scheme:

And uses these GPIO lines:

Signal Description Atmel Line Acqua pin
SDA I2C data PE1 N.A.
SCK I2C clock PE2 N.A.
WP Write protect PE7 N.A.

The I2C bus is managed by a bit banging Linux driver and activated by the device tree file in that way:

/* Bit banging I2C wired on the Atmel MAC chip */
i2c3@ {
    compatible = "i2c-gpio";
    gpios = <&pioE 1 0 /* SDA */
             &pioE 2 0 /* SCK */
            >;
    i2c-gpio,delay-us = <4>;    /* ~178 kHz */
    #address-cells = <1>;
    #size-cells = <0>;
};

The I2C address is: 0x58

Unfortunately we don't have yet any driver to manage this chip directly by Linux. This is an easy example in C to read its contents:

#include <stdio.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
#include <errno.h>
 
#define I2C_ADDR 0x58
 
int main (void) {
	char buffer[20];
	int fd;
	int i;
	int len;

	fd = open("/dev/i2c-1", O_RDWR);

	if (fd < 0) {
		printf("Open error: %s\n", strerror(errno));
		return 1;
	}

	if (ioctl(fd, I2C_SLAVE, I2C_ADDR) < 0) {
		printf("ioctl error: %s\n", strerror(errno));
		return 1;
	}

	// 128-bit serial number (Datasheet page 8)

	buffer[0]=0x80;
	if (write(fd, buffer, 1) != 1) {
		printf("Write error: %s\n", strerror(errno));
		return 1;
	}

	if (ioctl(fd, I2C_SLAVE, I2C_ADDR) < 0) {
		printf("ioctl error: %s\n", strerror(errno));
		return 1;
	}

	len=read(fd, buffer, 16);
	if (len<16) {
		printf("Read error: %s\n", strerror(errno));
		return 1;
	}
	 
	printf("128-bit serial number.....: ");
	for (i=0;i<16;i++) {
		printf("%02X ",buffer[i]);
	}
	printf("\n");


	// EUI-48 value (Datasheet page 8)

	buffer[0]=0x9A;
	if (write(fd, buffer, 1) != 1) {
		printf("Write error: %s\n", strerror(errno));
		return 1;
	}

	if (ioctl(fd, I2C_SLAVE, I2C_ADDR) < 0) {
		printf("ioctl error: %s\n", strerror(errno));
		return 1;
	}

	len=read(fd, buffer, 16);
	if (len<16) {
		printf("Read error: %s\n", strerror(errno));
		return 1;
	}
	 
	printf("EUI-48 value (MAC address): ");
	for (i=0;i<6;i++) {
		printf("%02X",buffer[i]);
		if (i<5) 
			printf("-");
	}
	printf("\n");

	
	usleep(100000);
	close(fd);

	return 0;
}	

If you are using a Debian microSD compile this program on board:

# gcc at24mac402.c -o at24mac402
# ./at24mac402 
root@acqua:~# ./at24mac402 
128-bit serial number.....: 0A 70 08 00 64 10 08 41 68 93 A0 00 A0 00 01 00 
EUI-48 value (MAC address): FC-C2-3D-0A-D3-CD

The first three bytes of the EUI-48 read-only address field are called the Organizationally Unique Identifier (OUI) and the IEEE Registration Authority has assigned FCC23Dh as the Atmel, OUI.

It is possible to check it from this web site:

Fill the form:

and press Search! button:

FC-C2-3D   (hex)        Atmel Corporation
  FCC23D     (base 16)      Atmel Corporation
                1150 E Cheyenne Mtn Blvd
                Colorado Springs CO 80906
                UNITED STATES

Links