Device Development Quick Start
To help developers quickly get started with M4R1 device development, this tutorial describes how to quickly build a development environment and perform device development using the VM image file we produced for the M4R1 device development environment.
Tips
All related materials have been uploaded to Baidu Netdisk. Developers can jump to Baidu Netdisk for download via the download link in Downloads.
0 Preface
Because the produced VM image file and the virtual-machine disk space required for compiling source code are very large, it is recommended to reserve 400-500G of disk space.
1 VM Image File Acquisition
- Baidu Netdisk provides M4R1_VMIMAGE_OH5.0_V1.0.zip, the compressed package of the VM image file. Download the compressed package.
Because it contains the ubuntu system and related development environment dependencies, the VM image file is large, about 46G. Please prepare enough space to download it.

Note
DevEco Studio installation package path: 05-Development Materials>01-OpenHarmory Development Materials>VM Image File>M4R1_VMIMAGE_OH5.0_V1.0.zip
- After the download is complete, extract the compressed package. If disk space is tight, you can delete the compressed package after extraction. After extraction, the internal files include an mf file, an ovf file, and a vmdk file.

2 Import the ovf File into VM
1) Open VM, select [File -> Open] from the menu bar.

2) In the popup window, find the folder you just extracted, select the ovf file inside, and click [Open].

3) In the new popup window [Import Virtual Machine], fill in the new virtual machine name and select the storage path. Click [Import] when done.

Note
The storage path should be at least 300GB. If you need to perform other operations on the image, you will need more space.
4) After completing the above operations, it will show Importing. Wait for the import to complete.

Note
To ensure that developers can complete the installation, the VM image file reserves a virtual-machine disk size of 200G, which is the extreme disk size for compiling source code. Anything smaller than this may cause compilation to fail. The storage disk space should be at least 300GB. The method to expand VM space can be searched online.
We will later release a VM image compressed package with a default disk space of 300GB as the default image.
5) After the import is complete, you can see the basic settings. Click [Edit Virtual Machine Settings] to modify the settings.

6) Adjust the memory size to 16GB. As shown, click [16GB]. After you see this virtual machine memory is 16384MB, click [OK].

You can see the virtual machine memory setting show as 16GB.

Note
The decompression and compilation time is related to the memory and number of threads. For better performance release and faster decompression and compilation, you need to increase the memory and the number of core threads of the virtual machine.
3 Extract the Source Code
1) Click the green play button on the VM interface to start the virtual machine.

Wait for the virtual machine to start. When the login interface below appears, the virtual machine has started successfully.

Click the user, and a password input box appears. Enter the password in the password box to enter the ubuntu desktop.
Account Information
Username: shimetapi Default password: 123456

2) Click the nine small dots below. After entering the interface, select [Terminal] to enter the terminal.


3) After entering the terminal, type the following command to check whether the source code compressed package exists.
lsAs shown in the figure below, if M4R1_OH5.0_V1.0.tar.gz is present, the source code compressed package exists.

4) Type the following command to extract the compressed package.
tar -zxvf M4R1_OH5.0_V1.0.tar.gzWait for the extraction to complete.
4 Compile the Source Code
After extraction is complete, type the following command to start compiling the source code.
cd OpenHarmony
./build.sh --product-name rk3568 --ccacheWhen compilation is complete, the following information is displayed, showing the compilation time. Because the example compiles with the minimum-requirement configuration, the compilation time is long.

5 Package the Firmware
After the source code compilation is complete, type the following command to package the firmware.
./build_package.sh