MitchBradley / openfirmware

Open Firmware (IEE1275-1994) implementation by its inventor.
63 stars 16 forks source link

Failed to build biosload on Ubuntu 17.04 x86_64 #4

Closed AdrianKoshka closed 7 years ago

AdrianKoshka commented 7 years ago

I made sure I had all dependencies (to my knowledge), followed the instructions, and got the following error:

$ cd openfirmware/cpu/x86/biosload
$ cp config-grub.fth config.fth
$ cd build
$ make
make[1]: Entering directory '/mnt/storage/openfirmware/cpu/x86/Linux'
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/wrapper.c -o wrapper.o
../../../forth/wrapper/wrapper.c: In function ‘f_ioctl’:
../../../forth/wrapper/wrapper.c:1962:15: warning: implicit declaration of function ‘ioctl’ [-Wimplicit-function-declaration]
  return((long)ioctl((int)fd, (int)code, buf));
               ^~~~~
../../../forth/wrapper/wrapper.c: In function ‘today’:
../../../forth/wrapper/wrapper.c:2139:2: warning: implicit declaration of function ‘time’ [-Wimplicit-function-declaration]
  time(&tadd);
  ^~~~
../../../forth/wrapper/wrapper.c:2140:15: warning: implicit declaration of function ‘localtime’ [-Wimplicit-function-declaration]
  return((long)localtime(&tadd));
               ^~~~~~~~~
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/logger.c -o logger.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/adler32.c -o adler32.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/compress.c -o compress.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/crc32.c -o crc32.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/deflate.c -o deflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/inflate.c -o inflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/trees.c -o trees.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/zutil.c -o zutil.o
cc -m32 -o forth wrapper.o logger.o adler32.o compress.o crc32.o deflate.o inflate.o trees.o zutil.o 
make[1]: Leaving directory '/mnt/storage/openfirmware/cpu/x86/Linux'
make[1]: Entering directory '/mnt/storage/openfirmware/cpu/x86/build'
make -C ../Linux ../build/inflate.bin
make[2]: Entering directory '/mnt/storage/openfirmware/cpu/x86/Linux'
cc -c -m32 -Wall -fno-builtin -fno-stack-protector -ffreestanding -DNEED_BCOPY -O2 -fpic ../../../forth/wrapper/zip/inflate.c -o xinflate.lo
ld -melf_i386 -T inflate.ld xinflate.lo -o xinflate.o
objcopy -O binary xinflate.o ../build/inflate.bin
make[2]: Leaving directory '/mnt/storage/openfirmware/cpu/x86/Linux'
make[1]: Leaving directory '/mnt/storage/openfirmware/cpu/x86/build'
./build ofw.c32
Target file ofw.c32 does not exist, and there is
no .log or .bth file for it.
Build aborted
Makefile:9: recipe for target 'ofw.c32' failed
make: *** [ofw.c32] Error 1
AdrianKoshka commented 7 years ago

wups, wrong repo.

AdrianKoshka commented 7 years ago

seems I got a tiny bit further then I got with the openbios/openfirmware repo.

cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/wrapper.c -o wrapper.o
../../../forth/wrapper/wrapper.c: In function ‘f_ioctl’:
../../../forth/wrapper/wrapper.c:1971:15: warning: implicit declaration of function ‘ioctl’ [-Wimplicit-function-declaration]
  return((long)ioctl((int)fd, (int)code, buf));
               ^~~~~
../../../forth/wrapper/wrapper.c: In function ‘today’:
../../../forth/wrapper/wrapper.c:2148:2: warning: implicit declaration of function ‘time’ [-Wimplicit-function-declaration]
  time(&tadd);
  ^~~~
