This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Why can't tests be built for pc target?
On 2008-03-17, Grant Edwards <grante@visi.com> wrote:
>> Might be worth checking the grub documentation. It might be
>> able to load from the floppy.
>
> It can, but if I'm going to have to generate a disk image,
> generating a hard-drive one is just as easy as generating a
> floppy one, and then I don't have the 1.44MB limit either.
> I'm running stuff on a virtual machine using Qemu and being
> able to point it at the bootable floppy images generated by
> the eCos "make" was awfully handy. I'll write a shell-script
> to generate a bootable hard-drive image with grub and the
> application on it.
It looks like making a bootable CD image is the simplest
solution since it can be done entirely with user-space
utilities that don't require any special privledges.
In case anybody else is interested, here's my Makefile
------------------------------Makefile------------------------------
ECOS=../build-ecos/install
hello.elf: hello.c $(ECOS)/lib/target.ld $(ECOS)/lib/libtarget.a
i386-elf-gcc -g -I$(ECOS)/include hello.c -L$(ECOS)/lib \
-Ttarget.ld -nostdlib -o hello.elf
grub.iso: hello.elf iso/boot/grub/menu.lst
cp hello.elf iso
strip iso/hello.elf
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
-boot-load-size 4 -boot-info-table -o grub.iso iso
qemu: grub.iso
(sleep 1; \
aterm -title "eCos Serial 0" -name "eCos Serial 0" \
-e telnet localhost 9876)&
qemu -boot cdrom -cdrom grub.iso -net nic,model=rtl8139 \
-nographic -serial telnet:localhost:9876,server
--------------------------------------------------------------------
The "grub.iso" target builds an el-torito bootable ISO9660
image. The "iso" directory needs to start out looking like
this:
$ tree iso
iso
`-- boot
`-- grub
|-- menu.lst
`-- stage2_eltorito
2 directories, 2 files
stage2_eltorito comes from wherever grub puts it's library
files (assuming you've already got grub installed somewhere).
My menu.lst file looks like this:
------------------------------menu.lst------------------------------
serial --unit=0 --speed=115200
terminal --timeout=2 serial console
default 0
timeout 1
title /hello.elf
kernel /hello.elf
--------------------------------------------------------------------
The second build rule for the "qemu" target starts qemu with no
graphics card support (just to eliminate a useless window that
clutters up the destkop). The lack of a graphics card in the
virtual target machine is why we configured grub to do serial
console in menu.lst above. Qemu's -serial option as shown
connects the first virtual 16550 serial port to a telnet server
on port 9876 -- to which the first build rule in the "qemu"
target connects after waiting for 1 second.
The net result is that you can edit hello.c and then just do
"make qemu" to build the program, generate the bootable ISO
image, and run it inside Qemu.
--
Grant
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss