xref: /OK3568_Linux_fs/u-boot/doc/SPL/README.am335x-network (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunUSING AM335x NETBOOT FEATURE
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun Some boards (like TI AM335x based ones) have quite big on-chip RAM and
4*4882a593Smuzhiyunhave support for booting via network in ROM. The following describes
5*4882a593Smuzhiyunhow to setup network booting and then optionally use this support to flash
6*4882a593SmuzhiyunNAND and bricked (empty) board with only a network cable.
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun I. Building the required images
9*4882a593Smuzhiyun  1. You have to enable generic SPL configuration options (see
10*4882a593Smuzhiyundoc/README.SPL) as well as CONFIG_SPL_NET_SUPPORT,
11*4882a593SmuzhiyunCONFIG_ETH_SUPPORT, CONFIG_SPL_LIBGENERIC_SUPPORT and
12*4882a593SmuzhiyunCONFIG_SPL_LIBCOMMON_SUPPORT in your board configuration file to build
13*4882a593SmuzhiyunSPL with support for booting over the network. Also you have to enable
14*4882a593Smuzhiyunthe driver for the NIC used and CONFIG_SPL_BOARD_INIT option if your
15*4882a593Smuzhiyunboard needs some board-specific initialization (TI AM335x EVM does).
16*4882a593SmuzhiyunIf you want SPL to use some Vendor Class Identifier (VCI) you can set
17*4882a593Smuzhiyunone with CONFIG_SPL_NET_VCI_STRING option. am335x_evm configuration
18*4882a593Smuzhiyuncomes with support for network booting preconfigured.
19*4882a593Smuzhiyun 2. Define CONFIG_BOOTCOMMAND for your board to load and run debrick
20*4882a593Smuzhiyunscript after boot:
21*4882a593Smuzhiyun#define CONFIG_BOOTCOMMAND					\
22*4882a593Smuzhiyun	"setenv autoload no; "					\
23*4882a593Smuzhiyun	"bootp; "						\
24*4882a593Smuzhiyun	"if tftp 80000000 debrick.scr; then "			\
25*4882a593Smuzhiyun		"source 80000000; "				\
26*4882a593Smuzhiyun	"fi"
27*4882a593Smuzhiyun(Or create additional board configuration with such option).
28*4882a593Smuzhiyun 3. Build U-Boot as usual
29*4882a593Smuzhiyun  $ make <your_board_name>
30*4882a593Smuzhiyun    You will need u-boot.img and spl/u-boot.bin images to perform
31*4882a593Smuzhiyunnetwork boot. Copy them to u-boot-restore.img and
32*4882a593Smuzhiyunu-boot-spl-restore.bin respectively to distinguish this version
33*4882a593Smuzhiyun(with automatic restore running) from the main one.
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun II. Host configuration.
36*4882a593Smuzhiyun  1. Setup DHCP server (recommended server is ISC DHCPd).
37*4882a593Smuzhiyun   - Install DHCP server and setup it to listen on the interface you
38*4882a593Smuzhiyunchose to connect to the board (usually configured in
39*4882a593Smuzhiyun/etc/default/dhcpd or /etc/default/isc-dhcp-server). Make sure there
40*4882a593Smuzhiyunare no other active DHCP servers in the same network segment.
41*4882a593Smuzhiyun   - Edit your dhcpd.conf and subnet declaration matching the address
42*4882a593Smuzhiyunon the interface. Specify the range of assigned addresses and bootfile
43*4882a593Smuzhiyunto use. IMPORTANT! Both RBL and SPL use the image filename provided
44*4882a593Smuzhiyunin the BOOTP reply but obviously they need different images (RBL needs
45*4882a593Smuzhiyunraw SPL image -- u-boot-spl-restore.bin while SPL needs main U-Boot
46*4882a593Smuzhiyunimage -- u-boot-restore.img). So you have to configure DHCP server to
47*4882a593Smuzhiyunprovide different image filenames to RBL and SPL (and possibly another
48*4882a593Smuzhiyunone to main U-Boot). This can be done by checking Vendor Class
49*4882a593SmuzhiyunIdentifier (VCI) set by BOOTP client (RBL sets VCI to "DM814x ROM v1.0"
50*4882a593Smuzhiyunand you can set VCI used by SPL with CONFIG_SPL_NET_VCI_STRING option,
51*4882a593Smuzhiyunsee above).
52*4882a593Smuzhiyun   - If you plan to use TFTP server on another machine you have to set
53*4882a593Smuzhiyunserver-name option to point to it.
54*4882a593Smuzhiyun   - Here is sample configuration for ISC DHCPd, assuming the interface
55*4882a593Smuzhiyunused to connect to the board is eth0, and it has address 192.168.8.1:
56*4882a593Smuzhiyun
57*4882a593Smuzhiyunsubnet 192.168.8.0 netmask 255.255.255.0 {
58*4882a593Smuzhiyun  range dynamic-bootp 192.168.8.100 192.168.8.199;
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun  if substring (option vendor-class-identifier, 0, 10) = "DM814x ROM" {
61*4882a593Smuzhiyun    filename "u-boot-spl-restore.bin";
62*4882a593Smuzhiyun  } elsif substring (option vendor-class-identifier, 0, 17) = "AM335x U-Boot SPL" {
63*4882a593Smuzhiyun    filename "u-boot-restore.img";
64*4882a593Smuzhiyun  } else {
65*4882a593Smuzhiyun    filename "uImage";
66*4882a593Smuzhiyun  }
67*4882a593Smuzhiyun}
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun  May the ROM bootloader sends another "vendor-class-identifier"
70*4882a593Smuzhiyun  on the shc board with an AM335X it is:
71*4882a593Smuzhiyun  "AM335x ROM"
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun  2. Setup TFTP server.
74*4882a593Smuzhiyun     Install TFTP server and put image files to it's root directory
75*4882a593Smuzhiyun(likely /tftpboot or /var/lib/tftpboot or /srv/tftp). You will need
76*4882a593Smuzhiyunu-boot.img and spl/u-boot-spl-bin files from U-Boot build directory.
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun III. Reflashing (debricking) the board.
79*4882a593Smuzhiyun  1. Write debrick script. You will need to write a script that will
80*4882a593Smuzhiyunbe executed after network boot to perform actual rescue actions. You
81*4882a593Smuzhiyuncan use usual U-Boot commands from this script: tftp to load additional
82*4882a593Smuzhiyunfiles, nand erase/nand write to erase/write the NAND flash.
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun  2. Create script image from your script. From U-Boot build directory:
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun$ ./tools/mkimage -A arm -O U-Boot -C none -T script -d <your script> debrick.scr
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunThis will create debrick.scr file with your script inside.
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun  3. Copy debrick.scr to TFTP root directory. You also need to copy
91*4882a593Smuzhiyunthere all the files your script tries to load via TFTP. Example script
92*4882a593Smuzhiyunloads u-boot.img and MLO. You have to create these files doing regular
93*4882a593Smuzhiyun(not restore_flash) build and copy them to tftpboot directory.
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun  4. Boot the board from the network, U-Boot will load debrick script
96*4882a593Smuzhiyunand run it after boot.
97