Sdctl

From embeddedTS Manuals

Overview

The utility sdctl allows manipulation of the FPGA SD core. This allows to you read/write data, and present a network block device to the OS.

Usage

In our scripts sdctl is typically invoked with these options:

sdctl -z 65536 --nbdserver lun0:disc,lun0:part1,lun0:part2,lun0:part3,lun0:part4

-z 65536

This sets the block size for the SD. The number of blocks will be automatically detected.

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

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

lun0:disc will create the raw block device at port 7500

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

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

...

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 7500 /dev/nbd5
  nbd-client 127.0.0.1 7501 /dev/nbd6
  nbd-client 127.0.0.1 7502 /dev/nbd7
  nbd-client 127.0.0.1 7503 /dev/nbd8
  nbd-client 127.0.0.1 7504 /dev/nbd9

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

Help

General options:
  -R, --read=N            Read N blocks of SD to stdout
  -W, --write=N           Write N blocks to SD
  -x, --writeset=BYTE     Write BYTE as value (default 0)
  -i, --writeimg=FILE     Use FILE as file to write to SD
  -t, --writetest         Run write speed test
  -r, --readtest          Run read speed test
  -n, --random=SEED       Do random seeks for tests
  -o, --noparking         Disable write parking optimization
  -z, --blocksize=SZ      Use SZ bytes each sdread/sdwrite call
  -E, --erasehint[=SZ]    Use erase hint write optimization
  -b, --sdboottoken=TOK   Use TOK as the boot token (to quicken init)
  -a, --address=ADD       Use ADD address instead of 0x13000000
  -k, --seek=SECTOR       Seek to 512b sector number SECTOR
  -l, --lun=N             Use N as numbered card slot (default 0)
  -S, --scanluns          Scan all LUNs for cards
  -m, --nodma             Dont use DMA
  -d, --nbdserver=NBDSPEC Run NBD userspace block driver server
  -I, --bind=IPADDR       Bind NBD server to IPADDR
  -Q, --stats             Print NBD server stats
  -P, --printmbr          Print MBR and partition table
  -M, --setmbr            Write MBR from environment variables
  -f, --foreground        Run NBD server in foreground
  -N, --nomultiwrite      Use only single block write SD commands
  -h, --help              This help

Security/SD lock options:
  -p, --password=PASS     Use PASS as password
  -c, --clear             Remove password lock
  -s, --set               Set password lock
  -u, --unlock            Unlock temporarily
  -e, --erase             Erase entire device (clears password)
  -w, --wprot             Enable permanent write protect

When running a NBD server, NBDSPEC is a comma separated list of
devices and partitions for the NBD servers starting at port 7500.
e.g. "lun0:part1,lun1:disc" corresponds to 2 NBD servers, one at port
7500 serving the first partition of SD lun 0, and the other at TCP
port 7501 serving the whole disc device of SD lun #1.