First we have to get the FreeBSD sources.

cd $ROOT/src/rtems-libbsd
git submodule init
git submodule update freebsd-org

$ROOT is your RTEMS Project root directory.

The module defnitions in libbsd.py is used to track the imported modules and to make the procedure of updating to a newer version of FreeBSD easier. We use the freebsd-to-rtems.py script in reverse mode to first apply the changes of rtems freebsd to freebsd-org.

./freebsd-to-rtems.py -R

Now we can add the files we want to import to the libbsd.py. Now we’ll add the module definitions for the CDC Ethernet.

These files are in the rtems-libbsd/freebsd-org/sys/dev/usb/template directory.

We only need the following files for now.

  1. usb_template.h
  2. usb_template.c
  3. usb_template_cdce.c

Create a module class for USB Template in libbsd.py

#
# USB Template
#
class dev_usb_template(builder.Module):

    def __init__(self, manager):
        super(dev_usb_template, self).__init__(manager, type(self).__name__)

def generate(self):
    mm = self.manager
    seld.addDependency('dev_usb')
    self.addKernelSpaceHeaderFiles(
        [
            'sys/dev/usb/template/usb_template.h',
        ]
    )
    self.addKernelSpaceSourceFiles(
        [
            'sys/dev/usb/template/usb_template.c',
            'sys/dev/usb/template/usb_template_cdce.c',
        ],
        mm.generator['source']()
    )

Register the dev_usb_template module in the end of the libbsd.py file.

 mm.addModule(dev_usb_template(mm))

Now run the script again in the forward mode to import the files

./freebsd-to-rtems.py

We now have successfully imported the files. In the next post we’ll see how to enable the module and include it in the Beagle BSP.