小知识点总结

个人总结

1,git管理代码

git init

git config --global user.email [email protected]

git config --global user.name "flf"

git checkout -b master

git add ./

git commi

这样就创建了一个分支名称为master的git 仓。

2,从ubuntu虚拟机拷贝镜像到windows

以下脚本自动拷贝image到windows,用法:

把脚本放到待拷贝目录,执行脚本,无需参数,就会在windows共享文件夹里创建相同工程名称的文件夹,并把镜像拷进去,有其他想拷贝的可以自行添加。

附脚本:

#!/bin/sh

var=$PWD

# current dir name
# echo ${var##*/}

# get destination dir, dir name is same with current dir
destDir=/mnt/hgfs/`ls /mnt/hgfs/`/${var##*/}
#echo $destDir

if [ ! -d "$destDir" ]; then
  mkdir -p "$destDir"
fi

cp /opt1/template/x497/top_hw_platform/top.bit $destDir
cp $PWD/images/linux/BOOT.BIN $destDir
cp $PWD/images/linux/image.ub $destDir

3,驱动代码编译成模块

在linux开发系统上编译arm内核模块不同于本机(x86),需要指定内核源码config文件的位置、架构、交叉编译套件

3.1 Makefile 代码如下

#
# Makefile for device drivers.
#
KDIR := /home/dev/prj_gpio_ctrl/build/linux/kernel/xlnx-4.0
ARCH = arm
CROSS_COMPILE = arm-xilinx-linux-gnueabi-
obj-$(CONFIG_GPIO_ST) += src_file.o

all:
       make -C $(KDIR) M=$(PWD) modules ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE)
#       make CONFIG_MY_DEFINE=m -C $(KDIR)  M=$(PWD) modules ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE)
clean: 
       rm -f *.o *.ko *.order

1,KDIR是包含.config的文件夹,否则报错

     make[2]: *** No rule to make target `include/config/auto.conf'.  Stop.

扫描二维码关注公众号,回复: 1272011 查看本文章

2,ARCH是目标板(即开发板)的架构,一般都是arm

3,CROSS_COMPILE是交叉编译工具链,一直到gcc但不包含gcc,例如现在用的是arm-xilinx-linux-gnueabi-gcc

     因为是在x86平台编译arm平台的内核模块,所以要用交叉编译工具链。

  4,注意空白字符,tab、空格,格式错误会显示红色

3.2 模块编译

1,直接执行make 或者make all,可以在编译时添加config定义(Makefile里注释掉那一行),这样就不用单独改内核config文件。

 2,make clean清除编译产生的文件

3.3 安装卸载模块

insmod、rmmod、lsmod

4. 编译app

arm-xilinx-linux-gnueabi-gcc app.c -o test

-------

end

猜你喜欢

转载自www.cnblogs.com/ereszsd/p/9118217.html