Tina R16开发说明

TinaV2.1 Development Introduction

TinaV2.1 开发说明

1.Use and installation of Adb tool

Adb工具的使用和安装

1.1 adb introduce

adb工具介绍

​ adb stands for Android Debug Bridge, which acts as a debugging bridge between PC and mobile phone, tablet, and development board. With the help of adb tool, we can manage the device and perform many operations, such as running shell commands and sending files to the development board.

adb全称Android Debug Bridge,对于PC和手机.平板.开发板之间,起到调试桥的作用。借助adb工具, 我们可以对设备进行管理,还可以进行很多操作,比如运行shell命令,向开发板发送文件等。

1.2 adb installation and configuration

adb工具的安装和配置

  • adb installation

    adb 安装

    sudo apt-get install android-tool-adb
    
  • adb configuration

    adb 的配置

    1. Connect the development board and the computer correctly, start minicom or putty, and see the system in the development board start normally and enter the shell in the minicom terminal. If you have not programmed the Tina system to the development board, please first program the system

    将开发板和电脑正确链接,启动minicom或putty,要在minicom终端里看见开发板里系统正常启动并进入shell,如果没有烧写Tina系统到开发板,请先烧写系统

    ​ 2.Open the terminal on the computer, run the command lsusb, check the device, and find the serial port connected between the computer and the development board, as follows:

    打开电脑上的终端,运行命令lsusb,查看设备,找到电脑和开发板相连接的串口,如下:

    lsusb

    ​ 3.Use the command sudo vim /etc/udev/rules.d/50-android.rules to open the 50-android.rules file on the computer (create one if not) for configuration, so that the computer can recognize this serial port. The specific configuration is as follows (that is, write in this file):

    使用命令 sudo vim /etc/udev/rules.d/50-android.rules 打开电脑上的50-android.rules文件(如果没有就创建一个)进行配置,这样电脑就能识别到此串口。具体配置如下(即在此文件里写入):

    50-android

    ​ The SUBSYSTEM option remains unchanged, the ATTR{idVendor} option fills in the device ID (the device ID is shown in the figure above, fill in according to your own device), the ATTR{idProduct} fills in the device product ID (the device product ID is in the figure above), and the MODE option remains unchanged. Save and exit. Then run the following command:

    SUBSYSTEM选项不变,ATTR{idVendor}选项中填写设备ID(设备ID见上图,根据自己设备填写),ATTR{idProduct}填写设备产品ID(设备产品ID见上图),MODE选项不变。保存退出。然后运行以下命令:

    sudo chmod a+rx /etc/udev/rules.d/50-android.rules
    sudo /etc/init.d/udev restart
    

    ​ 4.$sudo vim ~/.android/adb_usb.ini, open the adb_usb.ini file, and write 0x067b (device ID) to it

    $sudo vim ~/.android/adb_usb.ini,打开adb_usb.ini文件,向里面写入0x067b(设备ID)

    ​ 5.Open minicom and enter the adbd command in the shell to ensure that the adb service in the development board is normal (if there is an error, it cannot be used). Then run the following command on the computer:

    打开minicom,在shell里输入adbd命令,确保开发板里的adb服务正常(若出现错误,则不能使用)。然后在电脑端的运行e以下命令:

    sudo adb kill-server
    sudo adb start-server
    adb devices
    

    ​ After running, you can see the equipment list, as follows

    运行完成之后即可看见设备清单,如下

    adb devices

1.3 The use of adb basic commands

adb基本命令的使用

adb shell

This command will log in to the shell of the device, followed by the command to run the device directly, which is equivalent to executing a remote command

这个命令将登录设备的shell, 后面加直接运行设备命令, 相当于执行远程命令

adb push

This command can copy files on the computer to the development board

此命令可以把电脑上的文件复制到开发板上

adb push hello.c /tmp/

adb push hello.c /tmp/ This copies the hello.c file on the computer to the /tmp directory on the development board

adb push hello.c /tmp/ 这样就把电脑上的hello.c文件复制到了开发板上的/tmp目录下

adb pull /tmp/hello.c ./

adb pull /tmp/hello.c ./ Copy the file hello.c in the /tmp directory on the development board to the current directory

adb pull /tmp/hello.c ./ 将开发板上/tmp目录下的文件hello.c复制到当前目录

2.Write an application to run on the development board

编写应用程序在开发板上运行

2.1Environment variable configuration

