@@ -92,11 +92,13 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
9292 bool preview ,
9393 string applicationPath ,
9494 string deploymentAddress ,
95- PartitionTableSize ? partitionTableSize ,
96- VerbosityLevel verbosity )
95+ string clrFile ,
96+ VerbosityLevel verbosity ,
97+ PartitionTableSize ? partitionTableSize )
9798 {
9899 var operationResult = ExitCodes . OK ;
99100 uint address = 0 ;
101+ bool updateCLRfile = ! string . IsNullOrEmpty ( clrFile ) ;
100102
101103 // if a target name wasn't specified use the default (and only available) ESP32 target
102104 if ( string . IsNullOrEmpty ( targetName ) )
@@ -113,17 +115,46 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
113115 Verbosity = verbosity
114116 } ;
115117
118+ // if this is updating with a local CLR file, download the package silently
119+ if ( updateCLRfile )
120+ {
121+ // check file
122+ if ( ! File . Exists ( clrFile ) )
123+ {
124+ return ExitCodes . E9011 ;
125+ }
126+
127+ // has to be a binary file
128+ if ( Path . GetExtension ( clrFile ) != ".bin" )
129+ {
130+ return ExitCodes . E9012 ;
131+ }
132+
133+ firmware . Verbosity = VerbosityLevel . Quiet ;
134+ }
135+
116136 // need to download update package?
117137 if ( updateFw )
118138 {
119139 operationResult = await firmware . DownloadAndExtractAsync ( esp32Device . FlashSize ) ;
140+
120141 if ( operationResult != ExitCodes . OK )
121142 {
122143 return operationResult ;
123144 }
124145 // download successful
125146 }
126147
148+ // if updating with a CRL file, need to have a new fw package
149+ if ( updateCLRfile )
150+ {
151+ // remove the CLR file from the image
152+ firmware . FlashPartitions . Remove ( Esp32Firmware . CLRAddress ) ;
153+
154+ // add it back with the file image from the command line option
155+ firmware . FlashPartitions . Add ( Esp32Firmware . CLRAddress , clrFile ) ;
156+ }
157+
127158 // need to include application file?
128159 if ( ! string . IsNullOrEmpty ( applicationPath ) )
129160 {
@@ -197,7 +228,7 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
197228
198229 if ( verbosity >= VerbosityLevel . Normal )
199230 {
200- Console . Write ( $ "Flashing firmware...") ;
231+ Console . WriteLine ( $ "Flashing firmware...") ;
201232 }
202233
203234 // write to flash
0 commit comments