凌云实验室IGKBoard开发板BSP开发相关文件
guowenxue
2023-07-26 c766190cf18c6c437ba3bf411077af6d7760e225
Add build driver support

Signed-off-by: guowenxue <guowenxue@gmail.com>
2 files modified
2 files added
137 ■■■■■ changed files
.gitignore 1 ●●●● patch | view | raw | blame | history
kernel/build.sh 64 ●●●● patch | view | raw | blame | history
kernel/drivers/user/Makefile 37 ●●●●● patch | view | raw | blame | history
kernel/drivers/user/hello.c 35 ●●●●● patch | view | raw | blame | history
.gitignore
@@ -9,3 +9,4 @@
kirkstone/
langdale/
images/rootfs-*
rtl8188fu/
kernel/build.sh
@@ -156,14 +156,64 @@
    make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j ${JOBS}
}
function build_driver()
function build_driver_wifi()
{
    SRC=drivers
    cd $PRJ_PATH/drivers
    pr_info "Start build linux drivers"
    cd $PRJ_PATH/${SRC}
    if [[ $BOARD =~ 6ull ]] ; then
        SRC=rtl8188fu
        pr_info "Start build $SRC driver for $BOARD"
        if [ ! -d $SRC ] ; then
            if [ ! -s $TARBALL_PATH/$SRC.tar.xz ] ; then
                pr_info "start fetch $SRC source code"
                wget $URL/bsp/misc/$SRC.tar.xz -P $TARBALL_PATH
            fi
            do_unpack $TARBALL_PATH/$SRC.tar.xz
        fi
        cd $SRC
        # Remove noisy debug print information
        sed -i "s|^#define CONFIG_DEBUG|//#define CONFIG_DEBUG|g" include/autoconf.h
        sed -i "/nolinked power/d" core/rtw_pwrctrl.c
        sed -i "/request firmware/d" hal/rtl8188f/rtl8188f_hal_init.c
        make KSRC=$KER_PATH M=$PWD -j ${JOBS}
        make -C $KER_PATH M=$PWD modules_install INSTALL_MOD_PATH=$INST_PATH INSTALL_MOD_STRIP=1
        mkdir -p $INST_PATH/lib/firmware/rtlwifi/
        cp firmware/rtl8188fufw.bin $INST_PATH/lib/firmware/rtlwifi/
    fi
}
function build_driver_user()
{
    cd $PRJ_PATH/drivers/user
    pr_info "Start build user driver for $BOARD"
    make -C $KER_PATH M=$PWD
    make -C $KER_PATH M=$PWD modules_install INSTALL_MOD_PATH=$INST_PATH INSTALL_MOD_STRIP=1
}
function install_drv_kernel()
{
    # Install linux kernel modules
    cd $KER_PATH
    make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} modules_install INSTALL_MOD_PATH=$INST_PATH INSTALL_MOD_STRIP=1
}
function build_driver()
{
    install_drv_kernel
    build_driver_user
    build_driver_wifi
}
function do_install()
{
@@ -191,9 +241,6 @@
        set +x
    fi
    # Install linux kernel modules
    make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} modules_install INSTALL_MOD_PATH=$INST_PATH INSTALL_MOD_STRIP=1
    # List install information
    pr_info "\nlinux kernel installed to '$INST_PATH'"
    ls $INST_PATH && echo ""
@@ -207,7 +254,7 @@
    do_install
    #build_driver
    build_driver
}
function do_clean()
@@ -219,6 +266,7 @@
        rm -rf $PRJ_PATH/$d
    done
    rm -rf drivers/rtl8188fu/
    rm -rf $TARBALL_PATH
    rm -rf $INST_PATH
}
kernel/drivers/user/Makefile
New file
@@ -0,0 +1,37 @@
#*********************************************************************************
#      Copyright:  (C) 2021 LingYun IoT System Studio
#                  All rights reserved.
#
#       Filename:  Makefile
#    Description:  This Makefile used to compile all the drivers here
#
#        Version:  1.0.0(18/12/2021~)
#                  Author:  Guo Wenxue <guowenxue@gmail.com>
#      ChangeLog:  1, Release initial version on "18/12/2021 01:29:33 PM"
#
#********************************************************************************/
LINUX_SRC ?= ${shell pwd}/../../linux-imx/
INST_PATH ?= ${shell pwd}/../../install
EXTRA_INSTPATH=/tftp
PWD := $(shell pwd)
obj-m += hello.o
modules:
    @echo ${LINUX_SRC}
    @make -C $(LINUX_SRC) M=$(PWD) modules
    @make -C $(LINUX_SRC) M=$(PWD) modules_install INSTALL_MOD_PATH=${INST_PATH} INSTALL_MOD_STRIP=1
    @make clear
install:
    cp -af *.ko ${EXTRA_INSTPATH}
clear:
    @rm -f *.o *.mod* .*.cmd *.symvers *.order
clean: clear
    @rm -f  *.ko
kernel/drivers/user/hello.c
New file
@@ -0,0 +1,35 @@
/*********************************************************************************
 *      Copyright:  (C) 2021 LingYun IoT System Studio <www.weike-iot.com>
 *                  All rights reserved.
 *
 *       Filename:  hello.c
 *    Description:  This file is the linux kernel sample hello module
 *
 *        Version:  1.0.0(18/12/2021~)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "18/12/2021 10:50:26 AM"
 *
 ********************************************************************************/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
static __init int hello_init(void)
{
    printk(KERN_ALERT "Hello, LingYun IoT System Studio!\n");
    return 0;
}
static __exit void hello_exit(void)
{
    printk(KERN_ALERT "Goodbye, I have found a good job!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_AUTHOR("GuoWenxue <guowenxue@gmail.com>");
MODULE_DESCRIPTION("Linux Kernel hello module");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_INFO(intree, "Y");