Adding SATA HD boot support to DM814x U-Boot
TI DM814x/AM287x evaluation platform (TI8148 EVM) can boot from various connected devices depending on the setting of the BTMode[4-0] pins as described in chapter 4.5.2.1 of its respective technical reference manual [1]. Typically the EVM boot its first stage of u-boot as the minimum boot loaders. TI calls it min-nand boot loader configuration. This minimum boot then bootstraps a secondary boot phase which is a a full featured u-boot for this platform. The EV platform has SATA H/W support where I will bring up the SATA HDD in the second phase of booting so that I can load the Linux kernel image from HDD instead of loading it from NAND device.
Objective
While booting from NAND is working perfectly fine, having the option to boot from SATA HDD brings greater flexibility to the platform. I can have many versions of uImage in the disk partition where I can selectively use for booting. I may have five or ten versions of it. It won't matter because I have plenty of disk space to store it, load it and run it instead of limiting myself to the space available in NAND device.
SATA feature implementation
For this development, I use TI's latest SDK [3] and its associated cross toolchain [2]. The EZSDK u-boot source code resides in board-support/u-boot-2010.06-psp04.04.00.01 directory after the EZSDK installation. This would be the version that I modify to add SATA support. The integrated SATA controller of DM814x is capable of supporting up to 3Gbps per HBA port operating in AHCI mode. I will make use of AHCI driver that is already in place with some modifcation needed to get it to work properly.
What is/are needed to get SATA interface working
1) Program the PLL for the correct values. I modify sata_pll_config() of board/ti/ti8148/evm.c for the correct values that use to configure SATA_PLLCFGx as shown in TI document, section 21.3.1, base on the 100MHZ low-jitter clock.
Add small piece of code to program SATA PHY (SERDES) namely the RX and TX configuration registers.
3) Modify drivers/block/ahci.c slighty. The AHCI driver code assumes that the controller is connected via PCI bus which is not true for this EVM platform. Since the integrated SATA controller is memory mapped to the SoC physical address space, the modification is needed. I define CONFIG_SCSI_AHCI_PLAT to disable blocks of code that are PCI related, for example,
#ifndef CONFIG_SCSI_AHCI_PLAT pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor); ... #endif
and replace those blocks where memory mapped access is applicable. I also raise command timeout a little bit to ensure that it works for slower HDD.
4) Add CONFIG_SCSI_AHCI_PLAT for AHCI driver and enable SCSI (AHCI) support in u-boot configuration file, include/configs/ti8148_evm.h for one SCSI HDD, one SCSI LUN.
# define CONFIG_CMD_SCSI 1 ... #ifdef CONFIG_CMD_SCSI #define CONFIG_SCSI_AHCI #define CONFIG_SCSI_AHCI_PLAT #define CONFIG_SYS_SCSI_MAX_DEVICE 1 #define CONFIG_SYS_SCSI_MAX_SCSI_ID 1 #define CONFIG_SYS_SCSI_MAX_LUN 1 #endif
The complete code change is available in my git repository in the form of patch file where it could be patched to the TI's u-boot release directly (https://github.com/souktha/dm814x-u-boot-psp04.04.01). The patch file will patch four files for this implementation, drivers/block/ahci.c, common/cmd_scsi.c, include/configs/ti8148_evm.h, board/ti/ti8148/evm.c.
Building and testing
The code change is for the secondary stage of u-boot so ti8148_evm_config_nand is the configuration to be used when building this platform's u-boot.
Building
$make ARCH=arm ti8148_evm_config_nand $make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
are the command lines for configuring and building u-boot. After building is complete, u-boot.bin can be used for testing.
Testing
The new u-boot can be tested before flashing to NAND partition. To do this, stop the boot during its first stage boot (TI-MIN), then load the code to test it (one HDD connected).
... The 2nd stage U-Boot will now be auto-loaded Please do not interrupt the countdown till ... Hit any key to stop autoboot: 1 TI-MIN#
Use u-boot's loady 0x80800000 to download code to memory via UART port using Y-modem protocol. Once downloading is completed, just go <load address>,
The new u-boot detects the SATA controller as shown just below the text art(line 52). U-Boot's SCSI command and FAT command can be used for the rest of the tests relating to SATA HDD access.
The scan data above (line 1) is the result of the INQUIRY command while the data from part (line 7) is the result from reading HDD partition information. FAT commands that list file on partition as well as loading file are:
U-Boot's bootcmd can then be customize to fatload (line 8) the kernel image from the harddisk instead of NAND or SD card. To do this, set bootcmd='fatload scsi 0 $loadaddr uImage2 && bootm $loadaddr'.
u-boot.bin that is tested above can be flashed to NAND partition. For my case, the partition offset is at 0x20000, and the size of this u-boot is less than 256KB.
After I satisfy with the result, I download and flash to NAND using the commands below.
TI-MIN#nand erase 20000 40000 TI-MIN#nandecc hw 2 TI-MIN#nand write 80800000 20000 40000
Conclusion
Having SATA support added to u-boot for this platform gives me the flexibilty to have multiple images in the FAT partition of the HDD where I can selectively use.
Citations
- 1
-
TMS320DM814x Davinci Digital Video Processor Technical Reference Manual, SPRUGZ8D, Revised April 2013.
- 2
-
arm-2009q1-203-arm-none-linux-gnueabi.bin, TI cross toolchain.
- 3
-
LINUXEZSDK-DAVINCI: Linux EZ Software Development Kit (EZSDK) for DM814x and DM816x- ALPHA,ezsdk_dm814x-evm_5_05_01_04_setuplinux, www.ti.com/tool/linuxezsdk-davinci, v5.05.01.04-ALPHA, 10 OCt, 2012.