The Real-Time Executive for Multiprocessor Systems or RTEMS is a open source fully featured Real Time Operating System. More features you can get from the offical web-site.
Here, we try to build a simulation environments for RTEMS based on QEMU and platform x86 the most common one we used. This will be done form scratch, hope you can enjoy that.
This is test on the Ubuntu 13.10, maybe there are some bugs on other platforms, but I think most of Linux distributions will work.
The environment is based on QEMU, when start RTEMS we use the Grub2, so you should make sure that both have been installed. On most platform the Grub2 has installed, maybe only QEMU should to be intalled manually. You can install QEMU on Ubuntu through command
sudo apt-get install qemu. Maybe what you install is not the lastest version, you could install this through source code. That’s a little complicated we will not discuss that here.
Actually, I build the QEMU from source code and intsall it to /opt/qemu directory. You can test QEMU through
qemu-system-i386 -version, if QEMU works, the version informatin will be returned.
We will build a bootable image based on grub2, in fact I highly recommand you use this image which is based on Grub-0.97 to start the RTEMS. Grub2 has many fascinating functions, those make it become slower when start. The purpose of this article is to show you how a bootable image build, since when we try to use grub-0.97 to do this bugs occured.
dd if=/dev/zero of=rtems-boot.img bs=512 count=32130
losetup /dev/loop0 rtems-boot.img
kpartx -av /dev/loop0
losetup /dev/loop1 /dev/mapper/loop0p1
mkfs.ext2 /dev/loop1 && mount /dev/loop1 /mnt
mkdir -p /mnt/boot/grub && echo 'source (hd1,msdos1)/grub.cfg' > /mnt/boot/grub/grub.cfg
grub-install --allow-floppy --boot-directory=/mnt/boot --disk-module=biosdisk --modules="ext2 part_msdos" --force /dev/loop0
umount /mnt && losetup -d /dev/loop1 && kpartx -dv /dev/loop0 && losetup -d /dev/loop0
Until now, I think this hard disk image can work, try it now through command
qemu-system-i386 -m 128 -boot b -hda rtems-boot.img -hdb fat:. -serial stdio -no-reboot. It may take some time to start Grub2, that’s why Grub0.97 is recommended.
Assume you have built the compile environment for RTEMS. Copy the executable binary examples file, such as ticker.exe to examples folder, just like the following.
The ‘grub.cfg’ file is a configuration file for grub2, you can add the following contents to it.
Then start RTEMS with the following command.
qemu-system-i386 -m 128 -boot b -hda rtems-boot.img -hdb fat:. -serial stdio -no-reboot
and you will get the screen like
press enter to execute the ticker.exe, and you get that. Congratulations ^_^