Date:2015-06-07 00:28:03 (4 years 3 months ago)
Author:Stefan Schmidt
Commit:583a7b72ee2177391e6dca273a62ae17b70eb2fa
Message:atusb/fw: add EUI64 read and write fw interface to permanently set an EUI64

The kernel driver will now ask for ATUSB_EUI64_READ during init and sets this
extended address if available. Use the atusb-eui64 utility from the tools folder
to read or set the permanent address.

After a new address is set the device will reset to make sure we are in a sane
state after the change.
Files: atusb/fw/ep0.c (4 diffs)
atusb/fw/include/atusb/atusb.h (2 diffs)

Change Details

atusb/fw/ep0.c
33 *
44 * Written 2008-2011, 2013 by Werner Almesberger
55 * Copyright 2008-2011, 2013 Werner Almesberger
6 * Copyright 2015-2016 Stefan Schmidt
67 *
78 * This program is free software; you can redistribute it and/or modify
89 * it under the terms of the GNU General Public License as published by
...... 
1617#include <string.h>
1718
1819#include <avr/io.h>
20#include <avr/eeprom.h>
21
22#define F_CPU 8000000UL
23#include <util/delay.h>
1924
2025#ifndef NULL
2126#define NULL 0
...... 
4449static uint8_t size;
4550
4651
52static void do_eeprom_write(void *user)
53{
54    int i;
55
56    for (i = 0; i < size; i++)
57        eeprom_update_byte((uint8_t*)i, buf[i]);
58}
59
4760static void do_buf_write(void *user)
4861{
4962    uint8_t i;
...... 
246259        return mac_rx(setup->wValue);
247260    case ATUSB_TO_DEV(ATUSB_TX):
248261        return mac_tx(setup->wValue, setup->wIndex, setup->wLength);
262    case ATUSB_TO_DEV(ATUSB_EUI64_WRITE):
263        debug("ATUSB_EUI64_WRITE\n");
264        usb_recv(&eps[0], buf, setup->wLength, do_eeprom_write, NULL);
265        _delay_ms(100);
266        reset_cpu();
267        return 1;
268
269    case ATUSB_FROM_DEV(ATUSB_EUI64_READ):
270        debug("ATUSB_EUI64_READ\n");
271        eeprom_read_block(buf, (const void*)0, 8);
272        usb_send(&eps[0], buf, 8, NULL, NULL);
273        return 1;
249274
250275    default:
251276        error("Unrecognized SETUP: 0x%02x 0x%02x ...\n",
atusb/fw/include/atusb/atusb.h
4646    ATUSB_SPI_WRITE2_SYNC,
4747    ATUSB_RX_MODE = 0x40, /* HardMAC group */
4848    ATUSB_TX,
49    ATUSB_EUI64_WRITE = 0x50, /* Parameter in EEPROM grp */
50    ATUSB_EUI64_READ,
4951};
5052
5153/*
...... 
7779 *
7880 * host-> ATUSB_RX_MODE on - 0
7981 * host-> ATUSB_TX flags ack_seq #bytes
82 * host-> ATUSB_EUI64_WRITE - - #bytes (8)
83 * ->host ATUSB_EUI64_READ - - #bytes (8)
8084 */
8185
8286#define ATUSB_REQ_FROM_DEV (USB_TYPE_VENDOR | USB_DIR_IN)

Archive Download the corresponding diff file



interactive