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

5
Last change on this file since 8b67c91 was 8b67c91, checked in by Chris Johns <chrisj@…>, on 05/19/18 at 20:32:42

user: Add RTEMS executable and test documentation.

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