Tinker Board 3N - TinkerBoard/TinkerBoard GitHub Wiki
1. Linux Development
1.1 Build image
- Source code:
https://github.com/TinkerBoard-Linux/rockchip-linux-manifest/tree/linux5.10-rk356x (Debian)
1.1.1 Kernel 5.10
-
Install Docker environment
- Uninstall old versions
$ sudo apt-get remove docker docker-engine docker.io containerd runc
- Install Docker Engine – Community
$ sudo apt-get update $ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo apt-key fingerprint 0EBFCD88 $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io $ sudo docker run hello-world
Reference: https://docs.docker.com/engine/install/ubuntu/
- Manage Docker as a non-root user
$ sudo groupadd docker $ sudo usermod -aG docker $USER $ newgrp docker $ docker run hello-world
Reference: https://docs.docker.com/engine/install/linux-postinstall/
- Download the source code:
$ repo init -u https://github.com/TinkerBoard-Linux/rockchip-linux-manifest.git -b linux5.10-rk356x
-
Code compiling
- Go to the directory where you have downloaded the code base and execute the script. This will take a while to install the necessary packages on the host and build the Docker image.
$ ./docker_builder/docker-builder-run.sh
Once the above is done, you are in the shell of the newly started Docker container as the following. You can start to issue commands as usual.
Options to run docker: --privileged --rm -it --volume /mnt/2T-disk/linux5.10-rk356x_0620:/source your_usernmae@292c696527f6:/source$
- You can issue the following command to build all the images for Debian. All the images will be saved in the directory rockdev.
$ ./build.sh rockchip_rk3568_tinker_board_3n_debain_defconfig $ ./build.sh
It will generate a file which named sdcard_full.img and located at [source tree]/rockdev/sdcard_full.img
- You can issue the following command to build all the images for Yocto. All the images will be saved in the directory rockdev.
$ ./build.sh rockchip_rk3568_tinker_board_3n_yocto_defconfig $ ./build.sh
It will generate a file which named sdcard_full.img and located at [source tree]/rockdev/sdcard_full.img
-
Compiling u-boot/Kernel/Debian separately
- u-boot
$ ./build.sh uboot
It will generate a file which named uboot.img and located at [source tree]/u-boot/uboot.img
- Kernel
$ ./build.sh kernel
It will generate a file which named boot.img and located at [source tree]/kernel/boot.img
- Debian
$ ./build.sh debian
It will generate a file which named linaro-rootfs.img and located at [source tree]/debian/linaro-rootfs.img
- Yocto
$ ./build.sh yocto
It will generate a file which named linaro-rootfs.img and located at [source tree]/ yocto/build/latest/rootfs.img
1.2 Flash image
1.2.1 Booting from external Micro SD card
-
Requirement:
• 1 x Micro SD card with at least 8GB capacity
• 1 x 12~19V, DC 5.5/2.5 power supply
• 1 x Monitor with HDMI™ cable or USB Type-C® (DP) cable
• 1 x Keyboard and Mouse set -
Setting Up:
-
Insert the micro SD card into a Windows® PC.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the micro SD card using a third-party ISO software, such as Etcher.
-
Insert the bootable micro SD card into your Tinker Board 3N, then connect the power supply, keyboard, mouse, and monitor to boot up.
1.2.2 Booting from onboard eMMC
-
Requirement:
• 1 x USB Type-C® cable with data transfer function
• 1 x 12~19V, DC 5.5/2.5 power supply
• 1 x Monitor with HDMI™ cable or USB Type-C® (DP) cable
• 1 x Keyboard and Mouse set -
Setting Up:
1. Flash emmc by emmc UMS mode
- Keep MASK2 jumper and MASK1 (Left) -> connect type c usb to pc -> Power on the device
-
Connect the Tinker Board 3N to a PC using a USB Type-C® cable.
-
Connect the power adapter to the Tinker Board 3N.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the Tinker Board 3N using a third-party ISO software, such as Etcher.
-
After the TinkerOS image is successfully burned, disconnect the power adapter first, and then disconnect the USB Type-C® cable.
-
Connect the power supply, keyboard, mouse, and monitor to your Tinker Board 3N to boot up.
2. Flash emmc by SPINOR flash UMS mode
-
Remove MASK2 jumper and MASK1 (Left) -> connect type c usb to pc -> Power on the device
-
Connect the Tinker Board 3N to a PC using a USB Type-C® cable.
-
Connect the power adapter to the Tinker Board 3N.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the Tinker Board 3N using a third-party ISO software, such as Etcher.
-
After the TinkerOS image is successfully burned, disconnect the power adapter first, and then disconnect the USB Type-C® cable.
-
Insert the MASK2 jumper and MASK1 (Left)
- Connect the power supply, keyboard, mouse, and monitor to your Tinker Board 3N to boot up.
3. Flash emmc by SD card UMS mode
-
Insert the micro SD card into a Windows® PC.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the micro SD card using a third-party ISO software, such as Etcher.
-
Insert the SD card to Tinker Board 3 -> Keep MASK2 jumper and MASK1 (Left).
-
Connect the Tinker Board 3N to a PC using a USB Type-C® cable.
-
Connect the power adapter to the Tinker Board 3N.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the Tinker Board 3N using a third-party ISO software, such as Etcher.
-
After the TinkerOS image is successfully burned, disconnect all cables and remove the sd card from the Tinker Board 3N
-
Connect the power supply, keyboard, mouse, and monitor to your Tinker Board 3N to boot up.
1.3 How to Check Image Version
You can issue the following command to get the version of the image.
$ cat /etc/version
1.4 How to Get the SN (PPID)
Note: PPID (unique ID for Tinker board)
-
Copy the tinker_3N_read_sn.zip file to device.
-
Unzip tinker_3N_read_sn.zip.
-
You can issue the following command to get the serial number.
$ sudo bash tinker_3N_read_sn.sh
1.5 Resize image/partition
-
Connect Tinker Board 3N to PC via USB-C
-
Power on Tinker Board 3N and enter UMS mode
Note: If want to resize eMMC image, please power on Tinker Board 3N and enter SD card UMS mode.
• microSD card: With another Debian installed (It could be flashed an image thru Etcher or Win32DiskImager under Windows environment or dd under Linux.) -
Download tinker_resize.sh and dump image from eMMC with dd command
sudo dd bs=4M if=/dev/sdX of=/path/xxx.img
-
Use tinker_resize.sh to reduce image size
chmod +x tinker_resize.sh sudo ./tinker_resize.sh xxx.img
1.6 How to change LOGO
-
For Debian OS
-
Method 1:
-
Convert the logo file to 24 bit BMP file. It is recommended to use Window Paint for conversion.
Note: After converting to 24 bit BMP file, the BMP file MUST less than 700K bytes.
-
Rename the BMP file to logo.bmp
-
Copy logo.bmp and rename it to logo_kernel.bmp
-
Replace logo.bmp and logo_kernel.bmp with logo.bmp and logo_kernel.bmp under sourcecode/kernel.
-
Build kernel image and flash kernel image.
- Method 2:
-
Convert the logo file to 24 bit BMP file. It is recommended to use Window Paint for conversion
Note: After converting to 24 bit BMP file, the BMP file MUST less than 700K bytes.
-
Rename the BMP file to logo.bmp
-
Copy logo.bmp to sourcecode/kernel/scripts/
-
Execute the following command on the ubuntu server:
./bmpconvert logo.bmp
-
You will see the following message after the command is successful
-
Powering on device, and open terminal.
Enter
sudo reboot fastboot
in terminal to enter fastboot mode -
Execute command to flash logo.bmp into splash partition
fastboot flash splash logo.bmp
-
Reboot device
1.7 How to create Swapfile
In this example, we will create and activate 1G of swap. To create a bigger swap, replace 1G with the size of the desired swap space. The steps below show how to add swap space on Debian 10.
-
First create a file which will be used for swap:
$ sudo fallocate -l 1G /swapfile
-
Only the root user should be able to read and write to the swap file. Issue the command below to set the correct permissions :
$ sudo chmod 600 /swapfile
-
Use the mkswap tool to set up a Linux swap area on the file:
$ sudo mkswap /swapfile
-
Activate the swap file:
$ sudo swapon /swapfile
to make the change permanent open the /etc/fstab file:
$ sudo vim /etc/fstab
and paste the following line:
/swapfile swap swap defaults 0 0
-
Verify whether the swap is active using either the swapon or free command as shown below:
$ sudo swapon --show
Output NAME TYPE SIZE USED PRIO /swapfile file 1024M 507.4M -1
$ sudo free -h
Output total used free shared buff/cache available Mem: 488M 158M 83M 2.3M 246M 217M Swap: 1.0G 506M 517M
Reference link: https://linuxize.com/post/how-to-add-swap-space-on-debian-10/
1.8 Power management tool
-
Open a terminal in full screen mode and run the following command:
$ tinker-power-management
-
Adjust CPU or GPU Governor:
a. Press 'C' or 'G' to open the menu. 'C' is for CPU Governor and 'G' is for GPU Governor. There are 4 options to select: "auto", "manual", "powersave", and "performance".
b. Use the left or right arrow key to select. Option selected is shown in bold. Press the space bar to confirm, or press 'q' to cancel.
-
Adjust CPU frequency:
a. Follow Step 2 above to adjust CPU or GPU Governor to "manual"
b. Take CPU as example:
When CPU Governor = manual, options for CPU frequency adjustment will be highlighted. There are 2 options: "min.freq for A55" and "max.freq for A55". Use the arrow keys to select. Option selected is shown in bold. Press the space bar to confirm and open the selected CPU frequency menu. # Follow step 2. to adjust CPU or GPU Governor.
c. Once the frequency menu is shown
Use the left or right arrow key to select. Option selected is shown in bold. Press the space bar to confirm, or press 'Q' to cancel. # Frequency menu needs to be confirmed or closed before adjusting CPU or GPU Governor again.
-
Press "Ctrl" + "C" to exit Tinker Power Management anytime.
1.9 How to use power manager APP
-
CPU(A55) Governor setting is in /sys/devices/system/cpu/cpufreq/policy0/scaling_governor, use 'echo' to change.
EX: echo ondemand > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
CPU(A55) minimum frequency: /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
CPU(A55) maximum frequency: /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
Note: Check available parameter for CPU(A55) in /sys/devices/system/cpu/cpu0/cpufreq before setting.
-
GPU(G52) Governor setting: /sys/class/devfreq/fde60000.gpu/governor
GPU minimum frequency: /sys/class/devfreq/fde60000.gpu/min_freq
GPU maximum frequency: /sys/class/devfreq/fde60000.gpu/max_freq
Note: Check available parameter for GPU(G52) in /sys/class/devfreq/fde60000.gpu before setting.
1.10 How to Install OpenCV
-
Install the required packages
$ sudo apt-get update $ sudo apt-get -y upgrade $ sudo apt-get -y install aptitude $ sudo apt-get aptitude libavcodec-dev $ sudo apt-get -y install build-essential cmake git pkg-config libgtk-3-dev \ libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \ gfortran openexr libatlas-base-dev python3-dev python3-numpy \ libtbb2 libtbb-dev libdc1394-22-dev
-
Clone the OpenCV’s and OpenCV contrib repositories with the following commands:
$ mkdir ~/opencv_build && cd ~/opencv_build $ git clone https://github.com/opencv/opencv.git $ git clone https://github.com/opencv/opencv_contrib.git
-
Set up the build
$ cd ~/opencv_build/opencv $ mkdir build && cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_GENERATE_PKGCONFIG=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON ..
-
Build & install OpenCV
$ make -j4 $ sudo make install
Reference link: https://linuxize.com/post/how-to-install-opencv-on-debian-10/
1.11 How to control the reserved LED
Use the terminal to enter commands
-
Bright on the reserved led
echo 1 > /sys/devices/platform/gpio-leds/leds/rsv-led/brightness -
Bright off the reserved led
echo 0 > /sys/devices/platform/gpio-leds/leds/rsv-led/brightness
1.12 How to set WIFI as a Hotspot
-
Install dnsmasq & hostapd package
sudo apt install dnsmasq hostapd
-
Unzip SoftAP.zip
-
Open terminal and go to SoftAP folder, then
chmod 755 Enable_SoftAP.sh Disable_SoftAP.sh
-
Enable SoftAP mode:
./Enable_SoftAP.sh default SSID = TinkerSoftAP default Password = 87654321
-
Disable SoftAP mode:
./Disable_SoftAP.sh
-
You can modify /etc/hostapd/hostapd.conf for your own softap settings.
Ex.
ssid=TinkerSoftAP
wpa_passphrase=87654321
channel=6# For MAC address access-list # 0 = accept unless in deny list, deny_mac_file is used to specify deny list. # 1 = deny unless in accept list, accept_mac_file is used to specify accept list. macaddr_acl=1
# Accept/deny lists are read from separate files (containing list of # MAC addresses, one per line). accept_mac_file=/etc/hostapd/hostapd.accept deny_mac_file=/etc/hostapd/hostapd.deny
After modify hostapd.conf, you need to disable / re-enable softap again.
1.13 How to run the application at startup
Applications can be automatically started in a couple of ways:
-
Via GUI
a. Click Applications Menu > Settings > Settings Manager and then choose the Session and Startup option
b. Click “Apllication Autostart”
c. Add application name by the following item
d. Click “OK” button to get the following item.
-
Via config file
a. Edit autostart file
$ vim ~/.config/autostart/termianl-xfce4.desktop
b. Add application contents
For example: Execute the xfce4-terminal autostart
Reference link: https://wiki.archlinux.org/title/xfce
1.14 How to set a script from startup
- For Debian OS
Sample setting for starting up the applications when into Debian
This is a sample for the RTC clock, to set the applications will automatically run when into the Debian system.
-
Create rtc_clock_init.sh or copy rtc_clock_init.sh file into
/usr/local/bin/
folder
Add above green parts in rtc_clock_init.sh file -
Setting the permission
-
Create rtc-ds3231.service or copy rtc-ds3231.service into
/lib/systemd/system/
folder
Add above green parts in rtc_clock_init.sh file. -
Execute below command to enable RTC
-
Reboot the Debian system
1.15 How to collect log
- For Debian OS
-
Open Terminal and text the following command:
$ sudo tar -cvf /home/linaro/Desktop/$(date +'%Y%m%d_%H%M')_log.tar /var/log
-
Generate the file name like the following example
$ ls ~/Desktop/ 20230908_0313_log.tar
-
Decompress the tar
tar -xvf 20230908_0313_log.tar
1.16 How to update the Debian packages for the kernel and u-boot
On the Tinker Board 3N Debian system, edit the source.list file to add the PPA URL for Tinker Board 3N as the following.
$ sudo vim /etc/apt/sources.list
deb http://ppa.launchpad.net/asus-iot/tb3n/ubuntu focal main
Then use the following commands to update and install the packages.
$ sudo apt-get update
$ sudo apt-get install linux-headers-5.10.160-tinkerboard3n
$ sudo apt-get install linux-image-5.10.160-tinkerboard3n
$ sudo apt-get install uboot-tinkerboard3n
Once the installations are completed, please reboot the device to make the installations take effect.
1.17 How to set RTC
$ sudo date -s "2024-03-19 09:00:00" => setting time
$ sudo hwclock -w => write time into the RTC
=>Reboot the system
$ sudo hwclock -r => read time from the RTC
1.18 ASUS API Documentation
-
ASUS API Programming Guide Asus_API_Programming_Guide_v1.05_20240223.pdf
-
ASUS API (Library, Header files, Sample code) asusapi_1.0.7-1_aarch64-linux-gnu.tgz.zip
1.19 Tinker Board 3N - Yocto FOTA Command
- List the relevant commands for FOTA
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -h
- Check for Updates
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -q
- Download FOTA packages
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -d
- Performing update. The system will restart after the update is complete
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -u
- Print FOTA log
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -l
- Set query interval days. The current options are D (Day), W (Week), or M (Month). A restart is required for the new settings to take effect.
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -i [D/W/M]
- Set query time. The format for TIME is HH:mm. The default is empty. The automated process will only execute after this setting is configured. A restart is required for the new settings to take effect. (If TIME is set to 'print', it will display the configured time.)
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -t TIME
- Disable FOTA functionality. Query functionality will still be available
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -c
- Enable FOTA functionality. A restart is required to activate the client's automated process
/usr/bin/python3 /usr/share/FotaClient/ota_api.pyc -o
- Check the image version
cat cat /etc/os-release
1.20 Tinker Board 3N - PPA update(Kernel & U-boot) Command
1.On the Tinker Board 3N Debian system, edit the source.list file to add the PPA URL for Tinker Board 3N as the following
$ sudo vim /etc/apt/sources.list
deb http://ppa.launchpad.net/asus-iot/tb3n/ubuntu focal main
2.Using the following commands to update and install the general version. It will install the latest tinkerboard3n kernel image and headers
$ sudo apt-get update
$ sudo apt-get install linux-tinkerboard3n
2. Android Development
2.1 Build image
- Source code:
https://github.com/TinkerBoard-Android/rockchip-android-manifest/tree/android12-rockchip
1. Establish a build environment
Please refer to Install Docker Engine to install Docker engine.
2. Download the Android source
Please refer to Installing Repo to install the Repo Launcher and Downloading the Source to understand how to download the Android source.
3. Initiale a Repo client
Run repo init to get the latest version of Repo with its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source are placed within your working directory. For different projects, you must also specify the manifest branch or revision with option "-b REVISION".
repo init -u https://github.com/TinkerBoard-Android/rockchip-android-manifest.git -b REVISION
Optionally, you can also specify the initial manifest file with the option "-m NAME.xml" for the specific release for that project.
repo init -u https://github.com/TinkerBoard-Android/rockchip-android-manifest.git -b REVISION -m NAME.xml
- Android 12
repo init -u https://github.com/TinkerBoard-Android/rockchip-android-manifest.git -b android12-rockchip
4. Download the Android source tree
To download the Android source tree to your working directory from the repositories as specified in the default manifest, run:
repo sync
5. Build Android
Go to to the directory where you have downloaded the Android source and execute the script as the following. This will take a while to install the necessary packages on the host, build the Docker image, and start the container:
./docker_builder/docker-builder-run.sh
Once it is done. You are in the shell of this newly started Docker container and you are ready to build Android.
- Android 12
source build/envsetup.sh
lunch Tinker_Board_3N-userdebug
./build.sh -UCKAu
The image which is able to be flashed to the board via UMS mode will be stored as the following in the directory where you have downloaded the source.
./rockdev/ Image-Tinker_Board_3N/ Tinker_Board_3N-raw.img
2.2 Flash image
2.2.1 Booting from external Micro SD card
-
Requirement:
• 1 x Micro SD card with at least 8GB capacity
• 1 x 12~19V, DC 5.5/2.5 power supply
• 1 x Monitor with HDMI™ cable or USB Type-C® (DP) cable
• 1 x Keyboard and Mouse set -
Setting Up:
-
Insert the micro SD card into a Windows® PC.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the micro SD card using a third-party ISO software, such as Etcher.
-
Insert the bootable micro SD card into your Tinker Board 3N, then connect the power supply, keyboard, mouse, and monitor to boot up.
2.2.2 Booting from onboard eMMC
-
Requirement:
• 1 x USB Type-C® cable with data transfer function
• 1 x 12~19V, DC 5.5/2.5 power supply
• 1 x Monitor with HDMI™ cable or USB Type-C® (DP) cable
• 1 x Keyboard and Mouse set -
Setting Up:
1. Flash emmc by emmc UMS mode
- Keep MASK2 jumper and MASK1 (Left) -> connect type c usb to pc -> Power on the device
-
Connect the Tinker Board 3N to a PC using a USB Type-C® cable.
-
Connect the power adapter to the Tinker Board 3N.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the Tinker Board 3N using a third-party ISO software, such as Etcher.
-
After the TinkerOS image is successfully burned, disconnect the power adapter first, and then disconnect the USB Type-C® cable.
-
Connect the power supply, keyboard, mouse, and monitor to your Tinker Board 3N to boot up.
2. Flash emmc by SPINOR flash UMS mode
-
Remove MASK2 jumper and MASK1 (Left) -> connect type c usb to pc -> Power on the device
-
Connect the Tinker Board 3N to a PC using a USB Type-C® cable.
-
Connect the power adapter to the Tinker Board 3N.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the Tinker Board 3N using a third-party ISO software, such as Etcher.
-
After the TinkerOS image is successfully burned, disconnect the power adapter first, and then disconnect the USB Type-C® cable.
-
Insert the MASK2 jumper and MASK1 (Left)
- Connect the power supply, keyboard, mouse, and monitor to your Tinker Board 3N to boot up.
3. Flash emmc by SD card UMS mode
-
Insert the micro SD card into a Windows® PC.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the micro SD card using a third-party ISO software, such as Etcher.
-
Insert the SD card to Tinker Board 3 -> Keep MASK2 jumper and MASK1 (Left).
-
Connect the Tinker Board 3N to a PC using a USB Type-C® cable.
-
Connect the power adapter to the Tinker Board 3N.
-
Download the TinkerOS image from the Tinker Board website (https://tinker-board.asus.com/download.html) and burn it into the Tinker Board 3N using a third-party ISO software, such as Etcher.
-
After the TinkerOS image is successfully burned, disconnect all cables and remove the sd card from the Tinker Board 3N
-
Connect the power supply, keyboard, mouse, and monitor to your Tinker Board 3N to boot up.
2.3 How to use adb
-
Prepare an USB Type-C to Type-A cable
-
Enable USB debugging in the device system settings, under Developer options.
-
The Developer options screen is hidden by default. To make it visible, go to Settings > About tablet and tap Build number seven times. Return to the previous screen to find Developer options at the System > Advanced.
-
You can now connect your device with USB. Connect cable Type-C side to Tinker Board 3N and Type-A side to PC.
-
You can verify that your device is connected by check Device Manager.
-
If you have ever installed the ASUS_Android_USB_drivers_for_Windows, the device will appear as ASUS Android device.
-
Executing adb devices from the android_sdk/platform-tools/ directory. If connected, you'll see the device name listed as a device. The platform-tools can download from android website.
Ref: Android Debug Bridge (adb) | Android Developers (https://developer.android.com/tools/adb)
2.4 Get log file through adb
-
For Logcat:
$ adb logcat > logcat.txt
Logcat will save as logcat.txt
-
For Kernel:
$ adb shell dmesg > kernel.txt
Logcat will save as kernel.txt
Reference:
https://developer.android.com/studio/command-line/adb
https://developer.android.com/studio/command-line/logcat
2.5 How to use ASUS debugger
This file describes behaviors with the new version - AsusdeDugger v3.11
-
Start AsusDebugger
You CAN’T find AsusDebugger icon in Launcher, now. Please get into it from "Setting" Application
-
In Launcher, You can find Setting APK. Click to start Setting.
-
Click “About tablet” on the bottom of the list of the preference
- Click “Android Version” preference.
- Continuously click “Kernel version“ preference 10 times and will start open the AsusDebugger.
Note: There is a quick way. Please see Section 6
-
-
Set the configuration of logs
-
The path of capturing logs is shown at "Log file location", it is default set to "/sdcard/Logs"
-
"Logcat/kernel/tcpdump rotate number" is used to decide the number of log rotation. It affects logcat, kernel, and tcpdump.
-
"Logcat/kernel file size" is used to decide the size of log files. It affects logcat, and kernel.
-
-
Start to catch logs
- In Debugger, the logcat logs and kernel logs have been separated, if you need "Enable capture logcat" and "Enable capture kernel", make sure those toggles are checked.
- To enable tcpdump log for debugging internet related issue, make sure "Enable tcpdump" toggle is checked.
-
Collecting Logs
- When a bug is found, please press "COLLECT LOGS" button in AsusDebugger. You can describe your findings with short log or simply leave it blank.
- AsusDebugger runs dumpstate automatically when you request collecting logs and it will take some time (1~2 minutes) to generate current system state and information.
Moreover, AsusDebugger collect logs you captured. Once collecting procedure is done, a dialog will be prompted to inform you of the path of the collected logs as follow.
-
Output Debugger files
- After connecting device to computer, drag the status bar and press "USB connected". Then select "File transfers"
-
Log files in /sdcard/logs are logs for current capture session.
-
All collected logs go to /sdcard/Logs_collected/ directory
-
Quickly enter AsusDebugger
In Section 3 - "Start to catch logs", if any log toggles are enabled, you can see a notification shown the Logging mode is Debugger. You can quickly get into AsusDebugger activity by clicking.
-
Other function
-
Detect reboot
If you want to detect whether the device is rebooted, make sure "Detect reboot" toggle is checked.
If detect the device is rebooted, there is a full-screen floating window shown and display timestamp. Remove window by clicking it.
-
Display usage
If you want to know the device’s usage, includes the information of CPU, Memory, and Battery, make sure "Display CPU/GPU/MEM usage and battery level" toggle is checked. A floating window displays information at right-bottom corner.
-
Ping test
If you want to test the network connection, can use "Run PING test command" to run ping test
-
2.6 Changing the boot logo
2.6.1 Changing the boot logo
-
Launch Tinker Config App
-
Press “Boot Logo” button.
-
Press “Change Image” button.
-
Select the image you want to set, and press “Apply” button.
-
Reboot the device, you can get your own boot logo.
2.6.2 Changing the boot animation
-
Requirements
a. Type-C USB cableb. bootanimation.zip file
- You can create a bootanimation.zip by yourself or download it from the Internet.
-
Connect Tinker Board 3N to PC with Type-C USB cable.
-
Push bootanimation.zip to Tinker Board 3N
$ adb root $ adb remount $ adb push bootanimation.zip /system/media/bootanimation.zip $ adb reboot
-
After reboot, you can get your own Android boot animation.
2.7 Tinker config application
Introduction
Tinker Config is an Android-based application that offers flexibility and an easy way to configure I/O interfaces on 14pin header, LVDS/EDP connectors as well as Linux kernel Devicetree overlays while using Tinker Board 3N.
Prerequisites
Tinker Board 3N with Android OS v.1.0.0 (or later) installed. For image installation, please visit Tinker Board’s wiki page on Github.
Optional: hardware accessories such as LED modules, monitors … etc.
Tinker Config is built-in and can be found in the app list.
Features
-
Interfaces: allows users to configure functions for 14 pin GPIO header. The complete GPIO config table can be found on Github wiki. Below are the supported functions:
UART Settings: UART4, UART9
I2C Settings: I2C5
AUDIO Settings: I2S3_2CH, SPDIF_8CH
SPI Settings: SPI3
PWM Settings: PWM12, PWM13, PWM14, PWM15
Reset the all functions to default setting icon:
Note: Changes will not take effect immediately, please reboot the board each time after changes are made.
-
Linux Kernel Devicetree Overlays: For LVDS and EDP panel support to change configuration.
Device tree blob (DTB) supported include: edp_G156HAB02, mipi2lvds2_G156BGE-L01, mipi2lvds2_G215HAN01, mipi2lvds2_LM215WF3-SLN1, mipi2lvds2_AM1280800P2TZQW, mipi2lvds2_G185XW01, mipi2lvds2_G240HVT01
Note: Changes will not take effect immediately, please reboot the board each time after changes are made.
-
Application Whitelisting: allows users to prevent running applications being terminated when out of memory (OOM) occurred. Applications ticked in the Whitelist will be allowed running when OOM.
Note: Changes will not take effect immediately, please reboot the board each time after changes are made.
-
Power Management: users can scale the CPU and GPU frequency in order to either save power or enhance improvement. Below are the supported options of power policies:
CPU:
Governor: conservative, ondemand, userspace, powersave, interactive, performance, schedutil Core Frequency: 408000, 600000, 816000, 1104000, 1416000, 1608000, 1800000,1992000
GPU:
Governor: rknpu_ondemand, dmc_ondemand, vdec2_ondemand, venc_ondemand, userspace, powersave, performance, simple_ondemand
-
Boot Logo: This feature allows user to change the image shown when the board is booting.
Select an image (size limit: 233k pixels / 700KB), click “Change image“, and click “Apply”.
Reboot to make the change take effect.
The boot image change stays even when the board is reset to factory settings. Please wipe and re-flash the OS image to change boot logo back to default settings.
-
Power Scheduling: Allow users to set a scheduler to boot or shutdown the devices, users can be notified by SMS, email or system notification before the scheduler is triggered.
Add scheduler: Click the “+” icon button at the corner, choose the action, execution time, repeat, and notification and press “Save”.
Note: The default status of a new scheduler is disable, please remember to enable it by clicking the toggle button on the right side of the scheduler.
Modify scheduler: Click the scheduler to be modified, after setting the scheduler, press “Apply”.
Delete scheduler: Click the scheduler to be deleted, then click the delete button.Notification: Enable or disable the notification and set the notify time before the scheduler triggered.
The mail server settings can be set up by clicking the “Set up” button.
History: Shows the scheduler related logs and the reasons for the last shutdown.
3. Hardware Guide
3.1 How to set a serial port console log
Hardware:
-
Tinker Board 3N
-
Usb serial cable
-
Using a cable (pitch 2.0mm (female) to pitch 2.54mm (male)) and a USB serial cable to connect Tinker Board 3N and PC.
a. Connect TXD pin on the converter to RX pin on the Debug UART.
b. Connect RXD pin on the converter to TX pin on the Debug UART.
c. Connect GND pin on the converter to GND pin on the Debug UART.
-
On PC, open Putty and select Serial.
-
The Serial line can be checked from Windows >Device Manager >Ports (COM & LPT). The speed is 1500000 baud.
-
Click the Open button on Putty and power the board, and some boot logs will be printed on Putty from PC:
3.2 How to use CAN bus
The Linux CAN is depending on the SocketCAN:
https://en.wikipedia.org/wiki/SocketCAN
-
Run the CAN testing script (CAN loopback mode) and reboot device after running script:
Please use the bellowing command with root privilege by “sudo su” command in Debian and “adb root” in Android
Note: The testing files: can_loopback.sh, can_tx.sh, can_rx.sh
~/code/CAN/CAN_test$ sudo ./can_loopback.sh [sudo] password for asus: Start can tx/rx loop with iface can0 ! candump: no process found 20:21:51.967: can0 send 001#0011223344556677 can0 001 [8] 00 11 22 33 44 55 66 77 can0 001 [8] 00 11 22 33 44 55 66 77 20:21:51.975: can0 receive can packet …. ~/code/CAN/CAN_test$ sudo reboot
-
Use two devices A (Sender) and B (Receiver)
In B device (Receiver): refer can_rx.sh
# ip link set can0 down # ip link set can0 up type can bitrate 125000 # candump can0
In A device (Sender): refer can_tx.sh
# ip link set can0 down # ip link set can0 up type can bitrate 125000 # cansend can0 001#0011223344556677
-
Then we can see the dump message in B device
can0 001 [8] 00 11 22 33 44 55 66 77 can0 001 [8] 00 11 22 33 44 55 66 77
3.3 How to use COM
stty loopback: https://gist.github.com/midnight-wonderer/781facfe2fb6ee108a0e
Note:
-
Test for COM1
Set baudrate to 115200
stty -F /dev/ttyS0 115200
Transfer data to pc putty (String which input from device will display on putty.)
echo "test" > /dev/ttyS0
Receive pc putty data (String which input from putty will display on device.)
cat /dev/ttyS0
-
Test for COM2
Set baudrate to 115200
stty -F /dev/ttyS8 115200
Transfer data to pc putty (String which input from device will display on putty.)
echo "test" > /dev/ttyS8
Receive pc putty data (String which input from putty will display on device.)
cat /dev/ttyS8
-
Test for COM3
Push switch_uart3_protocol.sh into device by adb tool or copy the switch_uart3_protocol.sh to Desktop by usb flash
#Debian adb push switch_com3_protocol.sh /home/linaro/Desktop #Android adb push switch_com3_protocol.sh sdcard
Change mode of switch_uart3_protocol.sh before using it
#Debian chmod a+x /home/linaro/Desktop/switch_com3_protocol.sh #Android chmod a+x sdcard/switch_com3_protocol.sh
Switch protocol to rs232/rs422/rs485
#Debian ./home/linaro/Desktop/switch_com3_protocol.sh 232 ./home/linaro/Desktop/switch_com3_protocol.sh 422 ./home/linaro/Desktop/switch_com3_protocol.sh 485 #Android su sh sdcard/switch_com3_protocol.sh 232 sh sdcard/switch_com3_protocol.sh 422 sh sdcard/switch_com3_protocol.sh 485
Set baudrate to 115200
stty -F /dev/ttyS3 115200
Transfer data to pc putty (String which input from device will display on putty.)
echo "test" > /dev/ttyS3
Receive pc putty data (String which input from putty will display on device.)
cat /dev/ttyS3
-
Test with com_port_test.sh
chmod 777 com_port_test_tinker3.sh chmod 777 com_port_test chmod 777 switch_com3_protocol.sh
com_port_test.sh [COM1] [COM2] [PROTOCOL] [FLOW_CONTROL] com_port_test.sh [COM1] [FLOW_CONTROL] example: #COM1<=>COM2 without flow control sudo ./com_port_test_tinker3.sh /dev/ttyS0 /dev/ttyS8 0 0 #COM1<=>COM2 with flow control sudo ./com_port_test_tinker3.sh /dev/ttyS0 /dev/ttyS8 0 1 #COM1<=>COM3(232) with flow control sudo ./com_port_test_tinker3.sh /dev/ttyS0 /dev/ttyS3 232 1 #COM1 self test with flow control sudo ./com_port_test_tinker3.sh /dev/ttyS0 1
-
COM3 RS232 to usb converter
-
COM3 RS422 to RS232 converter
-
COM3 RS485 to RS232 converter
3.4 How to use GPIO
3.4.1 GPIO config table
- Hardware mapping
- Functions mapping
Chip, Line | PIN# | ALT Fun 1 | ALT Fun 0 | PIN | PIN | ALT Fun 0 | ALT Fun 1 | ALT Fun 2 | ALT Fun 3 | ALT Fun 4 | PIN# | Chip, Line |
---|---|---|---|---|---|---|---|---|---|---|---|---|
--- | --- | --- | VCC_5V0 | 1 | 2 | VCC_3V3 | --- | --- | --- | --- | --- | --- |
--- | --- | --- | GND | 3 | 4 | GPIO4_C2_d /sys/class/gpio/gpio146 | I2S3_MCLK_M1 | SPI3_CLK_M1 /dev/spidev3 | PWM14_M1 /sys/class/pwm/pwmchip5 | --- | 146 | 4, 18 |
3, 9 | 105 | UART4_RX_M1 /dev/ttyS4 | GPIO3_B1_d /sys/class/gpio/gpio105 | 5 | 6 | GPIO4_C3_d /sys/class/gpio/gpio147 | I2S3_SCLK_M1 | SPI3_MOSI_M1 /dev/spidev3 | PWM15_IR_M1 /sys/class/pwm/pwmchip6 | --- | 147 | 4, 19 |
3, 10 | 106 | UART4_TX_M1 /dev/ttyS4 | GPIO3_B2_d /sys/class/gpio/gpio106 | 7 | 8 | GPIO4_C4_d /sys/class/gpio/gpio148 | I2S3_LRCK_M1 | SPDIF_TX_M2 | SPI3_CS1 (NOT rk official) /dev/spidev3.1 | --- | 148 | 4, 20 |
3, 11 | 107 | I2C5_SCL_M0 /dev/i2c-5 | GPIO3_B3_d /sys/class/gpio/gpio107 | 9 | 10 | GPIO4_C5_d /sys/class/gpio/gpio149 | I2S3_SDO_M1 | SPI3_MISO_M1 /dev/spidev3 | PWM12_M1 /sys/class/pwm/pwmchip3 | UART9_TX_M1 /dev/ttyS9 | 149 | 4, 21 |
3, 12 | 108 | I2C5_SDA_M0 /dev/i2c-5 | GPIO3_B4_d /sys/class/gpio/gpio108 | 11 | 12 | GPIO4_C6_d /sys/class/gpio/gpio150 | I2S3_SDI_M1 | SPI3_CS0_M1 /dev/spidev3.0 | PWM13_M1 /sys/class/pwm/pwmchip4 | UART9_RX_M1 /dev/ttyS9 | 150 | 4, 22 |
--- | --- | --- | SARADC_VIN6 | 13 | 14 | SARADC_VIN7 | --- | --- | --- | --- | --- | --- |
3.4.2 Program with python-periphery
python3 -m pip install python-periphery
-
GPIO
- Input control example
from periphery import GPIO # Open GPIO /dev/gpiochip0 line 10 with input direction gpio_in = GPIO("/dev/gpiochip0", 10, "in") # Open GPIO /dev/gpiochip0 line 12 with output direction gpio_out = GPIO("/dev/gpiochip0", 12, "out") value = gpio_in.read() gpio_out.write(not value) gpio_in.close() gpio_out.close()
-
PWM
-
Enable PWMs function by modify /boot/config.txt. Then, reboot the device.
- “#intf:pwm12=off” → “intf:pwm12=on”
- “#intf:pwm13=off” → “intf:pwm13=on”
- “#intf:pwm14=off” → “intf:pwm14=on”
- “#intf:pwm15=off” → “intf:pwm15=on”
-
Example
from periphery import PWM # Open PWM chip 0, channel 10 pwm = PWM(0, 10) # Set frequency to 1 kHz pwm.frequency = 1e3 # Set duty cycle to 75% pwm.duty_cycle = 0.75 pwm.enable() # Change duty cycle to 50% pwm.duty_cycle = 0.50 pwm.close()
-
-
UART
-
Enable UARTs function by modify /boot/config.txt. Then, reboot the device.
- “#intf:uart4=off” → “intf:uart4=on”
- “#intf:uart9=off” → “intf:uart9=on”
-
Example
from periphery import Serial # Open /dev/ttyUSB0 with baudrate 115200, and defaults of 8N1, no flow control serial = Serial("/dev/ttyUSB0", 115200) serial.write(b"Hello World!") # Read up to 128 bytes with 500ms timeout buf = serial.read(128, 0.5) print("read {:d} bytes: _{:s}_".format(len(buf), buf)) serial.close()
-
-
I2C
-
Enable I2C function by modify /boot/config.txt. Then, reboot the device.
- “#intf:i2c5=off” → “intf:i2c5=on”
-
Example
from periphery import I2C # Open i2c-0 controller i2c = I2C("/dev/i2c-0") # Read byte at address 0x100 of EEPROM at 0x50 msgs = [I2C.Message([0x01, 0x00]), I2C.Message([0x00], read=True)] i2c.transfer(0x50, msgs) print("0x100: 0x{:02x}".format(msgs[1].data[0])) i2c.close()
-
-
SPI
-
Enable SPI function by modify /boot/config.txt. Then, reboot the device.
- “#intf:spi3=off” → “intf:spi3=on”
-
Example
from periphery import SPI # Open spidev1.0 with mode 0 and max speed 1MHz spi = SPI("/dev/spidev1.0", 0, 1000000) data_out = [0xaa, 0xbb, 0xcc, 0xdd] data_in = spi.transfer(data_out) print("shifted out [0x{:02x}, 0x{:02x}, 0x{:02x}, 0x{:02x}]".format(*data_out)) print("shifted in [0x{:02x}, 0x{:02x}, 0x{:02x}, 0x{:02x}]".format(*data_in)) spi.close()
-
-
ADC
-
Formula: Vin = Vraw * 1800 / 1023
-
Read RAW: cat /sys/bus/iio/devices/iio:device0/in_voltage[NUMBER]_raw
Ex. cat /sys/bus/iio/devices/iio:device0/in_voltage6_raw
-
3.4.3 MRAA library for Android
-
Android Archive file for the IO interface of 14 pins on ASUS Tinker Board 3N
-
The apk of Mraa API for Tinker Board 3N
-
Class
class | constructor | class | constructor |
---|---|---|---|
Gpio | Gpio(int pin_index) | Pwm | Pwm (int pin_index) |
I2c | I2c (int i2c_index) | Uart | Uart(int uart_index) |
Spi | Spi (int spi_index) | Aio | Aio(int adc_index) |
- Index Class
-- GPIO
Tinker Board | Field | Index Value |
---|---|---|
Tinker Board | TINKERBOARD_PIN4 | 4 |
Tinker Board | TINKERBOARD_PIN5 | 5 |
Tinker Board | TINKERBOARD_PIN6 | 6 |
Tinker Board | TINKERBOARD_PIN7 | 7 |
Tinker Board | TINKERBOARD_PIN8 | 8 |
Tinker Board | TINKERBOARD_PIN9 | 9 |
Tinker Board | TINKERBOARD_PIN10 | 10 |
Tinker Board | TINKERBOARD_PIN11 | 11 |
Tinker Board | TINKERBOARD_PIN12 | 12 |
-- I2C
TinkerBoard3NI2C | Field | Index Value | The Uart Interface |
---|---|---|---|
TinkerBoard3NI2C | TINKERBOARD_3N_I2C5 | 0 | I2c5 |
-- SPI
TinkerBoard3NSPI | Field | Index Value | The Uart Interface |
---|---|---|---|
TinkerBoard3NSPI | TINKERBOARD_3N_SPI3 | 0 | Spi3 |
-- Uart
TinkerBoard3NUART | Field | Index Value | The Uart Interface |
---|---|---|---|
TinkerBoard3NUART | TINKERBOARD_3N_UART4 | 0 | Uart4 |
TinkerBoard3NUART | TINKERBOARD_3N_UART9 | 1 | Uart9 |
-- ADC
TinkerBoard3NADC | Field | Index Value | The Uart Interface |
---|---|---|---|
TinkerBoard3NADC | TINKERBOARD_3N_ADC6 | 0 | Adc6 |
TinkerBoard3NADC | TINKERBOARD_3N_ADC7 | 1 | Adc7 |
- The mraa API Class for Android
-- GPIO
Methods | Parameter | Description | Return |
---|---|---|---|
dir(Dir dir) | Dir | Set input/output | Result |
readDir() | void | Read input/output dir | Dir |
read() | void | Set input and read gpio value | 0/1 |
write(int v) | 0/1 | Set output value | Result |
-- I2C
Methods | Parameter | Description | Return |
---|---|---|---|
address(short a) | 0x00-0xFF | Set i2c address | Result |
readByte() | void | Read a byte data form i2c | short |
writeByte(short b) | Mode | Write a byte data to i2c | Result |
read(byte[] buf) | byte[] | Read a byte[] data form i2c | read size |
write(byte[] buf) | byte[] | Write a byte[] data to i2c | Result |
readReg(short a) | 0x00-0xFF | Read a byte data form i2c addr | short |
writeReg(short a, short d) | 0x00-0xFF, 0x00-0xFF | Write a byte data to i2c addr | Result |
readWordReg(short a) | 0x00-0xFF | Read a byte[2] data form i2c addr | int |
writeWordReg(short a, int d) | 0x00-0xFF, 0x0000-0xFFFF | Write a byte[2] data to i2c addr | Result |
readBytesReg(short a, byte[] b) | 0x00-0xFF, byte[] | Read a byte[] data form i2c addr | int |
-- PWM
Methods | Parameter | Description | Return |
---|---|---|---|
period(float s) | 0.0001 - 2.147483 | Set pwm period | Result |
period_ms(int m) | 1 - 2147 | Set pwm period | Result |
period_us(int u) | 1 - 2147483 | Set pwm period | Result |
pulsewidth(float s) | 0.0001 - 2.147483 | Set pwm duty | Result |
pulsewidth_ms(int m) | 1 - 2147 | Set pwm duty | Result |
pulsewidth_us(int u) | 1 - 2147483 | Set pwm duty | Result |
max_period() | void | Get pwm max period | int(us) |
min_period() | void | Get pwm min period | int(us) |
read() | void | Get pwm period/duty | 0.0 - 1.0 |
write(float p) | 0.0 - 1.0 | Set pwm period/duty percentage | Result |
enable(boolean e) | true/false | dis/enable pwm | Result |
-- SPI
Methods | Parameter | Description | Return |
---|---|---|---|
defaultConfig() | void | Set mraa default config (mode0,lsb=0,bits=8) | Result |
mode(Spi_Mode m) | void | Set spi mode | Result |
frequency(int f) | int | Set spi frequency max=48000000 | Result |
lsbmode(boolean l) | true/false | Set spi lsmode | Result |
bitPerWord(long b) | 8/16 | Set spi bit_pre_word | Result |
writeByte(short a) | 0x00-0xFF | Write a byte data to spi | int(recv data) |
writeWord(int a) | 0x0000-0xFFFF | Write a byte[2] data to spi | int(recv data) |
write(byte[] b) | byte[] | Write a byte[] data to spi | byte[](recv data) |
-- UART
Methods | Parameter | Description | Return |
---|---|---|---|
defaultConfig() | void | Set mraa default config (9600 8N1, no echo or special character) | Result |
setBaudRate(long b) | long | Set uart baudrate max=150000000 | Result |
setMode(int bytesize, UartParity parity, int stopbits) | int | Set the transfer mode | Result |
setFlowcontrol(boolean xonxoff, boolean rtscts) | true/false | Set the flowcontrol | Result |
setTimeout(int read, int write, int interchar) | -1 - int_max | Set the timeout for read and write operations | Result |
setNonBlocking(boolean b) | true/false | Set the blocking state for write operations | Result |
sendBreak(int b) | 0 - max_int | Send a break to the device | Result |
flush() | void | Flush the outbound data | Result |
dataAvailable() | void | Check to see if data is available on the device for reading, return immediately | boolean |
dataAvailable(long timeout) | 1 - int_max | Check to see if data is available on the device for reading and time out | boolean |
readStr(int length) | 1 - int_max | Read bytes from the device into a String object | String |
writeStr(String s) | String | rite bytes in String object to a device | int |
read(byte[] data) | byte[] | Check to see if data is available on the device for reading and time out | int(read size) |
wrtie(byte[] data) | byte[] | Check to see if data is available on the device for reading and time out | int(write size) |
-- AIO
Methods | Parameter | Description | Return |
---|---|---|---|
getBit() | int | Gets the bit value mraa is shifting the analog read to | int |
read() | void | Read a value from the AIO pin | long |
readFloat() | void | Read a value from the AIO pin and return it as a normalized float | float |
setBit(int bits) | int | Set the bit value which mraa will shift the raw reading from the ADC to | Result |
- Example for 14 pin hardware interface
-- GPIO
import mraa.*;
// Test GPIO 5 hardware interface
Gpio gpio5 = new Gpio(TinkerBoard.TINKERBOARD_PIN5.swigValue());
gpio5.dir(Dir.DIR_OUT);
gpio5.write(1);
-- I2C
Enable I2C function by modify /dtoverlay/config.txt. Then, reboot the device.
- “#intf:i2c5=off” → “intf:i2c5=on”
import mraa.*;
// Test I2c5 interface
I2c i2c = new I2c(TinkerBoard3NI2C.TINKERBOARD_3N_I2C5.swigValue());
// Test by ADXL345 accelerometer I2c device
i2c.address((short) 0x53);
i2c.writeReg((short)0x01, (short) 0x57);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
i2c.address((short) 0x50);
Log.d(TAG, "i2c5 read: 0x" + Integer.toHexString(i2c.readReg((short)0x01)));
-- PWM
Enable PWMs function by modify /dtoverlay/config.txt. Then, reboot the device.
- “#intf:pwm12=off” → “intf:pwm12=on”
- “#intf:pwm13=off” → “intf:pwm13=on”
- “#intf:pwm14=off” → “intf:pwm14=on”
- “#intf:pwm15=off” → “intf:pwm15=on”
import mraa.*;
//enable the pwm15 signal
Pwm pwm = new Pwm(TinkerBoard.TINKERBOARD_PIN6.swigValue());
pwm.period_us(20000);
pwm.write((float) 0.5);
pwm.enable(true);
// release the pwm signal
pwm.enable(false);
pwm.unexport();
-- SPI
Enable SPI function by modify /dtoverlay/config.txt. Then, reboot the device.
- “#intf:spi3=off” → “intf:spi3=on”
import mraa.*;
// Test Spi3 interface
Spi spi = new Spi(TinkerBoard3NSPI.TINKERBOARD_3N_SPI3.swigValue());
byte[] recv = spi.write(new byte[]{0x41, 0x61});
Log.d(TAG, String.format("onCreate: recv[0]=0x%x, recv[1]=0x%x", recv[0], recv[1]));
-- UART
Enable UARTs function by modify /dtoverlay/config.txt. Then, reboot the device.
- “#intf:uart4=off” → “intf:uart4=on”
- “#intf:uart9=off” → “intf:uart9=on”
import mraa.*;
// Test Uart4 interface
Uart uart = new Uart(TinkerBoard3NUART.TINKERBOARD_3N_UART4.swigValue());
uart.defaultConfig();
uart.setBaudRate(115200);
uart.writeStr("ASUS Tinker Board 3N");
String read = uart.readStr(6);
Log.d(TAG, "uart4 read: " + read);
-- ADC
import mraa.*;
Aio aio6 = new Aio(TinkerBoard3NADC.TINKERBOARD_3N_ADC6.swigValue());
float vin_6 = aio6.readFloat();
Log.d(TAG, "adc6 read: " + String.valueOf(vin_6));
3.4.4 GPIO Driving
Chip, line | Current | Drive Strength | PWR | Pull | Name | Physical Pin | Physical Pin | Name | Pull | PWR | Drive strength | Current | Chip, line |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
400mA | 5V | VCC_5V0_14GPIO | 1 | 2 | VCC_3V3_14GPIO | 3.3V | 400mA | ||||||
0V | Ground | 3 | 4 | 12_GP4C2_SPI3_CLK | Down | 3.3v | 1*Note | 5mA | 4,18 | ||||
3,9 | 5mA | 1*Note | 3.3v | Down | 12_GP3B1_UART4_RX | 5 | 6 | 12_GP4C3_SPI3_MOSI | Down | 3.3V | 1*Note | 5mA | 4,19 |
3,10 | 5mA | 1*Note | 3.3v | Down | 12_GP3B2_UART4_TX | 7 | 8 | 12_GP4C4_SPDIF_TX | Down | 3.3V | 1*Note | 5mA | 4,20 |
3,11 | 5mA | 1*Note | 3.3v | Up | 12_GP3B3_I2C5_SCL | 9 | 10 | 12_GP4C5_SPI3_MISO | Down | 3.3V | 1*Note | 5mA | 4,21 |
3,12 | 5mA | 1*Note | 3.3v | Up | 12_GP3B4_I2C5_SDA | 11 | 12 | 12_GP4C6_SPI3_CS0 | Down | 3.3V | 1*Note | 5mA | 4,22 |
1.8v | SARADC_VIN6 | 13 | 14 | SARADC_VIN7 | 1.8V |
**Note:**
The following data represents the current corresponding to each drive level. GPIO Drvie strength level can be set by SW.
Drive level 0 : 3mA
Drive level 1 : 5mA
Drive level 2 : 10mA
Drive level 3 : 15mA
Drive level 4 : 20mA
Drive level 5 : 25mA
3.5 How to flash a recovery image
3.5.1 Flash the Recovry image to spinor flash by sdcard
-
Get the SPINOR flash image. SPINOR-Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery.zip
-
Get the SDcard to boot Debian system.
Debian image liink: https://tinker-board.asus.com/download-list.html?product=tinker-board-3n
-
Remove the SPINOR flash jumper
-
Boot Debian system. Use the following command to flash SPINOR flash
a. Install the mtd-utils tool for SPINOR flash and copy recovery_spi.sh to Desktop. recovery_spi.zip
$ sudo apt-get update;sudo apt-get install mtd-utils
b. Copy the SPINOR-Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery.zip and unzip img to Desktop
$ unzip SPINOR-Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery.zip
c. Run the recovery_spi.sh to SPINOR flash
$ chmod a+x [recovery_spi.sh](http://redmine.corpnet.asus/attachments/download/5184/recovery_spi.sh);sh recovery_spi.sh root@linaro-alip:/home/linaro/Desktop# ./recovery_spi.sh mtdblock0 31:0 0 16M 0 disk Erase SPI Flash Erased 16777216 bytes from address 0x00000000 in flash Flash SPINOR-Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery.img to SPI Flash 24576+0 records in 24576+0 records out 12582912 bytes (13 MB, 12 MiB) copied, 268.857 s, 46.8 kB/s 24576+0 records in 24576+0 records out 12582912 bytes (13 MB, 12 MiB) copied, 1.07753 s, 11.7 MB/s Recovery PASS
d. Power off the device
-
Remove the SDcard -> Insert the USB type C -> Insert the DC adaptor
-
Enter the UMS mode by SPINOR flash uboot.
3.5.2 Flash the Recovry image to spinor flash by RKDevTool
-
OS Requirement:
Windows 10 or later
-
Hardwares Requirement:
Tinker Board 3N have emmc and SPINOR flash versions
-
Tools and driver Requirement:
Unzip the RKDevTool_Release_v2.96.zip and install windows usb driver DriverAssitant_v5.12.zip
-
Get the recovery image Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.zip
-
Short the SPINOR flash pin and EMMC pin (left) -> connect type c usb to pc -> Power on the device
-
Open the RKDevTool.exe and then you can see the maskrom mode
-
Remove the SPINOR jumper
-
Flash the Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.img to SPINOR device by "升及固件" --> Select "固件" --> show the Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.img path
-
Flash the the Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.img to SPINOR by "升級"
Note
If can't update the Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.img to SPINOR flash, need to erase the SPINOR flash by the following command
a. Enter the uboot console by uart console port
Bootdev(atags): mtd 2
GUID Partition Table Header signature is wrong: 0xA9425BF5A94153F3 != 0x5452415020494645
*** ERROR: Can't write GPT header ***
Backup GPT repair fail!
PartType: EFI
...
Device 0: unknown device
No ethernet found.
missing environment variable: pxeuuid
...
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
No ethernet found.
No ethernet found.
=>
b. Erase the SPINOR flash by uboot command and reboot to Maskrom mode
=> mtd erase nor0
Erasing 0x00000000 ... 0x01ffffff (8192 eraseblock(s))
=> rbrom
3.5.3 Flash the Recovry image to EMMC by RKDevTool
-
OS Requirement:
Windows 10 or later
-
Hardwares Requirement:
Tinker Board 3N have emmc and SPINOR flash versions
-
Tools and driver Requirement:
Unzip the RKDevTool_Release_v2.96.zip and install windows usb driver DriverAssitant_v5.12.zip
-
Get the recovery image Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.zip
-
Short the SPINOR flash pin and EMMC pin (left) -> connect type c usb to pc -> Power on the device
-
Open the RKDevTool.exe and then you can see the maskrom mode
-
Change the EMMC switch to right.
-
Flash the Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.img to EMMC device by "升及固件" --> Select "固件" --> show the Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.img path
- Flash the the Tinker_Board_3N-Debian-Bullseye-v1.0.14-20231129-release-Recovery-rktools.img to EMMC by "升級"