环境变量配置

  • First add the directory where the tool chain of the development software is located into the environment variable. For Tina system, the arm tool chain is in the tina/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/bin directory. Then open the .bashrc file in your user directory, and add a sentence at the end of this file, as follows:

    首先将开发软件的工具链的所在目录添 加进环境变量里。对于Tina系统来说,其arm工具链在tina/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/bin目录下。然后在自己的用户目录下打开.bashrc文件,在这个文件的最后面添加一句话,如下:

export PATH=$PATH:/home/book/R16/tinaV2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi-musl/toolchain/bin
```

  • Save and exit, then log out of the system and log in again. After logging in, enter the command env in the terminal to check whether this directory is included in the PATH variable. If it does, the addition is successful.

    保存后退出,然后注销系统,重新登录。登录之后在终端里输入命令env查看一下PATH变量里是否包含此目录,若包含则添加成功。

2.2 The first development method

第一种开发方式

  1. Write a hello.c file

写一个hello.c文件

#include<stdio.h>

int main(int argc,char** argv)
{
  printf("hello world\n");
}
  1. Compile using cross-compilation tool chain

使用交叉编译工具链编译

 arm-openwrt-linux-muslgnueabi-gcc -o hello hello.c
  1. Use adb tool to upload to the development board to view the running effect

使用adb工具链上传到板子上运行,并看看效果

adb push hello /tmp/

compile and upload

board effect

2.3 The second development method

第二种开发方式

  1. First create a hello folder under /home/book/R16/tinaV2.1/package/allwinner/hello

首先在/home/book/R16/tinaV2.1/package/allwinner/hello下创建一个hello文件夹

  1. Create a makefile and src folder under the hello folder, add my hello.c file to the src folder, and add a makefile file to the src folder.

在hello文件夹下创建一个makefile和src文件夹,将我的hello.c文件添加到src文件夹中,并在src文件夹中添加makefile文件。

file1

fiel2

  1. Write makefile

写makefile

##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to
# specify a basic description of the package,
# where to build our program, where to find
# the source files, and where to install the
# compiled program on the router.
#
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and
# there should be no trailing whitespace in
# lines that are not commented.
#
##############################################
include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=hello
PKG_VERSION:=1.0
PKG_RELEASE:=1

# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(COMPILE_DIR)/$(PKG_NAME)


include $(BUILD_DIR)/package.mk

# Specify package information for this program.
# The variables defined here should be self explanatory.
# If you are running Kamikaze, delete the DESCRIPTION
# variable below and uncomment the Kamikaze define
# directive for the description below
define Package/hello
  SECTION:=utils
  CATEGORY:=Allwinner
  TITLE:=hello app test 

endef

# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) -r ./src/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR)/ \
		ARCH="$(TARGET_ARCH)" \
		AR="$(TARGET_AR)" \
		CC="$(TARGET_CC)" \
		CXX="$(TARGET_CXX)" \
		CFLAGS="$(TARGET_CFLAGS)" \
		LDFLAGS="$(TARGET_LDFLAGS)" \
		all
endef

# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one


# Specify where and how to install the program. Since we only have one file,
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/hello/install
	$(INSTALL_DIR) $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/hello $(1)/usr/bin/
endef


# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.

$(eval $(call BuildPackage,hello))

all:
	$(CC) $(CFLAGS) hello.c -o hello
 
clean:
	rm *.o hello
  1. make menuconfig to see if the addition is successful

在make menuconfig中看看是否添加成功

hello app

  1. Compile the .ipk package

编译ipk包

make package/allwinner/hello/{clean,install} V=s

helloapp1

  1. Download the ipk package to the development board

将ipk包下载到开发板上

cd  /home/book/R16/tinaV2.1/out/astar-parrot/packages/base/
adb push hello_1.0-1_sunxi.ipk /tmp/

helloapp2

  1. Install and check the effect

安装然后查看效果

opkg install hello_1.0-1_sunxi.ipk
hello

ipk package to the development board

将ipk包下载到开发板上

cd  /home/book/R16/tinaV2.1/out/astar-parrot/packages/base/
adb push hello_1.0-1_sunxi.ipk /tmp/

[外链图片转存中…(img-K824YqY8-1598404424159)]

  1. Install and check the effect

安装然后查看效果

opkg install hello_1.0-1_sunxi.ipk
hello

hello app3


版权声明:本文为qq_35383699原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。