Enabling Ethernet Connectivity on Octoclock and Octoclock-G

From Ettus Knowledge Base
Revision as of 12:40, 13 January 2020 by SamReiter (Talk | contribs) (Connect Programmer to Octoclock)

Jump to: navigation, search

Application Note Number

AN-800

Revision History

Date Author Details
2020-01-13 Sam Reiter Initial creation

Overview

This application note covers, in detail, the steps required to program an Octoclock or Octoclock-G to allow Ethernet connectivity and communication with UHD. This guide serves as a supplement to the UHD Manual's coverage of the topic. In this guide, we will use Ubuntu 19.10 to program an Octoclock using an ATMEL-ICE programmer.

Verify Current Octoclock Configuration

To get started, we want to make sure that this guide is appropriate for your device(s). Currently shipping Octoclocks will come with the following firmware pre-loaded. You can test which unit you have with a simple ping test:

    1. Connect the 6V DC power supply to the Octoclock
    2. Connect your Octoclock's RJ-45 port to a host PC via an Ethernet cable
    3. Configure your host's Ethernet port to a static connection with the IPV4 address: 192.168.10.1
    4. Configure your host's Ethernet port with a subnet mast of: 255.255.255.0
    5. Turn your host's Ethernet port off and back on for changes to take effect
    6. In a terminal, issue the command:
   ping 192.168.10.3

A successful ping between devices means that your device is already configured with updated firmware and this guide is *not* necessary. At this time, this guide has not been tested for recovering bricked devices.

Tools Required

    1. Philips head screwdriver
    2. ATMEL-ICE Programmer (or comparable AVR programmer) with SPI/ISP cable
    3. Ethernet cable

ATMEL-ICE Configuration

To utilize the ATMEL-ICE programmer, the avrdude utility must be used. The version of avrdude should be >= 6.1. At the time of this guide, version 6.3 is the default install from the Ubunu PPA and programming issues were observed. This guide will cover a build of avrdude 6.1 from source.

Install the following dependencies:

   sudo apt-get install bison flex libftdi1-dev libftdi-dev

Download the avrdude-6.1.tar.gz release here. From this download location, uncompress the directory:

   tar xvzf avrdude-6.1.tar.gz

Enter the source directory

   cd avrdude-6.1/

Run the configure script

   ./configure

Expected output:

<truncated output>

Configuration summary:
----------------------
DO HAVE    libelf
DO HAVE    libusb
DO HAVE    libusb_1_0
DO HAVE    libftdi1
DO HAVE    libftdi (but prefer to use libftdi1)
DON'T HAVE libhid
DO HAVE    pthread
DISABLED   doc
ENABLED    parport
DISABLED   linuxgpio

Build

   make

Install

   sudo make install

Test your avrdude installation

   avrdude -?

Expected output

<truncated output>

avrdude version 6.1, URL: <http://savannah.nongnu.org/projects/avrdude/>

Download Octoclock Firmware

If UHD is not already installed, install your preferred version with this guide: Building and Installing the USRP Open-Source Toolchain (UHD and GNU Radio) on Linux

Download images for UHD:

   sudo uhd_images_downloader

Verify that you have octoclock_bootloader.hex and octoclock_r4_fw.hex

   ls -l /usr/local/share/uhd/images | grep octoclock

Expected output

-rw-r--r-- 1 root root       17332 Jun  6  2019 octoclock_bootloader.hex
-rw-r--r-- 1 root root       22845 Jun  6  2019 octoclock_r4_fw.hex

Change to this directory:

   cd /usr/local/share/uhd/images

Connect Programmer to Octoclock

Begin this guide with the Octoclock unplugged. First, you'll need to remove the top plate from the Octoclock, exposing the PCB. There are 12 screws securing the top plate.

octoclock screws marked.jpg


With the top plate removed, locate the 6-pin header (J108, male) for SPI communication with the ATmega128.

octoclock header spi.jpg


Connect the ATMEL-ICE's 6-pin header (female) to the SPI header of the Octoclock as shown below. The tab of the header should be facing the ATmega128 chip.

octoclock spi orientation.jpeg

Note: If you plug the header in backwards, avrdude is expected to return a "please check your connections" message after a programming failure. See the section "Troubleshooting" at the bottom of this document.

If not already done, connect the other end of the SPI cable to the ATMEL-ICE's AVR squid connector, and connect the ATMEL-ICE to the host computer using the micro-usb port. There should be a single LED lit on the programmer.

Supply power to the Octoclock with the 6V power brick. You should see the Octoclock's Power LED come on and 1 additional green LED on the ATMEL-ICE programmer illuminate.

Program the Octoclock

With the terminal that is open in the same directory as the .hex images, run the following command

   sudo avrdude -p atmega128 -c atmelice_isp -P usb -U efuse:w:0xFF:m -U hfuse:w:0x80:m -U lfuse:w:0xEF:m -U flash:w:octoclock_bootloader.hex:i

