From 98cdb123ebf2dffcb19c4d903328e8de5b93ebc8 Mon Sep 17 00:00:00 2001 From: Oliver Rew Date: Tue, 14 Jan 2020 21:17:18 -0800 Subject: [PATCH] added some octavo board utils --- .../oresat-camera-card-v0/rev0_notes.txt | 6 +- utils/flash_emmc.txt | 71 +++++++++++++++++++ utils/i2c-program-board-id.py | 46 ++++++++++++ 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 utils/flash_emmc.txt create mode 100755 utils/i2c-program-board-id.py diff --git a/oresat-camera-hardware/oresat-camera-card-v0/rev0_notes.txt b/oresat-camera-hardware/oresat-camera-card-v0/rev0_notes.txt index 3fe5b5f..50813cc 100644 --- a/oresat-camera-hardware/oresat-camera-card-v0/rev0_notes.txt +++ b/oresat-camera-hardware/oresat-camera-card-v0/rev0_notes.txt @@ -7,4 +7,8 @@ - all parts should have correct MPN as attribute - D1 should user amber LED part, not green - 10uF 0603 should be 0805 -- in attributes, note part numbers for different temperature grades for ICs, like CLVCH16T245MDGGREP vs 74LVCH16T245DGGRE4 \ No newline at end of file +- in attributes, note part numbers for different temperature grades for ICs, like CLVCH16T245MDGGREP vs 74LVCH16T245DGGRE4 +- swap tx and rx on UART header +- fix resistor on MIC842 +- separate C38 and C37 +- fake label text bigger \ No newline at end of file diff --git a/utils/flash_emmc.txt b/utils/flash_emmc.txt new file mode 100644 index 0000000..8da4c27 --- /dev/null +++ b/utils/flash_emmc.txt @@ -0,0 +1,71 @@ +####################### +#### Enabling eMMC #### +####################### + +# build the needed eMMC device tree file +$ cd/opt/source/bb.org-overlays +$ make +... + +# copy the device tree file to /lib/firmware +$ cp /src/arm/BB-BONE-eMMC1-01-00A0.dtbo /lib/firmware + +# add the below line to your /boot/uEnv.txt file +uboot_overlay_addr4=/lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo + +# reboot and you should see mmcblk1 in /dev + +####################### +#### Flashing eMMC #### +####################### + +# grow the sd card partition so we have room to download the image +$ cd /opt/scripts/tools +$ sudo ./grow_partition.sh +$ sudo reboot + +# download the latest image, this might take a while +$ curl -O https://debian.beagleboard.org/images/bone-debian-9.9-iot-armhf-2019-08-03-4gb.img.xz + +# if you don't have internet on the board, download it +# to your computer and scp it onto the board + +# be root +$ sudo su + +# dd the image onto the eMMC. This could take +# a while, it took me 5~10 minutes +$ sudo xzcat bone-debian-9.9-iot-armhf-2019-08-03-4gb.img.xz | dd of=/dev/mmcblk1 bs=1M + +############################ +#### Make eMMC Bootable #### +############################ + +# the eMMC is now flashed, but we still have a few steps before it will boot Debian. +# recall before when we have to add the dtbo to /lib/firmware and modify the uEnv.txt +# file in order to enable the eMMC. Well, if we tried to boot the eMMC right now, it +# would boot into uBoot, but would not boot Debian because uBoot would not enable the +# eMMC for linux and thus there would be not roots. So, we need to add that device tree +# to the system on the eMMC and tell it to use it. + +# mount the eMMC +$ sudo mount /dev/mmcblk1p1 /mnt + +# copy the dtbo onto the eMMC system +$ cp /lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo /mnt/lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo + +# add the below line to the eMMC system uEnv.txt file (/mnt/boot/uEnv.txt) +uboot_overlay_addr4=/lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo + +# unmount the eMMC +$ sudo umount /mnt + +# shutdown +$ sudo shutdown -h now + +# unplug the micro SD card +# switch the sys boot jumpers to boot from the eMMC(mmc1) +# to boot from the SD card, the should be sysboot[4:0] == 0b11000 +# to boot from the eMMC, they should be sysboot[4:0] == 0b11100 + +# cycle power and it should boot into Debian on the eMMC \ No newline at end of file diff --git a/utils/i2c-program-board-id.py b/utils/i2c-program-board-id.py new file mode 100755 index 0000000..93e412c --- /dev/null +++ b/utils/i2c-program-board-id.py @@ -0,0 +1,46 @@ +#!/usr/bin/python3 + +# This script writes the board ID to the EEPROM in the OSD3358 and reads +# it back afterwards. I ran it on another pocketbealge using i2c-2, but +# it would probably work on other boards with a i2c peripheral + +import io +import fcntl + +# I think this is python ioctl/i2c specific? not sure +IOCTL_I2C_SLAVE = 0x0703 + +# board ID byte array, notice 2 non-ascii hex chars +board_id = b"\xaaU3\xeeA335PBGL00A21740GPB43424" + +# start of i2c message with EEPROM 16 bit address 0x0000 +msg = bytearray([0x00, 0x00]) + +# append board ID to address to create full message +msg.extend(board_id) + +# open the I2C device and set it up to talk to the slave +f = io.open("/dev/i2c-2", "wb+", buffering=0) +fcntl.ioctl(f, IOCTL_I2C_SLAVE, 0x50) + +# write the board ID message to the EEPROM +f.write(msg) + +# after receiving the write bytes, the EEPROM takes some time to write it to +# memory. The chip with NAK during this time, so the datasheet suggests polling +# the chip via i2c until it acks a command, at which point it can handle more +# commands. Here we attempt the initial command of reading back what we just +# wrote(which is a write to 0x0000), and when the chip ACKs the command, we can +# proceed with the read +while True: + # attempt the write to setup a read from 0x0000 + try: + f.write(bytearray([0x00, 0x00])) + break + # handle the OSError exception returned when we get a NAK + except OSError as err: + continue + +# read back the board id and print it +v = f.read(len(board_id)) +print("Board ID:", v)