summaryrefslogtreecommitdiff
path: root/test/flash_overwrite.py
blob: 93f282ad808306b8e023e4cc10126131c30c08b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Flash overwrite test
#

from flash_test_util import get_flash_size
from flash_test_util import get_ro_size
from flash_test_util import test_write
import time

def test(helper):
    helper.wait_output("--- UART initialized")

    # Jump to RO
    helper.ec_command("sysjump ro")
    helper.wait_output("idle task started") # jump completed
    time.sleep(0.5)

    # Get flash info
    flashsize = get_flash_size(helper)
    rosize = get_ro_size(helper)

    # We are in RO now. Writing to RO should fail.
    test_write(helper, rosize / 2, 0x10, expect_fail=True)

    # Writing to RW should succeed.
    test_write(helper, rosize, 0x10) # begin of RW
    test_write(helper, (rosize + flashsize) / 2, 0x10) # mid-point of RW
    test_write(helper, flashsize - 0x10, 0x10) # end of flash

    # Jump to RW-A
    helper.ec_command("sysjump a")
    helper.wait_output("idle task started") # jump completed
    time.sleep(0.5)

    # We are in RW now. Writing to RO should succeed.
    test_write(helper, 0, 0x10) # begin of RO
    test_write(helper, rosize / 2, 0x10) # mid-point of RO
    test_write(helper, rosize - 0x10, 0x10) # end of RO

    # Writing to RW-A should fail.
    test_write(helper, rosize, 0x10, expect_fail=True)

    return True