README.md
1### Qemu Arm Cortex-m55 mps3-an547 HOWTO
2
3#### 1. Brief introduction
4`arm_mps3_an547/` subdirectory contains part of the OpenHarmony LiteOS demonstration support for Qemu Arm Cortex-m55 mps3-an547 Platform, here called *arm_mps3_an547*.
5cortex-m55 Virtual platform is a `qemu-system-arm` machine target that provides emulation
6for a generic, arm-based board.
7
8Introduced functionality adds support for Cortex-m55 (1 CPU with security extensions), 16MB memory virtual platform.
9
10Note: System memory size is hard-coded to 16MB.
11
12#### 2. Setting up environment
13
14[Setting up a development environment](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/quick-start/quickstart-lite-env-setup.md)
15
16Compiler install
17
181.Command to install
19
20Note: Command to install toolchain without arm-none-eabi-gdb, gdb cannot be debugged.
21
22```
23sudo apt install gcc-arm-none-eabi
24```
25
262.The installation package to install
27
28Note: The MVE feature of cortex-m55 processor can only be supported by installing the cross tool chain launched after 2020. If you have already passed the command to install gcc-arm-none-eabi, can through the command: `sudo apt remove
29gcc-arm-none-eabi` after unloading, install again.
30
31Download toolchain: [package](https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2)。
32
33```
34chmod 777 gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
35tar -xvf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 install_path
36```
37
38Add the installation path to the environment variable:
39
40```
41vim ~/.bashrc
42```
43
44Add the following command line to the last line of ~/.bashrc:
45
46```
47export PATH=$PATH:install_path/gcc-arm-none-eabi-10.3-2021.10/bin
48```
49
50#### 3. Code acquisition
51
52[Code acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md)
53
54Note: One can use `repo` to fetch code in a straightforward manner.
55
56#### 4. Building from sources
57
58In the root directory of the obtained source code, run the following command:
59
60```
61hb set
62```
63
64Select `qemu_cm55_mini_system_demo` under **ohemu**.
65
66Run the following build command:
67```
68hb build -f
69```
70
71This will build `OHOS_Image` for Qemu Cortex-m55 mps3-an547 machine.
72
73
74After build is finished, the resulting image can be found in:
75```
76out/arm_mps3_an547/qemu_cm55_mini_system_demo/
77```
78#### 5. Running image in Qemu
79
80Note: The MVE feature of cortex-m55 processor can only be supported by installing QEMU version 6.2.0.
81
82a) If not installed, please install `qemu-system-arm`
83For details, please refer to the HOWTO: [Qemu installation](https://gitee.com/openharmony/device_qemu/blob/HEAD/README.md)
84
85b) Run
86
87Run the `./qemu-run --help` command. The following information is displayed:
88
89```
90Usage: qemu-run [OPTION]...
91Run a OHOS image in qemu according to the options.
92
93 Options:
94
95 -e, --exec file_name kernel exec file name
96 -g, --gdb enable gdb for kernel
97 -t, --test test mode, exclusive with -g
98 -h, --help print help info
99
100 By default, the kernel exec file is: out/arm_mps3_an547/qemu_cm55_mini_system_demo/OHOS_Image.
101```
102
103#### 6. gdb debug
104
105```
106cd device/qemu/arm_mps3_an547
107vim liteos_m/config.gni
108```
109
110In the modified `board_opt_flags` compiler options:
111
112```
113board_opt_flags = []
114```
115to:
116
117```
118board_opt_flags = [ "-g" ]
119```
120
121Save and exit, recompile under OHOS root directory:
122
123```
124hb build -f
125```
126
127In a window to enter the command:
128
129```
130./qemu-run -g
131```
132
133In another window to enter the command:
134
135```
136arm-none-eabi-gdb out/arm_mps3_an547/qemu_cm55_mini_system_demo/OHOS_Image
137(gdb) target remote localhost:1234
138(gdb) b main
139```
140
141More GDB related debugging can refer to [GDB instruction manual](https://sourceware.org/gdb/current/onlinedocs/gdb).
142