summary refs log tree commit diff stats
path: root/results/classifier/gemma3:12b/debug/1549654
blob: 90acbb14a0d725c1073db0b9964ab402dc74e5e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
qemu-system-arm emulator

Hi,

I don't know if this is a bug or a feature in new QEMU software. I was following an online tutorial using QEMU  to develop a simple bare-metal program for qemu-system-arm. I decided to try a more recent software and I got surprised when I found the small code can not run on newer QEMU software (all newer than 2.0.0) but can run on the old QEMU from Ubuntu (Debian 2.0.0+dfsg-2ubuntu1.22) and the stock version from website. After putting the qemu-system-arm in single step and saving the log, the following is the output which you can see the 1st instruction stores R3 at [fp, #-8] and the second instruction can not restores the value from the same address to R0:

0x00010074:  e50b3008      str	r3, [fp, #-8]

R00=00000000 R01=00000000 R02=00000000 R03=0001008c
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00011094
R12=00000000 R13=00011088 R14=00010008 R15=00010074
PSR=400001d3 -Z-- A S svc32
----------------
IN: kmain
0x00010078:  e51b0008      ldr	r0, [fp, #-8]

R00=00000000 R01=00000000 R02=00000000 R03=0001008c
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00011094
R12=00000000 R13=00011088 R14=00010008 R15=00010078
PSR=400001d3 -Z-- A S svc32
----------------
IN: kmain
0x0001007c:  ebffffe3      bl	0x10010

R00=00000000 R01=00000000 R02=00000000 R03=0001008c
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00011094
R12=00000000 R13=00011088 R14=00010008 R15=0001007c
PSR=400001d3 -Z-- A S svc32

--------------------------------------
Meanwhile the older version of QEMU 2.0.0 does this very well and can execute the program normally:

0x00010074:  e50b3008      str	r3, [fp, #-8]

R00=00000000 R01=00000000 R02=00000000 R03=0001008c
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00011094
R12=00000000 R13=00011088 R14=00010008 R15=00010074
PSR=400001d3 -Z-- A svc32
----------------
IN: kmain
0x00010078:  e51b0008      ldr	r0, [fp, #-8]

R00=00000000 R01=00000000 R02=00000000 R03=0001008c
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00011094
R12=00000000 R13=00011088 R14=00010008 R15=00010078
PSR=400001d3 -Z-- A svc32
----------------
IN: kmain
0x0001007c:  ebffffe3      bl	0x10010

R00=0001008c R01=00000000 R02=00000000 R03=0001008c
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00011094
R12=00000000 R13=00011088 R14=00010008 R15=0001007c
PSR=400001d3 -Z-- A svc32
----------------

The command line to use was:

qemu-system-arm -M vexpress-a9 -cpu cortex-a9 -smp 1 -m 64M -nographic -kernel kernel.elf -singlestep -D file.log -d in_asm,cpu

The kernel.elf is a simple program (elf) file, created from two sources:

boot.S:

.global _RESET
_RESET:
LDR sp, =_STACK
BL kmain
B .

And kernel.c:

# define UART0_MEM   0x10009000

volatile unsigned int * const UART0 = (unsigned int *) UART0_MEM;
void dprint(const char* message){
	while(*message != 0) {
		*UART0=*message;
		++message;
	}
}
void kmain() {
	const char *hi="Hello!";
	dprint(hi);
};

The linker scripts is:
ENTRY(_RESET)
SECTIONS
{
 . = 0x10000;
 .boot . : { boot.o(.text) }
 .text : { *(.text) }
 .data : { *(.data) }
 .bss : { *(.bss COMMON) }
 . = ALIGN(8);
 . = . + 0x1000; /* 4kB of stack memory */
 _STACK = .;
}

This error cases the dprint function to find *message as 0 and do not print the output in newer QEMU software.

Thank you for consideration.