-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_app.py
91 lines (68 loc) · 2.24 KB
/
load_app.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python3
import sys, os, shutil
from pyOCD.board import MbedBoard
import logging
import serial.tools.list_ports_linux as serial_tools
import glob
import configparser
import argparse
# Parse the arguments
parser = argparse.ArgumentParser()
parser.add_argument("app_files", help="source file to compile")
parser.add_argument("-m", "--m3pi",
help = "Specifies which version ( 0 : default, 1: modified) of m3pi library to use, default is 0 (original)",
default = 0)
args = parser.parse_args()
# if len(sys.argv) < 2:
# print("Please specify the test file to insert or 'remove' to remove the test code.")
# print("Note that removing a test will not move the test file back into the "
# "'tests/' directory. Please manually save your changes if you have made edits.")
# print("Examples:")
# print("python3 load_test.py app_files/hdlc_test/")
# sys.exit()
app_path = args.app_files + '.mbedignore'
ignore_file = 'app_files/ignore_file/.mbedignore'
if args.m3pi == '0':
m3pi_path = 'm3pi/original/.mbedignore'
elif args.m3pi == '1':
m3pi_path = 'm3pi/modified/.mbedignore'
else:
m3pi_path = 'm3pi/original/.mbedignore'
print(m3pi_path)
os.remove(app_path)
os.remove(m3pi_path)
def serial_ports(unique_id):
ports = list(serial_tools.comports())
for p in ports:
if unique_id in p.hwid:
return p.device
logging.basicConfig(level=logging.INFO)
os.system("mbed compile");
# os.remove("main.cpp")
shutil.copy(ignore_file, app_path)
shutil.copy(ignore_file, m3pi_path)
board = MbedBoard.chooseBoard()
target = board.target
flash = board.flash
target.resume()
target.halt()
# print "pc: 0x%X" % target.readCoreRegister("pc")
# pc: 0xA64
# target.step()
# print "pc: 0x%X" % target.readCoreRegister("pc")
# pc: 0xA30
# target.step()
# print "pc: 0x%X" % target.readCoreRegister("pc")
# pc: 0xA32
filename=glob.glob('./BUILD/LPC1768/GCC_ARM/*.bin')
flash.flashBinary(filename[0])
print("pc: 0x%X" % target.readCoreRegister("pc"))
# pc: 0x10000000
target.reset()
# target.halt()
# print "pc: 0x%X" % target.readCoreRegister("pc")
# # pc: 0xAAC
#
cmd = "./pyterm -b 115200 -p %s" % serial_ports(board.unique_id)
os.system(cmd)
# board.uninit())