TS-7970 U-boot Sections: Difference between revisions

From embeddedTS Manuals
Line 16: Line 16:


# Download u-boot for the imx_type variant: [ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7970-linux/u-boot/ here] for a list of images.  See the [[#U-Boot Changelog]] for information on the changes between versions.  
# Download u-boot for the imx_type variant: [ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7970-linux/u-boot/ here] for a list of images.  See the [[#U-Boot Changelog]] for information on the changes between versions.  
2) Install the "imx_usb" loader
# Install the "imx_usb" loader
* [https://community.freescale.com/docs/DOC-94117 IMX USB loader]
* [https://community.freescale.com/docs/DOC-94117 IMX USB loader]


# Disconnect power from the board
# Disconnect power from the board
4) Remove the "CON EN" jumper
# Remove the "CON EN" jumper
5) Apply power to the board
# Apply power to the board
6) Plug a USB type B cable into P2.
# Plug a USB type B cable into P2.
5) Check "dmesg" or lsusb for a new USB connection.  This should show a HID device listing Freescale.   
# Check "dmesg" or lsusb for a new USB connection.  This should show a HID device listing Freescale.   


   hid-generic 0003:15A2:0054.0006: hiddev0,hidraw3: USB HID v1.10 Device [Freescale SemiConductor Inc  SE Blank ARIK] on usb-0000:00:14.0-6.4.2/input0
   hid-generic 0003:15A2:0054.0006: hiddev0,hidraw3: USB HID v1.10 Device [Freescale SemiConductor Inc  SE Blank ARIK] on usb-0000:00:14.0-6.4.2/input0
Line 29: Line 29:
If it does not show this output, an RMA or TS-9468 board will be required to recover the board.  [https://www.embeddedarm.com/support/contact-us.php Contact us for more information].
If it does not show this output, an RMA or TS-9468 board will be required to recover the board.  [https://www.embeddedarm.com/support/contact-us.php Contact us for more information].


6) Hold down SW1
# Hold down SW1
7) Run "imx_usb path/to/u-boot.imx" while still holding down SW1.
# Run "imx_usb path/to/u-boot.imx" while still holding down SW1.
8) Disconnect USB on P2
# Disconnect USB on P2
9) Connect the "CON EN" jumper
# Connect the "CON EN" jumper
10) Plug a USB into P2.   
# Plug a USB into P2.   


