Skip to content

Commit 93d949e

Browse files
committed
Original Pebble changes
1 parent fdd76fe commit 93d949e

File tree

122 files changed

+97250
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+97250
-34
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.3)
2+
project(qemu_dev)
3+
4+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
5+
6+
file(GLOB_RECURSE src "*.c")
7+
8+
set(SOURCES
9+
${src})
10+
11+
include_directories(include)
12+
13+
add_custom_target(qemu_dev COMMAND make
14+
CLION_EXE_DIR=${PROJECT_BINARY_DIR})
15+

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ qemu-version.h: FORCE
494494

495495
config-host.h: config-host.h-timestamp
496496
config-host.h-timestamp: config-host.mak
497+
<<<<<<< HEAD
497498
qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
498499
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
499500

@@ -510,6 +511,27 @@ $(SOFTMMU_ALL_RULES): config-all-devices.mak
510511
ifdef DECOMPRESS_EDK2_BLOBS
511512
$(SOFTMMU_ALL_RULES): $(edk2-decompressed)
512513
endif
514+
=======
515+
qemu-options.def: $(SRC_PATH)/qemu-options.hx
516+
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $@")
517+
518+
SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
519+
SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
520+
521+
$(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
522+
$(SOFTMMU_SUBDIR_RULES): $(crypto-obj-y)
523+
$(SOFTMMU_SUBDIR_RULES): $(qom-obj-y)
524+
$(SOFTMMU_SUBDIR_RULES): config-all-devices.mak
525+
526+
subdir-%:
527+
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
528+
529+
subdir-pixman: pixman/Makefile
530+
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pixman V="$(V)" all,)
531+
532+
pixman/Makefile: $(SRC_PATH)/pixman/configure
533+
(cd pixman; CFLAGS="$(CFLAGS) -fPIC $(extra_cflags) $(extra_ldflags)" $(SRC_PATH)/pixman/configure $(AUTOCONF_HOST) --disable-gtk --disable-shared --enable-static)
534+
>>>>>>> 919b29ba7d... Pebble Qemu
513535

514536
SOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES))
515537
$(SOFTMMU_FUZZ_RULES): $(authz-obj-y)

Makefile.objs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#######################################################################
22
# Common libraries for tools and emulators
33
stub-obj-y = stubs/
4+
<<<<<<< HEAD
45
util-obj-y = crypto/ util/ qobject/ qapi/
56
qom-obj-y = qom/
7+
=======
8+
util-obj-y = util/ qobject/ qapi/
9+
util-obj-y += crypto/
10+
util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
11+
>>>>>>> 919b29ba7d... Pebble Qemu
612

713
#######################################################################
814
# code used by both qemu system emulation and qemu-img
@@ -36,6 +42,14 @@ storage-daemon-obj-y += blockdev.o blockdev-nbd.o iothread.o job-qmp.o
3642
storage-daemon-obj-$(CONFIG_WIN32) += os-win32.o
3743
storage-daemon-obj-$(CONFIG_POSIX) += os-posix.o
3844

45+
crypto-obj-y = crypto/
46+
crypto-aes-obj-y = crypto/
47+
48+
#######################################################################
49+
# qom-obj-y is code used by both qemu system emulation and qemu-img
50+
51+
qom-obj-y = qom/
52+
3953
######################################################################
4054
# Target independent part of system emulation. The long term path is to
4155
# suppress *all* target specific code in case of system emulation, i.e. a

