@@ -23,11 +23,18 @@ enum Command {
2323 /// Build only the application
2424 #[ arg( long) ]
2525 application : bool ,
26+ /// Build the application for the WIZnet W6100 instead of W5500
27+ #[ arg( long) ]
28+ w6100 : bool ,
2629 } ,
2730 /// Combine bootloader + application ELFs into build/combined.uf2
2831 Combine ,
2932 /// Build everything and produce the combined UF2 (build + combine)
30- Dist ,
33+ Dist {
34+ /// Build the application for the WIZnet W6100 instead of W5500
35+ #[ arg( long) ]
36+ w6100 : bool ,
37+ } ,
3138 /// Flash firmware to the device
3239 Flash {
3340 /// Flash only the bootloader
@@ -36,6 +43,9 @@ enum Command {
3643 /// Flash only the application
3744 #[ arg( long) ]
3845 application : bool ,
46+ /// Build the application for the WIZnet W6100 instead of W5500
47+ #[ arg( long) ]
48+ w6100 : bool ,
3949 /// Use probe-rs instead of UF2 drag-and-drop (attaches RTT for live logging)
4050 #[ arg( long) ]
4151 probe : bool ,
@@ -112,13 +122,17 @@ fn build_bootloader(sh: &Shell, root: &Path) -> Result<()> {
112122 Ok ( ( ) )
113123}
114124
115- fn build_application ( sh : & Shell , root : & Path ) -> Result < ( ) > {
125+ fn build_application ( sh : & Shell , root : & Path , w6100 : bool ) -> Result < ( ) > {
116126 eprintln ! ( "→ Building application…" ) ;
117127 let build_dir = build_dir ( root) ;
118128 std:: fs:: create_dir_all ( & build_dir) ?;
119129
120130 let _dir = sh. push_dir ( root. join ( "application" ) ) ;
121- cmd ! ( sh, "cargo build --release" ) . run ( ) ?;
131+ if w6100 {
132+ cmd ! ( sh, "cargo build --release --features w6100" ) . run ( ) ?;
133+ } else {
134+ cmd ! ( sh, "cargo build --release" ) . run ( ) ?;
135+ }
122136
123137 let src = root. join ( "target/thumbv6m-none-eabi/release/pdu-rp-application" ) ;
124138 let dst = application_elf ( root) ;
@@ -135,16 +149,24 @@ fn build_application(sh: &Shell, root: &Path) -> Result<()> {
135149/// Build the application with the `debug` feature (panic-probe + full defmt RTT logging).
136150/// The resulting ELF is stored separately as `build/application-debug.elf` so it
137151/// doesn't overwrite the production UF2 artefacts.
138- fn build_application_debug ( sh : & Shell , root : & Path ) -> Result < ( ) > {
152+ fn build_application_debug ( sh : & Shell , root : & Path , w6100 : bool ) -> Result < ( ) > {
139153 eprintln ! ( "→ Building application (debug / probe-rs)…" ) ;
140154 std:: fs:: create_dir_all ( build_dir ( root) ) ?;
141155
142156 let _dir = sh. push_dir ( root. join ( "application" ) ) ;
143- cmd ! (
144- sh,
145- "cargo build --release --no-default-features --features debug"
146- )
147- . run ( ) ?;
157+ if w6100 {
158+ cmd ! (
159+ sh,
160+ "cargo build --release --no-default-features --features debug,w6100"
161+ )
162+ . run ( ) ?;
163+ } else {
164+ cmd ! (
165+ sh,
166+ "cargo build --release --no-default-features --features debug"
167+ )
168+ . run ( ) ?;
169+ }
148170
149171 let src = root. join ( "target/thumbv6m-none-eabi/release/pdu-rp-application" ) ;
150172 let dst = application_debug_elf ( root) ;
@@ -559,29 +581,31 @@ fn main() -> Result<()> {
559581 Command :: Build {
560582 bootloader,
561583 application,
584+ w6100,
562585 } => {
563586 let both = !bootloader && !application;
564587 if both || bootloader {
565588 build_bootloader ( & sh, & root) ?;
566589 }
567590 if both || application {
568- build_application ( & sh, & root) ?;
591+ build_application ( & sh, & root, w6100 ) ?;
569592 }
570593 }
571594
572595 Command :: Combine => {
573596 combine ( & sh, & root) ?;
574597 }
575598
576- Command :: Dist => {
599+ Command :: Dist { w6100 } => {
577600 build_bootloader ( & sh, & root) ?;
578- build_application ( & sh, & root) ?;
601+ build_application ( & sh, & root, w6100 ) ?;
579602 combine ( & sh, & root) ?;
580603 }
581604
582605 Command :: Flash {
583606 bootloader,
584607 application,
608+ w6100,
585609 probe,
586610 debug,
587611 ota,
@@ -595,7 +619,7 @@ fn main() -> Result<()> {
595619 let uf2 = application_uf2 ( & root) ;
596620 if !uf2. exists ( ) {
597621 eprintln ! ( "Application UF2 not found — building first…" ) ;
598- build_application ( & sh, & root) ?;
622+ build_application ( & sh, & root, w6100 ) ?;
599623 }
600624 flash_ota ( & uf2, ip) ?;
601625 } else if probe {
@@ -610,9 +634,9 @@ fn main() -> Result<()> {
610634 } ;
611635 let build_app = |sh : & Shell , root : & Path | {
612636 if use_debug_build {
613- build_application_debug ( sh, root)
637+ build_application_debug ( sh, root, w6100 )
614638 } else {
615- build_application ( sh, root)
639+ build_application ( sh, root, w6100 )
616640 }
617641 } ;
618642
@@ -677,7 +701,7 @@ fn main() -> Result<()> {
677701 let uf2 = combined_uf2 ( & root) ;
678702 if !uf2. exists ( ) {
679703 build_bootloader ( & sh, & root) ?;
680- build_application ( & sh, & root) ?;
704+ build_application ( & sh, & root, w6100 ) ?;
681705 combine ( & sh, & root) ?;
682706 }
683707 flash_uf2 ( & uf2) ?;
@@ -692,7 +716,7 @@ fn main() -> Result<()> {
692716 if application {
693717 let uf2 = application_uf2 ( & root) ;
694718 if !uf2. exists ( ) {
695- build_application ( & sh, & root) ?;
719+ build_application ( & sh, & root, w6100 ) ?;
696720 }
697721 flash_uf2 ( & uf2) ?;
698722 }
0 commit comments