At this point on the USB console the board should be stopped in u-boot.  Follow the steps in [[#Update u-boot]] to reinstall the u-boot installed on the SPI flash.
At this point on the USB console the board should be stopped in u-boot.  Follow the steps in [[#Update u-boot]] to reinstall the u-boot installed on the SPI flash.

Revision as of 10:20, 13 February 2017

This platform uses U-Boot as the bootloader to launch the full operating system. The i.MX6 processor loads U-Boot from the on-board 8 MiB SPI flash. U-Boot provides support for loading data from various mediums; this allows booting a kernel from SD, eMMC, SATA, NFS, or USB. U-Boot is a general purpose bootloader that is capable of booting into common Linux distributions, Android, Windows, or custom software OSes.

On a normal boot the output should be similar to the output below:

U-Boot 2014.10-gee73348 (Oct 07 2015 - 11:12:20)

I2C:   ready
DRAM:  1 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
SF: Detected N25Q64 with page size 256 Bytes, erase size 4 KiB, total 8 MiB
In:    serial
Out:   serial
Err:   serial
Net:   using phy at 7
FEC [PRIME]

By default the device will boot to SD or eMMC depending on the status of the "SD Boot" jumper on startup.

To break into the U-Boot console, press and hold the SW1 button while the unit is being powered up. This mode will also check for a USB mass storage device to use for production purposes.

U-Boot Environment

The eMMC flash contains both the U-Boot executable binary and U-Boot environment. Our default build has 2 MiB of environment space which can be used for variables and boot scripts. The following commands are examples of how to manipulate the U-Boot environment:

# Print all environment variables
env print -a

# Sets the variable bootdelay to 5 seconds
env set bootdelay 5;

# Variables can also contain commands
env set hellocmd 'led red on; echo Hello world; led green on;'

# Execute commands saved in a variable
env run hellocmd;

# Commit environment changes to the SPI flash
# Otherwise changes are lost
env save

# Restore environment to default
env default -a

# Remove a variable
env delete emmcboot

U-Boot Commands

# The most important command is 
help
# This can also be used to see more information on a specific command
help i2c

# This is a command added to U-Boot by TS to read the baseboard ID on our 
# System on Module devices
bbdetect
echo ${baseboard} ${baseboardid} 
# The echo will return something similar to:
# TS-8390 2

# Boots into the binary at $loadaddr.  The loaded file needs to have
# the U-Boot header from mkimage.  A uImage already contains this.
bootm
# Boots into the binary at $loadaddr, skips the initrd, specifies
# the FDT addrress so Linux knows where to find the device tree
bootm ${loadaddr} - ${fdtaddr}

# Boot a Linux zImage loaded at $loadaddr
bootz
# Boot in to a Linux zImage at $loadaddr, skip initrd, specifies
# the FDT address to Linux knows where to find the device tree
bootz ${loadaddr} - ${fdtaddr}

# Get a DHCP address
dhcp
# This sets ${ipaddr}, ${dnsip}, ${gatewayip}, ${netmask}
# and ${ip_dyn} which can be used to check if the dhcp was successful

# These commands are used for scripting:
false # do nothing, unsuccessfully
true # do nothing, successfully

# This command can set fuses in the processor
# Setting fuses can brick the unit, will void the warranty,
# and should not be done in most cases
fuse

# GPIO can be manipulated from U-Boot.  Keep in mind that the IOMUX 
# in U-Boot is only setup enough to boot the device, so not all pins will
# be set to GPIO mode out of the box.  Boot to the full operating system
# for more GPIO support.
# GPIO are specified in bank and IO in this manual.  U-Boot uses a flat numberspace,
# so for bank 2 DIO 25, this would be number (32*1)+25=89
# The formula thus being (32*(bank-1)+dio)=flattened_dio
# Note that on some products, bank 1 is the first bank
# Set 2_25 low
gpio clear 83
# Set 2_25 high
gpio set 83
# Read 2_25
gpio input 83

# Control LEDs
led red on
led green on
led all off
led red toggle

# This command is used to copy a file from most devices
# Load kernel from SD
load mmc 0:1 ${loadaddr} /boot/uImage
# Load Kernel from eMMC
load mmc 1:1 ${loadaddr} /boot/uImage
# Load kernel from USB
usb start
load usb 0:1 ${loadaddr} /boot/uImage
# Load kernel from SATA
sata init
load sata 0:1 ${loadaddr} /boot/uImage

# View the FDT from U-Boot
load mmc 0:1 ${fdtaddr} /boot/imx6q-ts4900.dtb
fdt addr ${fdtaddr}
fdt print

# It is possible to blindly jump to any memory location
# This is similar to bootm, but it does not require
# the use of the U-Boot header
load mmc 0:1 ${loadaddr} /boot/custombinary
go ${loadaddr}

# Browse fat, ext2, ext3, or ext4 filesystems:
ls mmc 0:1 /

# Access memory like devmem in Linux, read/write arbitrary memory
# using mw and md
# write
mw 0x10000000 0xc0ffee00 1
# read
md 0x10000000 1

# Test memory.
mtest

# Check for new SD card
mmc rescan
# Read SD card size
mmc dev 0
mmcinfo
# Read eMMC Size
mmc dev 1
mmcinfo

# The NFS command is like 'load', but used over the network
dhcp
env set serverip 192.168.0.11
nfs ${loadaddr} 192.168.0.11:/path/to/somefile

# Test ICMP
dhcp
ping 192.168.0.11

# Reboot
reset

# SPI access is through the SF command
# Be careful with sf commands since
# this is where U-Boot and the FPGA bitstream exist
# Improper use can render the board unbootable
sf probe

# Delay in seconds
sleep 10

# Load HUSH scripts that have been created with mkimage
load mmc 0:1 ${loadaddr} /boot/ubootscript
source ${loadaddr}

# Most commands have return values that can be used to test
# success, and HUSH scripting supports comparisons like
# test in Bash, but much more minimal
if load mmc 1:1 ${fdtaddr} /boot/uImage;
	then echo Loaded Kernel
else
	echo Could not find kernel
fi

# Commands can be timed with "time"
time sf probe

# Print U-Boot version/build information
version

Modify Linux Kernel cmdline

The Linux kernel cmdline can be customized by modifying the cmdline_append variable. The variable contents are clobbered when set, so be sure to specify the full desired cmdline string.

env set cmdline_append console=ttymxc0,115200 init=/sbin/init quiet
env save

The kernel command line can also be modified from from the on-board Linux. Debian (and other distributions) provide a U-Boot utilities package that contains the tools necessary to create a U-Boot script:

apt-get update && apt-get install u-boot-tools -y
echo "env set cmdline_append console=ttymxc0,115200 init=/sbin/init quiet" > /boot/boot.scr
mkimage -A arm -T script -C none -n 'tsimx6 boot script' -d /boot/boot.scr /boot/boot.ub

The boot.scr includes the plain text commands to be run in U-Boot on startup. The mkimage tool adds a checksum and header to this file which can be loaded by U-Boot. The .ub file should not be edited directly.

U-boot Recovery

U-boot includes the CPU setup, and the RAM configuration which runs before u-boot. Separate binaries will his will vary between CPU grade, RAM parts, and RAM sizes. On a functional board run "echo ${imx_type}" this will show which variant of that board.

On startup the TS-7970 checks the SPI flash for a valid boot header in SPI flash. If it does not find one the CPU falls back to the "serial downloader" which allows the CPU to run code sent from USB. If the board has a valid, but broken U-Boot an RMA, or a TS-9468 development board will be required. Contact us in this case.

  1. Download u-boot for the imx_type variant: here for a list of images. See the #U-Boot Changelog for information on the changes between versions.
  2. Install the "imx_usb" loader
  1. Disconnect power from the board
  2. Remove the "CON EN" jumper
  3. Apply power to the board
  4. Plug a USB type B cable into P2.
  5. Check "dmesg" or lsusb for a new USB connection. This should show a HID device listing Freescale.
 hid-generic 0003:15A2:0054.0006: hiddev0,hidraw3: USB HID v1.10 Device [Freescale SemiConductor Inc  SE Blank ARIK] on usb-0000:00:14.0-6.4.2/input0

If it does not show this output, an RMA or TS-9468 board will be required to recover the board. Contact us for more information.

  1. Hold down SW1
  2. Run "imx_usb path/to/u-boot.imx" while still holding down SW1.
  3. Disconnect USB on P2
  4. Connect the "CON EN" jumper
  5. Plug a USB into P2.

At this point on the USB console the board should be stopped in u-boot. Follow the steps in #Update u-boot to reinstall the u-boot installed on the SPI flash.

Linux NFS Boot

U-Boot's NFS support can be used to load your kernel, device tree binary, and root filesystem. The default scripts include an example nfs boot script.

# Set this to your NFS root path.  The server root should be accessible at this path.
env set nfsroot 192.168.0.36:/mnt/storage/imx6/
env save

To boot your NFS root:

# Boot to NFS once
run nfsboot;

# To make the NFS boot the persistent default
env set bootcmd run nfsboot;
env save

Update u-boot

WARNING: Installing your own u-boot is not recommended and may cause the board to fail to boot.

U-boot requires a different build for Quad/Dual and Solo/Duallite. On your current u-boot, type "env print imx_type" and this will return the u-boot build you should use. Copy the u-boot.imx to the SD card, and run:

mmc dev 0
load mmc 0:1 ${loadaddr} /u-boot.imx
sf probe
sf erase 0 0x80000
sf write ${loadaddr} 0x400 $filesize