If you are using a programmer other than the ATMEL-ICE, you will need to change the -c parameter to match your programmer. Valid programmers for your version of avrdude can be found by running:

   avrdude -c help

The expected output from a successful run of avrdude is as follows:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9702
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "0xFF"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.09s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFF:
avrdude: load data efuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0x80"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.09s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0x80:
avrdude: load data hfuse data from input file 0x80:
avrdude: input file 0x80 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xEF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.09s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xEF:
avrdude: load data lfuse data from input file 0xEF:
avrdude: input file 0xEF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "octoclock_bootloader.hex"
avrdude: can't open input file octoclock_bootloader.hex: No such file or directory
avrdude: read from file 'octoclock_bootloader.hex' failed

avrdude: safemode: Fuses OK (E:FF, H:80, L:EF)

avrdude done.  Thank you.

Uploading Firmware via Ethernet

Upon successful burning of a bootloader, you will now need to upload firmware. Connect the USRP to your host via Ethernet and configure your host's IP as noted in the "Verify Current Octoclock Configuration" section. Next, run

   uhd_find_devices

Expected output:

uhd_find_Devices
--------------------------------------------------
-- UHD Device 0
--------------------------------------------------
Device Address:
    addr: 192.168.10.3
    type: octoclock-bootloader

This means that UHD successfully recognizes your device's bootloader and can download the firmware image. Run the following command:

   uhd_image_loader --args="type=octoclock,addr=192.168.10.3"

Once this completes, your OctoClock will load its firmware. Powercycle the device, then run the uhd_find_devices utility again, and the output should be similar to the following:

--------------------------------------------------
-- UHD Device 0
--------------------------------------------------
Device Address:
    addr: 192.168.10.3
    type: octoclock
    name:
    serial:

Note that the Octoclock will enter its bootloader once it first receives power. It will take ~10s to boot and be recognized as an octoclock as seen in the above output.

Updating the Octoclock's EEPROM

As a final step, the device's EEPROM will need to be updated. On the back of your device, you will see a label sticker with a serial number (labeled S/N) and a MAC address (labeled MAC). For later use, the MAC address will have to be used in a different format than is on the label. As an example, if the label lists the MAC address as 00802F112233, you will need to format it as 00:80:2F:11:22:33.

Update the Octoclock's EEPROM witht he following command:

   <UHD INSTALL DIRECTORY>/lib/uhd/utils/octoclock_burn_eeprom --args="addr=192.168.10.3" --values="mac-addr=<FORMATTED MAC HERE>,ip-addr=192.168.10.3,netmask=255.255.255.0,gateway=192.168.10.1,serial=<SERIAL HERE>,revision=4"

Additional Resources

Troubleshooting

This process has been run and confirmed in Ubuntu 19.10. Other versions of Linux may require different versions of dependencies to be installed.

You can use -v flags with avrdude to make the output verbose, if running into issues. Here is the ouput of avrdude with verbose flags set:

   sudo avrdude -v -v -p atmega128 -c atmelice_isp -P usb -U efuse:w:0xFF:m -U hfuse:w:0x80:m -U lfuse:w:0xEF:m -U flash:w:octoclock_bootloader.hex:i

Output when SPI plug is plugged into the header backwards:

avrdude: Version 6.1, compiled on Jan 10 2020 at 15:41:02
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/usr/local/etc/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : atmelice_isp
avrdude: stk500v2_jtag3_open()
avrdude: usbdev_open(): Found Atmel-ICE CMSIS-DAP, serno: J42700007132
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
avrdude: jtag3_edbg_prepare(): connection status 0x01
avrdude: Sending sign-on command: 0x80 (509 bytes msg)
         AVR Part                      : ATmega128
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    12    64    0 no       4096    8      0  9000  9000 0xff 0xff
           flash         33     6   128    0 yes    131072  256    512  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : JTAG3_ISP
         Description     : Atmel-ICE (ARM/AVR) in ISP mode
avrdude: jtag3_getparm()
avrdude: Sending get parameter (scope 0x01, section 1, parm 0) command: 0x84 (509 bytes msg)
         Vtarget         : 2.7 V
         SCK period      : 125.00 us

avrdude: jtag3_setparm()
avrdude: Sending set parameter (scope 0x12, section 0, parm 0) command: 0x80 (509 bytes msg)
avrdude: jtag3_setparm()
avrdude: Sending set parameter (scope 0x12, section 0, parm 1) command: 0x80 (509 bytes msg)
avrdude: jtag3_setparm()
avrdude: Sending set parameter (scope 0x12, section 1, parm 0) command: 0x80 (509 bytes msg)
avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500v2_jtag3_close()
avrdude: jtag3_close()
avrdude: Sending AVR sign-off command: 0x80 (509 bytes msg)
avrdude: Sending sign-off command: 0x80 (509 bytes msg)

avrdude done.  Thank you.