• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# QEMU(Tutorials of C-SKY )
2
3## 1.Introduction
4
5QEMU can simulate the kernel to run on different boards, freeing the dependence on the physical development board.The `SmartL_E802/` subdirectory contains part of the OpenHarmony kernel\_liteos\_m code verified by the Qemu C-SKY virtualization platform,you can simulate a single board based on the C-SKY architecture.
6
7## 2.Setup Environment
8
9   1. Set up the Compilation tool chain
10
11      Tip: Users can also skip this step by using the following instructions directly to use the compiler configured in the default environment.
12
13      To use the default environment, execute '3.Get source code' and then install the default compiler in the root directory by executing the following instructions.
14
15         ```shell
16         sh build/prebuilts_download.sh
17         ```
18
19      Optional compiler installation process:
20
21      a) Create the `csky_toolchain` folder and enter it
22
23         ```shell
24         mkdir csky_toolchain && cd csky_toolchain
25         ```
26
27      b) Download  csky-elfabiv2-tools-x86_64-minilibc-20210423.tar.gz to `csky_toolchain`folder and unzip,download link: https://occ.t-head.cn/community/download?id=3885366095506644992
28
29         ```shell
30         wget https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource/1356021/1619529111421/csky-elfabiv2-tools-x86_64-minilibc-20210423.tar.gz
31         tar -xf csky-elfabiv2-tools-x86_64-minilibc-20210423.tar.gz
32         ```
33
34      c) Add the csky-elfabiv2 compilation tool chain to the environment variable (modify user_toolchain_xxx_path to your own installation path):
35
36         ```shell
37         vim ~/.bashrc
38         export PATH=$PATH:user_toolchain_xxx_path/csky_toolchain/bin
39         source ~/.bashrc
40         ```
41
42      d) Delete the default compiler path:
43
44         change SmartL_E802\liteos_m\config.gni:
45
46         ```c
47         board_toolchain_path = "$ohos_root_path/prebuilts/gcc/linux-x86/csky/csky/bin"
48         ```
49
50         to
51
52         ```c
53         board_toolchain_path = ""
54         ```
55
56   2. Install qemu
57
58      a) create `csky_qemu` folder and enter it
59
60         ```shell
61         mkdir csky_qemu && cd csky_qemu
62         ```
63
64      b) download csky-qemu-x86_64-Ubuntu-16.04-20210202-1445.tar.gz to `csky_qemu`folder and unzip,download link: https://occ.t-head.cn/community/download?id=636946310057951232
65
66         ```shell
67         wget https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource/1356021/1612269502091/csky-qemu-x86_64-Ubuntu-16.04-20210202-1445.tar.gz
68         tar -xf csky-qemu-x86_64-Ubuntu-16.04-20210202-1445.tar.gz
69         ```
70
71      c) Add qemu to the environment variable (modify user_qemu_xxx_path to your own installation path):
72
73         ```shell
74         vim ~/.bashrc
75         export PATH=$PATH:user_qemu_xxx_path/csky-qemu/bin
76         source ~/.bashrc
77         ```
78
79      d) Installation dependencies
80
81         ```shell
82         ldd qemu_installation_path/bin/qemu-system-cskyv2
83         ```
84
85         According to the execution result of ldd, install the missing dependent libraries
86
87         (Annotation: For more installation instructions, please refer to the following link: https://occ.t-head.cn/community/download?id=636946310057951232)
88
89## 3.Get source code
90
91[code acquisition ](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md)
92
93Hint : You can use the `repo` command to get the source code.
94
95## 4.Source buildding
96
97   1. Execute the hb set command and select the project`qemu_csky_mini_system_demo`.
98
99   2. Execute the hb clean && hb build command to build the executable file that produces `OHOS_Image`.
100
101      ```shell
102      hb set
103      hb clean && hb build
104      ```
105
106   3. After the buildding is complete,the corresponding executable file is in the home directory:
107
108      ```
109      out/SmartL_E802/qemu_csky_mini_system_demo/
110      ```
111
112## 5.Run the image in Qemu
113
114   1. Run qemu(Don't cooperate with GDB)
115
116      ```shell
117      ./qemu-run
118      ```
119
120   2. Run qemu(Cooperate with GDB)
121
122      a) Start the GDB server and wait for the connection
123
124         ```shell
125         ./qemu-run -g
126         ```
127
128      b) Create a new terminal and use GDB to connect to qemu
129
130         ```shell
131         csky-abiv2-elf-gdb out/SmartL_E802/qemu_csky_mini_system_demo/OHOS_Image -ex "target remote localhost:1234"
132         ```
133
134   Annotation: The way to exit qemu : press ctrl and a,then release and press x.
135