URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [io/] [serial/] [v2_0/] [tests/] [README] - Rev 603
Go to most recent revision | Compare with Previous | Blame | View Log
Serial Testing with ser_filterRationale~~~~~~~~~Since some targets only have one serial connection, a serial testingharness needs to be able to share the connection with GDB (however,the test and GDB can also run on separate lines).The serial filter (ser_filter) sits between the serial port and GDBand monitors the exchange of data between GDB and thetarget. Normally, no changes are made to the data.When a test request packet is sent from the test on the target, it isintercepted by the filter. The filter and target then enter a loop,exchanging protocol data between them which GDB never sees.In the event of a timeout, or a crash on the target, the filter fallsback into its pass-through mode. If this happens due to a crash itshould be possible to start regular debugging with GDB. The filterwill then stay in the pass-though mode until GDB disconnects.Adding A New Platform~~~~~~~~~~~~~~~~~~~~~The file ser_test_protocol.inl contains information about how to runthe serial tests on supported platforms. When adding a new serialdriver to eCos, ser_test_protocol.inl should be updated accordinglyso the driver can be tested.The definitions TEST_SER_DEV and TEST_TTY_DEV are set according toplatform:TEST_SER_DEV is the name of the serial device over which the serialtest protocol runs. The definition should be conditional on allrequired configuration options.TEST_TTY_DEV is the name of the TTY device over which the TTY testprotocol runs. The definition should be conditional on all requiredconfiguration options. Note that this device is layered on top of aserial device and must be conditional on that device's configoptions as well as its own.Here's an example for the PowerPC/Cogent where GDB is connected viaserial connector B:#if defined(CYGPKG_HAL_POWERPC_COGENT) \&& defined(CYGPKG_IO_SERIAL_POWERPC_COGENT) \&& defined(CYGPKG_IO_SERIAL_POWERPC_COGENT_SERIAL_B)# define TEST_SER_DEV CYGDAT_IO_SERIAL_POWERPC_COGENT_SERIAL_B_NAME# if defined(CYGPKG_IO_SERIAL_TTY_TTY2)# define TEST_TTY_DEV CYGDAT_IO_SERIAL_TTY_TTY2_DEV# endif#endifOn some targets it may also be necessary to intialize interruptvectors which are otherwise used by CygMon or an eCos GDB stub tomonitor characters from the host (looking for Control-C):# define SER_OVERRIDE_INT_1 CYGNUM_HAL_INTERRUPT_9# define SER_OVERRIDE_INT_2 CYGNUM_HAL_INTERRUPT_10These definitions cause the serial test to restore the eCos handleron the specified vectors before opening the serial device.The file ser_test_protocol.inl also contains an array of serialconfigurations (test_configs). It may be necessary to comment some ofthese out for the platform if the driver or hardware cannot handleall the given serial configurations.The Protocol~~~~~~~~~~~~The protocol commands are prefixed with an @-character which theserial filter is looking for. The protocol commands include:PINGAllows the test on the target to probe for the filter. The filterresponds with OK, while GDB would just ignore the command. Thisallows the tests to do nothing if they require the filter and it isnot present.CONFIGRequests a change of serial line configuration. Arguments of thecommand specify baud rate, data bits, stop bits, and parity.OPTRequests changes in the filter's options. This allows variousamounts of tracing to be recorded when running tests withoutrequiring the filter to be restarted.BINARYRequests data to be sent from the filter to the target. The data ischecksummed, allowing errors in the transfer to be detected.Sub-options of this command control how the data transfer is made:NO_ECHO (serial driver receive test)Just send data from the filter to the target. The test verifiesthe checksum and PASS/FAIL depending on the result.EOP_ECHO (serial driver half-duplex receive and send test)As NO_ECHO but the test echoes back the data to the filter. Thefilter does a checksum on the received data and sends the resultto the target. The test PASS/FAIL depending on the result of bothchecksum verifications.DUPLEX_ECHO (serial driver duplex receive and send test)Smaller packets of data are sent back and forth in a pattern thatensures that the serial driver will be both sending and receivingat the same time. Again, checksums are computed and verifiedresulting in PASS/FAIL.TEXTThis is a test of the text translations in the TTY layer.Requests a transfer of text data from the target to the filter andpossibly back again. The filter treats this as a binary transfer,while the target may be doing translations on the data. The targetprovides the filter with checksums for what it should expect tosee.[This test is not implemented yet]The above commands may be extended, and new commands added, asrequired to test (new) parts of the serial drivers in eCos.See ser_test_protocol.inl for further details on the protocols.The Serial Tests~~~~~~~~~~~~~~~~The serial tests are built as any other eCos test. After running the'make tests' command, the tests can be found in:install/tests/io_serial/serial1A simple API test.serial2A simple serial send test. It writes out two strings, one raw andone encoded as a GDB O-packet.serial3 [requires the serial filter]This tests the half-duplex send and receive capabilities of theserial driver.serial4 [requires the serial filter]This test attempts to use a few different serial configurations,testing the driver's configuration/setup functionality.serial5 [requires the serial filter]This tests the duplex send and receive capabilities of the serialdriver.All tests should complete in less than 30 seconds.Serial Filter Usage~~~~~~~~~~~~~~~~~~~Running the ser_filter program with no (or wrong) arguments resultsin the below output:Usage: ser_filter [-t -c -g -S] TcpIPport SerialPort BaudRateor: ser_filter -n [-t -c -g -S] SerialPort BaudRate-t: Enable tracing.-f: Enable filter output tracing.-g: Enable GDB tracing.-S: Output data read from serial line.-c: Output data on console instead of via GDB.-n: No GDB.The normal way to use it with GDB is to start the filter:ser_filter -t 9000 com1 38400In this case, the filter will be listening on port 9000 and connectto the target via the serial port COM1 at 38400 baud. On a UNIX host,replace "com1" with a device such as "/dev/ttyS0".The '-t' option enables tracing which will cause the filter todescribe its actions on the console.Now start GDB with one of the tests as an argument:$ mips-tx39-elf-gdb -nw install/tests/io_serial/serial3Then connect to the filter:(gdb) target remote localhost:9000This should result in a connection in exactly the same way as if youhad connected directly to the target on the serial line.(gdb) load...(gdb) contWhich should result in output similar to the below:Continuing.INFO:<BINARY:16:1!>PASS:<Binary test completed>INFO:<BINARY:128:1!>PASS:<Binary test completed>INFO:<BINARY:256:1!>PASS:<Binary test completed>INFO:<BINARY:1024:1!>PASS:<Binary test completed>INFO:<BINARY:512:0!>PASS:<Binary test completed>...PASS:<Binary test completed>INFO:<BINARY:16384:0!>PASS:<Binary test completed>PASS:<serial3 test OK>EXIT:<done>If any of the individual tests fail the testing will terminate witha FAIL.With tracing enabled, you would also see the filter's status output:The PING command sent from the target to determine the presence ofthe filter:[400 11:35:16] Dispatching command PING[400 11:35:16] Responding with status OKEach of the binary commands result in output similar to:[400 11:35:16] Dispatching command BINARY[400 11:35:16] Binary data (Size:16, Flags:1).[400 11:35:16] Sending CRC: '170231!', len: 7.[400 11:35:16] Reading 16 bytes from target.[400 11:35:16] Done. in_crc 170231, out_crc 170231.[400 11:35:16] Responding with status OK[400 11:35:16] Received DONE from target.This tracing output is normally sent as O-packets to GDB which willdisplay the tracing text. By using the -c option, the tracing textcan be redirected to the console from which ser_filter was started.The trace options -f, -g, and -S cause data sent from filter, GDB ortarget to be output in hexadecimal form.A Note on Failures~~~~~~~~~~~~~~~~~~A serial connection (especially when driven at a high baud rate) cangarble the transmitted data because of noise from the environment. Itis not the job of the serial driver to ensure data integrity - thatis the job of protocols layering on top of the serial driver.In the current implementation the serial tests and the serial filterare not resilient to such data errors. This means that the test maycrash or hang (possibly without reporting a FAIL). It also means thatyou should be aware of random errors - a FAIL is not necessarilycaused by a bug in the serial driver.Ideally, the serial testing infrastructure should be able todistinguish random errors from consistent errors - the former aremost likely due to noise in the transfer medium, while the latter aremore likely to be caused by faulty drivers. The currentimplementation of the infrastructure does not have this capability.Debugging~~~~~~~~~If a test fails, the serial filter's output may provide some hintsabout what the problem is. If the option '-S' is used when startingthe filter, data received from the target is printed out:[400 11:35:16] 0000 50 41 53 53 3a 3c 42 69 'PASS:<Bi'[400 11:35:16] 0008 6e 61 72 79 20 74 65 73 'nary.tes'[400 11:35:16] 0010 74 20 63 6f 6d 70 6c 65 't.comple'[400 11:35:16] 0018 74 65 64 3e 0d 0a 49 4e 'ted>..IN'[400 11:35:16] 0020 46 4f 3a 3c 42 49 4e 41 'FO:<BINA'[400 11:35:16] 0028 52 59 3a 31 32 38 3a 31 'RY:128:1'[400 11:35:16] 0030 21 3e 0d 0a 40 42 49 4e '!>..@BIN'[400 11:35:16] 0038 41 52 59 3a 31 32 38 3a 'ARY:128:'[400 11:35:16] 0040 31 21 .. .. .. .. .. .. '1!'In the case of an error during a testing command the data received bythe filter will be printed out, as will the data that wasexpected. This allows the two data sets to be compared which may givesome idea of what the problem is.
Go to most recent revision | Compare with Previous | Blame | View Log
