Files
OpenCellular/test/flash_overwrite.py
Vic Yang 37b295fd6e Add a test of flash overwrite
This test checks we cannot overwrite current running system image.

BUG=chrome-os-partner:10262
TEST=Test passed

Change-Id: I72be277c9de2114e72000a102d8b885e842ef15a
Reviewed-on: https://gerrit.chromium.org/gerrit/27006
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-10 00:35:58 -07:00

47 lines
1.4 KiB
Python

# 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, 0x30, expect_fail=True)
# Writing to RW should succeed.
test_write(helper, rosize, 0x30) # begin of RW
test_write(helper, (rosize + flashsize) / 2, 0x30) # mid-point of RW
test_write(helper, flashsize - 0x30, 0x30) # 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, 0x30) # begin of RO
test_write(helper, rosize / 2, 0x30) # mid-point of RO
test_write(helper, rosize - 0x30, 0x30) # end of RO
# Writing to RW-A should fail.
test_write(helper, rosize, 0x30, expect_fail=True)
return True