First steps with the Cryptocape on the Beaglebone Black

William Waites wwaites at tardis.ed.ac.uk
Mon May 23 09:35:16 UTC 2016


The cryptocape is an addon board for the beaglebone with a TPM, an
SHA256 chip, one for ECC, an EEPROM that does AES, an RTC and an
ATMega328p microcontroller. All of these communicate over I2C, and there
are jumpers to connect UART4 tothe serial port on the ATMega328p. I
wanted to see how much of it I could get working.

Starting with the easiest stuff, the regular EEPROM works, as does the
RTC (with the DS3231 driver taken from 11) and the
micocontroller. Here's how.

First thing is to get the already supported hardware to be
recognised. Changing the hardware configuration means making a dtb file
and causing the bootloader to find it. It was difficult to find
instructions on how to do this. I started from

    sys/boot/fdt/dts/beaglebone-black.dts

and modified it to add,

	am335x {
 		scm at 44e10000 {
			scm-pad-config =
                                ...
				/* UART4 */
				"GPMC_WAIT0", "uart4_rxd", "input_pulldown",
				"GPMC_WPn", "uart4_txd", "output";
                        };
 		};

                ...
                
		/* UART4 attached to the expansion header (11,13) */
	 	uart4: serial at 481a8000 {
			status = "okay";
		};

		i2c2: i2c at 4819c000 {
                        status = "okay";
			/* Cryptocape EEPROM */
			icee at 57 {
				compatible = "atmel,24c256";
				reg = <0x57>;
                                status = "okay";
			};
			/* Cryptocape DS3231 RTC */
			ds3231 at 68 {
				compatible = "maxim,ds3231";
				reg = <0x68>;
				status = "okay";
			};
		};
	};

The first part sets up the pin mux to make UART4 functional, the second
lights up a couple of the I2C devices. The full file is at

    https://tardis.ed.ac.uk/~wwaites/2016/05/bbb-cryptocape.dts

The dts needs to be turned into a binary blob to be understood by the
bootloader, and there is a script in the kernel sources for doing this:

    /usr/src/sys/tools/fdt/make_dts.sh /usr/src/sys bbb-cryptocape.dts .

which will result in a bbb-cryptocape.dtb in the current working
directory. This needs to be copied into /boot/dtb and then the
bootloader needs to be told to use it instead of the default
beaglebone-black.dtb by putting

    fdt_file=bbb-cryptocape.dtb

in /boot/msdos/uenv.txt

Reboot now, or later, some changes to the kernel config are
necessary. First is to add support for the EEPROM

    device       icee      # Generic I2C EEPROM

this Just Works. For the RTC, I am running 10.3 but there is a driver in
11. Adding it to 10.3 is very easy. Just copy the files ds3231.c and
ds3231reg.h from sys/dev/iicbus and add

    dev/iicbus/ds3231.c             optional ds3231

to sys/conf/files. Then add

    device       ds3231    # Maxim DS3231 I2C RTC

to the kernel config. Now build and install the kernel as usual, and on
reboot the following can be seen:

    # dmesg | egrep 'icee|ds3231'
    icee0: <AT24C256> at addr 0xae on iicbus2 
    ds32310: <Maxim DS3231 RTC> at addr 0xd0 on iicbus2
    # sysctl -a | grep ds3231
    dev.ds3231.0.32khz_enable: 1
    dev.ds3231.0.sqw_mode: interrupt
    dev.ds3231.0.sqw_freq: 8192
    dev.ds3231.0.bbsqw: 0
    dev.ds3231.0.temp_conv: 0
    dev.ds3231.0.temperature: 30.7C
    dev.ds3231.0.%parent: iicbus2
    dev.ds3231.0.%pnpinfo: name=ds3231 at 68 compat=maxim,ds3231
    dev.ds3231.0.%location: addr=0xd0
    dev.ds3231.0.%driver: ds3231
    dev.ds3231.0.%desc: Maxim DS3231 RTC
    dev.ds3231.%parent:
    # strings /dev/icee0
    A1BB-BONE-CRYPTO
    00A0SparkFun
    BB-BONE-CRYPTO
    201400000000
    GPG Fingerprint: 0xB5919B1AC7135905F4669C847BFA5031BD2EDEA6

So far so good. Now for the microcontroller, after installing bits of
0.1" header and jumpers to connect the serial ports, flashing the hello
world of micocontrollerdom, blink.hex is a matter of bouncing the
microcontroller's reset line which is attached to GPIO 49 and using the
avrdude program which builds from devel/avrdude:

    gpioctl -c 49 OUT
    gpioctl 49 0
    sleep 1
    gpioctl 49 1
    sudo avrdude -V -F -c arduino -p m328p -b 57600 -P /dev/ttyu1 \
        -U flash:w:blink.hex

Unfortunately it is not possible to *build* blink.hex on the beaglebone
right now because the devel/avr-gcc port is broken: the initial part of
building the crosscompiler works, but when it begins to target the AVR
it is still passing -mfloat-abi=softfp which is unrecognised. This
appears not to be something that can be kludged in the Makefile and is
coming from somewhere deep within gcc, I gave up and just compiled the
program for the microcontroller on an amd64 host.

Perhaps this is more material for the wiki, but I don't seem to have
write access. Still, the search engines find the list archives just
fine. 

Best wishes,
-w

------------------------------------------------+------------------------
William Waites        <wwaites at tardis.ed.ac.uk> : School of Informatics
Synthsys Centre for Mammalian Synthetic Biology : University of Edinburgh
------------------------------------------------+------------------------
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


More information about the freebsd-arm mailing list