@@ -202,6 +202,31 @@ export abstract class HexUploader<InvokeParamsType> {
202202 return result ;
203203 }
204204
205+ resolveHexFilePathEnvs ( input : string , programs : FlashProgramFile [ ] ) : string {
206+
207+ const portList = ResManager . GetInstance ( ) . enumSerialPort ( ) ;
208+
209+ let commandLine = input
210+ . replace ( / \$ \{ h e x F i l e \} | \$ \{ b i n F i l e \} | \$ \{ p r o g r a m F i l e \} / ig, programs [ 0 ] . path )
211+ . replace ( / \$ \{ p o r t \} / ig, portList [ 0 ] || '' )
212+ . replace ( / \$ \{ p o r t L i s t \} / ig, portList . join ( ' ' ) ) ;
213+
214+ programs . forEach ( ( file , index ) => {
215+
216+ commandLine = commandLine
217+ . replace ( new RegExp ( String . raw `\$\{hexFile\[${ index } \]\}` , 'ig' ) , file . path )
218+ . replace ( new RegExp ( String . raw `\$\{binFile\[${ index } \]\}` , 'ig' ) , file . path )
219+ . replace ( new RegExp ( String . raw `\$\{programFile\[${ index } \]\}` , 'ig' ) , file . path ) ;
220+
221+ if ( file . addr ) {
222+ commandLine = commandLine
223+ . replace ( new RegExp ( String . raw `\$\{binAddr\[${ index } \]\}` , 'ig' ) , file . addr || '0x00000000' )
224+ }
225+ } ) ;
226+
227+ return commandLine
228+ }
229+
205230 getAllProgramFiles ( ) : FlashProgramFile [ ] {
206231 return this . parseProgramFiles ( this . getUploadOptions < any > ( ) ) ;
207232 }
@@ -313,6 +338,7 @@ class JLinkUploader extends HexUploader<any> {
313338
314339 // replace vars
315340 jlinkCommandtemplate = jlinkCommandtemplate . replace ( / \$ \{ E I D E _ J L I N K _ F L A S H E R _ C M D \} / g, flasherCmds . join ( os . EOL ) ) ;
341+ jlinkCommandtemplate = this . resolveHexFilePathEnvs ( jlinkCommandtemplate , files ) ;
316342 jlinkCommandtemplate = this . project . resolveEnvVar ( jlinkCommandtemplate ) ;
317343 jlinkCommandtemplate = jlinkCommandtemplate + os . EOL + 'exit' ; // append 'exit' command
318344
@@ -686,14 +712,16 @@ class STLinkUploader extends HexUploader<string[]> {
686712
687713 protected _launch ( commands : string [ ] ) : void {
688714
689- const commandLine = CmdLineHandler . getCommandLine (
690- SettingManager . GetInstance ( ) . getSTLinkExePath ( ) , commands
691- ) ;
692-
715+ const exe = new File ( SettingManager . GetInstance ( ) . getSTLinkExePath ( ) ) ;
716+ const commandLine = CmdLineHandler . getCommandLine ( exe . path , commands ) ;
693717 const options = this . getUploadOptions < STLinkOptions > ( ) ;
694718
695719 // run
696- runShellCommand ( this . toolType , `${ commandLine } ${ options . otherCmds || '' } ` . trimEnd ( ) ) ;
720+ let cmd = `${ commandLine } ${ options . otherCmds || '' } ` . trimEnd ( ) ;
721+ if ( osType ( ) == 'win32' && exe . noSuffixName . toLowerCase ( ) . startsWith ( 'stm32_programmer_cli' ) ) {
722+ cmd = 'chcp 437 && ' + cmd ;
723+ }
724+ runShellCommand ( this . toolType , cmd ) ;
697725 }
698726}
699727
@@ -1032,25 +1060,7 @@ class CustomUploader extends HexUploader<string> {
10321060 }
10331061 }
10341062
1035- const portList = ResManager . GetInstance ( ) . enumSerialPort ( ) ;
1036-
1037- let commandLine = option . commandLine
1038- . replace ( / \$ \{ h e x F i l e \} | \$ \{ b i n F i l e \} | \$ \{ p r o g r a m F i l e \} / ig, programs [ 0 ] . path )
1039- . replace ( / \$ \{ p o r t \} / ig, portList [ 0 ] || '' )
1040- . replace ( / \$ \{ p o r t L i s t \} / ig, portList . join ( ' ' ) ) ;
1041-
1042- programs . forEach ( ( file , index ) => {
1043-
1044- commandLine = commandLine
1045- . replace ( new RegExp ( String . raw `\$\{hexFile\[${ index } \]\}` , 'ig' ) , file . path )
1046- . replace ( new RegExp ( String . raw `\$\{binFile\[${ index } \]\}` , 'ig' ) , file . path )
1047- . replace ( new RegExp ( String . raw `\$\{programFile\[${ index } \]\}` , 'ig' ) , file . path ) ;
1048-
1049- if ( file . addr ) {
1050- commandLine = commandLine
1051- . replace ( new RegExp ( String . raw `\$\{binAddr\[${ index } \]\}` , 'ig' ) , file . addr || '0x00000000' )
1052- }
1053- } ) ;
1063+ let commandLine = this . resolveHexFilePathEnvs ( option . commandLine , programs ) ;
10541064
10551065 // replace env
10561066 commandLine = this . project . replacePathEnv ( commandLine ) ;
0 commit comments