README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Pebble Smartwatch QEMU Implementation
2+
3+
## Overview
4+
This is a derivative of QEMU v2.1.1 that has been modified to include an implementation of the STM32F2xx microcontroller.
5+
This is based off of a QEMU fork that is targeting the STM32F103: https://github.com/beckus/qemu_stm32.
6+
This repo contains both beckus' STM32F1xx implementation and Pebble's STM32F2xx additions.
7+
8+
__DANGER DANGER: It is very much a work-in-progress! Only some of the peripherals are working at the moment. Please contribute!__
9+
10+
## Dependencies
11+
QEMU requires that development packages for glib20 and pixman are installed.
12+
13+
### FreeBSD
14+
Install the `devel/glib20` and `x11/pixman` ports.
15+
16+
### Linux
17+
18+
### Mac OS X
19+
20+
### Windows
21+
22+
## Building
23+
Commands for a typical build:
24+
25+
./configure --disable-werror --enable-debug --target-list="arm-softmmu" \
26+
--extra-cflags=-DSTM32_UART_NO_BAUD_DELAY
27+
make
28+
29+
Summary set of configure options that are useful when developing (tested only on OS X 10.9.5):
30+
31+
./configure --enable-tcg-interpreter --extra-ldflags=-g \
32+
--with-coroutine=gthread --enable-debug-tcg --enable-cocoa \
33+
--enable-debug --disable-werror --target-list="arm-softmmu" \
34+
--extra-cflags=-DDEBUG_CLKTREE --extra-cflags=-DDEBUG_STM32_RCC \
35+
--extra-cflags=-DDEBUG_STM32_UART --extra-cflags=-DSTM32_UART_NO_BAUD_DELAY \
36+
--extra-cflags=-DDEBUG_GIC
37+
38+
####Configure options which control the STM32 implementation:
39+
40+
--extra-cflags=-DDEBUG_CLKTREE
41+
Print out clock tree debug statements.
42+
43+
--extra-cflags=-DDEBUG_STM32_RCC
44+
Print RCC debug statements.
45+
46+
--extra-cflags=-DDEBUG_STM32_UART
47+
Print UART debug statements.
48+
49+
--extra-cflags=-DSTM32_UART_NO_BAUD_DELAY
50+
Disable the BAUD rate timing simulation
51+
(i.e. the UART will transmit or receive as fast as possible, rather than
52+
using a realistic delay).
53+
54+
--extra-cflags=-DSTM32_UART_ENABLE_OVERRUN
55+
Enable setting of the overrun flag if a character is
56+
received before the last one is processed. If this is not set, the UART
57+
will not receive the next character until the previous one is read by
58+
software. Although less realisitic, it is safer NOT to use this, in case the VM is
59+
running slow.
60+
61+
####Other QEMU configure options which are useful for troubleshooting:
62+
--extra-cflags=-DDEBUG_GIC
63+
Extra logging around which interrupts are asserted
64+
65+
####qemu-system-arm options which are useful for troubleshooting:
66+
-d ?
67+
To see available log levels
68+
69+
-d cpu,in_asm
70+
Enable logging to view the CPU state during execution and the ARM
71+
instructions which are being executed. I believe --enable-debug must be
72+
used for this to work.
73+
74+
75+
Useful make commands when rebuilding:
76+
77+
make defconfig
78+
make clean
79+
80+
## Generating Images
81+
* Use `./waf build qemu_image_spi` to generate `qemu_spi_flash.bin` from tintin.
82+
* Use `./waf build qemu_image_micro` to generate `qemu_micro_flash.bin` from tintin.
83+
84+
85+
### Under the covers of the images
86+
87+
QEMU's -pflash argument is used to specify a file to use as the micro flash.
88+
An image can be created by concatenating the boot and main firmware files,
89+
like so:
90+
91+
truncate -s 64k tintin_boot.bin
92+
cat tintin_boot.bin tintin_fw.bin > micro_flash.bin
93+
truncate -s 512k micro_flash.bin
94+
95+
## Running
96+
There is a convenience script `pebble.sh` that runs QEMU. It depends on the existence of (symlinked) images `qemu_micro_flash.bin` and `qemu_spi_flash.bin`.
97+
98+
### More details about running QEMU
99+
100+
The generated executable is arm-softmmu/qemu-system-arm .
101+
102+
Example:
103+
104+
qemu-system-arm -rtc base=localtime -machine pebble-bb2 -cpu cortex-m3 -s \
105+
-pflash qemu_micro_flash.bin -mtdblock qemu_spi_flash.bin
106+
107+
Adding `-S` to the commandline will have QEMU wait in the monitor at start;
108+
the _c_ontinue command is necessary to start the virtual CPU.
109+
110+
## QEMU Docs
111+
Read original the documentation in qemu-doc.html or on http://wiki.qemu.org
112+
113+
## QEMU Modifications
114+
This emulator consists largely of new hardware device models; it includes
115+
only minor changes to existing QEMU functionality.
116+
117+
The changes can be reviewed by running `git diff --diff-filter=M v1.5.0-backports`.
118+
119+
To list the added files, use `git diff --name-only --diff-filter=A v1.5.0-backports`.
120+
121+
## License
122+
123+
The following points clarify the QEMU license:
124+
125+
1. QEMU as a whole is released under the GNU General Public License
126+
127+
2. Parts of QEMU have specific licenses which are compatible with the
128+
GNU General Public License. Hence each source file contains its own
129+
licensing information.
130+
131+
Many hardware device emulation sources are released under the BSD license.
132+
133+
3. The Tiny Code Generator (TCG) is released under the BSD license
134+
(see license headers in files).
135+
136+
4. QEMU is a trademark of Fabrice Bellard.

