Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页
    1. Home
    2. The_Qiang
    T
    • Profile
    • Following 0
    • Followers 0
    • my integral 353
    • Topics 2
    • Posts 7
    • Best 0
    • Groups 0

    The_QiangLV 3

    @The_Qiang

    353
    integral
    0
    Reputation
    3
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    The_Qiang Unfollow Follow

    Latest posts made by The_Qiang

    • Reply: 【萌新入门】如何编写一个应用程序,调用Tina Linux提供的GPIO驱动,实现某个GPIO脚的电平周期反转

      @yuzukitsuru 在 【萌新入门】如何编写一个应用程序,调用Tina Linux提供的GPIO驱动,实现某个GPIO脚的电平周期反转 中说:

      @the_qiang D1是RISCV,与ARM的不太一样,没有先删了看看能不能编译过,能就没问题
      编号计算:

      全志引脚计算器 AllwinnerPin 小工具发布
      https://bbs.aw-ol.com/topic/1166/share/1

      感谢大佬,是我向太复杂了,真就是你另一个标题里的PC1 = ('C'-'A')*32+1

      posted in D1-H/D1s
      T
      The_Qiang
    • Reply: 【萌新入门】如何编写一个应用程序,调用Tina Linux提供的GPIO驱动,实现某个GPIO脚的电平周期反转

      @yuzukitsuru 在 【萌新入门】如何编写一个应用程序,调用Tina Linux提供的GPIO驱动,实现某个GPIO脚的电平周期反转 中说:

      @lgkgkfg 是,在内核控制更方便些,不过一些高速操作都使用高速外设了

      我也请教一下😨
      40f7f169-9da9-4ae2-adef-c685e76aba0a-image.png
      tina SDK关于GPIO的参考文档里给出的介绍
      799d4d25-1d02-4bef-b842-5fee768a3be7-image.png
      如图,上面的这个gpio编号如何计算。例如PC1口。
      另外我编译ko文件时没有这个<mach/gpio.h>(抄的V853的led驱动头文件引用)

      posted in D1-H/D1s
      T
      The_Qiang
    • 我有很多很多问号【DH-H Tina】

      (我很菜,别骂😞 )
      大佬们指点下(如果可以的话,发俩demo参考学习下也好,尤其是带IO操作以及IIC设备的🌝 ):

      1.在SDK目录下 make kernel_menuconfig 里的选项如何保存并应用,直接选择save一路回车?
      (百度上搜了一堆,什么cp xxxx,还有make save 都没反应)
      
      2.想要编写驱动程序生成.KO文件,Makefile 文件如何编写(SDK目录下执行过mkernel,看了些论坛上和百度上的Makefile,尝试了未果)。
      
      3.写的网上学来的基本驱动框架没有在 /dev/下生成节点(放在/opt/d1/tina_d1_open_v2/lichee/linux-5.4/drivers/char/下 并修改
      Kconfig 追加hello_drv default y  然后SDK 下make时,就会在该目录下生成相应的ko文件,insmod后也没见节点,
      make kernel_menuconfig勾选后 再make,烧录img 也没有节点  )(相关代码在页面最底下)
      
      4.比如/opt/d1/tina_d1_open_v2/lichee/linux-5.4/drivers/ 里的i2c-dev-basexxx一类的c文件,里面的函数(如i2c_transfer();),
      编写APP时如何调用?还是说只能写的驱动才能调用?
      
      5.关于linux设备数上添加节点,SDK文档介绍说最好是在board.dts中添加,配置pin是这样嘛(也是到处参照写的)?
         &pio {
            ........
               dth_11_pin:dht_11_pin{
               pins = "PC1";
               function = "gpio_out";
               allwinner,pull = <1>;
                bias-pull-up;
                  };
          ........
      }
      不需要再 上面dht_11_pin 后面家@0x.....(地址)嘛?上下的差异很不解
      sun20iw1p1.dtsi中
      pio: pinctrl@2000000 {
      .....
              ledc: ledc@2008000 {
      			#address-cells = <1>;
      			#size-cells = <0>;
      			compatible = "allwinner,sunxi-leds";
      			reg = <0x0 0x02008000 0x0 0x400>;
      			interrupts-extended = <&plic0 36 IRQ_TYPE_LEVEL_HIGH>;
      			interrupt-names = "ledcirq";
      			clocks = <&ccu CLK_LEDC>, <&ccu CLK_BUS_LEDC>;
      			clock-names = "clk_ledc", "clk_cpuapb";
      			dmas = <&dma 42>, <&dma 42>;
      			dma-names = "rx", "tx";
      			resets = <&ccu RST_BUS_LEDC>;
      			reset-names = "ledc_reset";
      			status = "disable";
      		};
      ......
      }
      
      6.哪吒板子上的iio接口在哪(看到iio下有DHT11驱动想直接用)
      
      下面是参照官方的APP的Makefile
      CTOOL := riscv64-unknown-linux-gnu-
      CCL := /opt/d1/tina_d1_open_v2/prebuilt/gcc/linux-x86/riscv/toolchain-thead-glibc/riscv64-glibc-gcc-thead_20200702
      CC := ${CCL}/bin/${CTOOL}gcc
      
      myproject : *.c
      	${CC} -o myproject $^
      clean :
      	rm myproject
      
      

      相关路径给大佬参上:

      whycan@ubuntu:/opt/d1/tina_d1_open_v2$ pwd
      /opt/d1/tina_d1_open_v2
      whycan@ubuntu:/opt/d1/tina_d1_open_v2$ find -name "linux-5*"
      ./out/d1-h-nezha/compile_dir/target/linux-d1-h-nezha/linux-5.4.61
      ./.repo/project-objects/lichee/linux-5.4.git
      ./.repo/projects/lichee/linux-5.4.git
      ./lichee/linux-5.4
      ./device/config/chips/d1-h/configs/nezha_min/linux-5.4
      ./device/config/chips/d1-h/configs/nezha/linux-5.4
      ./device/config/chips/d1s/configs/nezha/linux-5.4
      whycan@ubuntu:/opt/d1/tina_d1_open_v2$ 
      

      漫长无聊的代码以及错误信息参上:

      whycan@ubuntu:/mnt/hgfs/vmout/project/hellodev$ ls
      
      hello_drv.c  Makefile
      
      whycan@ubuntu:/mnt/hgfs/vmout/project/hellodev$ cat Makefile 
      
      KDIR =/opt/d1/tina_d1_open_v2/out/d1-h-nezha/compile_dir/target/linux-d1-h-nezha/linux-5.4.61
      CTOOL := riscv64-unknown-linux-gnu-
      CCL := /opt/d1/tina_d1_open_v2/prebuilt/gcc/linux-x86/riscv/toolchain-thead-glibc/riscv64-glibc-gcc-thead_20200702
      CC := ${CCL}/bin/${CTOOL}gcc
      CURRENT_PATH:=$(shell pwd)
      LINUX_KERNEL:=$(shell uname -r)
      KVERSION:=5.4
      PWD:=$(shell pwd)
      
      all:
      	make -C $(KDIR) M=$(PWD) modules    CROSS_COMPILE=riscv64-unknown-linux-gnu-  ARCH=riscv
      #myproject : *.c
      #	${CC} -o myproject $^
      clean :
      	rm myproject
      
      obj-m += hello_drv.o
      whycan@ubuntu:/mnt/hgfs/vmout/project/hellodev$ make 
      make -C /opt/d1/tina_d1_open_v2/out/d1-h-nezha/compile_dir/target/linux-d1-h-nezha/linux-5.4.61 M=/mnt/hgfs/vmout/project/hellodev modules    CROSS_COMPILE=riscv64-unknown-linux-gnu-  ARCH=riscv
      make[1]: Entering directory '/opt/d1/tina_d1_open_v2/lichee/linux-5.4'
      make[1]: riscv64-unknown-linux-gnu-gcc: Command not found
        CC [M]  /mnt/hgfs/vmout/project/hellodev/hello_drv.o
      In file included from ./include/linux/list.h:9,
                       from ./include/linux/module.h:9,
                       from /mnt/hgfs/vmout/project/hellodev/hello_drv.c:1:
      ./include/linux/kernel.h:6:10: fatal error: stdarg.h: No such file or directory
       #include <stdarg.h>
                ^~~~~~~~~~
      compilation terminated.
      scripts/Makefile.build:286: recipe for target '/mnt/hgfs/vmout/project/hellodev/hello_drv.o' failed
      make[2]: *** [/mnt/hgfs/vmout/project/hellodev/hello_drv.o] Error 1
      Makefile:1810: recipe for target '/mnt/hgfs/vmout/project/hellodev' failed
      make[1]: *** [/mnt/hgfs/vmout/project/hellodev] Error 2
      make[1]: Leaving directory '/opt/d1/tina_d1_open_v2/lichee/linux-5.4'
      Makefile:15: recipe for target 'all' failed
      make: *** [all] Error 2
      
      whycan@ubuntu:/mnt/hgfs/vmout/project/hellodev$ cat hello_drv.c 
      
      //==============================================
      #include <linux/module.h>
      #include <linux/fs.h>
      #include <linux/errno.h>
      #include <linux/miscdevice.h>
      #include <linux/kernel.h>
      #include <linux/major.h>
      #include <linux/mutex.h>
      #include <linux/proc_fs.h>
      #include <linux/seq_file.h>
      #include <linux/stat.h>
      #include <linux/init.h>
      #include <linux/device.h>
      #include <linux/tty.h>
      #include <linux/kmod.h>
      #include <linux/gfp.h>
      
      static int major =0;
      static int err;
      static char kernel_buf [1024];
      static struct  class * hello_class;
      #define MIN(a,b)(a < b ? a : b)
      static ssize_t hello_drv_read(struct file *file, char __user *user, size_t bytesize, loff_t *this_loff_t){
      	int err0;
      	printk("%s %s line %d \n ",__FILE__,__FUNCTION__,__LINE__);
      	err0 = copy_to_user(user,kernel_buf,MIN(1024,bytesize));
      	return err0;
      }
      
      static ssize_t  hello_drv_write(struct file *file, const  char __user *user, size_t bytesize, loff_t *this_loff_t){
      	int err0;
      	printk("%s %s line %d \n ",__FILE__,__FUNCTION__,__LINE__);
      	err0 = copy_from_user(kernel_buf,user,MIN(1024,bytesize));
      	return err0;
      }
      
      static int hello_drv_open(struct inode *inode, struct file *file){
      	int err0; 
      	err0 = printk("%s %s line %d \n ",__FILE__,__FUNCTION__,__LINE__);
      	return err0;
      }
      
      static int hello_drv_close(struct inode *inode, struct file *file){
      	int err0;
      	err0 = printk("%s %s line %d \n ",__FILE__,__FUNCTION__,__LINE__);
      	return err0;
      }
      
      static struct file_operations hello_drv ={
      	.owner  	= THIS_MODULE,
      	.open 		= hello_drv_open,
      	.read 		= hello_drv_read,
      	.write 		= hello_drv_write,
      	.release	        = hello_drv_close 
      };
      
      static int __init hello_init(void){
      	printk("%s %s line %d \n ",__FILE__,__FUNCTION__,__LINE__);
      	register_chrdev(0,"hello",&hello_drv);
      	
      	hello_class = class_create(THIS_MODULE ,"hello_class");
      	err = PTR_ERR(hello_class);
      	if(IS_ERR (hello_class)){
      		unregister_chrdev(major,"hello");
      		return -1;
      	}
      	
      	device_create(hello_class,NULL ,MKDEV(major ,0),NULL,"hello");
      	
      	return 0;
      }
      static void __exit hello_exit(void){
      	printk("%s %s line %d \n ",__FILE__,__FUNCTION__,__LINE__);
      	unregister_chrdev(major,"hello");
      	device_destroy(hello_class,MKDEV(major,0));
      	class_destroy(hello_class);
      }
      
      module_init(hello_init);
      module_exit(hello_exit);
      
      MODULE_LICENSE("GPL");
      MODULE_AUTHOR("XD");
      //==============================================
      
      posted in D1-H/D1s
      T
      The_Qiang
    • Reply: 【Tina_哪吒】在虚拟机上按流程make后部分构建失败

      @yuzukitsuru 在 【Tina_哪吒】在虚拟机上按流程make后部分构建失败 中说:

      @the_qiang 是的,sudo rm -rf out/ tmp/ 然后 make clean && make distclean

      感谢大佬~
      下回知道避免root了
      不过我make clean && make distclean 的时候报错了
      f56c34be-5dd4-4dd3-a6e2-88fb81f6c479-image.png
      当初忘了复制一遍虚拟机了,现在在下载新的了。😊

      posted in D1-H/D1s
      T
      The_Qiang
    • Reply: 【Tina_哪吒】在虚拟机上按流程make后部分构建失败

      @yuzukitsuru 佬,我在同目录下执行了下,还是必须root才能正常make,还是有一些构建失败,是因为我之前用root整过一遍,文件权限变了嘛。
      db64bcd5-83bf-4475-bb48-8504d2240908-image.png

      posted in D1-H/D1s
      T
      The_Qiang
    • 【Tina_哪吒】在虚拟机上按流程make后部分构建失败

      大佬们帮我这小白看看问题在哪。

      在这个虚拟机上倒是成功过,都按流程source buid..... lunch ....然后再make的
      (后用make kernel_menuconfig修改过.config和cp .config /arch/riscv/config/xxxxdeconfig 后又改回原文件)。
      错误信息如图
      (root:make):
      错误信息2.png
      错误信息.png
      (直接make):
      610b711e-2117-4cc1-89fa-d515c6e3d3c3-image.png
      (sudo make):
      173d1e2f-d907-42e3-8340-4f0f2188553d-image.png

      posted in D1-H/D1s
      T
      The_Qiang