Spiflashctl

From embeddedTS Manuals

Overview

The userspace utility spiflashctl is the software layer that presents an NBD device to the NOR flash.

Usage

spiflashctl would usually be called with something similar to this:

spiflashctl --lun 1 --nbdserver lun0:disc,lun0:part1,lun0:part2,lun0:part3

--lun 1

This specifies which chip select you want to use. Typically we will use chip select 1 for offboard flash, and 0 for onboard flash.

--nbdserver lun0:disc,lun0:part1,lun0:part2,lun0:part3

This sets up an nbd server with the various partitions and raw block devices.

lun0:disc will create the raw block device at port 7525.

lun0:part1 will create the first partition at port 7526.

lun0:part2 will create the first partition at port 7527.

Connecting a client

You can set up any number of partitions you need this way. The network block device ports are accessed using the standard nbd-client. Typically they will be invoked like this:

  nbd-client 127.0.0.1 7525 /dev/nbd0
  nbd-client 127.0.0.1 7526 /dev/nbd1
  nbd-client 127.0.0.1 7527 /dev/nbd2
  nbd-client 127.0.0.1 7528 /dev/nbd3
  nbd-client 127.0.0.1 7529 /dev/nbd4

This way /dev/nbd0 will be the block device, /dev/nbd1 will be the first partition, and so on.


Help

Usage: spiflashctl [OPTION] ...                                                                                                                                                                                                                                                
Technologic Systems SPI flash manipulation.                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                               
General options:                                                                                                                                                                                                                                                               
  -R, --read=N            Read N blocks of flash to stdout                                                                                                                                                                                                                     
  -W, --write=N           Write N blocks to flash                                                                                                                                                                                                                              
  -x, --writeset=BYTE     Write BYTE as value (default 0)                                                                                                                                                                                                                      
  -i, --writeimg=FILE     Use FILE as file to write to flash                                                                                                                                                                                                                   
  -t, --writetest         Run write speed test                                                                                                                                                                                                                                 
  -r, --readtest          Run read speed test                                                                                                                                                                                                                                  
  -n, --random=SEED       Do random seeks for tests                                                                                                                                                                                                                            
  -z, --blocksize=SZ      Use SZ bytes each sdread/sdwrite call                                                                                                                                                                                                                
  -k, --seek=SECTOR       Seek to 512b sector number SECTOR                                                                                                                                                                                                                    
  -V, --verify            Verify reads and writes                                                                                                                                                                                                                              
  -e, --erase             Erase entire device                                                                                                                                                                                                                                  
  -d, --nbdserver=NBDSPEC Run NBD userspace block driver server                                                                                                                                                                                                                
  -Q, --stats             Print NBD server stats                                                                                                                                                                                                                               
  -I, --bind=IPADDR       Bind NBD server to IPADDR                                                                                                                                                                                                                            
  -l, --lun=N             Use chip number N                                                                                                                                                                                                                                    
  -P, --printmbr          Print MBR and partition table                                                                                                                                                                                                                        
  -M, --setmbr            Write MBR from environment variables                                                                                                                                                                                                                 
  -h, --help              This help                                                                                                                                                                                                                                            
                          
When running a NBD server, NBDSPEC is a comma separated list of                                                                                                                                                                                                                
devices and partitions for the NBD servers starting at port 7525.                                                                                                                                                                                                              
e.g. "lun0:part1,lun1:disc" corresponds to 2 NBD servers, one at port                                                                                                                                                                                                          
7525 serving the first partition of chip #0, and the other at TCP                                                                                                                                                                                                              
port 7526 serving the whole disc device of chip #1.