# Rebuilding early ISO boot programs (cdboot)



## Chris Lalancette (Sep 7, 2016)

Hello,
     I'm a new FreeBSD user, but I'm kind of jumping in on the deep end.  What I'm trying to do is to modify the very early bootup process of FreeBSD 10 when booting from a CD[1].  I'm not entirely sure of the bootup process of FreeBSD 10, but it seems to look something like:

CD Loader -> BTX loader -> bootstrap loader

(the latter is what I'm having trouble with).  I've done the following so far:

1.  Installed a VM with FreeBSD 10.
2.  Installed the ports snapshot with `portsnap fetch ; portsnap extract`
3.  Built the subversion port with `cd /usr/ports/devel/subversion ; make install clean`
4.  Checked out the FreeBSD base collection with `svn checkout https://svn.FreeBSD.org/base/stable/10 /usr/src`

This is where I start running into trouble.  I believe I need to rebuild what is known as the "loader", so I run:

```
# cd /usr/src/sys/boot/i386/loader
# make
```
That compiles a few files, but then fails with:

```
cc -O2 -pipe  -DLOADER_NFS_SUPPORT -DBOOT_FORTH -I/usr/src/sys/boot/i386/loader/../../ficl -I/usr/src/sys/boot/i386/loader/../../ficl/i386 -DLOADER_GZIP_SUPPORT -DLOADER_DISK_SUPPORT -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT -I/usr/src/sys/boot/i386/loader/../../common -I. -Wall -I/usr/src/sys/boot/i386/loader/.. -I/usr/src/sys/boot/i386/loader/../btx/lib -march=i386 -ffreestanding -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float -m32 -std=gnu99 -Qunused-arguments  -DLOADER_PREFER_AMD64 -c /usr/src/sys/boot/i386/loader/../../common/load_elf32_obj.c
In file included from /usr/src/sys/boot/i386/loader/../../common/load_elf32_obj.c:7:
/usr/src/sys/boot/i386/loader/../../common/load_elf_obj.c:415:8: error: use of
  undeclared identifier 'MDT_PNP_INFO'
  case MDT_PNP_INFO:
  ^
1 error generated.
*** Error code 1
```
Any idea what I'm doing wrong?

Thanks!

[1] I'm trying to do this because I'm the maintainer of http://github.com/clalancette/pyiso, and I can't seem to make pyiso work properly with FreeBSD, which I would like to do.  I can't see what I'm doing wrong from the pyiso side, so I'd like to modify cdboot to print additional debugging information.


----------



## SirDice (Sep 7, 2016)

On FreeBSD 10.0 and higher there's no need to install devel/subversion, you can use svnlite(1). 

One thing I'm guessing is wrong is that you have a 10.3-RELEASE (guessing here) and the sources you checked out are for 10.3-STABLE. I don't think there's been a lot of changes but it's always best to keep the system and the sources at the same version. For 10.3-RELEASE use /releng/10.3 instead of /stable/10.


----------



## Chris Lalancette (Sep 7, 2016)

Ah, OK.  I'll checkout releng/10.3 instead and try that.  Thanks.

Just so I know in the future, what's the relationship between releng and stable?


----------



## tobik@ (Sep 8, 2016)

stable/10 is the development branch for what would in theory become 10.4-RELEASE (unsure atm if there actually will be 10.4-RELEASE). It might contain new drivers, features etc. releng/10.3 is the branch with only security or errata patches against 10.3-RELEASE.

Also see https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html#stable.


----------



## Chris Lalancette (Sep 9, 2016)

Yep, that did it.  And I was able to find my bug .  Thanks again for the help, I'm going to close this out.


----------

