source: rtems-docs/user/testing/tftp.rst @ d5b631f

5
Last change on this file since d5b631f was d5b631f, checked in by Chris Johns <chrisj@…>, on 02/27/19 at 21:36:39

User: Change output block to type none.

  • Property mode set to 100644
File size: 8.7 KB
Line 
1.. SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. Copyright (C) 2018 Chris Johns <chrisj@rtems.org>
4
5TFTP and U-Boot
6---------------
7
8.. index:: TFTP, U-Boot, Testing
9
10TFTP and U-Boot provides a simple way to test RTEMS on a network capable
11target. The RTEMS Tester starts a TFTP server for each test and the target's
12boot monitor, in this case U-Boot request a file, any file, which the TFTP
13server supplies. U-Boot loads the executable and boots it using a standard
14U-Boot script.
15
16.. _fig-tester-tftp-u-boot:
17
18.. figure:: ../../images/user/test-tftp.png
19   :width: 35%
20   :alt: RTEMS Tester using TFTP and U-Boot
21   :figclass: align-center
22
23   RTEMS Tester using TFTP and U-Boot.
24
25The Figure :ref:`fig-tester-tftp-u-boot` figure shows the structure and
26control flow of the RTEMS Tester using TFTP and U-boot. The executables are
27built and the ``rtems-test`` command is run from the top of the build
28directory.
29
30This test mode can only support a single test job running at once. You cannot
31add more test target hardware and run the tests in parallel.
32
33Target Hardware
34^^^^^^^^^^^^^^^
35
36The RTEMS Tester TFTP and U-Boot method of testing requires:
37
38#. A target with network interface.
39
40#. U-Boot, iPXE or similar boot loader with network driver support for your
41   target hardware and support for the TFTP protocol.
42
43#. Network power of IO switch.
44
45#. Network DHCP server.
46
47#. Console interface cable that matches your target's console UART interface.
48
49#. Telnet terminal server. See :ref:`TesterConsoles`.
50
51The network power or IO switch is a device that can control power or an IO pin
52over a network connection using a script-able protocol such as Telnet or
53curl. This device can be used with the target control commands.
54
55U-Boot Set Up
56~~~~~~~~~~~~~
57
58Obtain a working image of the U-Boot boot loader for your target. We suggest
59you follow the instructions for you target.
60
61Configure U-Boot to network boot using the TFTP protocol. This is U-Boot script
62for a Zedboard:
63
64.. code-block:: none
65
66  loadaddr=0x02000000
67  uenvcmd=echo Booting RTEMS Zed from net; set autoload no; dhcp; set serverip 10.10.5.2; tftpboot zed/rtems.img; bootm; reset;
68
69The load address variable ``loadaddr`` is specific to the Zedboard and can be
70found in the various examples scripts on the internet. The script then sets
71U-Boot environment variable ``autoload`` to ``no`` causing DHCP to only request
72a DHCP lease from the DHCP server. The script sets the ``serverip`` to the host
73that will be running the RTEMS Tester then issues a TFTP request. The file name
74can be anything because the RTEMS Tester ignores it sending the executable
75image under test. Finally the script boots the download executable and if that
76fails the catch all ``reset`` resets the board and starts the boot process
77over.
78
79Test the target boots and U-Boot runs and obtains a valid DHCP lease. Manually
80connect the console's telnet port.
81
82BSP Configuration
83^^^^^^^^^^^^^^^^^
84
85The BSP's configuration file must contain the standard fields:
86
87- ``bsp``
88- ``arch``
89- ``jobs`` - Must be set to ``1``.
90- ``tester`` - Set to ``%{_rtscripts}/tftp.cfg``
91
92For example the Zedboard's configuration is:
93
94.. code-block:: ini
95
96  [xilinx_zynq_zedboard]
97  bsp    = xilinx_zynq_zedboard
98  arch   = arm
99  jobs   = 1
100  tester = %{_rtscripts}/tftp.cfg
101
102The TFTP configuration supports the following field's:
103
104``bsp_tty_dev``
105  The target's tty console. For telnet this is a host and port pair written in
106  the standard networking format, for example ``serserver:12345``.
107
108``test_restarts``
109  The number of restarts before the test is considered ``invalid``.
110
111``target_reset_regex``
112  The target reset regular expression. This is a `Python regular expression
113  <https://docs.python.org/2/library/re.html#regular-expression-syntax>`_ used
114  to filter the console input. If a match is made something has happened during
115  the boot process that requires a reset. The ``target_reset_command``
116  is issued to perform the reset. This field is typically looks for boot loader
117  error messages that indicate the boot process as failed.
118
119``target_start_regex``
120  The target start regular expression. This also a Python regular expression to
121  filter the console input to detect if a target has reset. If a board crashes
122  running a test or at any point in time and reset this filter detects this as
123  happened and end the test with a suitable result.
124
125``target_on_command``
126  The target on command is a host shell command that is called before the first
127  test. This command powers on a target. Targets should be left powered off
128  when not running tests or the target may request TFTP downloads that are for
129  another target interfering with those test results. We recommend you
130  implement this command as a target off command, a pause, then a target on
131  command.
132
133``target_off_command``
134  The target off command is a host shell command that is called after the last
135  test powering off the target.
136
137``target_reset_command``
138  The target reset command is a host shell command that is called when the
139  target needs to be reset. This command can power cycle the target or toggle a
140  reset signal connected to the target. If you are power cycling a target make
141  sure you have a suitable pause to let the target completely power down.
142
143``target_pretest_command``
144  The target pretest command is a host shell comment that is called before the
145  test is run
146
147The commands in the listed fields can include parameters that are
148substituted. The parameters are:
149
150``@ARCH@``
151 The BSP architecture
152
153``@BSP@``
154 The BSP's name
155
156``@EXE@``
157  The executable name.
158
159``@FEXE@``
160 The
161. The
162  ``@ARCH`` is the
163
164substituted
165
166Some of these field are normally provided by a user's configuration. To do this
167use:
168
169.. code-block:: ini
170
171  requires = bsp_tty_dev, target_on_command, target_off_command, target_reset_command
172
173The ``requires`` value requires the user provide these settings in their
174configuration file.
175
176The Zedboard's configuration file is:
177
178.. code-block:: ini
179
180  [xilinx_zynq_zedboard]
181  bsp                = xilinx_zynq_zedboard
182  arch               = arm
183  jobs               = 1
184  tester             = %{_rtscripts}/tftp.cfg
185  test_restarts      = 3
186  target_reset_regex = ^No ethernet found.*|^BOOTP broadcast 6.*|^.+complete\.+ TIMEOUT.*
187  target_start_regex = ^U-Boot SPL .*
188  requires           = target_on_command, target_off_command, target_reset_command, bsp_tty_dev
189
190The ``target_start_regex`` searches for U-Boot's first console message. This
191indicate the board can restarted.
192
193The ``target_reset_regex`` checks if no ethernet interface is found. This can
194happen if U-Boot cannot detect the PHY device. It also checks if too many DHCP
195requests happen and finally a check is made for any timeouts reported by
196U-Boot.
197
198An example of a user configuration for the Zedboard is:
199
200.. code-block:: ini
201
202  [xilinx_zynq_zedboard]
203  bsp_tty_dev            = selserver:12345
204  target_pretest_command = zynq-mkimg @EXE@
205  target_exe_filter      = /\.exe/.exe.img/
206  target_on_command      = power-ctl toggle-on 1 4
207  target_off_command     = power-ctl off 1
208  target_reset_command   = power-ctl toggle-on 1 3
209
210TFTP Sequences
211^^^^^^^^^^^^^^
212
213Running a large number of tests on real hardware exposes a range of issues and
214RTEMS Tester is designed to be tolerant of failures in booting or loading that
215can happen, for example a hardware design. These sequence diagrams document
216some of the sequences that can occur when errors happen.
217
218The simplest sequence is running a test. The target is powered on, the test is
219loaded and executed and a pass or fail is determined:
220
221.. _fig-tester-tftp-seq-1:
222
223.. figure:: ../../images/user/test-tftp-seq-1.png
224   :width: 90%
225   :alt: Test Pass and Fail Sequence
226   :figclass: align-center
227
228   Test Pass and Fail Sequences
229
230The target start filter triggers if a start condition is detected. This can
231happen if the board crashes or resets with no output. If this happens
232repeatedly the test result is invalid:
233
234.. _fig-tester-tftp-seq-2:
235
236.. figure:: ../../images/user/test-tftp-seq-2.png
237   :width: 80%
238   :alt: Target Start Filter Trigger
239   :figclass: align-center
240
241   Target Start Filter Trigger
242
243The reset filter triggers if an error condition is found such as the bootloader
244not being able to load the test executable. If the filter triggers the
245``target_reset_command`` is run:
246
247.. _fig-tester-tftp-seq-3:
248
249.. figure:: ../../images/user/test-tftp-seq-3.png
250   :width: 50%
251   :alt: Target Reset Filter Trigger
252   :figclass: align-center
253
254   Target Reset Filter Trigger
255
256If the RTEMS Tester does not detect a test has started it can restart the test
257by resetting the target. The reset command can toggle an IO pin connected to
258reset, request a JTAG pod issue a reset or turn the power off and on:
259
260.. _fig-tester-tftp-seq-4:
261
262.. figure:: ../../images/user/test-tftp-seq-4.png
263   :width: 60%
264   :alt: Target Timeout
265   :figclass: align-center
266
267   Target Timeout
Note: See TracBrowser for help on using the repository browser.