Changes

Jump to: navigation, search

Orange Pi RK3399

8,398 bytes added, 19:37, 23 June 2022
no edit summary
After flashed, there would show the following information and the Orange Pi would reboot. (UF command would reboot, but not DI command.)
<div>[[文件:Orange-pi-rk3399-img22.png|600px|]]</div>
<br>
'''2)Write Scripts to Implement User-Defined Flash'''
<br>
upgrade_tool also supports used as Linux command for flashing, you only need to add the path of tool into environment variable.<br>
For example, when debug Kernel, if you want to make it realize modify-compile-flash, you could also try the following:
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
<nowiki># Compile part of the firmware of kernel it will generated kernel.img and resource.img</nowiki><br>
<nowiki>make -j2 rk3399-orangepi.img</nowiki><br>
<nowiki># enter into Loader mode with adb command</nowiki><br>
adb shell rebot bootloader<br>
<nowiki># finished flashing with di Command</nowiki><br>
sudo upgrade_tool di resource resource.img<br>
sudo upgrade_tool di kernel kernel.img<br>
<nowiki># reboot with rd Command</nowiki><br>
sudo upgrade_tool rd
</div>
=== '''FAQ of Image Flashing''' ===
<br>
* '''Cannot power on because of error firmware'''
<br>
Usually we could enter into LOADER mode to flashing hardware, however, if it cannot be powered on because of error firmware, we could try to use MASKROM mode to write image and boot.<br>
1. Power off the device<br>
2. Use metal tweezers to keep TP50265 and GND connected<br>
3. Power on the board with DC<br>
4. Wait a moment then release the metal tweezers<br>
5. Use a micro USB Type-C cable to connect device and host PC<br>
6. Device should enter MASKROM mode<br>
<br>
<div>[[文件:Orange-pi-rk3399-img11.png|600px|]]</div>
<br>
<div>[[文件:Orange-pi-rk3399-img12.png|600px|]]</div>
<br>
It would show the following with AndroidTools on Windows:
<div>[[文件:Orange-pi-rk3399-img25.png|600px|]]</div>
<br>
After this could flash the image in the normal way.<br>
<br>
It would show the following if use upgrade_tool on Linux:
<div>[[文件:Orange-pi-rk3399-img26.png|600px|]]</div>
<br>
It would be re-flash the image with uf command.<br>
Principle:<br>
It would clean data on flash if short connect pin and GND because the system would consider data error of flash.<br>
<br>
== '''Linux Environment Construction and Firmware Compilation''' ==
<br>
=== '''Download Linux Source Code''' ===
<br>
* '''OrangePi Souce Code Downloader'''
The Linux source for the Orange Pi RK3399 has been uploaded to GitHub, the kernel version is Linux 4.4, we can use it<br>
Download with the downloader for OrangePi Linux source code, the method to get the downloader source code is as follows:
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ sudo apt-get install git<br>
$ git clone https://github.com/orangepi-xunlong/OrangePi_Build.git<br>
$ cd OrangePi_Build<br>
$ ls<br>
Build_OrangePi.sh lib README.md
</div>
<br>
* '''Run the downloader'''
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ ./Build_OrangePi.sh
</div>
<br>
Enter the root password and press Enter<br>
<br>
<div>[[文件:Orange-pi-rk3399-img27.png|600px|]]</div>
<br>
Select 0 Build system with kernel/uboot/rootfs, enter the development board model selection interface.<br>
<br>
<div>[[文件:Orange-pi-rk3399-img28.png|600px|]]</div>
<br>
Select 20 orangepi RK3399 and press Enter to start downloading the Linux source code for Orange Pi RK3399<br>
<br>
<div>[[文件:Orange-pi-rk3399-img29.png|600px|]]</div>
<br>
The downloaded source code will be stored in the same directory of OrangePi_Build<br>
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ ls ../<br>
OrangePi_Build OrangePiRK3399
</div>
<br>
The Linux source code directory structure of OrangePi RK3399 is as follows<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ cd OrangePiRK3399<br>
$ tree -L 1<br>
.<br>
├── build.sh -> scripts/build.sh Compile the startup script<br>
├── external Store extra configuration files<br>
├── kernel Linux kernel source<br>
├── output Store output files<br>
├── scripts Compile script<br>
├── toolchain Cross compilation tool<br>
└── uboot uboot source code<br>
<br>
6 directories, 1 file
</div>
<br>
=== '''Compile Linux source code''' ===
<br>
* Execute the compile startup script
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ cd OrangePiRK3399<br>
$ ./build.sh
</div>
<br>
Select Enter<br>
<br>
<div>[[文件:Orange-pi-rk3399-img30.png|600px|]]</div>
<br>
Enter the root password and press Enter, then select the function needed to be executed<br>
<br>
<div>[[文件:Orange-pi-rk3399-img31.png|600px|]]</div>
<br>
The functions of each option are as follows:<br>
<br>
* 0 Build Release Image Compile Ubuntu or Debian Release image
* 1 Build Uboot Compile uboot source code
* 2 Build Linux Compile Linux kernel source code
* 3 Update kernel Image Update kernel
0 SD Card Update the kernel of Linux in SD card<br>
1 EMMC Update the kernel of Linux in EMMC<br>
* 4 Update Module Update the kernel module of Linux in SD card
* 5 Update Uboot
0 SD Card Update the uboot of Linux in SD card
1 EMMC Update the uboot of Linux in EMMC
<br>
<div>[[文件:Orange-pi-rk3399-img32.png|600px|]]</div>
<br>
After compiling u-boot and kernel source code,the final generated file will be stored in the output directory<br>
<br>
'''Uboot image'''
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ tree -L 1 output/u-boot/<br>
├── idbloader.img<br>
├── rk3399_loader_v1.08.106.bin<br>
├── trust.img<br>
└── uboot.img<br>
<br>
0 directories, 4 files
</div>
<br>
'''Kernel image'''
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ tree -L 1 output/kernel/<br>
output/kernel/<br>
├── Image<br>
└── rk3399-orangepi.dtb<br>
<br>
0 directories, 2 files
</div>
<br>
Rootfs Compilation<br>
<br>
Refer to the chapter "Building a Compilation Environment and Making a Rootfs Image"<br>
<br>
Execute the following steps to package the images of all partitions into one complete firmware:<br>
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ cd scripts
</div>
<br>
Package Image and extlinux configuration files to generate boot.img, path in the output folder<br>
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
$ ./mk-image.sh -c rk3399 -t boot -f emmc
</div>
<br>
c for chip,represent chip<br>
<br>
t for target,represent the generated image name <br>
<br>
s for size,represent the pre-allocated size when making the firmware (does not represent the actual final firmware size, the final firmware will be dynamically re-adjusted), unit Mbyte<br>
<br>
r for rootfs,represent the used rootfs path<br>
<br>
After the execution is completed, system.img is generated in the out directory as the final complete firmware.<br>
<br>
=== '''Linux firmware flashing''' ===
<br>
Flash the complete linux firmware to the EMMC<br>
<br>
1.Connect the DC power supply while short-connecting the Clk and GND of the EMMC. Enter the Maskrom mode. EMMC Clk is on the lower left corner of the miniPCIe on the back of the board shown as following picture<br>
<br>
<div>[[文件:Orange-pi-rk3399-img11.png|600px|]]</div>
<br>
<div>[[文件:Orange-pi-rk3399-img12.png|600px|]]</div>
<br>
2.Connect the TypeC line<br>
3.Execute the following command to flash <br>
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
./flash_tool.sh -c rk3399 -p system -i ../output/system.img
</div>
<br>
c for chip,represent the chip model <br>
p for partation,represent Partition,such as boot loader1 system <br>
i for image,represent the image path<br>
You can also flash different partitions separately, such as
Separately flash boot:<br>
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
./flash_tool.sh -c rk3399 -p boot -i ../output//boot.img
</div>
<br>
Separately flash uboot:<br>
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
./flash_tool.sh -p loader1 -i ../output/u-boot/idbloader.img -c rk3399<br>
./flash_tool.sh -p loader2 -i ../output/u-boot/uboot.img -c rk3399
</div>
<br>
Flash the linux image published in the official website<br>
<br>
<div style="background:#f1f1f1;border:1px solid #ddd;padding:5px;">
./flash_tool.sh -c rk3399 -p system -i \<br>
OrangePi_rk3399_xenial_desktop_v1.0.img
</div>
<br>

Navigation menu