Changes between Version 60 and Version 61 of Developer/Simulators/QEMU
- Timestamp:
- 03/10/15 23:40:01 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Developer/Simulators/QEMU
v60 v61 1 1 = QEMU = 2 2 3 4 5 [[TOC(TBR/UserManual/QEMU, depth=2)]] 3 [[TOC(Developer/Simulators/QEMU, depth=2)]] 6 4 7 5 You can run RTEMS in the open source processor emulator [http://www.nongnu.org/qemu/ QEMU]. The QEMU emulator runs on a number of hosts including Linux and Windows. It also supports a number of [http://www.nongnu.org/qemu/status.html processors]. … … 9 7 = QEMU On Windows = 10 8 11 12 Install the RTEMS [wiki:TBR/UserManual/MinGW_Tools_for_Windows MinGW Tools for Windows]. Download the processor emulator you wish to use and install. For example we will install the i368 emulator to '''c:\rtems\i386\qemu-0.8.2-windows'''. Download the boot floppy image http://www.rtems.org/ftp/pub/rtems/qemu/i386-pc/rtems-boot.img to '''c:\rtems\i386'''. To run QEMU create the batch file '''c:\rtems\i386\qemu.bat''' with: 13 14 rem @echo off 15 set QEMU=C:\rtems\i386\qemu-0.8.2-windows 16 %QEMU%\qemu -L %QEMU% -m 128 -boot a -fda c:\rtems\i386\rtems-boot.img -hda fat:%1 17 18 You can download this batch file from http://www.rtems.org/ftp/pub/rtems/qemu/i386-pc/qemu.bat. 9 Install the RTEMS [wiki:TBR/UserManual/MinGW_Tools_for_Windows MinGW Tools for Windows]. Download the processor emulator you wish to use and install. For example we will install the i368 emulator to '''c:\rtems\i386\qemu-0.8.2-windows'''. Download the boot floppy image https://ftp.rtems.org/pub/rtems/qemu/i386-pc/rtems-boot.img to '''c:\rtems\i386'''. To run QEMU create the batch file '''c:\rtems\i386\qemu.bat''' with: 10 11 {{{ 12 rem @echo off 13 set QEMU=C:\rtems\i386\qemu-0.8.2-windows 14 %QEMU%\qemu -L %QEMU% -m 128 -boot a -fda c:\rtems\i386\rtems-boot.img -hda fat:%1 15 }}} 16 17 You can download this batch file from https://ftp.rtems.org/pub/rtems/qemu/i386-pc/qemu.bat. 19 18 20 19 The boot floppy will look in the root directory the QEMU C: drive for a file called '''rtems-grub.cfg'''. The QEMU C: is a directory on your hard disk passed to QEMU on its command line and can be seen in the '''qemu.bat''' file we created as the '''-hda fat:%1''' option. The command line option we pass to '''qemu.bat''' is a directory that is the root directory the QEMU C: drive. For example download and build RTEMS for the i386 target as described on the [wiki:TBR/UserManual/MinGW_Tools_for_Windows MinGW Tools for Windows] page. Then install http://www.rtems.org/ftp/pub/rtems/qemu/i386-pc/rtems-grub.cfg into the '''c:\rtems\src\i386\i386-rtems4.7\c\pc586\testsuites\samples''' directory. Open the '''RTEMS (i386)''' command window by running '''c:\rtems\i386\rtems-cmd.bat''' then enter: 21 20 22 RTEMS(i386) C:\rtems\i386>qemu c:\rtems\src\i386\i386-rtems4.7\c\pc586\testsuites\samples 21 {{{ 22 RTEMS(i386) C:\rtems\i386>qemu c:\rtems\src\i386\i386-rtems4.7\c\pc586\testsuites\samples 23 }}} 23 24 24 25 The QEMU windows will open and GRUB will provide you with a menu of the RTEMS sample applications. Select an application and watch it run. 26 25 27 = QEMU PC (i386) Emulator = 26 28 27 29 28 30 The RTEMS PC BSP runs in the QEMU emulator (it also runs in the [wiki:RTEMS_on_Virtualbox_ VirtualBox emulator]). The QEMU emulator needs a boot image that will load RTEMS and we use GRUB for this. The simplest may to do this is to create a floppy disk image and tell QEMU to boot from a floppy disk. 31 29 32 = Making a Boot Floppy Disk = 30 33 31 34 32 We run RTEMS in QEMU by first booting from a floppy disk image containing the GRUB boot loader. You can use the [http ://www.rtems.org/ftp/pub/rtems/people/chrisj/grub/rtems-boot.img image] we have made by downloading it from the RTEMS ftp server. The script builds the floppy disk, the grub source as per GPL, and the boot image.35 We run RTEMS in QEMU by first booting from a floppy disk image containing the GRUB boot loader. You can use the [https://ftp.rtems.org/pub/rtems/people/chrisj/grub/rtems-boot.img image] we have made by downloading it from the RTEMS ftp server. The script builds the floppy disk, the grub source as per GPL, and the boot image. 33 36 34 37 Instructions on how to built the image and were run on a Fedora Core 5 Linux host can be found at [http://www.rtems.org/wiki/index.php/Building_Grub http://www.rtems.org/wiki/index.php/Building_Grub] 35 38 36 39 Now we need to setup some disk drivers for Qemu: 37 {{{$ dd if=/dev/zero of=hda.img count=1000 38 $ ls -las hda.img 40 41 {{{ 42 $ dd if=/dev/zero of=hda.img count=1000 43 $ ls -las hda.img 39 44 }}} 40 45 41 46 The first creates a disk and second shows you the details of the disk you just created. 42 47 43 The default '''grub.cfg''' file will attempt to read a GRUB configuration file called '''[http ://www.rtems.org/ftp/pub/rtems/qemu/i386-pc/rtems-grub.cfg rtems-grub.cfg]''' from the root directory of the harddisk. This lets you create a specific GRUB configuration for you testing without needing to rebuild the floppy image.48 The default '''grub.cfg''' file will attempt to read a GRUB configuration file called '''[https://ftp.rtems.org/pub/rtems/qemu/i386-pc/rtems-grub.cfg rtems-grub.cfg]''' from the root directory of the hard-disk. This lets you create a specific GRUB configuration for you testing without needing to rebuild the floppy image. 44 49 An example configuration that lets you run the RTEMS Samples is: 45 50 46 {{{# RTEMS Grub configuration for the Samples 51 {{{ 52 # RTEMS Grub configuration for the Samples 47 53 48 54 set default=0 49 55 50 56 menuentry "RTEMS - Hello" { 51 57 set root=(hd1,1) … … 123 129 List of the options explained: 124 130 125 '''-m 128''' sets the memory size to 128M 126 '''-boot a''' boot from the floppy disk a (best option) 127 '''-fda <path to rtems-boot.img>''' defines the second best floppy disk image 128 '''-hda <path to hda.img>''' defines the first hard disk image 129 '''-hdb fat:.''' says hdb is fat disk and . is the directory to make the root of that disk and 130 '''-hdb''' is the mapping to the local disk so we can read the RTEMS executable into memory 131 '''-serial stdio''' directs the serial port to the stdio of qemu 132 '''-no-reboot''' tells Qemu to not reboot if the code running wants to. 133 Stops an error looping over and over. 134 '''-s''' tells Qemu to start a GDB server 135 = "Couldn't open file" = 136 131 -m 128:: 132 sets the memory size to 128M 133 -boot a:: 134 boot from the floppy disk a (best option) 135 -fda <path to rtems-boot.img>:: 136 defines the second best floppy disk image 137 -hda <path to hda.img>:: 138 defines the first hard disk image 139 -hdb fat:: 140 says hdb is fat disk and . is the directory to make the root of that disk and 141 '''-hdb''' is the mapping to the local disk so we can read the RTEMS executable into memory 142 -serial stdio:: 143 directs the serial port to the stdio of qemu 144 -no-reboot':: 145 tells Qemu to not reboot if the code running wants to. Stops an error looping over and over. 146 -s:: 147 tells Qemu to start a GDB server 148 149 = "Couldn't open file" GRUB Error Message = 137 150 138 151 If GRUB gives this error while trying to load a menu entry, press 'c' on the keyboard at the GRUB menu screen to open the GRUB command prompt. … … 140 153 Then type: 141 154 142 grub> ls 155 {{{ 156 grub> ls 157 }}} 143 158 144 159 which should give you a list of the devices currently on the system. … … 146 161 Try the following for every device until you find the application you want: 147 162 148 grub> ls DEVICE/ 163 {{{ 164 grub> ls DEVICE/ 165 }}} 149 166 150 167 Now edit the entry that gave you the error (press 'e' at the GRUB menu screen) and correct the path. 168 151 169 = Running Other Images = 152 153 170 154 171 Instead of adding menu entries to the rtems-grub.cfg file, you can instead boot an RTEMS image directly from the GRUB command prompt. … … 157 174 the keyboard to switch from the menu to the GRUB command prompt. At the prompt type: 158 175 159 grub> set root=(hd1,1)/ 160 grub> multiboot (hd1,1)/myimage.exe 176 {{{ 177 grub> set root=(hd1,1)/ 178 grub> multiboot (hd1,1)/myimage.exe 179 }}} 161 180 162 181 where myimage.exe should be replaced with the name of the RTEMS image that you want to run. … … 166 185 Then just type 167 186 168 grub> boot 187 {{{ 188 grub> boot 189 }}} 169 190 170 191 to load and run your image. 192 171 193 = Using the rtems-testing Module = 172 194 … … 180 202 181 203 Create two directories, ~/qemu and ~/qemu/hd. 182 mkdir ~/qemu 183 mkdir ~/qemu/hd 204 {{{ 205 mkdir ~/qemu 206 mkdir ~/qemu/hd 207 }}} 184 208 185 209 There is a qemu-support directory in rtems-testing with a boot floppy image. Copy rtems-testing/qemu-support/pc386_fda.bz2 to ~/qemu. 186 cp ./qemu-support/pc386_fda.bz2 ~/qemu 210 211 {{{ 212 cp ./qemu-support/pc386_fda.bz2 ~/qemu 213 }}} 187 214 188 215 Unzip (bunzip or bzip2) pc386_fda.bz2. 189 bunzip ~/qemu/pc386_fda* 216 217 {{{ 218 bunzip ~/qemu/pc386_fda* 219 }}} 190 220 191 221 Run make at the root of the rtems-testing module. This should create a pc386 script in ./sim-scripts. … … 193 223 To use these scripts for pc386, you have to build RTEMS with USE_COM1_AS_CONSOLE=1 and BSP_PRESS_KEY_FOR_RESET=0 on the configure command line. 194 224 For example, if rtems is checked out at /home/user/rtems/rtems and you build in /home/user/rtems/b-rtems, then from b-rtems you will configure rtems as: 225 195 226 {{{ 196 227 ../rtems/configure --target=i386-rtems4.10 \ … … 205 236 }}} 206 237 207 If you run 208 ./sim-script/pc386 -i PATH_TO_MY_EXE 238 If you run: 239 {{{ 240 ./sim-script/pc386 -i PATH_TO_MY_EXE 241 }}} 242 209 243 The pc386 script will copy your executable to ~/qemu/hd/test.exe, which is what pc386_fda boots. You should see the result in your console. Scripts to run other simulators are in the sim-scripts directory. 210 244 … … 215 249 = Booting an RTEMS executable directly with qemu = 216 250 217 218 251 Qemu has a native multiboot implementation that is smart enough to load an ELF .exe into memory and transfer control to it. This makes it unnecessary to prepare a full floppy or harddisk image complete with MBR and boot loader. To use it, provide the -kernel option: 219 252 … … 221 254 qemu-system-i386 -kernel hello/hello.exe 222 255 }}} 256 223 257 = Running RTEMS TCP/IP Applications = 224 225 258 226 259 You can run RTEMS applications that use TCP/IP on QEMU. It requires getting a few very picky things just right so hang on and this section should help. The RTEMS application running on QEMU is executing on a virtual machine and thus QEMU must provide a simulation of a real NIC whose I/O is relayed or tunneled through a virtual interface to the real world. For most testing purposes, it is sufficient to have the connection work between just your QEMU session and the host computer running QEMU. AFAIK, for this to work, you must execute qemu as root. In all other cases of running QEMU with RTEMS, you can be a regular user. So the lesson here is only turn on TCP/IP support in QEMU when you really need it. … … 253 286 254 287 This matches the defaults as presented in the QEMU manual. The single network interface available to the RTEMS application will have the IP address 10.0.2.5. All of the RTEMS network demos can run in this environment given proper configuration. 288 255 289 == "isa irq 9 already assigned" == 256 290 257 258 291 With a more recent QEMU (0.13), I needed to add the "-M isapc" flag to make this error message go away. 259 292 260 293 --[wiki:User:SimonPerreault User:SimonPerreault] Mon Nov 29 16:43:38 EST 2010 294 261 295 == Setting the IRQ number == 262 296 … … 291 325 --ne2k-irq=9 292 326 }}} 327 293 328 to the grub command line to let RTEMS' ne driver know it should use interrupt 9. 329 294 330 = Running CAN Applications = 295 331 296 332 See the [wiki:TBR/UserManual/QEMU_with_CAN_Emulation QEMU with CAN Emulation] page for more details. 333 297 334 = Debugging with QEMU = 298 335 299 300 336 You can connect a debugger to QEMU and debug your application. If you start QEMU and load your application then switch consoles by pressing Ctl-Alt-2 to the QEMU command console then enter the command ''gdbserver''. After this start '''gdb''' for your target with the ELF image for the execute. Once gdb has started enter the remote target command for ''localhost:1234''. On Windows with and the i386 target the commands are: 301 337 338 {{{ 302 339 RTEMS(i386) C:\rtems\src\i386\i386-rtems4.7\c\pc586\testsuites\samples\capture>i386-rtems4.7-gdb capture.elf 303 340 GNU gdb 6.5 … … 325 362 117 addl $4, esp 326 363 (gdb) 364 }}} 327 365 328 366 Do not forget to build RTEMS with the ''--enable-rtems-debug'' configure option to get debug information built into RTEMS. … … 330 368 = QEMU and USB = 331 369 332 333 370 As of 10 March 2007, RTEMS does not support USB. One of the issues in RTEMS supporting USB is finding a target BSP where it is easy to debug the USB stack initially. QEMU appears to be a viable candidate for this task. QEMU is supposed to support USB emulation and there are reports on the Internet that it does work. My experimentation was not so lucky. 334 371 335 372 Since my effort was all about making sure I knew how to setup and use QEMU's emulated USB, I used a Knoppix LiveCD image. I thought that if I could get Knoppix to access a USB mouse and a USB flash drive, I would be happy in the capabilities in QEMU. 336 373 337 The USB mouse emulation worked well enough that Knoppix recogni zed it automatically and it worked.338 339 I could never figure out a way to get the USB flash drive recogni zed. There are comments that there might be a patch needed but I wasn't very confident.374 The USB mouse emulation worked well enough that Knoppix recognised it automatically and it worked. 375 376 I could never figure out a way to get the USB flash drive recognised. There are comments that there might be a patch needed but I wasn't very confident. 340 377 341 378 I saw a report that someone got a USB GPS working with Windows XP running under QEMU (http://jw.n--tree.net/blog/dev/qemu-usb-garmin) so there must be a magic combination of things that actually make this work 342 379 343 344 380 So that's my report. Maybe someone can follow up and make more work. 345 381 346 382 --[wiki:User:JoelSherrill Dr. Joel] 13:25, 10 March 2007 (CST) 383 347 384 = Emulating Other Platforms with QEMU = 348 = == PowerPC PReP Emulation === 349 350 See [wiki:TBR/BSP/Qemuprep qemuprep]. 385 386 === PowerPC PReP Emulation === 387 388 See [wiki:Developer/Simulators/Qemu/Preparation]. 389 351 390 === Motorola Coldfire Emulation === 352 391 353 392 I have this also working but need to document. 393 354 394 --[[User:Strauman|Strauman]] 16:43, 18 July 2011 (CDT) 355 395 === LEON3 Emulation ===