README.rst

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,77 @@
1+
<<<<<<< HEAD:README.rst
12
===========
23
QEMU README
34
===========
5+
=======
6+
QEMU with STM32 Microcontroller Implementation
7+
8+
Official Homepage: http://beckus.github.io/qemu_stm32/
9+
10+
OVERVIEW
11+
This is a copy of QEMU that has been modified to include an implementation
12+
of the STM32 microcontroller. It also implements an Olimex STM32_P103
13+
developmentvboard. This project runs the demos located in the
14+
stm32_p103_demos project located at: https://github.com/beckus/stm32_p103_demos .
15+
16+
Commands for a typical build:
17+
./configure --enable-debug --target-list="arm-softmmu"
18+
make
19+
20+
Useful make commands when rebuilding:
21+
make defconfig
22+
make clean
23+
24+
The generated executable is arm-softmmu/qemu-system-arm .
25+
26+
Other configure options which control the STM32 implementation:
27+
28+
--extra-cflags=-DDEBUG_CLKTREE
29+
Print out clock tree debug statements.
30+
31+
--extra-cflags=-DDEBUG_STM32_RCC
32+
Print RCC debug statements.
33+
34+
--extra-cflags=-DDEBUG_STM32_UART
35+
Print UART debug statements.
36+
37+
--extra-cflags=-DSTM32_UART_NO_BAUD_DELAY
38+
Disable the BAUD rate timing simulation
39+
(i.e. the UART will transmit or receive as fast as possible, rather than
40+
using a realistic delay).
41+
42+
--extra-cflags=-DSTM32_UART_ENABLE_OVERRUN
43+
Enable setting of the overrun flag if a character is
44+
received before the last one is processed. If this is not set, the UART
45+
will not receive the next character until the previous one is read by
46+
software. Although less realisitic, this is safer in case the VM is
47+
running slow.
48+
49+
Other QEMU configure options which are useful for troubleshooting:
50+
--extra-cflags=-DDEBUG_GIC
51+
52+
qemu-system-arm options which are useful for trobuleshooting:
53+
-d ?
54+
To see available log levels
55+
56+
-d cpu,in_asm
57+
Enable logging to view the CPU state during execution and the ARM
58+
instructions which are being executed. I believe --enable-debug must be
59+
used for this to work.
60+
By default, you can find the output in /tmp/qemu.log:
61+
62+
UNIT TESTING
63+
Unit test scripts are included for the STM32 implementation.
64+
These test will be executed when running "make" with the standard
65+
check targets (see tests/Makefile for documentation of QEMU's unit
66+
testing features):
67+
make check
68+
make check-qtest-arm
69+
70+
71+
72+
The original QEMU README follows:
73+
74+
>>>>>>> 919b29ba7d... Pebble Qemu:README
475

576
QEMU is a generic and open source machine & userspace emulator and
677
virtualizer.

VERSION

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<<<<<<< HEAD
12
5.0.0
3+
=======
4+
2.5.0-pebble4
5+
>>>>>>> 919b29ba7d... Pebble Qemu

assets/qemu-spalding-overlay.png

3.76 KB
Loading

assets/qemu-spalding-overlay.psd

69.9 KB
Binary file not shown.

block/qcow2-cache.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,12 @@ int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c)
308308
c->entries[i].offset = 0;
309309
c->entries[i].lru_counter = 0;
310310
}
311+
<<<<<<< HEAD
311312

312313
qcow2_cache_table_release(c, 0, c->size);
314+
=======
315+
qcow2_cache_table_release(bs, c, 0, c->size);
316+
>>>>>>> 919b29ba7d... Pebble Qemu
313317

314318
c->lru_counter = 0;
315319

block/qcow2.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,11 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
12531253
Error *local_err = NULL;
12541254
uint64_t ext_end;
12551255
uint64_t l1_vm_state_index;
1256+
<<<<<<< HEAD
12561257
bool update_header = false;
1258+
=======
1259+
uint64_t l2_cache_size, refcount_cache_size;
1260+
>>>>>>> 919b29ba7d... Pebble Qemu
12571261

12581262
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
12591263
if (ret < 0) {
@@ -1516,6 +1520,11 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
15161520
if (ret < 0) {
15171521
goto fail;
15181522
}
1523+
if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) {
1524+
error_setg(errp, "Could not allocate metadata caches");
1525+
ret = -ENOMEM;
1526+
goto fail;
1527+
}
15191528

15201529
s->flags = flags;
15211530

0 commit comments

Comments
 (0)