1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import copy
1516import json
1617import os
1718
@@ -31,7 +32,7 @@ def configure_default_packages(self, variables, targets):
3132 variables .get ("board" )).get (
3233 "upload.protocol" , "" ))
3334 if upload_protocol == "cmsis-dap" :
34- self .packages [' tool-pyocd' ][ ' type' ] = "uploader"
35+ self .packages [" tool-pyocd" ][ " type" ] = "uploader"
3536
3637 if "mbed" in variables .get ("pioframework" , []):
3738 deprecated_boards_file = os .path .join (
@@ -48,7 +49,7 @@ def configure_default_packages(self, variables, targets):
4849 "tool-cmake" , "tool-dtc" , "tool-ninja" ):
4950 self .packages [p ]["optional" ] = False
5051 if "windows" not in get_systype ():
51- self .packages [' tool-gperf' ][ ' optional' ] = False
52+ self .packages [" tool-gperf" ][ " optional" ] = False
5253
5354 # configure J-LINK tool
5455 jlink_conds = [
@@ -84,15 +85,15 @@ def _add_default_debug_tools(self, board):
8485 upload_protocols = board .manifest .get ("upload" , {}).get (
8586 "protocols" , [])
8687 if "tools" not in debug :
87- debug [' tools' ] = {}
88+ debug [" tools" ] = {}
8889
8990 # J-Link / BlackMagic Probe
9091 for link in ("blackmagic" , "cmsis-dap" , "jlink" ):
91- if link not in upload_protocols or link in debug [' tools' ]:
92+ if link not in upload_protocols or link in debug [" tools" ]:
9293 continue
9394
9495 if link == "blackmagic" :
95- debug [' tools' ][ ' blackmagic' ] = {
96+ debug [" tools" ][ " blackmagic" ] = {
9697 "hwids" : [["0x1d50" , "0x6018" ]],
9798 "require_debug_port" : True
9899 }
@@ -101,7 +102,7 @@ def _add_default_debug_tools(self, board):
101102 if debug .get ("pyocd_target" ):
102103 pyocd_target = debug .get ("pyocd_target" )
103104 assert pyocd_target
104- debug [' tools' ][link ] = {
105+ debug [" tools" ][link ] = {
105106 "onboard" : True ,
106107 "server" : {
107108 "package" : "tool-pyocd" ,
@@ -117,7 +118,7 @@ def _add_default_debug_tools(self, board):
117118 else :
118119 openocd_target = debug .get ("openocd_target" )
119120 assert openocd_target
120- debug [' tools' ][link ] = {
121+ debug [" tools" ][link ] = {
121122 "load_cmd" : "preload" ,
122123 "onboard" : True ,
123124 "server" : {
@@ -134,7 +135,7 @@ def _add_default_debug_tools(self, board):
134135 elif link == "jlink" :
135136 assert debug .get ("jlink_device" ), (
136137 "Missed J-Link Device ID for %s" % board .id )
137- debug [' tools' ][link ] = {
138+ debug [" tools" ][link ] = {
138139 "server" : {
139140 "package" : "tool-jlink" ,
140141 "arguments" : [
@@ -151,5 +152,28 @@ def _add_default_debug_tools(self, board):
151152 "onboard" : link in debug .get ("onboard_tools" , [])
152153 }
153154
154- board .manifest [' debug' ] = debug
155+ board .manifest [" debug" ] = debug
155156 return board
157+
158+ def configure_debug_options (self , initial_debug_options , ide_data ):
159+ debug_options = copy .deepcopy (initial_debug_options )
160+ server_executable = debug_options ["server" ]["executable" ].lower ()
161+ adapter_speed = initial_debug_options .get ("speed" )
162+ if adapter_speed :
163+ if "openocd" in server_executable :
164+ debug_options ["server" ]["arguments" ].extend (
165+ ["-c" , "adapter speed %s" % adapter_speed ]
166+ )
167+ elif "jlink" in server_executable :
168+ debug_options ["server" ]["arguments" ].extend (
169+ ["-speed" , adapter_speed ]
170+ )
171+ elif "pyocd" in debug_options ["server" ]["package" ]:
172+ assert (
173+ adapter_speed .isdigit ()
174+ ), "pyOCD requires the debug frequency value in Hz, e.g. 4000"
175+ debug_options ["server" ]["arguments" ].extend (
176+ ["--frequency" , "%d" % int (adapter_speed )]
177+ )
178+
179+ return debug_options
0 commit comments