Project

General

Profile

Getting Started » History » Version 1

Sergey Smolov, 05/16/2018 04:32 PM

1 1 Sergey Smolov
h1. Getting Started
2
3
{{toc}}
4
5
h2. Aarch64
6
7
It is supposed that the following tools are successfully installed in your system:
8
- Toolchain for Aarch64 assembler programs compilation, linking, etc. (can be downloaded from "Linaro website":http://releases.linaro.org/components/toolchain/binaries or just below, installation instruction is "here":http://forge.ispras.ru/projects/microtesk-armv8/wiki/Toolchain).
9
10
# First of all, let's write a simple Aarch64 program (it is called @sample.s@ and is attached below) that does nothing but puts 0x10 value to X0 register and then halts. Here it is:
11
<pre>
12
.text
13
	.globl _start
14
	bl _start
15
_start:
16
	movz x1, #0x10, LSL #0
17
	hlt #57005
18
</pre>
19
# To compile the Aarch64 assembler program called @sample.s@, do the following:
20
<pre>
21
aarch64-linux-gnu-as sample.s -o sample.o
22
aarch64-linux-gnu-ld sample.o -o sample.elf
23
aarch64-linux-gnu-objcopy -O binary sample.elf sample.bin
24
</pre>
25
# Finally, run _QEMU4V_ emulator with enabled option of microprocessor execution trace logging:
26
<pre>
27
qemu-system-aarch64 -M virt -cpu cortex-a57 -bios sample.bin -d nochain,in_asm -singlestep -nographic -trace-log -D log-file.txt
28
</pre>
29
# Wait for a while, then stop QEMU by hands (_NOTE_: neither Ctrl-C nor Ctrl-Z works, use 'kill <process-id>' or 'killall qemu-system*', for example). The following @log-file.txt@ trace file should be generated:
30
<pre>
31
0 clk IT (0) 0000000000000000 94000001 A svc_ns : bl #+0x4 (addr 0x4)
32
1 clk IT (1) 0000000000000004 d2800201 A svc_ns : movz x1, #0x10, LSL #0
33
2 clk IT (2) 0000000000000008 d45bd5a0 A svc_ns : hlt #57005
34
</pre>
35
36
h2. RISC-V
37
38
It is supposed that the following tools are successfully installed in your system:
39
- Toolchain for RISC-V assembler programs compilation, linking, etc. (the source code and the installation guide are available "here":https://github.com/riscv/riscv-gnu-toolchain).
40
41
# First of all, let's write a simple RISC-V program (it is called @sample.s@ and is attached below) that does nothing but puts 0x18 value to @t1@ register and puts 0x21 value to @t2@ register. Here it is:
42
<pre>
43
.text
44
.globl _start
45
_start:
46
 addi t1, zero, 0x18
47
 addi t2, zero, 0x21
48
</pre>
49
# To compile the RISC-V assembler program called @sample.s@, do the following:
50
<pre>
51
aarch64-linux-gnu-as sample.s -o sample.o
52
aarch64-linux-gnu-ld sample.o -Ttext 0x1000 -o sample.elf
53
</pre>
54
# Finally, run _QEMU4V_ emulator with enabled option of microprocessor execution trace logging (0x1000 value was used by linker because of QEMU-related features):
55
<pre>
56
qemu-system-riscv64 -M spike -cpu any -d unimp,nochain,in_asm -nographic -singlestep -trace-log -kernel sample.elf
57
</pre>
58
# Wait for a while, then stop QEMU by hands (_NOTE_: neither Ctrl-C nor Ctrl-Z works, use 'kill <process-id>' or 'killall qemu-system*', for example). The following trace should be generated:
59
<pre>
60
0 clk 0 IT (0) 0000000000001000 01800313 A svc_ns : li t1,24
61
1 clk R t1 0000000000000018
62
1 clk 0 IT (1) 0000000000001004 02100393 A svc_ns : li t2,33
63
2 clk R t2 0000000000000021
64
2 clk 0 IT (2) 0000000000001008 00000000 A svc_ns : unimp
65
3 clk 0 IT (3) 0000000000001010 00000000 A svc_ns : unimp
66
</pre>