tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Creating a hackable kernel for AMD64



Hey,

I watched "How to get started hacking NetBSD" and it was great, I just noticed that some things didn't work when cross compiling for amd64. and frankly, I'm not sure what I did wrong.


I use the following script to build the kernel

```
#/usr/bin/sh

export DESTDIR=/home/jared/Projects/netbsd/obj/destdir
export RELEASEDIR=/home/jared/Projects/netbsd/obj/releasedir
export KERNDIR=/home/jared/Projects/netbsd/obj/sys/arch/amd64/compile/DEBUG_KERNEL


cd src/
./build.sh -u -O ../obj -U -m amd64 -N1 -j24 -V MKCROSSGDB=yes tools kernel.gdb=DEBUG_KERNEL

cd ../
```

And this creates the following directory

```
/home/jared/Projects/netbsd/obj/releasedir/amd64/binary/kernel/DEBUG_KERNEL
├── MD5
├── netbsd-DEBUG_KERNEL.gz
├── netbsd-GENERIC.gz
├── netbsd-GENERIC_KASLR.gz
├── netbsd-GENERIC.symbols.gz
├── netbsd-INSTALL.gz
├── netbsd-INSTALL.symbols.gz
├── netbsd-INSTALL_XEN3_DOMU.gz
├── netbsd-XEN3_DOM0.gz
├── netbsd-XEN3_DOMU.gz
└── SHA512
```

I unzipped the  `netbsd-DEBUG_KERNEL.gz` file and redirected the output to `vm/disk.img` with:

```
gunzip -c <netbsd-DEBUG_KERNEL.gz > ~/Projects/netbsd/vm/disk.img
```

And I created a sparse disk image with (note: `-oseek` is not a valid switch on my machine and `10g` didn't work, so I substituted it with `2^30` which is `1073741824` ):

```
$ dd if=/dev/zero of=disk.img seek=1073741824 bs=1 count=1
1+0 records in
1+0 records out
1 byte copied, 0.000180831 s, 5.5 kB/s
```

And I cannot figure out why, but I don't have a `netbsd.img` under

```
/home/jared/Projects/netbsd/obj/sys/arch/amd64/compile
```

so the following does not work:

```
#!/urs/bin/sh

/usr/bin/qemu-system-x86_64 \
    -kernel netbsd.img \ # This file does not exist
    -machine 'ubuntu'
    -append "root=dk1" \
    -M virt \
    -smp 2 \
    -m 1g \
    -drive if=none,file=disk.img,id=disk,format=raw \
    -device virtio-blk-device,drive=disk \
    -device virtio-rng-device \
    -nic user,model=virtio-net-pci \
    -nographic
```

And when I run that, I get:

```
qemu: could not open kernel file 'netbsd.img': No such file or directory
```

I'm also not sure what to substitute `-cpu` for when using `amd64`.

Some guidance would be great!


Home | Main Index | Thread Index | Old Index