xref: /openbmc/u-boot/doc/SPL/README.am335x-network (revision dc557e9a1fe00ca9d884bd88feef5bebf23fede4)
1427ac8ccSIlya YanokUSING AM335x NETBOOT FEATURE
2427ac8ccSIlya Yanok
3427ac8ccSIlya Yanok Some boards (like TI AM335x based ones) have quite big on-chip RAM and
4427ac8ccSIlya Yanokhave support for booting via network in ROM. The following describes
5427ac8ccSIlya Yanokhow to setup network booting and then optionally use this support to flash
6427ac8ccSIlya YanokNAND and bricked (empty) board with only a network cable.
7427ac8ccSIlya Yanok
8427ac8ccSIlya Yanok I. Building the required images
9427ac8ccSIlya Yanok  1. You have to enable generic SPL configuration options (see
10b1e6c4c3SAnatolij Gustschindoc/README.SPL) as well as CONFIG_SPL_NET_SUPPORT,
11427ac8ccSIlya YanokCONFIG_ETH_SUPPORT, CONFIG_SPL_LIBGENERIC_SUPPORT and
12427ac8ccSIlya YanokCONFIG_SPL_LIBCOMMON_SUPPORT in your board configuration file to build
13427ac8ccSIlya YanokSPL with support for booting over the network. Also you have to enable
14427ac8ccSIlya Yanokthe driver for the NIC used and CONFIG_SPL_BOARD_INIT option if your
15427ac8ccSIlya Yanokboard needs some board-specific initialization (TI AM335x EVM does).
16427ac8ccSIlya YanokIf you want SPL to use some Vendor Class Identifier (VCI) you can set
17427ac8ccSIlya Yanokone with CONFIG_SPL_NET_VCI_STRING option. am335x_evm configuration
18427ac8ccSIlya Yanokcomes with support for network booting preconfigured.
19427ac8ccSIlya Yanok 2. Define CONFIG_BOOTCOMMAND for your board to load and run debrick
20427ac8ccSIlya Yanokscript after boot:
21427ac8ccSIlya Yanok#define CONFIG_BOOTCOMMAND					\
22427ac8ccSIlya Yanok	"setenv autoload no; "					\
23427ac8ccSIlya Yanok	"bootp; "						\
24427ac8ccSIlya Yanok	"if tftp 80000000 debrick.scr; then "			\
25427ac8ccSIlya Yanok		"source 80000000; "				\
26427ac8ccSIlya Yanok	"fi"
27427ac8ccSIlya Yanok(Or create additional board configuration with such option).
28427ac8ccSIlya Yanok 3. Build U-Boot as usual
29427ac8ccSIlya Yanok  $ make <your_board_name>
30427ac8ccSIlya Yanok    You will need u-boot.img and spl/u-boot.bin images to perform
31427ac8ccSIlya Yanoknetwork boot. Copy them to u-boot-restore.img and
32427ac8ccSIlya Yanoku-boot-spl-restore.bin respectively to distinguish this version
33427ac8ccSIlya Yanok(with automatic restore running) from the main one.
34427ac8ccSIlya Yanok
35427ac8ccSIlya Yanok II. Host configuration.
36427ac8ccSIlya Yanok  1. Setup DHCP server (recommended server is ISC DHCPd).
37427ac8ccSIlya Yanok   - Install DHCP server and setup it to listen on the interface you
38427ac8ccSIlya Yanokchose to connect to the board (usually configured in
39427ac8ccSIlya Yanok/etc/default/dhcpd or /etc/default/isc-dhcp-server). Make sure there
40427ac8ccSIlya Yanokare no other active DHCP servers in the same network segment.
41427ac8ccSIlya Yanok   - Edit your dhcpd.conf and subnet declaration matching the address
42427ac8ccSIlya Yanokon the interface. Specify the range of assigned addresses and bootfile
43427ac8ccSIlya Yanokto use. IMPORTANT! Both RBL and SPL use the image filename provided
44427ac8ccSIlya Yanokin the BOOTP reply but obviously they need different images (RBL needs
45427ac8ccSIlya Yanokraw SPL image -- u-boot-spl-restore.bin while SPL needs main U-Boot
46427ac8ccSIlya Yanokimage -- u-boot-restore.img). So you have to configure DHCP server to
47427ac8ccSIlya Yanokprovide different image filenames to RBL and SPL (and possibly another
48427ac8ccSIlya Yanokone to main U-Boot). This can be done by checking Vendor Class
49427ac8ccSIlya YanokIdentifier (VCI) set by BOOTP client (RBL sets VCI to "DM814x ROM v1.0"
50427ac8ccSIlya Yanokand you can set VCI used by SPL with CONFIG_SPL_NET_VCI_STRING option,
51427ac8ccSIlya Yanoksee above).
52427ac8ccSIlya Yanok   - If you plan to use TFTP server on another machine you have to set
53427ac8ccSIlya Yanokserver-name option to point to it.
54427ac8ccSIlya Yanok   - Here is sample configuration for ISC DHCPd, assuming the interface
55427ac8ccSIlya Yanokused to connect to the board is eth0, and it has address 192.168.8.1:
56427ac8ccSIlya Yanok
57427ac8ccSIlya Yanoksubnet 192.168.8.0 netmask 255.255.255.0 {
58427ac8ccSIlya Yanok  range dynamic-bootp 192.168.8.100 192.168.8.199;
59427ac8ccSIlya Yanok
60427ac8ccSIlya Yanok  if substring (option vendor-class-identifier, 0, 10) = "DM814x ROM" {
61427ac8ccSIlya Yanok    filename "u-boot-spl-restore.bin";
62427ac8ccSIlya Yanok  } elsif substring (option vendor-class-identifier, 0, 17) = "AM335x U-Boot SPL" {
63427ac8ccSIlya Yanok    filename "u-boot-restore.img";
64427ac8ccSIlya Yanok  } else {
65427ac8ccSIlya Yanok    filename "uImage";
66427ac8ccSIlya Yanok  }
67427ac8ccSIlya Yanok}
68427ac8ccSIlya Yanok
69*3e584b94SHeiko Schocher  May the ROM bootloader sends another "vendor-class-identifier"
70*3e584b94SHeiko Schocher  on the shc board with an AM335X it is:
71*3e584b94SHeiko Schocher  "AM335x ROM"
72*3e584b94SHeiko Schocher
73427ac8ccSIlya Yanok  2. Setup TFTP server.
74427ac8ccSIlya Yanok     Install TFTP server and put image files to it's root directory
75427ac8ccSIlya Yanok(likely /tftpboot or /var/lib/tftpboot or /srv/tftp). You will need
76427ac8ccSIlya Yanoku-boot.img and spl/u-boot-spl-bin files from U-Boot build directory.
77427ac8ccSIlya Yanok
78427ac8ccSIlya Yanok III. Reflashing (debricking) the board.
79427ac8ccSIlya Yanok  1. Write debrick script. You will need to write a script that will
80427ac8ccSIlya Yanokbe executed after network boot to perform actual rescue actions. You
81427ac8ccSIlya Yanokcan use usual U-Boot commands from this script: tftp to load additional
82427ac8ccSIlya Yanokfiles, nand erase/nand write to erase/write the NAND flash.
83427ac8ccSIlya Yanok
84427ac8ccSIlya Yanok  2. Create script image from your script. From U-Boot build directory:
85427ac8ccSIlya Yanok
86427ac8ccSIlya Yanok$ ./tools/mkimage -A arm -O U-Boot -C none -T script -d <your script> debrick.scr
87427ac8ccSIlya Yanok
88427ac8ccSIlya YanokThis will create debrick.scr file with your script inside.
89427ac8ccSIlya Yanok
90427ac8ccSIlya Yanok  3. Copy debrick.scr to TFTP root directory. You also need to copy
91427ac8ccSIlya Yanokthere all the files your script tries to load via TFTP. Example script
92427ac8ccSIlya Yanokloads u-boot.img and MLO. You have to create these files doing regular
93427ac8ccSIlya Yanok(not restore_flash) build and copy them to tftpboot directory.
94427ac8ccSIlya Yanok
95427ac8ccSIlya Yanok  4. Boot the board from the network, U-Boot will load debrick script
96427ac8ccSIlya Yanokand run it after boot.
97