Debian Codegraph @

test/blank_test.py

raw symbols SCIP
1 #!/usr/bin/env python
2 # pyOCD debugger
3 # Copyright (c) 2006-2020,2025 Arm Limited
4 # SPDX-License-Identifier: Apache-2.0
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 import os
18 import sys
19 from time import sleep
20 from random import randrange
21 import math
22 import logging
23
24 from pyocd.core.helpers import ConnectHelper
25 from pyocd.flash.file_programmer import FileProgrammer
26 from test_util import (
27 get_session_options,
28 get_test_binary_path,
29 )
30
31 logging.basicConfig(level=logging.WARNING)
32
33 print("\n\n------ Test attaching to locked board ------")
34 for i in range(0, 10):
35 with ConnectHelper.session_with_chosen_probe(**get_session_options()) as session:
36 board = session.board
37 flash = session.target.memory_map.get_boot_memory().flash
38 # Erase and then reset - This locks Kinetis devices
39 board.target.reset_and_halt()
40 flash.init(flash.Operation.ERASE)
41 flash.erase_all()
42 flash.cleanup()
43 board.target.reset()
44
45 print("\n\n------ Testing Attaching to board ------")
46 for i in range(0, 100):
47 with ConnectHelper.session_with_chosen_probe(**get_session_options()) as session:
48 board = session.board
49 board.target.halt()
50 sleep(0.01)
51 board.target.resume()
52 sleep(0.01)
53
54 print("\n\n------ Flashing new code ------")
55 with ConnectHelper.session_with_chosen_probe(**get_session_options()) as session:
56 board = session.board
57 binary_file = get_test_binary_path(board.test_binary)
58 board.target.reset_and_halt()
59 FileProgrammer(session).program(binary_file)
60
61 print("\n\n------ Testing Attaching to regular board ------")
62 for i in range(0, 10):
63 with ConnectHelper.session_with_chosen_probe(**get_session_options()) as session:
64 board = session.board
65 board.target.reset_and_halt()
66 board.target.halt()
67 sleep(0.2)
68 board.target.resume()
69 sleep(0.2)