../../../forth/wrapper/wrapper.c:2149:15: warning: implicit declaration of function ‘localtime’ [-Wimplicit-function-declaration]
  return((long)localtime(&tadd));
               ^~~~~~~~~
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/logger.c -o logger.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/adler32.c -o adler32.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/compress.c -o compress.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/crc32.c -o crc32.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/deflate.c -o deflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/inflate.c -o inflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/trees.c -o trees.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/zutil.c -o zutil.o
cc -m32 -o forth wrapper.o logger.o adler32.o compress.o crc32.o deflate.o inflate.o trees.o zutil.o 
make[1]: Leaving directory '/mnt/storage/mitch/openfirmware/cpu/x86/Linux'
make[1]: Entering directory '/mnt/storage/mitch/openfirmware/cpu/x86/build'
make -C ../Linux ../build/inflate.bin
make[2]: Entering directory '/mnt/storage/mitch/openfirmware/cpu/x86/Linux'
cc -c -m32 -Wall -fno-builtin -fno-stack-protector -ffreestanding -DNEED_BCOPY -O2 -fpic ../../../forth/wrapper/zip/inflate.c -o xinflate.lo
ld -melf_i386 -T inflate.ld xinflate.lo -o xinflate.o
objcopy -O binary xinflate.o ../build/inflate.bin
make[2]: Leaving directory '/mnt/storage/mitch/openfirmware/cpu/x86/Linux'
make[1]: Leaving directory '/mnt/storage/mitch/openfirmware/cpu/x86/build'
./build ofw.c32
--- Rebuilding biostart.img
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../biostart.bth
biostart.img is missing
Build aborted
Makefile:9: recipe for target 'ofw.c32' failed
make: *** [ofw.c32] Error 1
MitchBradley commented 7 years ago

Try:

./build ofw

and tell me what happens.

The problem is that the target name changes depending on the config file and the Makefile doesn't know that.

AdrianKoshka commented 7 years ago

Thanks for the timely response. This happens:

$ ./build ofw
--- Rebuilding biostart.img
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../biostart.bth
biostart.img is missing
Build aborted
MitchBradley commented 7 years ago

This is very strange. The build is working perfectly for me on Ubuntu 14.04. It is late here so I am not thinking very effectively. I will look into the problem some more tomorrow. Meanwhile, here is one more thing to try, although I doubt that it will help much:

rm *.log ./build -v ofw

MitchBradley commented 7 years ago

One more thing to try - apply the following patch and then

