X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=board%2Fsandbox%2FREADME.sandbox;h=9bc13e142bdce30acc45cc247ed448829deaff56;hb=c513e9e1e6e1ea2aa177aae3b0eb306c949dcd69;hp=529c447a5b351b387e2a027f610b7cfd6e6281d1;hpb=c534d2fdcf7aa80230a0f1ed54d5e3164ba595eb;p=oweals%2Fu-boot.git diff --git a/board/sandbox/README.sandbox b/board/sandbox/README.sandbox index 529c447a5b..9bc13e142b 100644 --- a/board/sandbox/README.sandbox +++ b/board/sandbox/README.sandbox @@ -18,12 +18,15 @@ create unit tests which we can run to test this upper level code. CONFIG_SANDBOX is defined when building a native board. -The chosen vendor and board names are also 'sandbox', so there is a single -board in board/sandbox/sandbox. +The board name is 'sandbox' but the vendor name is unset, so there is a +single board in board/sandbox. CONFIG_SANDBOX_BIG_ENDIAN should be defined when running on big-endian machines. +By default sandbox builds and runs on 64-bit hosts. If you are going to build +and run sandbox on a 32-bit host, select CONFIG_SANDBOX_32BIT. + Note that standalone/API support is not available at present. @@ -32,7 +35,7 @@ Basic Operation To run sandbox U-Boot use something like: - make sandbox_config all + make sandbox_defconfig all ./u-boot Note: @@ -41,10 +44,9 @@ Note: build sandbox without SDL (i.e. no display/keyboard support) by removing the CONFIG_SANDBOX_SDL line in include/configs/sandbox.h or using: - make sandbox_config all NO_SDL=1 + make sandbox_defconfig all NO_SDL=1 ./u-boot - U-Boot will start on your computer, showing a sandbox emulation of the serial console: @@ -173,21 +175,94 @@ U-Boot sandbox supports these emulations: - Chrome OS EC - GPIO - Host filesystem (access files on the host from within U-Boot) +- I2C - Keyboard (Chrome OS) - LCD +- Network - Serial (for console only) - Sound (incomplete - see sandbox_sdl_sound_init() for details) - SPI - SPI flash - TPM (Trusted Platform Module) -Notable omissions are networking and I2C. - A wide range of commands is implemented. Filesystems which use a block device are supported. -Also sandbox uses generic board (CONFIG_SYS_GENERIC_BOARD) and supports -driver model (CONFIG_DM) and associated commands. +Also sandbox supports driver model (CONFIG_DM) and associated commands. + + +Linux RAW Networking Bridge +--------------------------- + +The sandbox_eth_raw driver bridges traffic between the bottom of the network +stack and the RAW sockets API in Linux. This allows much of the U-Boot network +functionality to be tested in sandbox against real network traffic. + +For Ethernet network adapters, the bridge utilizes the RAW AF_PACKET API. This +is needed to get access to the lowest level of the network stack in Linux. This +means that all of the Ethernet frame is included. This allows the U-Boot network +stack to be fully used. In other words, nothing about the Linux network stack is +involved in forming the packets that end up on the wire. To receive the +responses to packets sent from U-Boot the network interface has to be set to +promiscuous mode so that the network card won't filter out packets not destined +for its configured (on Linux) MAC address. + +The RAW sockets Ethernet API requires elevated privileges in Linux. You can +either run as root, or you can add the capability needed like so: + +sudo /sbin/setcap "CAP_NET_RAW+ep" /path/to/u-boot + +The default device tree for sandbox includes an entry for eth0 on the sandbox +host machine whose alias is "eth1". The following are a few examples of network +operations being tested on the eth0 interface. + +sudo /path/to/u-boot -D + +DHCP +.... + +set autoload no +set ethact eth1 +dhcp + +PING +.... + +set autoload no +set ethact eth1 +dhcp +ping $gatewayip + +TFTP +.... + +set autoload no +set ethact eth1 +dhcp +set serverip WWW.XXX.YYY.ZZZ +tftpboot u-boot.bin + +The bridge also support (to a lesser extent) the localhost inderface, 'lo'. + +The 'lo' interface cannot use the RAW AF_PACKET API because the lo interface +doesn't support Ethernet-level traffic. It is a higher-level interface that is +expected only to be used at the AF_INET level of the API. As such, the most raw +we can get on that interface is the RAW AF_INET API on UDP. This allows us to +set the IP_HDRINCL option to include everything except the Ethernet header in +the packets we send and receive. + +Because only UDP is supported, ICMP traffic will not work, so expect that ping +commands will time out. + +The default device tree for sandbox includes an entry for lo on the sandbox +host machine whose alias is "eth5". The following is an example of a network +operation being tested on the lo interface. + +TFTP +.... + +set ethact eth5 +tftpboot u-boot.bin SPI Emulation @@ -244,6 +319,30 @@ CONFIG_SPI_IDLE_VAL The idle value on the SPI bus +Block Device Emulation +---------------------- + +U-Boot can use raw disk images for block device emulation. To e.g. list +the contents of the root directory on the second partion of the image +"disk.raw", you can use the following commands: + +=>host bind 0 ./disk.raw +=>ls host 0:2 + +A disk image can be created using the following commands: + +$> truncate -s 1200M ./disk.raw +$> echo -e "label: gpt\n,64M,U\n,,L" | /usr/sbin/sgdisk ./disk.raw +$> lodev=`sudo losetup -P -f --show ./disk.raw` +$> sudo mkfs.vfat -n EFI -v ${lodev}p1 +$> sudo mkfs.ext4 -L ROOT -v ${lodev}p2 + +or utilize the device described in test/py/make_test_disk.py: + + #!/usr/bin/python + import make_test_disk + make_test_disk.makeDisk() + Writing Sandbox Drivers ----------------------- @@ -275,7 +374,8 @@ directory. These include: - Unit tests for U-Boot's compression algorithms, useful for security checking. It supports gzip, bzip2, lzma and lzo. driver model - - test/dm/test-dm.sh to run these. + - Run this pytest + ./test/py/test.py --bd sandbox --build -k ut_dm -v image - Unit tests for images: test/image/test-imagetools.sh - multi-file images