Commit Graph

273 Commits

Author SHA1 Message Date
Fabio Utzig 19b2c1a927 Add extra information on errors
* Print bail out error information
* Print specific location of non-ff writes
2017-04-20 08:25:30 -03:00
David Brown 4cb2623574 Back out unneeded part of random reset test
In change

    commit bb5635e074
    Author: Fabio Utzig <utzig@utzig.org>
    Date:   Mon Apr 10 09:07:02 2017 -0300

        Add test of multiple random resets while upgrading

in addition to adding the try_random_fails, it shuffled the order that
the initial interruption test ran.  However, this test always clones
the flash device, so it doesn't matter what order the tests are run.
Revert this part of the change to avoid unnecessary complexity in the
code.
2017-04-11 08:18:18 -06:00
Fabio Utzig bb5635e074 Add test of multiple random resets while upgrading 2017-04-10 09:07:02 -03:00
David Brown a3b93cfe95 sim: Add runall command
Add a `runall` command that will run all combinations of devices and
alignments.

Jira: MCUB-44
2017-03-29 13:02:13 -06:00
David Brown 361be7ade7 sim: Return exit status from sim run
Instead of just printing a message, return an exit status so that
scripts running the sim can more easily tell if the tests passed.

Jira: MCUB-45
2017-03-29 13:01:44 -06:00
David Brown 274f7874db sim: Show address for overwrite error
When trying to write to the flash to a non-FF location, put the
location of the failure in the error message to help diagnose the
problem.
2017-03-29 13:01:13 -06:00
David Brown 07fb8fa0c8 sim: Add NRF52840 device
Add the flash device from the NRF52840 SoC.
2017-03-29 13:01:13 -06:00
David Brown 5c6b6798d0 sim: Use simulated flash configuration
There are some instances of hard-coded offsets, which break if the
simulated device doesn't have the same configuration.  Query these
from the flash descriptor rather than hard-coding them.
2017-03-29 13:01:13 -06:00
David Brown 0daa36c99f sim: Remove phantom declaration from CAreaDesc
Although this contains a phantom pointer, because it is passed to C,
this generates a warning on every compile.  Until this is fixed,
remove the lifetime declarations from the structures.  The user will
have to make sure that the pointed-to structures remain until the C
structure is completed.  For the common case of generating the C
structures just to make a call, this should be safe.
2017-03-29 12:58:40 -06:00
David Brown e380fa6e30 sim: Set version numbers in images
To make the images easier to identify during analysis, set the version
number.  The major number tries to be set to the slot number, and the
build number is the byte offset.
2017-01-23 16:01:02 -07:00
David Brown 163ab23340 sim: Add some debug code to dump images
The code is commented out, but can easily be uncommented to allow the
various images to be dumped out for external analysis.
2017-01-23 16:01:02 -07:00
David Brown 75e16d6900 sim: Write image_ok properly
With stricter checking of alignment, always write the image ok flag as a
group of 'align' bytes.
2017-01-23 16:01:02 -07:00
David Brown 74cc14c31e sim: pad images to alignment
Adjust the image sizes up to a multiple of 8.  With the strict checking
in the flash driver, we aren't allowed to write partial lines.
2017-01-23 16:01:02 -07:00
David Brown f253fa815c sim: Make misaligned writes panic
To make things a little easier to debug, change misaligned writes to
panics, so that the debugger can more easily intercept them.
2017-01-23 16:01:01 -07:00
David Brown 5acda26f88 sim: Be consistent about flash alignment
The flash API has two calls that can return the device alignment.  Fix
this so that both calls return the same alignment.
2017-01-23 16:01:01 -07:00
David Brown 562a7a05d4 sim: Verify write alignment
When an alignment greater than one is specified, enforce this in the
simulated flash driver.
2017-01-23 16:01:01 -07:00
David Brown 90c1913c13 sim: Add the K64fBig target
This target simulates running with pretend large sectors on a device
that really has small sectors.
2017-01-23 16:01:01 -07:00
David Brown dc1964c0a6 sim: Fix build paths for new directory layout
The zephyr sources have moved to a different directory.  Adjust the
build script to fix the paths referenced.
2017-01-10 16:45:05 -07:00
David Brown c638f799a0 sim: Test multiple reverts
Make sure reboots after an image is reverted never results in the images
being swapped again.
2017-01-10 16:43:07 -07:00
David Brown 1a44316c85 sim: Add dependency output
Output the names of source files used to build the C library so that
Cargo knows to rerun the compilation if these have changed.
2017-01-10 16:43:07 -07:00
David Brown 841d73aaf1 sim: Create a small README.rst
Describe how to build and run the simulator.
2017-01-09 12:28:11 -07:00
David Brown 4440af8f59 sim: Use logging to control output
Use the Rust logging so that normal messaging isn't overwhelmed by
messages printed.  The default level is 'error' which will only print
full errors (including the failures at the end).

To run with warnings:

   RUST_LOG=warn ./target/release/bootsim ...

This will print warnings, showing the particular failures in mind.
Using 'info' instead of 'warn' will print lots of progress as it runs.
2017-01-09 12:28:10 -07:00
David Brown de7729e6ec sim: Add simulator code
'sim' is a small simulator for the bootloader's update code.  It tests
untimely powerdowns to ensure that the bootloader will recover from a
power loss or reset at any time during the boot.

Note that, as of this commit, there are some failures in the test that
need to be investigated.

Also note that this build script does not output proper dependencies for
source files outside of the simulator directory, and won't rebuild the C
files if they or headers are modified.
2017-01-09 12:28:10 -07:00