NetBSD/Dreamcast: Difference between revisions

From dreamcast.wiki
Jump to navigation Jump to search
(Created page with "'''This article is a WIP. It is subject to rapid change. Beware!''' Before building NetBSD, it's important to undertand [http://www.netbsd.org/releases/release-map.html relea...")
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
NetBSD is a powerful, UNIX-based operating system with an official Dreamcast port. Earlier versions were partially maintained by Sega employees. NetBSD includes BBA support, Video Support and Keyboard support. [[Marcus Comstedt]] also maintained NetBSD/Dreamcast.
'''This article is a WIP. It is subject to rapid change. Beware!'''
'''This article is a WIP. It is subject to rapid change. Beware!'''


Before building NetBSD, it's important to undertand [http://www.netbsd.org/releases/release-map.html release types] and pick one of release, stable, or current types. Example is using 10.0_BETA
Before building NetBSD, it's important to undertand [http://www.netbsd.org/releases/release-map.html release types] and pick one of release, stable, or current types.
 
The example we'll follow here is using is using 10.0-release BETA.
 
In general, the instructions are made to be able to copy/paste, but read the text before and after the commands to make sure you understand them in case you need to adjust paramaters to your liking.


References: [https://www.netbsd.org/docs/guide/en/chap-fetch.html How to fetch NetBSD sources], [https://www.netbsd.org/docs/guide/en/chap-build.html How to build NetBSD]
References: [https://www.netbsd.org/docs/guide/en/chap-fetch.html How to fetch NetBSD sources], [https://www.netbsd.org/docs/guide/en/chap-build.html How to build NetBSD]


==Example==
==Building NetBSD source from scratch==
===Initial folder setup===
===Initial folder setup===
Create a working directory in your home folder and enter it:
Create a working directory in your home folder to hold everything, and enter it:
  mkdir ~/netbsd
  mkdir ~/netbsd
  cd netbsd
  cd ~/netbsd
Create additional directories for files:
Create additional directories for files:
  mkdir -p usr obj src-tars xsrc-tars
  mkdir obj toolchain dest release src-tars xsrc-tars


===Download files===
===Download files===
Download from ftp.netbsd.org/pub/NetBSD/NetBSD-release-10/tar_files/src/ and place files into directory src-tars
Download all files from ftp.netbsd.org/pub/NetBSD/NetBSD-release-10/tar_files/src/ and place files into directory src-tars


Download from ftp.netbsd.org/pub/NetBSD/NetBSD-release-10/tar_files/xsrc/ and place files into directory xsrc-tars
Download all files from ftp.netbsd.org/pub/NetBSD/NetBSD-release-10/tar_files/xsrc/ and place files into directory xsrc-tars


===Extract files===
===Extract files===
  for file in src-tars/*.tar.gz; do tar -zxf $file -C usr; done
cd ~/netbsd
  for file in xsrc-tars/*.tar.gz; do tar -zxf $file -C usr; done
  for file in src-tars/*.tar.gz; do tar -zxf $file; done
  for file in xsrc-tars/*.tar.gz; do tar -zxf $file; done


===Build toolchain===
===Build toolchain===
  cd usr/src
First, we need to build the cross-compiler to compile SuperH code on your desktop machine.
  /build.sh -U -O ~/netbsd/obj -j2 -m dreamcast tools
  cd ~/netbsd/src
(-U is unprivileged, -O is where to store object files, -j is number of threads during build, -m is machine type, tools is toolchain)
  ./build.sh -U -O ~/netbsd/obj -T ~/netbsd/toolchain -D ~/netbsd/dest -R ~/netbsd/release -j2 -m dreamcast tools
(-U is unprivileged, -O is where to store object files, -T is your toolchain directory, -D is the directory to place built NetBSD files, -R is the directory to place release files, -j is number of threads during build, -m is machine type, tools indcates you want to build toolchain)


run the following command and take note of your tooldir name, e.g. on Linux:
Be sure to adjust -j to the number of threads you want to use depending on how many cores/threads your processor provides.  
ls -l ~/netbsd/obj
will returns something like...
- tooldir.Linux-6.0.15-gentoo-x86_64
- tools
The one with "tooldir" in the name is the directory to note.


===Build kernel===
===Build kernel===
  cd sys/arch/dreamcast/conf
  cd ~/netbsd/src/sys/arch/dreamcast/conf
If your target Dreamcast is modded with 32MB of RAM and you wish to build for that, open std.dreamcast and replace
If your target Dreamcast is [[32MB RAM expansion|modded with 32MB of RAM]] and you wish to build for that, open <code>std.dreamcast</code> and replace
  options IOM_RAM_SIZE=0x01000000        # 16MB
  options IOM_RAM_SIZE=0x01000000        # 16MB
with
with
  options IOM_RAM_SIZE=0x02000000        # 32MB
  options IOM_RAM_SIZE=0x02000000        # 32MB
You can pick GENERIC, GENERIC_MD (memory disk), or G1ATA kernel types, or copy one of them to a new file in the same dir and edit to configure your own kernel options.
You can pick GENERIC, GENERIC_MD (memory disk), or G1ATA kernel types. You can also copy one of them to a new file in the same dir and edit to configure your own kernel options for a custom kernel type.
Run nbconfig on your kernel config, putting in the tooldir you noted before:
If you have a serial or USB [[coder's cable]] and want to run headless, or don't have a Dreamcast keyboard and want to use your computer keyboard for input, you may want to set <code>options SCIFCONSOLE</code> in your kernel config to communicate over serial connection.
  ~/netbsd/obj/<YOUR_TOOLDIR_NAME>/bin/nbconfig GENERIC
 
Run nbconfig on your kernel config:
  ~/netbsd/toolchain/bin/nbconfig GENERIC
Enter the configuration directory:
cd ../compile/GENERIC
Then build dependencies and kernel:
Then build dependencies and kernel:
  ~/netbsd/obj/<YOUR_TOOLDIR_NAME>/bin/nbmake-dreamcast depend
  ~/netbsd/toolchain/bin/nbmake-dreamcast depend
  ~/netbsd/obj/<YOUR_TOOLDIR_NAME>/bin/nbmake-dreamcast
  ~/netbsd/toolchain/bin/nbmake-dreamcast
netbsd.bin is your kernel file and Dreamcast executable (e.g. it can be sent over dcload-ip to boot NetBSD, or it can be scrambled and burned to CD-R as 1ST_READ.BIN).
cp netbsd.bin ~/netbsd/NetBSD-10.0_BETA-GENERIC.bin
You can repeat these steps to build multiple kernels.


===Build userland===
===Build userland===
  cd ~/netbsd/usr/src
  cd ~/netbsd/src
  ./build.sh -U -u -j2 -O ~/netbsd/obj -m dreamcast release
  ./build.sh -U -O ~/netbsd/obj -T ~/netbsd/toolchain -D ~/netbsd/dest -R ~/netbsd/release -j2 -u -m dreamcast release
(-u is update-only so we use what we've already built before instead of building another toolchain, and don't forget -j is number of threads during build)
(-u is update-only so we use what we've already built before instead of building another toolchain, and don't forget -j is number of threads during build)


===Build X Server===
===Build X Server===
  ./build.sh -U -u -O ../../obj -j30 -x -X ../xsrc -m dreamcast release
cd ~/netbsd/src
  ./build.sh -U -O ~/netbsd/obj -T ~/netbsd/toolchain -D ~/netbsd/dest -R ~/netbsd/release -x -X ~/netbsd/xsrc -j2 -u -m dreamcast release
(-x is to build the X server, -X is the path of the X source code)
(-x is to build the X server, -X is the path of the X source code)
===Output directories===
* <code>~/netbsd/dest</code> will contain a copy of your NetBSD/Dreamcast userland.
* <code>~/netbsd/release/dreamcast/binary</code> will contain packaged copies of kernels and userland sets for resharing with others.
==Kernel Options==
===NFS booting===
options        NFS_BOOT_BOOTSTATIC
options        NFS_BOOTSTATIC_MYIP="\"192.168.0.100\""
options        NFS_BOOTSTATIC_GWIP="\"192.168.0.1\""
options        NFS_BOOTSTATIC_MASK="\"255.255.255.0\""
options        NFS_BOOTSTATIC_SERVADDR="\"192.168.0.2\""
options        NFS_BOOTSTATIC_SERVER="\"192.168.0.2:/home/user/netbsdmount\""
options        NFS_BOOT_RWSIZE=1024

Latest revision as of 18:02, 1 March 2023

NetBSD is a powerful, UNIX-based operating system with an official Dreamcast port. Earlier versions were partially maintained by Sega employees. NetBSD includes BBA support, Video Support and Keyboard support. Marcus Comstedt also maintained NetBSD/Dreamcast.

This article is a WIP. It is subject to rapid change. Beware!

Before building NetBSD, it's important to undertand release types and pick one of release, stable, or current types.

The example we'll follow here is using is using 10.0-release BETA.

In general, the instructions are made to be able to copy/paste, but read the text before and after the commands to make sure you understand them in case you need to adjust paramaters to your liking.

References: How to fetch NetBSD sources, How to build NetBSD

Building NetBSD source from scratch

Initial folder setup

Create a working directory in your home folder to hold everything, and enter it:

mkdir ~/netbsd
cd ~/netbsd

Create additional directories for files:

mkdir obj toolchain dest release src-tars xsrc-tars

Download files

Download all files from ftp.netbsd.org/pub/NetBSD/NetBSD-release-10/tar_files/src/ and place files into directory src-tars

Download all files from ftp.netbsd.org/pub/NetBSD/NetBSD-release-10/tar_files/xsrc/ and place files into directory xsrc-tars

Extract files

cd ~/netbsd
for file in src-tars/*.tar.gz; do tar -zxf $file; done
for file in xsrc-tars/*.tar.gz; do tar -zxf $file; done

Build toolchain

First, we need to build the cross-compiler to compile SuperH code on your desktop machine.

cd ~/netbsd/src
./build.sh -U -O ~/netbsd/obj -T ~/netbsd/toolchain -D ~/netbsd/dest -R ~/netbsd/release -j2 -m dreamcast tools

(-U is unprivileged, -O is where to store object files, -T is your toolchain directory, -D is the directory to place built NetBSD files, -R is the directory to place release files, -j is number of threads during build, -m is machine type, tools indcates you want to build toolchain)

Be sure to adjust -j to the number of threads you want to use depending on how many cores/threads your processor provides.

Build kernel

cd ~/netbsd/src/sys/arch/dreamcast/conf

If your target Dreamcast is modded with 32MB of RAM and you wish to build for that, open std.dreamcast and replace

options 	IOM_RAM_SIZE=0x01000000         # 16MB

with

options 	IOM_RAM_SIZE=0x02000000         # 32MB

You can pick GENERIC, GENERIC_MD (memory disk), or G1ATA kernel types. You can also copy one of them to a new file in the same dir and edit to configure your own kernel options for a custom kernel type. If you have a serial or USB coder's cable and want to run headless, or don't have a Dreamcast keyboard and want to use your computer keyboard for input, you may want to set options SCIFCONSOLE in your kernel config to communicate over serial connection.

Run nbconfig on your kernel config:

~/netbsd/toolchain/bin/nbconfig GENERIC

Enter the configuration directory:

cd ../compile/GENERIC

Then build dependencies and kernel:

~/netbsd/toolchain/bin/nbmake-dreamcast depend
~/netbsd/toolchain/bin/nbmake-dreamcast

netbsd.bin is your kernel file and Dreamcast executable (e.g. it can be sent over dcload-ip to boot NetBSD, or it can be scrambled and burned to CD-R as 1ST_READ.BIN).

cp netbsd.bin ~/netbsd/NetBSD-10.0_BETA-GENERIC.bin

You can repeat these steps to build multiple kernels.

Build userland

cd ~/netbsd/src
./build.sh -U -O ~/netbsd/obj -T ~/netbsd/toolchain -D ~/netbsd/dest -R ~/netbsd/release -j2 -u -m dreamcast release

(-u is update-only so we use what we've already built before instead of building another toolchain, and don't forget -j is number of threads during build)

Build X Server

cd ~/netbsd/src
./build.sh -U -O ~/netbsd/obj -T ~/netbsd/toolchain -D ~/netbsd/dest -R ~/netbsd/release -x -X ~/netbsd/xsrc -j2 -u -m dreamcast release

(-x is to build the X server, -X is the path of the X source code)

Output directories

  • ~/netbsd/dest will contain a copy of your NetBSD/Dreamcast userland.
  • ~/netbsd/release/dreamcast/binary will contain packaged copies of kernels and userland sets for resharing with others.

Kernel Options

NFS booting

options         NFS_BOOT_BOOTSTATIC
options         NFS_BOOTSTATIC_MYIP="\"192.168.0.100\""
options         NFS_BOOTSTATIC_GWIP="\"192.168.0.1\""
options         NFS_BOOTSTATIC_MASK="\"255.255.255.0\""
options         NFS_BOOTSTATIC_SERVADDR="\"192.168.0.2\""
options         NFS_BOOTSTATIC_SERVER="\"192.168.0.2:/home/user/netbsdmount\""
options         NFS_BOOT_RWSIZE=1024