Changes between Version 16 and Version 17 of Internal/OpenFlow/QuantaSetup


Ignore:
Timestamp:
Jun 14, 2011, 7:23:14 PM (13 years ago)
Author:
akoshibe
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Internal/OpenFlow/QuantaSetup

    v16 v17  
    121121
    122122== III A u-boot Primer == #III
    123 This section is a HOW-TO for using u-boot with respect to the Quanta, e.g. variables, scripts, and memory maps unique to this switch. !OpenFlow related u-boot stuff can be found in the [#IV next section].
     123This section is a HOW-TO for scripting in u-boot with respect to the Quanta, e.g. variables, scripts, and memory maps unique to this switch. !OpenFlow related u-boot stuff can be found in the [#IV next section].
    124124
    125125=== 3.1 Environment variables ===
     
    152152
    153153}}}
    154 Each entry is a line of the form [variable name]=[parameters]. the parameters can be a combination of u-boot commands and other variables in a way similar to a simple shell script. 
    155 
    156 The general case for these variables can be summarized as follows:
    157 
    158  * syntax is `[name]=[parameters]`, where [parameter] is some string
    159  * `$[name]` returns the value of the separately defined variable, [name]
     154The output above is from a fresh Quanta out of the box. Each entry is a line of the form [variable name]=[parameters]. the parameters can be a combination of u-boot commands and other variables in a way similar to a simple shell script. 
     155
     156The general syntax for these variables can be summarized as follows:
     157
     158 * `[name]=[parameters]`, where [parameter] is some string relevant to the variable, [name]
     159 * `$[name]` returns the value of a variable, [name], which is defined in a separate line (same as in bash shell scripting)
    160160 * semicolon (;) delimits individual commands 
    161161
    162 For example, note the first two entries in the "screen shot" above:
     162Variable definitions can be inlined as parameters for other variables. For example, note the first two entries in the "screen shot" above:
    163163{{{
    164164<entry 1> flash_bootcmd=setenv bootargs root=/dev/ram console=ttyS0,$baudrate; bootm ffd00000 ff000000 ffee0000
    165 <entry 2> cfcard_bootcmd=setenv bootargs root=/dev/ram console=ttyS0,$baudrate; ext2load ide 0:1 0x1000000 /uImage;ext2load ide 0:1 0x2000000/uInitrd2m;ext2load ide 0:1 0x400000 /LB9A.dtb;bootm 1000000 2000000 400000
    166 }}}   
    167 they were part of the `run` commands mentioned earlier. The parameters to these variables create another variable called "bootargs" using command `setenv`. What follows are the parameters for this new variable (which are also environment variables):
     165<entry 2> cfcard_bootcmd=setenv bootargs root=/dev/ram console=ttyS0,$baudrate; ext2load ide 0:1 0x1000000 /uImage;ext2load ide 0:1 0x2000000 /uInitrd2m;ext2load ide 0:1 0x400000 /LB9A.dtb;bootm 1000000 2000000 400000
     166}}}    
     167Both `flash_bootcmd` and `cfcard_bootcmd` are part of the `run` commands from the previous section that boot the different Linux images. These entries are made up of multiple strings comprised of u-boot commands and variable declarations and separated by semicolons. The first strings for both define a new variable called "bootargs" using command `setenv`. `setenv` is given multiple variables that define "bootargs":
    168168
    169169 * `root=/dev/ram` - probably specifies where the root filesystem should be loaded^2^
    170170 * `console=ttyS0` - set output to /dev/ttyS0
    171  * `$baudrate` - use the parameters specified in the variable "baudrate," which we can see above is set to 115200 (baud)
    172 
    173 The parameters that follow the semicolon after `$baudrate` differ a bit for the two variables. For the cfcard_bootcmd entry the `ext2load` commands specifies where to fetch the kernel, ramdisk, and device tree files from, respectively. The specific syntax for each `ext2load` command is:
    174 
    175  `ext2load [interface] [memory address]`
    176 
    177 What is really important here are the memory location values. For the cf card, the values should be:
    178  * 0x1000000 for kernel image
    179  * 0x2000000 for filesystem
    180  * 0x400000 for the device tree
     171 * `$baudrate` - use the parameters specified in the variable "baudrate," which we can see is set to 115200 (baud) in the above `printenv` output
     172
     173The strings that follow the semicolon after `$baudrate` differ a bit for the two variables. For the cfcard_bootcmd entry the `ext2load` commands specifies where to fetch the kernel, ramdisk, and device tree files from, respectively. The specific syntax for each `ext2load` command is:
     174
     175 `ext2load [interface] [memory address] [path to file]`
     176
     177What is really important here (and for troubleshooting things) are the memory location values. For the cf card, the values should be:
     178 * 0x1000000 for kernel image (uImage)
     179 * 0x2000000 for filesystem (uInitrd2m)
     180 * 0x400000 for the device tree (LB9A.dtb)
    181181
    182182The same follows for the flash image, with ffd00000, ff00000, and ffee0000 being the address locations where the kernel, ramdisk, and device tree files always begin, respectively. The current version of u-boot has some tools for inspecting flash memory. These will be discussed in the [#ts troubleshooting section].     
    183183
    184 Both script variables end with the `bootm` command, which loads the program files from the memory locations given by `ext2load` in the cf card or implied in the flash.   
     184Both variable definitions end with the `bootm` command, which loads the program files from the memory locations given by `ext2load` in the cf card or implied in the flash. `bootm` takes parameters as follows:
     185 
     186 `bootm [kernel img. address] [filesystem address] [device tree address]`   
    185187
    186188=== 3.2 modifying the environment variables list ===
    187 `setenv` allows you to modify and create environment variables. In general:
    188 
    189  * `setenv [name]`, where [name] is new, creates a new variable with that name.
    190  * `setenv [name]`, where [name] already exists, wipes out its previous parameters.
    191  * `setenv [name] [parameters]` sets/overwrites parameters for the variable [name] with [parameters]. 
    192  
    193 ''Long parameters.'' For variables with whitespaces in its parameters (e.g. "script variables" like flash_bootcmd), the parameters have to be surrounded by single quotes to let u-boot know that everything is part of a single script. For example, to create and configure the variable dn_boot, we'd type this at the command line:
     189`setenv` allows you to modify, create, and delete environment variables. In general:
     190
     191 * `setenv [name] [parameters]`, where [name] is new, creates a new variable called [name] defined by parameters specified in [parameters].
     192 * `setenv [name]`, where [name] already exists, deletes the variable.
     193 * `setenv [name] [parameters]` where [name] already exists, overwrites old parameters for the variable [name] with [parameters]. 
     194 
     195''Long parameters.'' For variables with whitespaces in its parameters (e.g. "script variables" like flash_bootcmd), the parameters have to be surrounded by single quotes to let u-boot know that everything is part of a single script. For example, to create and configure the variable dn_boot (this script tells u-boot to fetch the filesystem via network using NFS and to boot from flash), we'd type this at the u-boot prompt:
    194196
    195197{{{
     
    197199}}} 
    198200
    199 Note the single quotes before `dhcp` and after `ffee0000`. Another important thing about long parameters is that they cannot contain newlines; The whole command must be typed in a single line.   
    200 
    201 === 3.3 Some important variables ===
    202 
    203  * http://www.openflow.org/wk/index.php/IndigoConfiguration - !OpenFlow specific variables
     201Note the single quotes before `dhcp` and after `ffee0000`. Another important thing about long parameters is that they cannot contain newlines or backslashes; The whole command must be typed as a single line.   
     202
     203=== 3.3 boot parameters ===
     204Most long variables are bootup scripts. By default, there are two bootup scripts on a Quanta: `cfcard_bootcmd` and `flash_bootcmd`. As you can see throughout these docs, a user can easily create new bootup scripts of any arbitrary name.
     205
     206A script called [name] can be run by invoking it with the `run` command. For example, to run `dn_boot`, you'd type
     207 
     208 `run dn_boot`
     209
     210at the u-boot prompt. This runs the command only once. In order to make a bootup script persist (e.g. be the default one that the switch boots to), you must set the variable `bootcmd` to the run command. The default script used in these switches is `cfcard_bootcmd`. You can see that in the `printenv` output.
     211
     212{{{
     213=> printenv
     214
     215...
     216
     217bootcmd=run cfcard_bootcmd
     218}}}
     219
     220=== 3.4 Flashing the switch/testing out images ===
     221The `copy` command is the primary way to flash the switch with new firmware, as well as for updating u-boot itsself:
     222
     223 {{{
     224copy <-b/-k/-r/-d> <tftp://serverip/filename | xmodem>
     225        <-b/-boot> boot image file
     226        <-k/-kernel> kernel image file
     227        <-r/-ramdidk> ramdisk image file
     228        <-d/-dtb> Device Tree Binary file
     229 }}}
     230
     231`copy` leverages TFTP in order to fetch files into the proper locations in flash memory. Memory locations and file type are implied through flags; as such, `copy` does not check for consistency between flag and file type of the file you specify. This makes it critical that you double-check the flags and filenames you give `copy`^3^.
     232
     233Firmware updates may also be done via NFS. Usages of both `copy` and bootup via NFS are covered in [#IV section IV].
     234
     235Another tool to consider is the system shell, available from the CF card Linux image. For example, if you don't want to flash the new firmware, one can just add the images to /cf_card and point a u-boot script to the names of the new files:
     236
     237{{{
     238cfboot=setenv bootargs root=/dev/ram console=ttyS0,$baudrate; ext2load ide 0:1 0x1000000 /uImage2;ext2load ide 0:1 0x2000000 /uInitrd2m2;ext2load ide 0:1 0x400000 /LB9A2.dtb;bootm 1000000 2000000 400000
     239}}}
     240
     241`cfboot` can then be manually started with the command `run cfboot`, or be set as the default boot parameter by setting it as `bootcmd`'s parameter. 
    204242 
    205243=== 3.4 troubleshooting === #ts
    206 
     244Mis-configurations in u-boot can cause various interesting^4^ issues including non-persistent configurations, hanging on bootup, and bricked switches. The first two are mildly annoying; the latter requires a JTAG cable and is serious enough an issue that everyone is discouraged from touching u-boot unless absolutely necessary. A Grid service is provided for manipulating the Quantas. 
     245
     246=== 3.4.1 Flash memory ===
     247U-boot comes with tools such as `imls` and `flinfo` that allow you to inspect flash memory. Under normal circumstances, the memory map of the switch should look like below. Note the memory location and size of the ramdisk and kernel images. Any deviation can be a potential issue e.g the use of wrong firmware and wrongly copied files. 
     248
     249{{{
     250=> imls
     251Image at FF000000:
     252   Image Name:   
     253   Image Type:   PowerPC Linux RAMDisk Image (gzip compressed)
     254   Data Size:    12275941 Bytes = 11.7 MB
     255   Load Address: 00000000
     256   Entry Point:  00000000
     257   Verifying Checksum ... OK
     258Image at FFD00000:
     259   Image Name:   Linux-2.6.27
     260   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
     261   Data Size:    1742743 Bytes =  1.7 MB
     262   Load Address: 00000000
     263   Entry Point:  00000000
     264   Verifying Checksum ... OK
     265}}}
     266
     267A more detailed memory map can be found with flinfo. The 'E' next to the octets indicate empty spots in memory, RO write protected spots.
     268
     269{{{
     270=> flinfo
     271
     272Bank # 1: CFI conformant FLASH (16 x 16)  Size: 32 MB in 256 Sectors
     273  AMD Standard command set, Manufacturer ID: 0x01, Device ID: 0x7E2201
     274  Erase timeout: 4096 ms, write timeout: 1 ms
     275  Buffer write timeout: 3 ms, buffer size: 64 bytes
     276
     277  Sector Start Addresses:
     278  FE000000        FE020000        FE040000        FE060000 E      FE080000 E   
     279  FE0A0000 E      FE0C0000 E      FE0E0000 E      FE100000 E      FE120000 E   
     280  FE140000 E      FE160000 E      FE180000 E      FE1A0000 E      FE1C0000 E   
     281  FE1E0000 E      FE200000 E      FE220000 E      FE240000 E      FE260000 E   
     282  FE280000 E      FE2A0000 E      FE2C0000 E      FE2E0000 E      FE300000 E   
     283
     284...
     285
     286  FFE00000        FFE20000        FFE40000        FFE60000        FFE80000     
     287  FFEA0000        FFEC0000 E      FFEE0000        FFF00000   RO   FFF20000   RO
     288  FFF40000 E      FFF60000 E      FFF80000 E      FFFA0000 E      FFFC0000   RO
     289  FFFE0000     
     290
     291}}}
     292
     293The output can be pretty big. It is also far less intuitive than `imls` (and often less useful).
     294
     295=== 3.4.2 CF Card ===
     296There are no means of inspecting the CF card from U-boot directly, maybe except from getting a glance of the memory map during (attempted) bootup. It should look like the following:
     297
     298{{{
     299## Booting image at 01000000 ...
     300   Image Name:   Linux-2.6.27-svn3877
     301   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
     302   Data Size:    1711826 Bytes =  1.6 MB
     303   Load Address: 00000000
     304   Entry Point:  00000000
     305   Verifying Checksum ... OK
     306   Uncompressing Kernel Image ... OK
     307## Loading RAMDisk Image at 02000000 ...
     308   Image Name:   svn3877
     309   Image Type:   PowerPC Linux RAMDisk Image (gzip compressed)
     310   Data Size:    20822821 Bytes = 19.9 MB
     311   Load Address: 00000000
     312   Entry Point:  00000000
     313   Verifying Checksum ... OK
     314   Booting using the fdt at 0x400000
     315   Loading Ramdisk to 1eae1000, end 1febcb25 ... OK
     316}}}
     317
     318If the switch can boot from the CF Card, choosing the system shell will give you access to a shell that will let you poke around the CF card. It should be mounted as the /cf_card directory.
     319 
    207320== IV OpenFlow Switching == #IV
    208321This section provides example uses of the u-Boot facilities for manipulating the !OpenFlow properties of the LB9A. We will also introduce the ORBIT Grid Service facilities that can be used to configure the switch without dealing with the gory details of u-boot (given the switch has the proper firmware, that is).
     
    361474The ORBIT grid services allow you to query and configure various components of the testbed(s) through a browser from gw.orbit-lab.org. Here our focus is on the network services.
    362475
    363 ==== !addOpenFlow ====
     476==== addOpenFlow ====
    364477This allows you to set u-Boot environment variables without going into the gory details of u-Boot. For example, to boot a switch into !OpenFlow mode, issue the following command at the navigation bar on your browser from external2 (make sure you have X11 tunneling):
    365478{{{
     
    380493^1. I honestly don't know what it does.^ [[BR]]
    381494^2. These are educated guesses through observation, and by no means guaranteed to be what is actually happening. If anyone has an actual explanation I'd be very happy to learn about it.^
    382  
     495^3. The importance was demonstrated by a mix-up between the -b and -d flags for `copy`, which happily overwrote u-boot with the device tree, bricking the switch.^
     496^4. There are no sarcasm tags in Wiki notation.^