概述
最近在为rtems-libbsd添加无线网卡驱动,需要添加网卡的固件文件,本人所用的网卡芯片是rtl8188eu,接下来讲讲如何在rtems-libbsd中生成固件文件。
首先固件文件生成是采用make-build system(吐槽一下,目前rtems-libbsd包含waf的python脚本编译和一部分的make脚本编译,实在不忍直视,不过rtems也说了会在将来全部采用waf作为唯一的编译方式,甚至连rtems的core code都是采用python脚本)。
在源码的根目录下有Makefile.todo文件,修改此文件即可得到固件文件,Makefile.todo 源码 如下:
LOCAL_INC = rtemsbsd/include/rtems/bsd/local
LOCAL_SRC = rtemsbsd/local
FREEBSD_SRC = freebsd-org
TOOLS = freebsd-org/sys/tools
GENERATED =
GENERATED += $(LOCAL_INC)/usb_if.h
GENERATED += $(LOCAL_SRC)/usb_if.c
GENERATED += $(LOCAL_INC)/bus_if.h
GENERATED += $(LOCAL_SRC)/bus_if.c
GENERATED += $(LOCAL_INC)/device_if.h
GENERATED += $(LOCAL_SRC)/device_if.c
GENERATED += $(LOCAL_INC)/usbdevs_data.h
GENERATED += $(LOCAL_INC)/usbdevs.h
GENERATED += $(LOCAL_INC)/ifdi_if.h
GENERATED += $(LOCAL_SRC)/ifdi_if.c
GENERATED += $(LOCAL_INC)/miibus_if.h
GENERATED += $(LOCAL_SRC)/miibus_if.c
GENERATED += $(LOCAL_INC)/miidevs.h
GENERATED += $(LOCAL_INC)/ofw_if.h
GENERATED += $(LOCAL_SRC)/ofw_if.c
GENERATED += $(LOCAL_INC)/ofw_bus_if.h
GENERATED += $(LOCAL_SRC)/ofw_bus_if.c
GENERATED += $(LOCAL_INC)/pci_if.h
GENERATED += $(LOCAL_SRC)/pci_if.c
GENERATED += $(LOCAL_INC)/pcib_if.h
GENERATED += $(LOCAL_SRC)/pcib_if.c
GENERATED += $(LOCAL_INC)/mmcbr_if.h
GENERATED += $(LOCAL_SRC)/mmcbr_if.c
GENERATED += $(LOCAL_INC)/mmcbus_if.h
GENERATED += $(LOCAL_SRC)/mmcbus_if.c
GENERATED += $(LOCAL_SRC)/rtwn-rtl8192cfwT.c
GENERATED += $(LOCAL_SRC)/runfw.c
GENERATED += rtemsbsd/include/machine/rtems-bsd-regdomain.h
GENERATED += rtemsbsd/rtems/rtems-bsd-regdomain.c
all: $(GENERATED)
$(LOCAL_INC)/usbdevs.h: $(FREEBSD_SRC)/sys/dev/usb/usbdevs
awk -f $(TOOLS)/usbdevs2h.awk $< -h
mv usbdevs.h $@
$(LOCAL_INC)/usbdevs_data.h: $(FREEBSD_SRC)/sys/dev/usb/usbdevs
awk -f $(TOOLS)/usbdevs2h.awk $< -d
mv usbdevs_data.h $@
$(LOCAL_INC)/usb_if.h: $(FREEBSD_SRC)/sys/dev/usb/usb_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv usb_if.h $@
$(LOCAL_SRC)/usb_if.c: $(FREEBSD_SRC)/sys/dev/usb/usb_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv usb_if.c $@
$(LOCAL_INC)/bus_if.h: $(FREEBSD_SRC)/sys/kern/bus_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv bus_if.h $@
$(LOCAL_SRC)/bus_if.c: $(FREEBSD_SRC)/sys/kern/bus_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv bus_if.c $@
$(LOCAL_INC)/device_if.h: $(FREEBSD_SRC)/sys/kern/device_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv device_if.h $@
$(LOCAL_SRC)/device_if.c: $(FREEBSD_SRC)/sys/kern/device_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv device_if.c $@
$(LOCAL_INC)/ifdi_if.h: $(FREEBSD_SRC)/sys/net/ifdi_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv ifdi_if.h $@
$(LOCAL_SRC)/ifdi_if.c: $(FREEBSD_SRC)/sys/net/ifdi_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv ifdi_if.c $@
$(LOCAL_INC)/miidevs.h: $(FREEBSD_SRC)/sys/dev/mii/miidevs
awk -f $(TOOLS)/miidevs2h.awk $<
mv miidevs.h $@
$(LOCAL_INC)/miibus_if.h: $(FREEBSD_SRC)/sys/dev/mii/miibus_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv miibus_if.h $@
$(LOCAL_SRC)/miibus_if.c: $(FREEBSD_SRC)/sys/dev/mii/miibus_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv miibus_if.c $@
$(LOCAL_INC)/pci_if.h: $(FREEBSD_SRC)/sys/dev/pci/pci_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv pci_if.h $@
$(LOCAL_SRC)/pci_if.c: $(FREEBSD_SRC)/sys/dev/pci/pci_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv pci_if.c $@
$(LOCAL_INC)/pcib_if.h: $(FREEBSD_SRC)/sys/dev/pci/pcib_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv pcib_if.h $@
$(LOCAL_SRC)/pcib_if.c: $(FREEBSD_SRC)/sys/dev/pci/pcib_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv pcib_if.c $@
$(LOCAL_INC)/mmcbus_if.h: $(FREEBSD_SRC)/sys/dev/mmc/mmcbus_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv mmcbus_if.h $@
$(LOCAL_SRC)/mmcbus_if.c: $(FREEBSD_SRC)/sys/dev/mmc/mmcbus_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv mmcbus_if.c $@
$(LOCAL_INC)/mmcbr_if.h: $(FREEBSD_SRC)/sys/dev/mmc/mmcbr_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv mmcbr_if.h $@
$(LOCAL_SRC)/mmcbr_if.c: $(FREEBSD_SRC)/sys/dev/mmc/mmcbr_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv mmcbr_if.c $@
$(LOCAL_INC)/ofw_if.h: $(FREEBSD_SRC)/sys/dev/ofw/ofw_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv ofw_if.h $@
$(LOCAL_SRC)/ofw_if.c: $(FREEBSD_SRC)/sys/dev/ofw/ofw_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv ofw_if.c $@
$(LOCAL_INC)/ofw_bus_if.h: $(FREEBSD_SRC)/sys/dev/ofw/ofw_bus_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv ofw_bus_if.h $@
$(LOCAL_SRC)/ofw_bus_if.c: $(FREEBSD_SRC)/sys/dev/ofw/ofw_bus_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv ofw_bus_if.c $@
$(LOCAL_INC)/if_dwc_if.h: $(FREEBSD_SRC)/sys/dev/dwc/if_dwc_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv if_dwc_if.h $@
$(LOCAL_SRC)/if_dwc_if.c: $(FREEBSD_SRC)/sys/dev/dwc/if_dwc_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv if_dwc_if.c $@
$(LOCAL_INC)/gpio_if.h: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv gpio_if.h $@
$(LOCAL_SRC)/gpio_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv gpio_if.c $@
$(LOCAL_SRC)/rtwn-rtl8192cfwT.c: $(FREEBSD_SRC)/sys/contrib/dev/rtwn/rtwn-rtl8192cfwT.fw.uu
uudecode -o /dev/stdout $< | python firmware-gen.py
-l "$(FREEBSD_SRC)/sys/contrib/dev/rtwn/LICENSE"
rtwn-rtl8192cfwT - $@
$(LOCAL_SRC)/runfw.c: $(FREEBSD_SRC)/sys/contrib/dev/run/rt2870.fw.uu
uudecode -o /dev/stdout $< | python firmware-gen.py
-l "$(FREEBSD_SRC)/sys/contrib/dev/run/LICENSE"
runfw - $@
freebsd/usr.bin/netstat/nl_symbols.c: $(FREEBSD_SRC)/usr.bin/netstat/nlist_symbols
awk '
BEGIN {
print "#include <sys/param.h>";
print "#include <nlist.h>";
print "const struct nlist nl[] = {";
}
!/^#/ { printf("t{ .n_name = "%s" },n", $$2); }
END { print "t{ .n_name = NULL },n};" }
' < $< > $@ || rm -f $@
freebsd/usr.bin/netstat/nl_defs.h: $(FREEBSD_SRC)/usr.bin/netstat/nlist_symbols
awk '
BEGIN {
print "#include <nlist.h>";
print "extern const struct nlist nl[];";
i = 0;
}
!/^#/ { printf("#definetN%st%sn", toupper($$2), i++); }'
< $< > $@ || rm -f $@
rtemsbsd/include/machine/rtems-bsd-regdomain.h: $(FREEBSD_SRC)/etc/regdomain.xml
rtems-bin2c -H $< $@
rtemsbsd/rtems/rtems-bsd-regdomain.c: $(FREEBSD_SRC)/etc/regdomain.xml
rtems-bin2c -C $< $@
clean:
rm $(GENERATED)
首先声明添加:
GENERATED += $(LOCAL_SRC)/rtwn-rtl8192cfwT.c
$(LOCAL_SRC)/rtwn-rtl8192cfwT.c: $(FREEBSD_SRC)/sys/contrib/dev/rtwn/rtwn-rtl8192cfwT.fw.uu
uudecode -o /dev/stdout $< | python firmware-gen.py
-l "$(FREEBSD_SRC)/sys/contrib/dev/rtwn/LICENSE"
rtwn-rtl8192cfwT - $@
固件文件所需的源文件如下所示:
利用git clone 将rtems-libbsd源码clone到本地,但是默认freeBSD-org文件夹是空的。因此需要以下命令来将freeBSD clone到文件夹下:
git submodule update
分析完固件文件的生成后,添加rtl8188eu固件生成代码,在Makefile.todo 中添加:
GENERATED += $(LOCAL_SRC)/rtwn-rtl8188eufw.c
$(LOCAL_SRC)/rtwn-rtl8188eufw.c: $(FREEBSD_SRC)/sys/contrib/dev/rtwn/rtwn-rtl8188eufw.fw.uu
uudecode -o /dev/stdout $< | python firmware-gen.py
-l "$(FREEBSD_SRC)/sys/contrib/dev/rtwn/LICENSE"
rtwn-rtl8188eufw - $@
然后编译:
make -f Makefile.todo
./freebsd-to-rtems.py
即可在libbsd_waf.py中更新此文件,最后利用waf编译即可。如此,固件文件已经生成,那么如何应用呢?
在nexus-devices.h中添加如下模块则表示加载固件模块:
SYSINIT_REFERENCE(rtwn_rtl8188eufw);
最后
以上就是友好酒窝为你收集整理的RTEMS-libbsd 生成驱动设备firmware的全部内容,希望文章能够帮你解决RTEMS-libbsd 生成驱动设备firmware所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复