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