rm -f ../../../Linux/*.o ../../../Linux/forth ../../../Linux/x86forth make clean make

Here is the patch:

diff --git a/forth/wrapper/wrapper.c b/forth/wrapper/wrapper.c index 58e591d..033b998 100644 --- a/forth/wrapper/wrapper.c +++ b/forth/wrapper/wrapper.c @@ -256,6 +256,11 @@ typedef long quadlet;

include <sys/ioctl.h> / For FIONREAD /

endif

+#ifdef linux +# include +# include <sys/ioctl.h> +#endif +

ifdef SYS5

define USE_TERMIOS

endif

AdrianKoshka commented 7 years ago

uh...I think you need to put that in a properly formatted codeblock :)

MitchBradley commented 7 years ago

Sorry about the markdown mess. Here is the patch as an attachment. ofwpatch.txt

AdrianKoshka commented 7 years ago

Thanks, got it to build on my CentOS7 VM, will try the patch too though!

AdrianKoshka commented 7 years ago

Dang...yet again:

$ make
make[1]: Entering directory '/mnt/storage/mitch/openfirmware/cpu/x86/Linux'
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/wrapper.c -o wrapper.o
../../../forth/wrapper/wrapper.c: In function ‘f_ioctl’:
../../../forth/wrapper/wrapper.c:1971:15: warning: implicit declaration of function ‘ioctl’ [-Wimplicit-function-declaration]
  return((long)ioctl((int)fd, (int)code, buf));
               ^~~~~
../../../forth/wrapper/wrapper.c: In function ‘today’:
../../../forth/wrapper/wrapper.c:2148:2: warning: implicit declaration of function ‘time’ [-Wimplicit-function-declaration]
  time(&tadd);
  ^~~~
../../../forth/wrapper/wrapper.c:2149:15: warning: implicit declaration of function ‘localtime’ [-Wimplicit-function-declaration]
  return((long)localtime(&tadd));
               ^~~~~~~~~
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/logger.c -o logger.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/adler32.c -o adler32.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/compress.c -o compress.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/crc32.c -o crc32.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/deflate.c -o deflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/inflate.c -o inflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/trees.c -o trees.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/zutil.c -o zutil.o
cc -m32 -o forth wrapper.o logger.o adler32.o compress.o crc32.o deflate.o inflate.o trees.o zutil.o 
make[1]: Leaving directory '/mnt/storage/mitch/openfirmware/cpu/x86/Linux'
make[1]: Entering directory '/mnt/storage/mitch/openfirmware/cpu/x86/build'
make -C ../Linux ../build/inflate.bin
make[2]: Entering directory '/mnt/storage/mitch/openfirmware/cpu/x86/Linux'
cc -c -m32 -Wall -fno-builtin -fno-stack-protector -ffreestanding -DNEED_BCOPY -O2 -fpic ../../../forth/wrapper/zip/inflate.c -o xinflate.lo
ld -melf_i386 -T inflate.ld xinflate.lo -o xinflate.o
objcopy -O binary xinflate.o ../build/inflate.bin
make[2]: Leaving directory '/mnt/storage/mitch/openfirmware/cpu/x86/Linux'
make[1]: Leaving directory '/mnt/storage/mitch/openfirmware/cpu/x86/build'
./build ofw.c32
--- Rebuilding biostart.img
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../biostart.bth
biostart.img is missing
Build aborted
Makefile:9: recipe for target 'ofw.c32' failed
make: *** [ofw.c32] Error 1
AdrianKoshka commented 7 years ago

Also ./build ofw still gives:

./build ofw
--- Rebuilding biostart.img
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../biostart.bth
biostart.img is missing
Build aborted
MitchBradley commented 7 years ago

I pushed up the patch to fix the compilation warnings. I got a clean build on Ubuntu 17.10 running on an Amazon EC2 instance.

The message "biostart.img is missing" means that stat() cannot find biostart.img, which should have been created by the preceding command. I suspect that something strange is happening with your filesystem, preventing the file "biostart.img" from being written properly.

Try building from a fresh clone of the latest, as follows:

$ git clone https://github.com/MitchBradley/openfirmware.git
<output suppressed>
$ cd openfirmware/cpu/x86/pc/biosload
$ cp config-grub.fth config.fth
$ cd build
$ make build
<output suppressed - but note that there were no warnings>
$ ./build biostart
--- Rebuilding biostart
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../biostart.bth
$ ls -lt
total 12
-rwxrwxr-t 1 ubuntu ubuntu  911 Jul 17 20:19 biostart.img
-rw-rw-r-- 1 ubuntu ubuntu 1116 Jul 17 20:19 biostart.log
lrwxrwxrwx 1 ubuntu ubuntu   20 Jul 17 20:18 build -> ../../../Linux/forth
-rw-rw-r-- 1 ubuntu ubuntu  542 Jul 17 19:18 Makefile
MitchBradley commented 7 years ago

I got a successful build - no problems at all - on Ubuntu 17.04, using this AMI on an Amazon EC2 instance:

ubuntu/images/ebs-ssd/ubuntu-zesty-17.04-amd64-server-20170619.1 (ami-fcf3de9c)

The sequence of commands, starting from scratch on a new instance, was:

ubuntu@ip-172-31-17-17:$ sudo apt update
...
ubuntu@ip-172-31-17-17:$ sudo apt install gcc make libc6-dev-i386
...
ubuntu@ip-172-31-17-17:$ git clone https://github.com/MitchBradley/openfirmware.git
...
ubuntu@ip-172-31-17-17:~$ cd openfirmware/cpu/x86/pc/biosload/
ubuntu@ip-172-31-17-17:~/openfirmware/cpu/x86/pc/biosload$ cp config-grub.fth config.fth
ubuntu@ip-172-31-17-17:~/openfirmware/cpu/x86/pc/biosload$ cd build
ubuntu@ip-172-31-17-17:~/openfirmware/cpu/x86/pc/biosload/build$ make
make[1]: Entering directory '/home/ubuntu/openfirmware/cpu/x86/Linux'
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/wrapper.c -o wrapper.o
cc -c -O -g -m32 -DTARGET_X86 ../../../forth/wrapper/logger.c -o logger.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/adler32.c -o adler32.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/compress.c -o compress.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/crc32.c -o crc32.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/deflate.c -o deflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/inflate.c -o inflate.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/trees.c -o trees.o
cc -c -O -g -m32 -DTARGET_X86 -I../../../forth/wrapper/zip ../../../forth/wrapper/zip/zutil.c -o zutil.o
cc -m32 -o forth wrapper.o logger.o adler32.o compress.o crc32.o deflate.o inflate.o trees.o zutil.o 
make[1]: Leaving directory '/home/ubuntu/openfirmware/cpu/x86/Linux'
make[1]: Entering directory '/home/ubuntu/openfirmware/cpu/x86/build'
make -C ../Linux ../build/inflate.bin
make[2]: Entering directory '/home/ubuntu/openfirmware/cpu/x86/Linux'
cc -c -m32 -Wall -fno-builtin -fno-stack-protector -ffreestanding -DNEED_BCOPY -O2 -fpic ../../../forth/wrapper/zip/inflate.c -o xinflate.lo
ld -melf_i386 -T inflate.ld xinflate.lo -o xinflate.o
objcopy -O binary xinflate.o ../build/inflate.bin
make[2]: Leaving directory '/home/ubuntu/openfirmware/cpu/x86/Linux'
make[1]: Leaving directory '/home/ubuntu/openfirmware/cpu/x86/build'
./build ofw.c32
--- Rebuilding biostart.img
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../biostart.bth
--- Rebuilding reset.di
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../reset.bth
--- Rebuilding start.di
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../start.bth
--- Rebuilding paging.di
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../paging.bth
--- Rebuilding kernel.dic
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../kernel.bth
--- Saving kernel.dic ---
--- Rebuilding tools.dic
--- Cmd: ${HOSTDIR}/x86forth ${BP}/cpu/x86/build/kernel.dic ../tools.bth
--- Saving tools.dic --- 
--- Rebuilding basefw.dic
--- Cmd: ${HOSTDIR}/x86forth ${BP}/cpu/x86/build/tools.dic ../basefw.bth

--- Saving basefw.dic --- 
--- Rebuilding bootsec.hex
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../bootsec.bth
1fe 1f0 
400 400 
--- Rebuilding fw.img
--- Cmd: ${HOSTDIR}/x86forth ${BP}/cpu/x86/build/basefw.dic ../fw.bth
SAVING FW.dic ...
Saving fw.img ...
--- Rebuilding ohci.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../ohci.bth
--- Rebuilding uhci.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../uhci.bth
--- Rebuilding ehci.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../ehci.bth
--- Rebuilding hub.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../hub.bth
--- Rebuilding usbnet.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../usbnet.bth
--- Rebuilding usbserial.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../usbserial.bth
--- Rebuilding usbstorage.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../usbstorage.bth
--- Rebuilding usbkbd.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../usbkbd.bth
--- Rebuilding usbmouse.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../usbmouse.bth
--- Rebuilding pcibridg.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../pcibridg.bth
--- Rebuilding node.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../node.bth
--- Rebuilding leghier.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../leghier.bth
--- Rebuilding sdhci2.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../sdhci2.bth
--- Rebuilding sdhci.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../sdhci.bth
--- Rebuilding sdmmc.fc
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../sdmmc.bth
--- Rebuilding ofw.c32
--- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../ofw.bth
--- Saving as ofwgrub.elf - GRUB multiboot format
AdrianKoshka commented 7 years ago

huh...odd! This is outside of scope of this issue, but I was curious if you've used this to boot Linux distros on traditional PCs. Managed to get the firmware I built to run on a netbook I have via chainloading it from iPXE, but couldn't figure out much else from there.