@@ -217,8 +217,9 @@ fn build_family(
217217 . ok_or_else ( || anyhow ! ( "missing kind for algo {}" , algo_name) ) ?;
218218 let start = ranges. iter ( ) . map ( |r| r. start ) . min ( ) . unwrap ( ) ;
219219 let end = ranges. iter ( ) . map ( |r| r. end ) . max ( ) . unwrap ( ) ;
220+ let blob_kind = if kind == "usr-legacy" { "usr" } else { kind } ;
220221 // Prefer Fast over Standard (v0/v1 OB only has Standard).
221- let template_region = find_template_region ( chips, kind ) ?;
222+ let template_region = find_template_region ( chips, blob_kind ) ?;
222223 let ( page_size, _) = template_region
223224 . modes
224225 . iter ( )
@@ -233,7 +234,7 @@ fn build_family(
233234
234235 let blob = algos
235236 . iter ( )
236- . find ( |a| a. silicon == silicon && a. arch == arch && a. region_kind == * kind )
237+ . find ( |a| a. silicon == silicon && a. arch == arch && a. region_kind == blob_kind )
237238 . ok_or_else ( || {
238239 anyhow ! (
239240 "no algo blob for silicon {} arch {} kind {}" ,
@@ -332,8 +333,31 @@ fn build_variant(
332333 if !variant_algos. contains ( & algo_name) {
333334 variant_algos. push ( algo_name. clone ( ) ) ;
334335 }
335- algo_uses. entry ( algo_name. clone ( ) ) . or_default ( ) . push ( range) ;
336+ algo_uses
337+ . entry ( algo_name. clone ( ) )
338+ . or_default ( )
339+ . push ( range. clone ( ) ) ;
336340 algo_kind. insert ( algo_name, kind. to_string ( ) ) ;
341+
342+ if kind == "usr" {
343+ let alias_range = 0u64 ..( range. end - range. start ) ;
344+ memory_map. push ( PrMemoryRegion :: Nvm ( NvmRegion {
345+ name : Some ( "USR_LEGACY" . to_string ( ) ) ,
346+ range : alias_range. clone ( ) ,
347+ cores : vec ! [ core_name. to_string( ) ] ,
348+ is_alias : true ,
349+ access : Some ( access) ,
350+ } ) ) ;
351+ let legacy_name = format ! ( "ch32-{}-usr-legacy" , silicon) ;
352+ if !variant_algos. contains ( & legacy_name) {
353+ variant_algos. push ( legacy_name. clone ( ) ) ;
354+ }
355+ algo_uses
356+ . entry ( legacy_name. clone ( ) )
357+ . or_default ( )
358+ . push ( alias_range) ;
359+ algo_kind. insert ( legacy_name, "usr-legacy" . to_string ( ) ) ;
360+ }
337361 }
338362 }
339363 _ => { }
0 commit comments