Wiki

This version is outdated by a newer approved version.DiffThis version (08 Dec 2020 08:41) is a draft.
Approvals: 0/1

This is an old revision of the document!


Loading file from USB storage in u-boot

Overview

This document talks about how we can load files on USB memory stick, into system RAM from u-boot. Here we take ADSP-SC573 board as example.

Hardware Setup

  • An ADSP-SC5xx EZ-Board:
    • ADSP-SC589 Ezkit v1.1 and above, or,
    • ADSP-SC584 Ezkit v1.0 and above, or,
    • ADSP-SC573 Ezkit v1.2 (BOM 1.8) and above
  • A USB memory stick
  • A USB adapter cable (provided in the ezkit box)

Connect USB stick to the USB OTG port, via the USB adapter cable, as following, and reset the board 

Test method

Formatting the USB stick

Insert the USB memory stick into a Linux PC, you will see new items show up in /dev/sd*, as following:

$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sdb  /dev/sdb1

In this case the /dev/sdb is for the USB stick we just plugged in.

Caution : Please double check the device node newly created for your memory stick, otherwise serious damage like system permanent crash down happens!

The format a vfat partiton on it:

$ sudo mkfs.vfat /dev/sdb1
[sudo] password for ...
mkfs.vfat 3.0.12 (29 Oct 2011)

Copy files in it

$ sudo mount /dev/sdb1 /mnt
$ cd build/tmp/deploy/images/adsp-sc573-ezkit
$ sudo cp zImage /mnt/zImage
$ sudo cp adsp-sc5xx-ramdisk-adsp-sc573-ezkit.cpio.gz.u-boot /mnt/ramdisk.cpio.gz.u-boot
$ sudo cp sc573-ezkit.dtb /mnt
$ sudo umount /mnt

Then plug the USB stick to the USB OTG port in board, via the USB adapter cable, and reset the board 

Start the USB

Run “start usb” In the u-boot console:

sc # usb start
(Re)start USB...
USB0:   scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found

 

Run “fatls usb 0:1” In the u-boot console:

sc # fatls usb 0:1
 12452384   zImage
    10306   sc573-ezkit.dtb
2 file(s), 0 dir(s)

This shows the FAT files information in USB device 0 partition 1, with files we copied.

Load file into RAM

 As example we load both the dtb, zImage and the ramdisk file into proper location.

Don't forget to change the file/dtb name and load address according to your board type (i.e. SC589-ezkit or SC584-ezkit or SC573-ezkit), otherwise it may not boot properly.

sc # fatload usb 0:1 0x84000000 sc573-ezkit.dtb
reading sc573-ezkit.dtb
10306 bytes read in 30 ms (335 KiB/s)
sc # fatload usb 0:1 0x82000000 zImage
reading zImage
12452384 bytes read in 7772 ms (1.5 MiB/s)

 Verify the read operation:

sc # bootz 0x82000000 - 0x84000000
## Booting kernel from Legacy Image at 82000000 ...
   Image Name:   Linux-4.0.0-ADI-1.1.0-00027-g5c7
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    12452320 Bytes = 11.9 MiB
   Load Address: 82008000
   Entry Point:  82008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 84000000
   Booting using the fdt blob at 0x84000000
   Loading Kernel Image ... OK
   Loading Device Tree to 8fe5d000, end 8fe62841 ... OK
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 4.0.0-ADI-1.1.0-00027-g5c77b60 (i7@i7-OptiPlex-9010) (gcc version 4.8.3 (Analog Devices Inc. ARM Tools (e596c0da91703b047df99f5513e6
CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: ADI sc57x-ezkit
bootconsole [earlycon0] enabled
Memory policy: Data cache writeback
dump init clock rate
CGU0_PLL 450 MHz
CGU0_SYSCLK 225 MHz
CGU0_CCLK 450 MHz
CGU0_SYS0 112 MHz
CGU0_DCLK 225 MHz
CGU0_OCLK 150 MHz
CGU0_SYS0 112 MHz
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 56896
Kernel command line: root=/dev/mtdblock2 rw rootfstype=jffs2 clkin_hz=(25000000) earlyprintk=serial,uart0,57600 console=ttySC0,57600 mem=224M
PID hash table entries: 1024 (order: 0, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 215024K/229376K available (3139K kernel code, 96K rwdata, 1184K rodata, 7736K init, 71K bss, 14352K reserved, 0K cma-reserved)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xce800000 - 0xff000000   ( 776 MB)
    lowmem  : 0xc0000000 - 0xce000000   ( 224 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc044113c   (4325 kB)
      .init : 0xc0442000 - 0xc0bd0000   (7736 kB)
      .data : 0xc0bd0000 - 0xc0be81e0   (  97 kB)
       .bss : 0xc0be81e0 - 0xc0bfa098   (  72 kB)
NR_IRQS:16 nr_irqs:16 16
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
sched_clock: 32 bits at 112MHz, resolution 8ns, wraps every 38177486839ns
Console: colour dummy device 80x30
Calibrating delay loop... 297.98 BogoMIPS (lpj=595968)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x822fdd48 - 0x822fdd7c
devtmpfs: initialized
do_initcall_level level 0
do_initcall_level level 1
VFP support v0.3: implementor 41 architecture 2 part 30 variant 5 rev 1
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
do_initcall_level level 2
DMA: preallocated 256 KiB pool for atomic coherent allocations
do_initcall_level level 3
L2C: device tree omits to specify unified cache
L2C-310 dynamic clock gating enabled, standby mode enabled
L2C-310 cache controller enabled, 8 ways, 256 kB
L2C-310: CACHE_ID 0x410000c9, AUX_CTRL 0x06040000
sc57x_init: registering device resources
sec init...
enabled
hw-breakpoint: Failed to enable monitor mode on CPU 0.
ADI DMA2 Controller
adi-dma2 31026180.dma: Invalid ADI DMA channel.
adi-dma2: probe of 31026180.dma failed with error -2
adi-dma2 31026100.dma: Invalid ADI DMA channel.
adi-dma2: probe of 31026100.dma failed with error -2
adi-dma2 30fff080.dma: Invalid ADI DMA channel.
adi-dma2: probe of 30fff080.dma failed with error -2
adi-dma2 31026280.dma: Invalid ADI DMA channel.
adi-dma2: probe of 31026280.dma failed with error -2
adi-dma2 31026200.dma: Invalid ADI DMA channel.
adi-dma2: probe of 31026200.dma failed with error -2
adi-dma2 3109a000.dma: Invalid ADI DMA channel.
adi-dma2: probe of 3109a000.dma failed with error -2
adi-dma2 3109a080.dma: Invalid ADI DMA channel.
adi-dma2: probe of 3109a080.dma failed with error -2
adi-dma2 3109b000.dma: Invalid ADI DMA channel.
adi-dma2: probe of 3109b000.dma failed with error -2
adi-dma2 3109b080.dma: Invalid ADI DMA channel.
adi-dma2: probe of 3109b080.dma failed with error -2
DMA channel 40 is not registed
DMA channel 39 is not registed
do_initcall_level level 4
SCSI subsystem initialized
i2c-bfin-twi 31001400.twi: Blackfin on-chip I2C TWI Contoller, regs_base@f4001400
i2c-bfin-twi 31001500.twi: Blackfin on-chip I2C TWI Contoller, regs_base@f4001500
i2c-bfin-twi 31001600.twi: Blackfin on-chip I2C TWI Contoller, regs_base@f4001600
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
do_initcall_level level 5
Switched to clocksource cs_gptimer
NET: Registered protocol family 2
TCP established hash table entries: 2048 (order: 1, 8192 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
do_initcall_level level 6
hw perfevents: enabled with armv7_cortex_a5 PMU driver, 3 counters available
futex hash table entries: 256 (order: -1, 3072 bytes)
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
io scheduler noop registered (default)
ADI serial driver
adi-uart4.0: ttySC0 at MMIO 0x31003000 (irq = 20, base_baud = 7031250) is a ADI-UART4
console [ttySC0] enabled
console [ttySC0] enabled
bootconsole [earlycon0] disabled
bootconsole [earlycon0] disabled
adi-uart4.2: ttySC2 at MMIO 0x31003800 (irq = 60, base_baud = 7031250) is a ADI-UART4
loop: module loaded
adi-spi3 3102e000.spi: registered ADI SPI controller spi0
adi-spi3 3102f000.spi: registered ADI SPI controller spi1
adi-spi3 31044000.spi: registered ADI SPI controller spi2
stmmaceth 3100c000.ethernet: no reset control found
stmmac - user ID: 0x10, Synopsys ID: 0x37
 Ring mode enabled
 DMA HW capability register supported
 Enhanced/Alternate descriptors
        Enabled extended descriptors
 RX Checksum Offload Engine supported (type 2)
 TX Checksum insertion supported
 Wake-Up On Lan supported
 Enable RX Mitigation via HW Watchdog Timer
libphy: stmmac: probed
eth0: PHY ID 20005c7a at 1 IRQ POLL (stmmac-0:01) active
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
adi_wdt: initialized: timeout=20 sec (nowayout=0)
TCP: cubic registered
NET: Registered protocol family 17
do_initcall_level level 7
ThumbEE CPU extension supported.
Freeing unused kernel memory: 7736K (c0442000 - c0bd0000)
Starting logging: OK
Starting mdev...
Starting watchdog...
Initializing random number generator... random: dd urandom read with 8 bits of entropy available
done.
Starting network...
/bin/sh: run-parts: not found
ssh-keygen: generating new host keys: ED25519
Starting sshd: OK
Starting inetd: OK

More information

There are more command available for USB in u-boot:

sc # usb info
1: Mass Storage,  USB Revision 2.0
 - Generic  USB Storage 000000009451
 - Class: (from Interface) Mass Storage
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x05e3  Product 0x0723 Version 148.81
   Configuration: 1
   - Interfaces: 1 Bus Powered 500mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 2
     - Class Mass Storage, Transp. SCSI, Bulk only
     - Endpoint 1 In Bulk MaxPacket 512
     - Endpoint 2 Out Bulk MaxPacket 512
sc # usb storage
  Device 0: Vendor: Generic  Rev: 9451 Prod: STORAGE DEVICE
            Type: Removable Hard Disk
            Capacity: 1897.0 MB = 1.8 GB (3885056 x 512)
sc # usb tree
USB device tree:
  1  Mass Storage (12 Mb/s, 500mA)
     Generic  USB Storage 000000009451
sc # fatinfo usb 0:1
Interface:  USB
  Device 0: Vendor: Generic  Rev: 9451 Prod: STORAGE DEVICE
            Type: Removable Hard Disk
            Capacity: 1897.0 MB = 1.8 GB (3885056 x 512)
Filesystem: FAT32 "           "

 

Appendix: Macro Definition

MACHINE DTB_FILE FULL_FS_IMAGE MINIMAL_FS_IMAGE RAMDISK_FILE
adsp-sc589-mini sc589-mini.dtb adsp-sc5xx-full-adsp-sc589-mini.tar.xz adsp-sc5xx-minimal-adsp-sc589-mini.tar.xz adsp-sc5xx-ramdisk-adsp-sc589-mini.cpio.xz.u-boot
adsp-sc589-ezkit sc589-ezkit.dtb adsp-sc5xx-full-adsp-sc589-ezkit.tar.xz adsp-sc5xx-minimal-adsp-sc589-ezkit.tar.xz adsp-sc5xx-ramdisk-adsp-sc589-ezkit.cpio.xz.u-boot
adsp-sc584-ezkit sc584-ezkit.dtb adsp-sc5xx-full-adsp-sc584-ezkit.tar.xz adsp-sc5xx-minimal-adsp-sc584-ezkit.tar.xz adsp-sc5xx-ramdisk-adsp-sc584-ezkit.cpio.xz.u-boot
adsp-sc573-ezkit sc573-ezkit.dtb adsp-sc5xx-full-adsp-sc573-ezkit.tar.xz adsp-sc5xx-minimal-adsp-sc573-ezkit.tar.xz adsp-sc5xx-ramdisk-adsp-sc573-ezkit.cpio.xz.u-boot

 


Back To: Das U-boot  

 

 

resources/tools-software/linuxdsp/docs/das-u-boot/loading_file_from_usb_storage_in_uboot.1607413269.txt.gz · Last modified: 08 Dec 2020 08:41 by Sunny Feng