@@ -24,6 +24,10 @@ pub struct Qemu {
2424 #[ arg( long) ]
2525 microvm : bool ,
2626
27+ /// Run with U-Boot.
28+ #[ arg( long) ]
29+ u_boot : bool ,
30+
2731 #[ command( flatten) ]
2832 build : Build ,
2933
@@ -77,13 +81,35 @@ impl Qemu {
7781 fn prepare_image ( & self ) -> Result < ( ) > {
7882 let sh = crate :: sh ( ) ?;
7983
80- if self . build . target ( ) == Target :: X86_64Uefi {
81- sh. create_dir ( "target/esp/efi/boot" ) ?;
82- sh. copy_file ( self . build . dist_object ( ) , "target/esp/efi/boot/bootx64.efi" ) ?;
83- sh. copy_file (
84- self . build . ci_image ( self . image . as_deref ( ) . unwrap ( ) ) ,
85- "target/esp/efi/boot/hermit-app" ,
86- ) ?;
84+ match self . build . target ( ) {
85+ Target :: X86_64Uefi => {
86+ sh. create_dir ( "target/esp/efi/boot" ) ?;
87+ sh. copy_file ( self . build . dist_object ( ) , "target/esp/efi/boot/bootx64.efi" ) ?;
88+ sh. copy_file (
89+ self . build . ci_image ( self . image . as_deref ( ) . unwrap ( ) ) ,
90+ "target/esp/efi/boot/hermit-app" ,
91+ ) ?;
92+ }
93+ Target :: Aarch64Elf | Target :: Aarch64BeElf if self . u_boot => {
94+ sh. create_dir ( "target/boot" ) ?;
95+ sh. copy_file ( self . build . dist_object ( ) , "target/boot/hermit-loader" ) ?;
96+ sh. copy_file (
97+ self . build . ci_image ( self . image . as_deref ( ) . unwrap ( ) ) ,
98+ "target/boot/hermit-app" ,
99+ ) ?;
100+
101+ cmd ! (
102+ sh,
103+ "mkimage -f xtask/src/ci/u-boot/boot.its target/boot/boot.scr"
104+ )
105+ . run ( ) ?;
106+ cmd ! (
107+ sh,
108+ "mkimage -E -f xtask/src/ci/u-boot/hermit.its target/boot/hermit.fit"
109+ )
110+ . run ( ) ?;
111+ }
112+ _ => ( ) ,
87113 }
88114
89115 Ok ( ( ) )
@@ -200,13 +226,20 @@ impl Qemu {
200226 ]
201227 } ;
202228 cpu_args. push ( "-semihosting" . to_string ( ) ) ;
203- cpu_args. push ( "-device" . to_string ( ) ) ;
204- cpu_args. push ( format ! (
205- "guest-loader,addr=0x48000000,initrd={}" ,
206- self . build
207- . ci_image( self . image. as_deref( ) . unwrap( ) )
208- . display( )
209- ) ) ;
229+ if self . u_boot {
230+ cpu_args. push ( "-bios" . to_string ( ) ) ;
231+ cpu_args. push ( "/usr/lib/u-boot/qemu_arm64/u-boot.bin" . to_string ( ) ) ;
232+ cpu_args. push ( "-drive" . to_string ( ) ) ;
233+ cpu_args. push ( "format=raw,file=fat:rw:target/boot" . to_string ( ) ) ;
234+ } else {
235+ cpu_args. push ( "-device" . to_string ( ) ) ;
236+ cpu_args. push ( format ! (
237+ "guest-loader,addr=0x48000000,initrd={}" ,
238+ self . build
239+ . ci_image( self . image. as_deref( ) . unwrap( ) )
240+ . display( )
241+ ) ) ;
242+ }
210243 cpu_args
211244 }
212245 Target :: Riscv64Sbi => {
0 commit comments