Problems with building i386 simulation environment based on Grub and QEMU

Andre Marques andre.lousa.marques at gmail.com
Fri Jan 31 09:45:51 UTC 2014


Hello Yin,

On 01/31/14 00:49, Yin Yan wrote:
> Hi Guys,
>
> My goal is running the rtems-4.10 application on the Intel Galileo board.
> Before that, I want to build an i386 simulation environment based on 
> Grub and QEMU.
> I found the wiki page for it from 
> http://www.rtems.org/wiki/index.php/Building_Grub
>
> Unfortunately, The scripts provided from the wiki don't work on my 
> Ubuntu12.04.03.
>
> I did the modification for the permission issues, however I am still 
> getting the following error:
> For floppy image:
>
> grub-setup: warning: Embedding is not possible. GRUB can only be 
> installed in this setup by using blocklists. However, blocklistst are 
> UNRELIABLE and their use is discouraged..
> grub-setup: error: will not proceed with blocklists.
>
>
> For hard-disk image:
> /home/gassa/research/grub/src/grub/grub-bios-setup: error: disk 
> `hostdisk//dev/loop4' not found.
>
> I have found a pre-build floppy disk image from FTP site, but I still 
> need the hard-disk image.
>
> Does anyone build the hard-disk image? Please provide me some hints.
>

You can create an hard-disk image with


dd if=/dev/zero of=hda.img count=1000 (512kB)

mkfs.vfat hda.img


And load it with the grub.conf, if you didn't change the floppy (by 
default the floppy looks for the grub.conf on the hard disk)
To open programs the easier is to put them in a folder on your computer 
and with qemu call a second "hard disk" with

-hdb fat:<program directory> (around 500MB limit on that directory for 
it to load, I think)

http://www.rtems.org/wiki/index.php/QEMU#Making_a_Boot_Floppy_Disk

You may also try ignoring grub, if you just want to run the programs:


qemu-system-i386 -no-reboot -kernel <program>.exe


Which I think is an easier aproach than changing the grub.conf everytime.

There is also an pc386 script (rtems-testing/sim-scripts/pc386) that you 
can use to run programs.

> The grub I am using is from Grub git repo: git clone 
> git://git.savannah.gnu.org/grub.git <http://git.savannah.gnu.org/grub.git>
>
> Thank a lot.
>
> Yin Yan
>
>
>
> ==================below is the script I am 
> using===============================
> #!/bin/bash
> set -e
>
> image="rtems-boot.img"
> # Hack to make everything owned by the original user.
> user=`whoami | awk '{print $1}'`
> echo $user
> group=`groups $user | awk '{print $3}'`
> echo $group
>
> # Create the actual disk image - 15MB
> dd if=/dev/zero of=${image} bs=512 count=32130
>
> chown ${user}:${group} ${image}
>
> # Setup the loopback device, and reture the devie name.
> lodev=`sudo losetup -f --show ${image}`
> #/dev/loop5
>
> trap 'sudo losetup -d ${lodev}; exit $?' INT TERM EXIT
>
> loname=${lodev##*/}
> #/loop5
>
> # Make the partition table, partition and set it bootable.
> sudo parted -a min -s ${lodev} mklabel msdos mkpart primary ext2 1M 100% \
>     set 1 boot on
>
> # Get the start sectors.
> start=`sudo fdisk -lu ${lodev} | grep "${loname}p1" | awk '{ print $3}'`
> # Find the first unused loop device.
> lonxt=`sudo losetup -f`
> #/dev/loop6
>
>
> # Create a loop device for this partition, like /dev/sda and /dev/sda0 
> work.
> sudo losetup -o $(expr 512 \* ${start}) ${lonxt} ${lodev}
>
> # Make an ext2 filesystem on the first partition.
> sudo mkfs.ext2 ${lonxt}
> # Mount the filesystem via loopback.
> sudo mount ${lonxt} /mnt
> trap 'sudo umount /mnt; sudo losetup -d ${lonxt}; sudo losetup -d 
> ${lodev}; exit $?' INT TERM EXIT
> sudo mkdir -p /mnt/boot/grub
> sudo touch /mnt/boot/grub/grub.cfg
> sudo chmod 777 /mnt/boot/grub/grub.cfg
> echo 'source (hd1,msdos1)/grub.cfg'>/mnt/boot/grub/grub.cfg
>
> sudo mkdir -p /mnt/boot/grub/i386-pc
> sudo cp /home/gassa/research/grub/build/lib/grub/i386-pc/* 
> /mnt/boot/grub/i386-pc/
> sudo rm /mnt/boot/grub/i386-pc/*.module
>
> # Make a bootable image of GRUB.
> grub-mkimage -d /home/gassa/research/grub/build/lib/grub/i386-pc -O 
> i386-pc --output=core.img \
>         --prefix=\(,msdos1\)/boot/grub ext2 part_msdos biosdisk 
> search_fs_uuid
> sudo cp core.img /mnt/boot/grub/i386-pc
> # Set up a device to boot using GRUB.
> /home/gassa/research/grub/src/grub/grub-bios-setup --allow-floppy 
>  --force --directory=/mnt/boot/grub/i386-pc --device-map= ${lodev}
>
> sync
> trap - INT TERM EXIT
> umount /mnt
> sudo losetup -d ${lonxt}
> sudo losetup -d ${lodev}
>
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20140131/e0ea1413/attachment-0001.html>


More information about the users mailing list