1*** Keywords ***
2Create Machine
3    Execute Command                         using sysbus
4    Execute Command                         mach create
5    Execute Command                         machine LoadPlatformDescription @platforms/boards/stm32f4_discovery-kit.repl
6
7Unlock Control Register
8    Execute Command                         sysbus WriteDoubleWord 0x40023c04 0x45670123
9    Execute Command                         sysbus WriteDoubleWord 0x40023c04 0xcdef89ab
10
11*** Test Cases ***
12
13Should Ignore Erase When MER And SER Are Reset
14    Create Machine
15    Create Log Tester                       3
16
17    Execute Command                         sysbus WriteDoubleWord 0x08000000 0xdeadbeef
18    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x08000000
19    Should Be True      """${read_result}""".strip() == "0xDEADBEEF"
20
21    Unlock Control Register
22
23    Execute Command                         sysbus WriteDoubleWord 0x40023c10 0x00010000    ## Try to perform erase with both SER and MER unset
24
25    Wait For Log Entry                      Tried to erase flash, but MER and SER are reset. This should be forbidden, ignoring...
26
27    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x08000000                ## Should ignore erase attempt
28    Should Be True      """${read_result}""".strip() == "0xDEADBEEF"
29
30Should Perform Mass Erase
31    Create Machine
32
33    Execute Command                         sysbus WriteDoubleWord 0x08000000 0xdeadbeef
34    Execute Command                         sysbus WriteDoubleWord 0x080E0000 0xcafebabe
35    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x08000000
36    Should Be True      """${read_result}""".strip() == "0xDEADBEEF"
37    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x080E0000
38    Should Be True      """${read_result}""".strip() == "0xCAFEBABE"
39
40    Unlock Control Register
41
42    Execute Command                         sysbus WriteDoubleWord 0x40023c10 0x00010004    ## Set MER and try to perform mass erase
43
44    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x08000000
45    Should Be True      """${read_result}""".strip() == "0xFFFFFFFF"
46    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x080E0000
47    Should Be True      """${read_result}""".strip() == "0xFFFFFFFF"
48
49Should Perform Sector Erase
50    Create Machine
51
52    Execute Command                         sysbus WriteDoubleWord 0x08000000 0xdeadbeef
53    Execute Command                         sysbus WriteDoubleWord 0x080E0000 0xcafebabe
54    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x08000000
55    Should Be True      """${read_result}""".strip() == "0xDEADBEEF"
56    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x080E0000
57    Should Be True      """${read_result}""".strip() == "0xCAFEBABE"
58
59    Unlock Control Register
60
61    Execute Command                         sysbus WriteDoubleWord 0x40023c10 0x0001005a    ## Set SER and SNB to sector 11, and try to perform sector erase
62
63    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x08000000
64    Should Be True      """${read_result}""".strip() == "0xDEADBEEF"
65    ${read_result} =    Execute Command     sysbus ReadDoubleWord 0x080E0000
66    Should Be True      """${read_result}""".strip() == "0xFFFFFFFF"
67