There are a number of ways of setting up a target board. In this page, only one of them will be detailed - which is the way most users perform these common tasks.
First of all, it is required to connect to the correct serial port to the target board, (typically ST40 linux's /dev/ttyAS0) from a terminal emulator (running on a host system) with the following communications parameters:
baud=115200, data=8, parity=none, Flow Control=none
In another window on the host system, then use sh4-linux-gdb to download and run U-Boot on the target system, over the JTAG debug link. For example, for executing on a STx7111 Mboard (MB618), then the following would be appropriate.
host% sh4-linux-gdb GNU gdb STMicroelectronics/Linux Base 6.5-33 [build Jul 30 2008] Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=sh4-linux". (gdb) sh4tp TARGET:mb618:st40,silent=1 The target is assumed to be little endian The target architecture is assumed to be sh4 0xa0000000 in ?? () (gdb) load /opt/STM/STLinux-2.3/devkit/sh4/target/boot/u-boot-1.3.1_stm23_0042-mb618/u-boot Loading section .text, size 0x1f6b0 lma 0x93f00000 Loading section .rodata, size 0x834 lma 0x93f1f6b0 Loading section .rodata.str1.4, size 0x7ddc lma 0x93f1fee4 Loading section .data, size 0xcf0 lma 0x93f27cc0 Loading section .u_boot_cmd, size 0x570 lma 0x93f289b0 Start address 0x93f00000, load size 167712 Transfer rate: 1753850 bits/sec, 33542 bytes/write. (gdb) continue Continuing.
Where "TARGET" is the DNS name (or IP address) of the ST MicroConnect.
Something similar to the following should be observed on the terminal emulator from the serial port:
Board: STx7111-Mboard (MB618) [29-bit mode] MB618: revision D, EPLD version 11 U-Boot 1.3.1 (Oct 15 2008 - 00:16:15) - stm23_0042 DRAM: 128 MiB NOR: 32 MiB In: serial Out: serial Err: serial MB618>
It is now possible to enter any U-Boot command on the serial console for U-Boot to execute. For a list of all the U-Boot commands type:
MB618> help
The following sub-sections show how to download U-Boot and burn it in to flash on the target board. This section will also help in understanding how to use various common U-Boot commands.
Also it should be noted that there are two binary files built when U-Boot is compiled, and one must ensure one uses the correct file, in all cases.
In order to burn U-Boot in to flash, then it is required first to have U-Boot running on the target system, typically this is achieved by downloading U-Boot ("u-boot") with GDB, as above. Secondly, we need to download in to SDRAM (on the target system) with the U-Boot binary ("u-boot.bin") to be flashed. This download can be done by several different means (for example: Serial, USB, IDE, SATA, NFS, HDCP, BOOTP, TFTP). However, in this section we will just use the most popular means: NFS.
It should be noted that although it is possible to burn an image straight in to flash from NFS, typically a 2-stage solution is preferred. That is, normally, the image to be burned is first loaded in to the target's SDRAM, and then subsequently burned from SDRAM in to the flash. This approach will be used throughout this guide.
Note: "load_addr" is a U-Boot environment variable containing a desirable download address on the target. The actual depends on the location of SDRAM for the board being used, and it also depends if the system is in 29-bit mode or 32-bit (SE) mode. Typically this address will be the very beginning of SDRAM (as U-Boot itself typically runs from the end of SDRAM). See the ST40 Memory Map for further information on the memory map for the ST40.
Note: The "u-boot.bin" file needs to be in a directory exported by the NFS server, accessible to the target board. In the following examples it is assumed the directory containing the pre-built U-Boot binaries (in /opt/STM/...) are exported.
Increasingly, some boards do not have their MAC address programmed in to EEPROM. In these cases, it is required to supply a unique MAC address to U-Boot, to use when on the network. (See this page, for further details.) One way of telling U-Boot to use such an address, is by adding an extra parameter to CONFIG_EXTRA_ENV_SETTINGS in the board-specific "include/configs/board-name.h" configuration. For example:
#define CONFIG_EXTRA_ENV_SETTINGS \
"ethaddr=XX:XX:XX:XX:XX:XX\0" \Alternatively, if it is not desired to put the MAC address in the board-specific configuration file, then a MAC address may be provided by setting an environment variable interactively. To do this, then the CONFIG_ENV_OVERWRITE macro should be defined in the board-specific "include/configs/board-name.h" configuration file, such as:
/* If this board does not have eeprom for ethernet address so allow the user
* to set it in the environment
*/
#define CONFIG_ENV_OVERWRITEThen the "ethaddr" environment variable should be set (as appropriate) and saved in flash:
MB618> setenv ethaddr XX:XX:XX:XX:XX:XX
MB618> saveenvTo use the network function, it is required need to set up the target board's IP address and other network parameters. This may be done by setting the following environment variables:
MB618> setenv serverip <server-ip> MB618> setenv netmask <netmask> MB618> setenv gatewayip <gateway-ip> MB618> setenv ipaddr <board-ip-addr>
Where "<server-ip>" is the IP address of the NFS server machine; "<netmask>" is the appropriate site's netmask; "<gateway-ip>" is the site's gateway IP address; and "<board-ip-addr>" is the desired IP address of the target board itself. To save these changes to the environment variables permanently in to non-volatile flash, then type:
MB618> saveenv Saving Environment to Flash... Unprotecting Flash... . done Un-Protected 1 sectors Erasing Flash... . done Erased 1 sectors Writing to Flash... ........ done Protecting Flash... . done Protected 1 sectors
Once the appropriate network parameters have been set, it is now possible to use the "nfs" command to copy the U-Boot binary "u-boot.bin" file, from the server, over the network, in to SDRAM on the target system:
MB618> nfs $load_addr /opt/STM/STLinux-2.3/devkit/sh4/target/boot/u-boot-1.3.1_stm23_0042-mb618/u-boot.bin Warning: MAC addresses don't match: HW MAC address: FF:FF:FF:FF:FF:FF "ethaddr" value: AA:00:04:00:0F:0F Using MAC Address AA:00:04:00:0F:0F STM-GMAC: SMSC LAN8700 found STM-GMAC: 100Mbs full duplex link detected File transfer via NFS from server 164.129.12.192; our IP address is 164.129.15.15 Filename '/opt/STM/STLinux-2.3/devkit/sh4/target/boot/u-boot-1.3.1_stm23_0042-mb618/u-boot.bin'. Load address: 0x8c000000 Loading: ################################# done Bytes transferred = 167712 (28f20 hex)
To burn (a previously downloaded) U-Boot image (in SDRAM) in to flash, then type:
MB618> run unprot Un-Protect Flash Sectors 0-4 in Bank # 1 ..... done MB618> run update Erase Flash Sectors 0-4 in Bank # 1 ..... done Copy to Flash ................ done Protect Flash Sectors 0-4 in Bank # 1 ..... done
This executes the two scripts held in the environment variables "unprot" and "update", which are defined as:
MB618> print unprot ; print update
unprot=protect off $monitor_sec
update=erase $monitor_sec;cp.b $load_addr $monitor_base $monitor_len;protect on $monitor_secThese scripts rely on the following environment variables all being correctly setup: monitor_sec, load_addr, monitor_base, and monitor_len.
Once U-Boot has been burned in to the flash, the kernel image should be burned info flash. The process involved in doing this is very similar to that of burning U-Boot into flash.
The linux image file can then be downloaded in to SDRAM using any supported mechanism, as mentioned above. In this example, NFS is used to download the image as this is very fast. After it is downloaded, the "iminfo" command is used to check the image was downloaded correctly, by verifying its inherent CRC checksum.
MB618> nfs $load_addr /opt/STM/STLinux-2.3/devkit/sh4/target/boot/vmlinux-2.6.23.17_stm23_0117-mb618.ub Warning: MAC addresses don't match: HW MAC address: FF:FF:FF:FF:FF:FF "ethaddr" value: AA:00:04:00:0F:0F Using MAC Address AA:00:04:00:0F:0F STM-GMAC: SMSC LAN8700 found STM-GMAC: 100Mbs full duplex link detected File transfer via NFS from server 164.129.12.192; our IP address is 164.129.15.15 Filename '/opt/STM/STLinux-2.3/devkit/sh4/target/boot/vmlinux-2.6.23.17_stm23_0117-mb618.ub'. Load address: 0x8c000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# #################################### done Bytes transferred = 1845332 (1c2854 hex) MB618> iminfo $load_addr ## Checking Image at 8c000000 ... Image Name: Linux-2.6.23.17_stm23_0117-mb618 Image Type: SuperH Linux Kernel Image (gzip compressed) Data Size: 1845268 Bytes = 1.8 MiB Load Address: 8c001000 Entry Point: 8c002000 Verifying Checksum ... OK
Next we can burn the Linux image to flash and then check it is valid. It is required to choose some empty sectors in the flash to store the kernel image. In this example (MB618), the Linux image will be written in to flash sectors 1:6-20, as the first six sectors are already used by U-Boot - the first five (1:0-4) contains the U-Boot image ("u-boot.bin") and the sixth (1:5) holds the U-Boot environment variables. After burning the image in to flash, it is recommended that it has been flashed correctly, by re-verifying the CRC checksum using the "iminfo" command.
MB618> protect off 1:6-20 Un-Protect Flash Sectors 6-20 in Bank # 1 ............... done MB618> erase 1:6-20 Erase Flash Sectors 6-20 in Bank # 1 ............... done MB618> cp.b $load_addr a0060000 $filesize Copy to Flash ................................................................................ ................................ done MB618> iminfo a0060000 ## Checking Image at a0060000 ... Image Name: Linux-2.6.23.17_stm23_0117-mb618 Image Type: SuperH Linux Kernel Image (gzip compressed) Data Size: 1845268 Bytes = 1.8 MiB Load Address: 8c001000 Entry Point: 8c002000 Verifying Checksum ... OK
Note: that the environment variable "filesize", is automatically created and initialized after a successful nfs download command.