Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页
    1. Home
    2. yanmingjian
    Y
    • Profile
    • Following 0
    • Followers 1
    • my integral 2191
    • Topics 25
    • Posts 39
    • Best 2
    • Groups 0

    giaoLV 5

    @yanmingjian

    2191
    integral
    3
    Reputation
    40
    Profile views
    39
    Posts
    1
    Followers
    0
    Following
    Joined Last Online
    Location 直布罗陀

    yanmingjian Unfollow Follow

    Best posts made by yanmingjian

    • 【全志T113-S3_100ask】Linux蓝牙通信实战

      (一)初始化蓝牙

      # 复位蓝牙
      echo 0 > /sys/class/rfkill/rfkill0/state
      sleep 1
      echo 1 > /sys/class/rfkill/rfkill0/state
      sleep 1
      
      # 绑定蓝牙设备
      hciattach -n ttyS1 xradio > /dev/null 2>&1 &
      sleep 8
      
      # 启用蓝牙设备
      hciconfig hci0 up
      hciconfig hci0 piscan
      

      (二)Linux下蓝牙工具(bluez 工具集)

      • hcitool、bluetoothctl等工具,可以进行BLE设备的扫描、连接、配对、广播等操作
      • hcitool 可以发送HCI command,设置BLE的广播数据
      • bluetoothctl 可以新增蓝牙服务,返回回调等操作
      • sdptool 查看蓝牙信息和提供的服务
      • hciconfig 查看蓝牙信息
      • l2ping 测试蓝牙的连通性
      • gatttool :可以在GATT层面,完成GATT profile的连接、service
      • attribute的读写等操作

      (三)蓝牙扫描

      hcitool scan 	#扫描经典蓝牙
      
      hcitool lescan	 #扫描BL低功耗蓝牙
      

      (四)使用Bluetoothctl创建蓝牙服务

      1、先启动蓝牙,进入可搜索状态

      # 复位蓝牙
      echo 0 > /sys/class/rfkill/rfkill0/state
      sleep 1
      echo 1 > /sys/class/rfkill/rfkill0/state
      sleep 1
      
      # 绑定设备
      hciattach -n ttyS1 xradio > /dev/null 2>&1 &
      sleep 8
      
      # 启用蓝牙设备
      hciconfig hci0 up
      hciconfig hci0 piscan
      
      # 免认证
      hciconfig hci0 auth
      # 广播
      hciconfig hci0 leadv
      

      2、进入 bluetoothctl 交互界面

      # bluetoothctl
      Agent registered
      [CHG] Controller 22:92:C9:8C:04:EA Pairable: yes
      [bluetooth]#
      

      3、手机使用BLE调试助手连接蓝牙,如下图所示

      d0b7a80a50f54b4b97d83d16901c7a69.jpeg

      4、连接后,bluetoothctl会发生变化,此时已经进入交互界面

      60c7807b5b42449cb17eb4e0e8d8b178.png

      4、但是我们没有其他服务,只能做一些简单的操作,比如读取,因为现有的服务是 bluetoothctl 提供的

      4d528dd7f4f743b997a69f9eeb76f4f5.jpeg

      5、下面我们添加自己的服务

      5.1 进入菜单

      [6B-3C-BF-AD-2A-A8]# menu gatt
      Menu gatt:
      Available commands:
      -------------------
      list-attributes [dev/local]                       List attributes
      select-attribute <attribute/UUID>                 Select attribute
      attribute-info [attribute/UUID]                   Select attribute
      read [offset]                                     Read attribute value
      write <data=xx xx ...> [offset] [type]            Write attribute value
      acquire-write                                     Acquire Write file descriptor
      release-write                                     Release Write file descriptor
      ....
      

      5.2 添加自己的service和characteristic

      [bluetoothctl] register-service 0xFFFF # (Choose yes when asked if primary service)
      [bluetoothctl] register-characteristic 0xAAAA read       # (Select a value of 1 when prompted)# 输入的值是初始值,每次读取,会加一
      [bluetoothctl] register-characteristic 0xBBBB read,write # (Select a value of 0 when prompted)
      [bluetoothctl] register-characteristic 0xCCCC read       # (Select a value of 2 when prompted)
      [bluetoothctl] register-application # (This commits the services/characteristics and registers the profile)
      [bluetoothctl] back
      [bluetoothctl] advertise on
      

      通过 show 操作可以看到刚才添加的0xffff 服务

      5.3 手机重新连接蓝牙
      服务从 3 项变为 4 项,第 4 项即为我们刚才添加的服务。

      be8fe95d320e42ccb5be219f087fee32.png

      5.4 读写操作
      在有上传按钮的服务上传数据

      92d75d26a94440e5aa84a19d9298ed2f.png

      此时收到:

      75c9a34123c246318a871e302ba74cd4.png

      读操作的话,直接读取就好了,值为刚才我们设置的值。
      至此测试完毕

      (五)其他操作

      1、启动/关闭/重启蓝牙

      hciconfig hci0 up  		#启动蓝牙设备
      hciconfig hci0 off 		#关闭蓝牙设备
      hciconfig hci0 reset 	#重启蓝牙设备
      

      2、测试蓝牙是否可达 l2ping

      l2ping -i hci0 -c 4 21:12:A3:C4:50:66
      

      3、查看功能与服务

      sdptool browse local    # local可以改成其它蓝牙的mac地址
      

      4、查看蓝牙的状态和信息

      hciconfig -a
      

      5、查看蓝牙设备

      hcitool dev
      Devices:
              hci0    22:22:2A:B0:9C:3C
      

      6、开启/关闭蓝牙广播

      hciconfig hci0 leadv / noleadv
      

      7、查看已经连接的BLE设备
      (此时调试助手已经连接)

      hcitool -i hci0 con
      Connections:
              > LE 60:AB:D1:B5:A6:FB handle 0 state 1 lm PERIPHERAL
      

      8、 蓝牙认证打开/关闭
      直接体现在进行蓝牙连接时,是否输入连接PIN密码,用于PIN配对

      hciconfig hci0 auth/noauth
      

      9、 查看/改变蓝牙主从状态

      hciconfig hci0 lm master、hciconfig hci0 lm slave
      

      10、查看/设置蓝牙名称

      hciconfig hci0 name 、hciconfig hci0 name BLXX
      

      11、 查看支持的链路层状态

      hciconfig hci0 lestates
      

      12、列出低功耗蓝牙的服务

      bluetoothctl --monitor gatt.list-attributes
      

      其他操作自己慢慢摸索哈,我一个人只能啃成这样了,如有写得不对的地方大佬指正。

      原文链接:https://blog.csdn.net/qq_46079439/article/details/126244998

      posted in D1系列-RISC-V
      Y
      giao
    • 2022年7月版——在“哪吒”上跑AI 全志D1 ncnn框架移植笔记

      ncnn框架是当前边缘计算的主流框架,关于全志D1运行ncnn框架的笔记,nihui大佬曾经于2021年发表了相关的帖子。但是目前工具链和ncnn版本有所变化,因此在大佬的基础上将,完整过程记录如下。

      相关链接:
      1.https://bbs.aw-ol.com/topic/705/
      2.https://zhuanlan.zhihu.com/p/386312071?utm_source=qq&utm_medium=social&utm_oi=872955404320141312

      1 准备交叉编译工具链

      目前使用的交叉工具链是v2.2.6版本,具体下载链接见:https://occ.t-head.cn/community/download?id=4046947553902661632

      下载这个文件:Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.2.6-20220516.tar.gz

      tar -xf Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.2.6-20220516.tar.gz
      export RISCV_ROOT_PATH=/home/{你的用户名}/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.2.6
      

      2 下载和编译ncnn

      这边的toolchain file选用c906-v226.toolchain.cmake,其余的不用修改,在toolchain file里面都已经改好了。其中可能有路径问题,根据ncnn文件夹,实际所在的路径修改即可。

      git clone https://github.com/Tencent/ncnn.git
      cd ncnn
      mkdir build-c906
      cd build-c906
      cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/c906-v226.toolchain.cmake -DCMAKE_BUILD_TYPE=release -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF -DNCNN_RUNTIME_CPU=OFF -DNCNN_RVV=ON -DNCNN_SIMPLEOCV=ON -DNCNN_BUILD_EXAMPLES=ON ..
      make -j4
      

      3 测试benchncnn

      目前2.0版本的TinaLinux 执行 ncnn 程序已经不会有问题

      将 ncnn/build-c906/benchmark/benchncnn 和 ncnn/benchmark/*.param 拷贝到 d1开发板上,路径结构如下:

      80abd156fc86ba2c318912d87e220577.png

      chmod 0777 benchncnn 
      ./benchncnn 4 1 0 -1 0
      
      oot@TinaLinux:~/ncnn# ./benchncnn 4 1 0 -1 0
      syscall error -1
      loop_count = 4
      num_threads = 1
      powersave = 0
      gpu_device = -1
      cooling_down = 0
      fopen squeezenet.param failed
      network graph not ready
      Segmentation fault
      root@TinaLinux:~/ncnn# ./benchncnn 4 1 0 -1 0
      syscall error -1
      loop_count = 4
      num_threads = 1
      powersave = 0
      gpu_device = -1
      cooling_down = 0
                squeezenet  min =  382.77  max =  385.92  avg =  384.66
           squeezenet_int8  min = 8975.18  max = 8979.84  avg = 8977.72
                 mobilenet  min =  702.76  max =  704.76  avg =  703.74
            mobilenet_int8  min = 29501.19  max = 29546.07  avg = 29514.59
              mobilenet_v2  min =  451.34  max =  452.27  avg =  451.78
              mobilenet_v3  min =  358.12  max =  359.24  avg =  358.42
                shufflenet  min =  527.04  max =  528.48  avg =  527.69
             shufflenet_v2  min =  310.96  max =  312.30  avg =  311.59
                   mnasnet  min =  435.13  max =  437.02  avg =  435.94
           proxylessnasnet  min =  473.05  max =  476.37  avg =  475.19
           efficientnet_b0  min =  601.75  max =  610.41  avg =  606.18
         efficientnetv2_b0  min =  859.37  max =  861.75  avg =  860.67
              regnety_400m  min =  653.71  max =  654.24  avg =  653.88
                 blazeface  min =  154.08  max =  154.67  avg =  154.38
                 googlenet  min = 1404.80  max = 1409.50  avg = 1407.33
            googlenet_int8  min = 42586.56  max = 42608.04  avg = 42597.36
                  resnet18  min = 1047.81  max = 1050.59  avg = 1049.40
             resnet18_int8  min = 45011.41  max = 45185.10  avg = 45098.12
                   alexnet  min =  955.34  max =  956.98  avg =  956.06
                     vgg16  min = 5355.40  max = 5356.05  avg = 5355.75
      

      如果一切运行正常,则会出现上述信息。

      4 测试example

      将 ncnn/build-c906/examples/nanodet 和测试图片拷贝到 d1开发板上

      从这里下载 nanodet 模型文件并拷贝到 d1开发板上

      nihui/ncnn-assets​github.com/nihui/ncnn-assets/tree/master/models

      目录结构如下:

      35b2dd1eb5e8a25b37f92325da1c0b16.png

      注意,进过测试,jpg格式的图像读取时会报错,png格式没有问题

      ./nanodet test.png
      

      bd0e8ab3ee50032c1a82e873a5aa8576.png
      177b58a5b1e4b24788974154c648b8b8.png

      posted in D1系列-RISC-V
      Y
      giao

    Latest posts made by yanmingjian

    • 【全志T113-S3_100ask】Linux蓝牙通信实战

      (一)初始化蓝牙

      # 复位蓝牙
      echo 0 > /sys/class/rfkill/rfkill0/state
      sleep 1
      echo 1 > /sys/class/rfkill/rfkill0/state
      sleep 1
      
      # 绑定蓝牙设备
      hciattach -n ttyS1 xradio > /dev/null 2>&1 &
      sleep 8
      
      # 启用蓝牙设备
      hciconfig hci0 up
      hciconfig hci0 piscan
      

      (二)Linux下蓝牙工具(bluez 工具集)

      • hcitool、bluetoothctl等工具,可以进行BLE设备的扫描、连接、配对、广播等操作
      • hcitool 可以发送HCI command,设置BLE的广播数据
      • bluetoothctl 可以新增蓝牙服务,返回回调等操作
      • sdptool 查看蓝牙信息和提供的服务
      • hciconfig 查看蓝牙信息
      • l2ping 测试蓝牙的连通性
      • gatttool :可以在GATT层面,完成GATT profile的连接、service
      • attribute的读写等操作

      (三)蓝牙扫描

      hcitool scan 	#扫描经典蓝牙
      
      hcitool lescan	 #扫描BL低功耗蓝牙
      

      (四)使用Bluetoothctl创建蓝牙服务

      1、先启动蓝牙,进入可搜索状态

      # 复位蓝牙
      echo 0 > /sys/class/rfkill/rfkill0/state
      sleep 1
      echo 1 > /sys/class/rfkill/rfkill0/state
      sleep 1
      
      # 绑定设备
      hciattach -n ttyS1 xradio > /dev/null 2>&1 &
      sleep 8
      
      # 启用蓝牙设备
      hciconfig hci0 up
      hciconfig hci0 piscan
      
      # 免认证
      hciconfig hci0 auth
      # 广播
      hciconfig hci0 leadv
      

      2、进入 bluetoothctl 交互界面

      # bluetoothctl
      Agent registered
      [CHG] Controller 22:92:C9:8C:04:EA Pairable: yes
      [bluetooth]#
      

      3、手机使用BLE调试助手连接蓝牙,如下图所示

      d0b7a80a50f54b4b97d83d16901c7a69.jpeg

      4、连接后,bluetoothctl会发生变化,此时已经进入交互界面

      60c7807b5b42449cb17eb4e0e8d8b178.png

      4、但是我们没有其他服务,只能做一些简单的操作,比如读取,因为现有的服务是 bluetoothctl 提供的

      4d528dd7f4f743b997a69f9eeb76f4f5.jpeg

      5、下面我们添加自己的服务

      5.1 进入菜单

      [6B-3C-BF-AD-2A-A8]# menu gatt
      Menu gatt:
      Available commands:
      -------------------
      list-attributes [dev/local]                       List attributes
      select-attribute <attribute/UUID>                 Select attribute
      attribute-info [attribute/UUID]                   Select attribute
      read [offset]                                     Read attribute value
      write <data=xx xx ...> [offset] [type]            Write attribute value
      acquire-write                                     Acquire Write file descriptor
      release-write                                     Release Write file descriptor
      ....
      

      5.2 添加自己的service和characteristic

      [bluetoothctl] register-service 0xFFFF # (Choose yes when asked if primary service)
      [bluetoothctl] register-characteristic 0xAAAA read       # (Select a value of 1 when prompted)# 输入的值是初始值,每次读取,会加一
      [bluetoothctl] register-characteristic 0xBBBB read,write # (Select a value of 0 when prompted)
      [bluetoothctl] register-characteristic 0xCCCC read       # (Select a value of 2 when prompted)
      [bluetoothctl] register-application # (This commits the services/characteristics and registers the profile)
      [bluetoothctl] back
      [bluetoothctl] advertise on
      

      通过 show 操作可以看到刚才添加的0xffff 服务

      5.3 手机重新连接蓝牙
      服务从 3 项变为 4 项,第 4 项即为我们刚才添加的服务。

      be8fe95d320e42ccb5be219f087fee32.png

      5.4 读写操作
      在有上传按钮的服务上传数据

      92d75d26a94440e5aa84a19d9298ed2f.png

      此时收到:

      75c9a34123c246318a871e302ba74cd4.png

      读操作的话,直接读取就好了,值为刚才我们设置的值。
      至此测试完毕

      (五)其他操作

      1、启动/关闭/重启蓝牙

      hciconfig hci0 up  		#启动蓝牙设备
      hciconfig hci0 off 		#关闭蓝牙设备
      hciconfig hci0 reset 	#重启蓝牙设备
      

      2、测试蓝牙是否可达 l2ping

      l2ping -i hci0 -c 4 21:12:A3:C4:50:66
      

      3、查看功能与服务

      sdptool browse local    # local可以改成其它蓝牙的mac地址
      

      4、查看蓝牙的状态和信息

      hciconfig -a
      

      5、查看蓝牙设备

      hcitool dev
      Devices:
              hci0    22:22:2A:B0:9C:3C
      

      6、开启/关闭蓝牙广播

      hciconfig hci0 leadv / noleadv
      

      7、查看已经连接的BLE设备
      (此时调试助手已经连接)

      hcitool -i hci0 con
      Connections:
              > LE 60:AB:D1:B5:A6:FB handle 0 state 1 lm PERIPHERAL
      

      8、 蓝牙认证打开/关闭
      直接体现在进行蓝牙连接时,是否输入连接PIN密码,用于PIN配对

      hciconfig hci0 auth/noauth
      

      9、 查看/改变蓝牙主从状态

      hciconfig hci0 lm master、hciconfig hci0 lm slave
      

      10、查看/设置蓝牙名称

      hciconfig hci0 name 、hciconfig hci0 name BLXX
      

      11、 查看支持的链路层状态

      hciconfig hci0 lestates
      

      12、列出低功耗蓝牙的服务

      bluetoothctl --monitor gatt.list-attributes
      

      其他操作自己慢慢摸索哈,我一个人只能啃成这样了,如有写得不对的地方大佬指正。

      原文链接:https://blog.csdn.net/qq_46079439/article/details/126244998

      posted in D1系列-RISC-V
      Y
      giao
    • 【全志T113-S3_100ask】使用内核驱动点灯(控制继电器)

      背景

      开发板上没有led灯,且没用其他引出的GPIO,所以就借rgb屏幕的引脚来点个灯(不过分吧@狗头),实现控制继电器。

      (一)寻找合适的GPIO

      看了好久的原理图,怕与其他功能冲突,所以就使用了 PD13 作为本次实验的引脚。

      该引脚除了作为rgb屏幕的功能外,好像没其他作用了,好,就它了。

      4f64437d6891425bbdf72cd15c831ea1.png

      (二)跳线

      焊接飞线接到继电器上。

      88d1fc81a8da470eb4dab00da065c4d0.png

      (三)修改设备树

      参考开发文档

      Documentation/devicetree/bindings/leds/leds-gpio.txt

      LEDs connected to GPIO lines
      
      Required properties:
      - compatible : should be "gpio-leds".
      
      Each LED is represented as a sub-node of the gpio-leds device.  Each
      node's name represents the name of the corresponding LED.
      
      LED sub-node properties:
      - gpios :  Should specify the LED's GPIO, see "gpios property" in
        Documentation/devicetree/bindings/gpio/gpio.txt.  Active low LEDs should be
        indicated using flags in the GPIO specifier.
      - function :  (optional)
        see Documentation/devicetree/bindings/leds/common.txt
      - color :  (optional)
        see Documentation/devicetree/bindings/leds/common.txt
      - label :  (optional)
        see Documentation/devicetree/bindings/leds/common.txt (deprecated)
      - linux,default-trigger :  (optional)
        see Documentation/devicetree/bindings/leds/common.txt
      - default-state:  (optional) The initial state of the LED.
        see Documentation/devicetree/bindings/leds/common.txt
      - retain-state-suspended: (optional) The suspend state can be retained.Such
        as charge-led gpio.
      - retain-state-shutdown: (optional) Retain the state of the LED on shutdown.
        Useful in BMC systems, for example when the BMC is rebooted while the host
        remains up.
      - panic-indicator : (optional)
        see Documentation/devicetree/bindings/leds/common.txt
      
      Examples:
      
      #include <dt-bindings/gpio/gpio.h>
      #include <dt-bindings/leds/common.h>
      
      leds {
              compatible = "gpio-leds";
              led0 {
                      gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW>;
                      linux,default-trigger = "disk-activity";
                      function = LED_FUNCTION_DISK;
              };
      
              led1 {
                      gpios = <&mcu_pio 1 GPIO_ACTIVE_HIGH>;
                      /* Keep LED on if BIOS detected hardware fault */
                      default-state = "keep";
                      function = LED_FUNCTION_FAULT;
              };
      };
      
      run-control {
              compatible = "gpio-leds";
              led0 {
                      gpios = <&mpc8572 6 GPIO_ACTIVE_HIGH>;
                      color = <LED_COLOR_ID_RED>;
                      default-state = "off";
              };
              led1 {
                      gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>;
                      color = <LED_COLOR_ID_GREEN>;
                      default-state = "on";
              };
      };
      
      leds {
              compatible = "gpio-leds";
      
              led0 {
                      gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
                      linux,default-trigger = "max8903-charger-charging";
                      retain-state-suspended;
                      function = LED_FUNCTION_CHARGE;
              };
      };
      

      简单来说就是指定 compatible = “gpio-leds” 就好了

      在根节点下添加:

      dtsleds { 
       	compatible = "gpio-leds";
       	led0 { 
      	 	label = "red";
      	  	gpios = <&pio PD 13 GPIO_ACTIVE_HIGH>; 
      	  	default-state = "off"; 
      	}; 
      };
      

      实例:

      ccc98029b00242ca904ebe910195495c.png

      (四)使能内核的LED驱动

      cbb51d2bde1b437a81d953fc17574778.png

      路径参考:

      Symbol: LEDS_GPIO [=y]                                                                                       │
       │ Type  : tristate                                                                                             │
       │ Prompt: LED Support for GPIO connected LEDs                                                                  │
       │   Location:                                                                                                  │
       │     -> Device Drivers                                                                                        │
       │       -> LED Support (NEW_LEDS [=y])                                                                         │
       │   Defined at drivers/leds/Kconfig:307                                                                        │
       │   Depends on: NEW_LEDS [=y] && LEDS_CLASS [=y] && (GPIOLIB [=y] || COMPILE_TEST [=n])                        │
       │   Selected by [n]:                                                                                           │
       │   - PCENGINES_APU2 [=n] && X86 && X86_PLATFORM_DEVICES [=n] && INPUT [=y] && INPUT_KEYBOARD [=y] && \        │
       │ GPIOLIB [=y] && LEDS_CLASS [=y]
      

      然后编译烧写系统。

      (五)测试验证

      1、寻找设备树,在 /proc/device-tree 下

      9ffd69cded23467d85204c0a6efdeb78.png

      2、点亮

      在 /sys/class/leds/red 下可以找到相关的属性

      下面使 brightness 属性为 1 .即可点亮

      echo 1 > /sys/class/leds/red/brightness
      

      继电器接通!!

      关闭的话,使用以下命令即可

      echo 0 > /sys/class/leds/red/brightness
      

      至此测试完毕

      原文链接:https://blog.csdn.net/qq_46079439/article/details/126131219
      作者@第四维度

      posted in D1系列-RISC-V
      Y
      giao
    • 【全志T113-S3_100ask】音频输入与输出

      背景

      之前查看系统命令,发现有个aplay命令,然后尝试使用 aplay -Dhw:audiocodec -vvv gz.wav 播放音频,然后报错 aplay: pcm_write:2127: write error: Input/output error

      # aplay -Dhw:audiocodec  gz.wav
      Playing WAVE 'gz.wav' : [   46.786665] [SNDCODEC][sunxi_card_hw_params][620]:stream_flag: 0
      Signed 16 bit Little Endian, Rate 16000 Hz, Mono
      aplay: pcm_write:2127: write error: Input/output error
      

      然后就不会了。

      8月2日100ask出了简单的教程,是需要先使用tinymix 设置参数的,但是。-bash: tinymix: command not found

      我又不想再去编译安装 tinymix ,发现有个 amixer 命令,查阅资料成功配置,播放了音乐。

      (一)amixer 的使用

      1、查看用法

      # amixer -h
      Usage: amixer <options> [command]
      
      Available options:
        -h,--help       this help
        -c,--card N     select the card
        -D,--device N   select the device, default 'default'
        -d,--debug      debug mode
        -n,--nocheck    do not perform range checking
        -v,--version    print version of this program
        -q,--quiet      be quiet
        -i,--inactive   show also inactive controls
        -a,--abstract L select abstraction level (none or basic)
        -s,--stdin      Read and execute commands from stdin sequentially
        -R,--raw-volume Use the raw value (default)
        -M,--mapped-volume Use the mapped volume
      
      Available commands:
        scontrols       show all mixer simple controls
        scontents       show contents of all mixer simple controls (default command)
        sset sID P      set contents for one mixer simple control
        sget sID        get contents for one mixer simple control
        controls        show all controls for given card
        contents        show contents of all controls for given card
        cset cID P      set control contents for one control
        cget cID        get control contents for one control
      
      Available advanced commands:
        sevents         show the mixer events for simple controls
        events          show the mixer events for simple controls
      

      有点复杂看不懂。。。查阅资料。

      2、常用命令

      本节参考 https://blog.csdn.net/meirixuexi/article/details/71513007

      amixer controls 用于查看音频系统提供的操作接口
      amixer contents 用于查看接口配置参数
      amixer cget + 接口函数
      amixer cset + 接口函数 + 设置值
      

      解释:比如想要设置主音量,第一次使用的话先得查询一下接口函数的配置参数,但是又不知道接口叫什么,先查询所有接口

      # amixer controls
      numid=17,iface=MIXER,name='Headphone volume'
      numid=30,iface=MIXER,name='Headphone Switch'
      numid=12,iface=MIXER,name='FMINL gain volume'
      numid=13,iface=MIXER,name='FMINR gain volume'
      numid=2,iface=MIXER,name='ADC1 ADC2 swap'
      numid=24,iface=MIXER,name='ADC1 Input FMINL Switch'
      numid=25,iface=MIXER,name='ADC1 Input LINEINL Switch'
      numid=23,iface=MIXER,name='ADC1 Input MIC1 Boost Switch'
      numid=6,iface=MIXER,name='ADC1 volume'
      ...省略...
      

      找到了Headphone volume,意思是耳机音量,因为我们是使用3.5mm接口的,所以这一项和我们想要的很像。

      使用 amixer cget + 接口函数查询现在的参数,如:

      # amixer cget numid=17,iface=MIXER,name='Headphone volume'
      
      numid=17,iface=MIXER,name='Headphone volume'
        ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
        : values=4
        | dBscale-min=-42.00dB,step=6.00dB,mute=0
      

      value = 4,最大值为7

      修改音量值为6:

      # amixer cset numid=17,iface=MIXER,name='Headphone volume' 6
      
      numid=17,iface=MIXER,name='Headphone volume'
        ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
        : values=6
        | dBscale-min=-42.00dB,step=6.00dB,mute=0
      

      (二)amixer 设置音频输出参数

      经过查询,之所以出现 aplay: pcm_write:2127: write error: Input/output error 错误是因为没有输出设备。

      # amixer cget numid=30,iface=MIXER,name='Headphone Switch'
      
      numid=30,iface=MIXER,name='Headphone Switch'
        ; type=BOOLEAN,access=rw------,values=1
        : values=off
      

      耳机开关的输出是 off !!!

      将其开启:

      # amixer cset numid=30,iface=MIXER,name='Headphone Switch' on
      
      numid=30,iface=MIXER,name='Headphone Switch'
        ; type=BOOLEAN,access=rw------,values=1
        : values=on
      

      使用 aplay 可以从耳机输出音乐了!!

      (三)使用 aplay 播放音乐

      1、配置音频输出渠道:

      # amixer cset numid=30,iface=MIXER,name='Headphone Switch' on
      
      numid=30,iface=MIXER,name='Headphone Switch'
        ; type=BOOLEAN,access=rw------,values=1
        : values=on
      

      2、设置音量1:

      # amixer cset numid=17,iface=MIXER,name='Headphone volume' 6
      
      numid=17,iface=MIXER,name='Headphone volume'
        ; type=INTEGER,access=rw---R--,values=1,min=0,max=7,step=0
        : values=6
        | dBscale-min=-42.00dB,step=6.00dB,mute=0
      

      设置音量2:

      # amixer cset numid=5,iface=MIXER,name="PCM Volume" 170
      
      numid=5,iface=MIXER,name='DAC volume'
        ; type=INTEGER,access=rw---R--,values=2,min=0,max=255,step=0
        : values=170,170
        | dBscale-min=-119.25dB,step=0.75dB,mute=0
      

      3、播放音乐:

      # aplay -Dhw:audiocodec -vvv piao.wav
      
      Playing WAVE 'piao.wav' : [  228.205229] [SNDCODEC][sunxi_card_hw_params][620]:stream_flag: 0
      Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
      Hardware PCM card 0 'audiocodec' device 0 subdevice 0
      Its setup is:
        stream       : PLAYBACK
        access       : RW_INTERLEAVED
        format       : S16_LE
        subformat    : STD
      ...省略...
      

      实测:

      3bd5a2f03b5b4b3cb835dd8a7af85391.png

      (四)使用 arecord 录音

      配置音频输入渠道:

      amixer cset numid=29,iface=MIXER,name='ADC3 Input MIC3 Boost Switch' on
      amixer cset numid=31,iface=MIXER,name='HpSpeaker Switch' on
      

      录音

      arecord -Dhw:audiocodec -f S24_LE -r 16000 -c 1 -d 10 -vv ./in.wav
      

      解释:使用 设备audiocodec
      录制 格式为S24_LE
      输入比特率为16000
      通道1
      时间为10s
      保存在 ./in.wav
      更多内容\查看帮助 arecord -h

      实测:

      8b880533322f40d7a396b588da537fd6.png

      原文链接:https://blog.csdn.net/qq_46079439/article/details/126127325

      posted in D1系列-RISC-V
      Y
      giao
    • Reply: uboot正确启动了,RGB屏点不亮

      @zznzzn

      运气不错~竟然没烧哈哈

      Licheepi这个支持电阻屏,想要测试触摸功能要重新买块电阻屏哦

      也是通用的

      QQ图片20220922163413.jpg

      posted in 其它全志芯片讨论区
      Y
      giao
    • Reply: uboot正确启动了,RGB屏点不亮

      屏是标准的rgb接口屏,可是正点原子转接过啦

      应该是用这个,插Licheepi,这个是通用的RGB 40pin接口

      QQ图片20220922160245.jpg

      不确定接口顺序就直接插上去,不怕冒烟嘛?

      posted in 其它全志芯片讨论区
      Y
      giao
    • 【全志T113-S3_100ask】USB串口获取GPS数据

      背景

      板子上有两个串口,但是串口1被xr829模块占用了,串口3主要用于调试,为简单实现串口功能,本讲将实现usb转串口(ch340)来采集gps的数据,并解析。

      (一)USB串口驱动

      @本讲不使用Tina系统,使用 百问Buildroot 。

      Tips:CH340是CH341的阉割版,CH340不支持并口、打印口、IIC,专为串口应用设计

      在buildroot已经集成了ch341的驱动,我们将其 使能 即可使用,非常简单。

      Symbol: USB_SERIAL_CH341 [=y]                                                                                
         Type  : tristate                                                                                             
         Prompt: USB Winchiphead CH341 Single Port Serial Driver                                                      
           Location:                                                                                                  
             -> Device Drivers                                                                                        
               -> USB support (USB_SUPPORT [=y])                                                                      
         (1)     -> USB Serial Converter support (USB_SERIAL [=y])                                                    
           Defined at drivers/usb/serial/Kconfig:105                                                                  
           Depends on: USB_SUPPORT [=y] && USB [=y] && USB_SERIAL [=y]
      

      (二)驱动加载

      驱动是编译进内核的,不用手动加载,把USB转TTL插到USB口就自动匹配识别,生成ttyUSB0设备。
      以下是开机显示信息:

      [   11.529946] usbcore: registered new interface driver ch341
      [   11.537840] usbserial: USB Serial support registered for ch341-uart
      [   11.545934] ch341 1-1.2:1.0: ch341-uart converter detected
      [   11.578483] usb 1-1.2: ch341-uart converter now attached to ttyUSB0
      
      ls /dev
      

      e70eb4435354446080861b476af87b14.png

      (三)简单读取串口数据

      此时已经将ch340和gps模块连接上开发板了
      5de7d28df1c44082a5227e0c256a338e.jpeg

      使用 cat 命令即可简单读取串口返回的信息。

      # cat /dev/ttyUSB0
      
      A*7B
      
      $GPVTG,,T,,M,1.070,N,1.982,K,A*27
      
      $GPGGA,072008.00,2306.6$GPTXT,01,01,01,NMEA unknown msg*58
      
      $GPRMC,072232.00,A,2306.62360,N,11316.59966,E,0.311,,020822,,,A*78
      
      $GPVTG,,T,,M,0.311,N,0.577,K,A*25
      
      $GPGGA,072232.00,2306.62360,N,11316.59966,E,1,08,1.62,21.7,M,-5.6,M,,*7A
      
      $GPGSA,A,3,13,02,05,11,20,18,24,23,,,,,3.06,1.62,2.59*05
      
      $GPGSV,3,1,11,02,49,126,20,05,43,034,37,11,28,123,12,13,58,033,35*72
      
      $GPGSV,3,2,11,15,73,291,21,18,27,324,37,20,24,071,29,23,10,286,32*78
      
      $GPGSV,3,3,11,24,26,175,20,29,48,259,10,30,06,046,*45
      
      $GPGLL,2306.62360,N,11316.59966,E,072232.00,A,A*68
      

      (四)数据解析

      本解析参考: https://blog.csdn.net/qq_30665009/article/details/121434507

      我们在编写正式的应用程序之前,先了解这一堆数据里面我们想要的部分 --> $GPRMC

      $GPRMC格式:

      $GPRMC,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11>,<12>*hh<CR><LF>
      
      $GPRMC,072232.00,A,2306.62360,N,11316.59966,E,0.311,,020822,,,A*78
      

      其中:

      99299559-7F78-4cb0-9987-DC72A0B68F3F.png

      (五)编写应用程序

      参考 https://www.likecs.com/show-205110023.html

      1、定义结构体

      typedef struct __gprmc__
      {
          UINT time;         /* gps定位时间 */
          char pos_state;    /*gps状态位*/
          float latitude;    /*纬度 */
          float longitude;   /* 经度 */
          float speed;       /* 速度 */
          float direction;   /*航向 */
          UINT date;         /*日期  */
          float declination; /* 磁偏角 */
          char dd;
          char mode; /* GPS模式位 */
      } GPRMC;
      

      2、使用 open 和 read 函数读取串口数据

      3、获取想要的部分

      /* 如果buff字符串中包含字符"$GPRMC"则将$GPRMC的地址赋值给ptr */
      if (NULL == (ptr = strstr(buff, "$GPRMC")))
      {
          return -1;
      }
      

      4、使用 sscanf 进行格式化处理,存进结构体

      5、计算、回显处理

      (六)测试

      编译后放到开发板,测试程序

      # ls
      gps_test
      
      # ./gps_test
      buff:1,13,36,033,33*7F
      $GPGSV,3,2,10,15,62,356,30,18,48,324,20,20,14,092,19,23,21,306,23*7A
      $GPGSV,3,3,10,24,48,164,20,29,35,229,25*70
      $GPGLL,2306.62377,N,11316.59930,E,081227.00,A,A*65
      $GPRMC,081228.00,A,2306.62398,N,11316.59935,E,0.294,,020822,,,A*72
      $GPVTG,,T,,M,0.294,N,0.545,K,A*28
      $GPGGA,081228.00,2306.62398,N,11316.59935,E,1,08,1.04,-0.4,M,-5.6,M,,*61
      $GPGSA,A,3,15,18,24,13,05,02,23,20,,,,,2.10,1.04,1.82*02
      $GPGSV,3,1,10,02,29,144,21,05,36,062,35,11,10,138,,13,36,033,32*7E
      $GPGSV,3,2,10,15,62,356,30,18,48,324,17,20,14,092,20,23,21,306,22*75
      $GPGSV,3,3,10,24,48,164,20,29,35,229,26*73
      $GPGLL,2306.62398,N,11316.59935,E,081228.00,A,A*6E
      $GPRMC,081229.00,A,2306.62396,N,11316.59928,E,0.427,,020822,,,A*7F
      $GPVTG,,T,,M,0.427,N,0.791,K,A*2D
      $GPGGA,081229.00,2306.62396,N,11316.59928,E,1,09,1.04,-0.8,M,-5.6,M,,*6F
      $GPGSA,A,3,15,18,24,13,05,02,23,20,11,,,,2.10,1.04,1.82*02
      $GPGSV,3,1,10,02,29,144,21,05,36,062,35,11,10,138,1,1144,15,05,36,062,36,11,10,138,12)▒▒
      ===========================================================
      ==
      ==   GPS state bit : A  [A:有效状态 V:无效状态]
      ==   GPS mode  bit : A  [A:自主定位 D:差分定位]
      ==   Date : 2022-08-02
      ==   Time : 16:12:28
      ==   纬度 : 北纬:23度6分37秒
      ==   经度 : 东经:113度16分35秒
      ==   速度 : 0.294  m/s
      ==
      ============================================================
      

      但是要留意,某些gps模块获取不到该字段的数据,需要将其对应修改匹配。

      至此,测试完毕。

      源码地址:
      https://download.csdn.net/download/qq_46079439/86272180
      原文链接:https://blog.csdn.net/qq_46079439/article/details/126122756

      posted in D1系列-RISC-V
      Y
      giao
    • Reply: 全志V853编译出现问题

      缺少一个命令,需要安装uboot-tools包

      posted in V853系列-AI视觉
      Y
      giao
    • 【全志T113-S3_100ask】编译Tina系统初体验

      背景

      7月28日,百问网官方发布适配Tina系统的SDK。因为使用Tina系统开发还是比较方便的,有全志的SDK支持,可以参考的内容比较多。
      https://forums.100ask.net/t/topic/399

      (一)SDK准备

      通过上面的百度网盘下载SDK,拷贝到linux下。
      解压缩命令:

      cat Tina-t113-pro.tar.bz2.* | tar jx
      

      (二)环境准备

      全志Tina官方推荐下载:

      sudo apt-get update
      
      sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip lib32z1 lib32z1-dev lib32stdc++6 libstdc++6 -y
      

      对于Ubuntu 16.04以上版本,部分软件包已不再提供或者采用了其他的包,执行上述命令时, 安装失败的包可先忽略,进一步执行以下命令:

      sudo apt-get install libc6:i386 libstdc++6:i386 lib32ncurses5 lib32z1
      

      (三)编译系统

      1、初次编译系统

      root@znh-ubuntu:~# cd Tina-t113-pro
      root@znh-ubuntu:~/Tina-t113-pro# ls
      build   Config.in  dl      linux     package   rules.mk  target  toolchain
      config  device     lichee  Makefile  prebuilt  scripts   tmp     tools
      

      步骤:

      source build/envsetup.sh
      lunch
      make
      pack
      
      • source build/envsetup.sh :获取环境变量(一个shell生效一次)
      • lunch 会提供方案选项以供选。
      • make -j8 :编译,其中-j后面的数字参数为编译用的线程数,可根据开发者编译用的PC实际情况选择。
      • pack : 打包,将编译好的固件打包成一个.img格式的固件,固件路径 /out

      实例:

      root@znh-ubuntu:~/Tina-t113-pro# source build/envsetup.sh
      Setup env done! Please run lunch next.
      
      root@znh-ubuntu:~/Tina-t113-pro# lunch
      
      You're building on Linux
      
      Lunch menu... pick a combo:
           1. t113_pro-tina
      
      Which would you like? [Default t113_mq]: 1
      ============================================
      TINA_BUILD_TOP=/disk/Tina_T113_100ask/Tina-t113-pro
      TINA_TARGET_ARCH=arm
      TARGET_PRODUCT=t113_pro
      TARGET_PLATFORM=t113
      TARGET_BOARD=t113-pro
      TARGET_PLAN=pro
      TARGET_BUILD_VARIANT=tina
      TARGET_BUILD_TYPE=release
      TARGET_KERNEL_VERSION=5.4
      TARGET_UBOOT=u-boot-2018
      TARGET_CHIP=sun8iw20p1
      ============================================
      no buildserver to clean
      [1] 4054
      root@znh-ubuntu:~/Tina-t113-pro#
      [1]+  已完成               $T/tools/build/buildserver --path $T 2> /dev/null 1>&2
      root@znh-ubuntu:~/Tina-t113-pro#
      root@znh-ubuntu:~/Tina-t113-pro# ls
      build   Config.in  dl      linux     package   rules.mk  target     tools
      config  device     lichee  Makefile  prebuilt  scripts   toolchain
      root@znh-ubuntu:~/Tina-t113-pro# make -j8
      ...
      make[1]: Leaving directory '/disk/Tina_T113_100ask/Tina-t113-pro'
      [2]+  已完成               $T/tools/build/buildserver --path $T 2> /dev/null 1>&2
      
      #### make completed successfully (02:49:28 (hh:mm:ss)) ####
      
      root@znh-ubuntu:~/Tina-t113-pro#
      

      当然我的编译过程没有那么顺利

      错误1:

      you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment
      

      解决(大概意思就是root用户需要设置这个):

      export FORCE_UNSAFE_CONFIGURE=1
      

      错误2:缺失 gmp.h

      enwrt-linux-muslgnueabi/6.4.1/plugin/include/system.h:681:10: fatal error: gmp.h: No such file or directory
      

      解决:

      sudo apt-get install libgmp-dev
      

      错误3:缺失 mpc.h

      enwrt-linux-muslgnueabi/6.4.1/plugin/include/builtins.h:23:10: fatal error: mpc.h: No such file or directory
      

      解决:

      sudo apt-get install libmpc-dev
      

      错误4 致命:不安全的存储库由其他人拥有

      `atal: detected dubious ownership in repository at '/disk/Tina_T113_100ask/Tina-t113-pro'
      To add an exception for this directory, call:
      
              git config --global --add safe.directory /disk/Tina_T113_100ask/Tina-t113-pro
      Makefile:646: recipe for target '/disk/Tina_T113_100ask/Tina-t113-pro/out/t113-pro/packages/base/libgcc_-1_sunxi.ipk' failed
      make[3]: *** [/disk/Tina_T113_100ask/Tina-t113-pro/out/t113-pro/packages/base/libgcc_-1_sunxi.ipk] Error 128
      make[3]: Leaving directory '/disk/Tina_T113_100ask/Tina-t113-pro/package/libs/toolchain'
      package/Makefile:192: recipe for target 'package/libs/toolchain/compile' failed
      make[2]: *** [package/libs/toolchain/compile] Error 2
      make[2]: Leaving directory '/disk/Tina_T113_100ask/Tina-t113-pro'
      package/Makefile:189: recipe for target '/disk/Tina_T113_100ask/Tina-t113-pro/out/t113-pro/staging_dir/target/stamp/.package_compile' failed
      make[1]: *** [/disk/Tina_T113_100ask/Tina-t113-pro/out/t113-pro/staging_dir/target/stamp/.package_compile] Error 2
      make[1]: Leaving directory '/disk/Tina_T113_100ask/Tina-t113-pro'
      /disk/Tina_T113_100ask/Tina-t113-pro/build/toplevel.mk:304: recipe for target 'world' failed
      make: *** [world] Error 2
      
      #### make failed to build some targets (01:18 (mm:ss)) ####
      
      root@znh-ubuntu:~/Tina-t113-pro#
      

      解决(该目录每个人都不一样):

      git config --global --add safe.directory /disk/Tina_T113_100ask/Tina-t113-pro
      

      2、进阶编译操作

      如果不需要完整编译整个系统,也可以对部分模块进行编译,如单独编译boot0、单独编译uboot、单独编译内核和单独编译某个包等,Tina环境都提供了相应的快捷命令:

      mboot
      - 单独编译boot0和uboot,可在Tina任意目录下使用.
      
      mboot0
      - 单独编译boot0,可在Tina任意目录下使用
      - 
      muboot
      - 单独编译uboot,可在Tina任意目录下使用
      
      mkernel
      - 单独编译内核,可在Tina任意目录下使用
      
      mm
      - 单独编译某个包,只能在编译的包路径下操作,如包路径为 tina/package/utils/rwcheck,则需要进入到 tina/package/utils/rwcheck路径下再输入 mm 命令,编译出来对应的安装包的路径在 tina/out/d1-nezha/packages/base下
      
      
      - 在根目录下编译某个软件包:make <应用包的路径>/install,需要在根目录下操作
      如 make package/utils/rwcheck/install
      - 在根目录下清空应用包临时文件:make <应用包的路径>/clean,需要在根目录下操作
      如 make package/utils/rwcheck/clean0.img。
      

      (四)烧录系统

      编译出来的镜像可以通过sd卡启动。通过全志工具PhoenixCard烧写。

      d800bd1605ed4cb4b672c2c6018e8f5c.png

      启动系统

      14b9b32df3bd43e88523026431bc28f0.png

      原文链接:https://blog.csdn.net/qq_46079439/article/details/126053220

      posted in D1系列-RISC-V
      Y
      giao
    • Reply: D1 DOCK PRO buildroot编译的内核烧录之后上电

      udhcpc一直在尝试获取ip,可以关了udhcpc或者启用wlan/net

      posted in D1系列-RISC-V
      Y
      giao
    • Reply: V853 NPU的demo试玩

      @haaland 正有此意,最近在做模型转换,突然发现CPU不支持AVX指令集…

      posted in V853系列-AI视觉
      Y
      giao