3.5. Debugging and Testing your Flash Algorithm

The flash algorithm is a normal C program so it can be loaded and run in a debugger such as RVD. The Debug build configuration includes the flashDeviceTest.c test harness that you can use to debug and test your flash algorithm.

To load your flash algorithm into RVD:

  1. In the C/C++ Projects pane, navigate to the build directory for your current build configuration, for example Debug, in your project, and select the .axf file that contains your flash algorithm.

  2. Select Run → Debug As → Load into RealView Debugger from the Eclipse main menu. RVD starts.

  3. Configure and connect to your target hardware in RVD. After connecting the image should load automatically. If the image does not load, repeat steps 1 and 2 whilst remaining connected to your target in RVD.

You can now run the executable in the RVD to test your flash algorithm. The test harness exercises all aspects of your flash algorithm and uses semihosting to output the results to the RVD console (see Figure 3).

Figure 3. Test results in the RVD console

Test results in the RVD console

For each test the test harness outputs a short description of the purpose of the test, followed by some logging during the test, finally followed by the overall result. Results from the test harness are one of PASSED, FAILED or SKIPPED.

Tests are skipped if the test harness detects that the necessary functionality is not available in your flash algorithm. You should examine skipped tests to ensure that this outcome is consistent with what you have implemented.

Failed tests indicate a problem in your flash algorithm. You can use the log generated during the test to help diagnose the problem. If the built-in logging is insufficient, you can modify the test harness or your algorithm to include additional printf() statements. However, if you add printf() statements to your flash algorithm you must be careful to remove them before importing the algorithm into the Eclipse Flash Programmer plug-in, because the Eclipse Flash Programmer plug-in does not support semihosting. Alternatively you can rerun the tests and use the standard debugger facilities to step through the tests and examine variables and memory.

If you are unsure about some aspect of your flash device's operation, you can use the memory window in RVD to manually poke commands and data at the flash device and observe the results. If you do this you may find it necessary to edit the memory map in RVD so that correct sized memory accesses are used for your flash device. You can edit the memory map in RVD either using the Memory Map tab in the Process Control pane or by creating a Board/Chip Definition (BCD) file. See the RVD documentation for further details.

The test harness contains some extended tests that are disabled by default. These extended tests check that each bit in the flash device can be written as zero and written as one. You can enable these extended tests by uncommenting the #define EXTENDED_TESTS line near the top of the flashDeviceTest.c file. Enabling the extended tests increases the time taken to run the tests.

Copyright © 2007. All rights reserved.DAI0190A