Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.3)
project(qemu_dev)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

file(GLOB_RECURSE src "*.c" ".h")

set(SOURCES
${src})


add_executable(qemu_dev ${SOURCES})
target_compile_options(qemu_dev PRIVATE -iquote "${CMAKE_CURRENT_SOURCE_DIR}/include")
#target_include_directories(qemu_dev PRIVATE include)

8 changes: 8 additions & 0 deletions Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ storage-daemon-obj-y += blockdev.o blockdev-nbd.o iothread.o job-qmp.o
storage-daemon-obj-$(CONFIG_WIN32) += os-win32.o
storage-daemon-obj-$(CONFIG_POSIX) += os-posix.o

crypto-obj-y = crypto/
crypto-aes-obj-y = crypto/

#######################################################################
# qom-obj-y is code used by both qemu system emulation and qemu-img

qom-obj-y = qom/

######################################################################
# Target independent part of system emulation. The long term path is to
# suppress *all* target specific code in case of system emulation, i.e. a
Expand Down
136 changes: 136 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Pebble Smartwatch QEMU Implementation

## Overview
This is a derivative of QEMU v2.1.1 that has been modified to include an implementation of the STM32F2xx microcontroller.
This is based off of a QEMU fork that is targeting the STM32F103: https://github.com/beckus/qemu_stm32.
This repo contains both beckus' STM32F1xx implementation and Pebble's STM32F2xx additions.

__DANGER DANGER: It is very much a work-in-progress! Only some of the peripherals are working at the moment. Please contribute!__

## Dependencies
QEMU requires that development packages for glib20 and pixman are installed.

### FreeBSD
Install the `devel/glib20` and `x11/pixman` ports.

### Linux

### Mac OS X

### Windows

## Building
Commands for a typical build:

./configure --disable-werror --enable-debug --target-list="arm-softmmu" \
--extra-cflags=-DSTM32_UART_NO_BAUD_DELAY
make

Summary set of configure options that are useful when developing (tested only on OS X 10.9.5):

./configure --enable-tcg-interpreter --extra-ldflags=-g \
--with-coroutine=gthread --enable-debug-tcg --enable-cocoa \
--enable-debug --disable-werror --target-list="arm-softmmu" \
--extra-cflags=-DDEBUG_CLKTREE --extra-cflags=-DDEBUG_STM32_RCC \
--extra-cflags=-DDEBUG_STM32_UART --extra-cflags=-DSTM32_UART_NO_BAUD_DELAY \
--extra-cflags=-DDEBUG_GIC

####Configure options which control the STM32 implementation:

--extra-cflags=-DDEBUG_CLKTREE
Print out clock tree debug statements.

--extra-cflags=-DDEBUG_STM32_RCC
Print RCC debug statements.

--extra-cflags=-DDEBUG_STM32_UART
Print UART debug statements.

--extra-cflags=-DSTM32_UART_NO_BAUD_DELAY
Disable the BAUD rate timing simulation
(i.e. the UART will transmit or receive as fast as possible, rather than
using a realistic delay).

--extra-cflags=-DSTM32_UART_ENABLE_OVERRUN
Enable setting of the overrun flag if a character is
received before the last one is processed. If this is not set, the UART
will not receive the next character until the previous one is read by
software. Although less realisitic, it is safer NOT to use this, in case the VM is
running slow.

####Other QEMU configure options which are useful for troubleshooting:
--extra-cflags=-DDEBUG_GIC
Extra logging around which interrupts are asserted

####qemu-system-arm options which are useful for troubleshooting:
-d ?
To see available log levels

-d cpu,in_asm
Enable logging to view the CPU state during execution and the ARM
instructions which are being executed. I believe --enable-debug must be
used for this to work.


Useful make commands when rebuilding:

make defconfig
make clean

## Generating Images
* Use `./waf build qemu_image_spi` to generate `qemu_spi_flash.bin` from tintin.
* Use `./waf build qemu_image_micro` to generate `qemu_micro_flash.bin` from tintin.


### Under the covers of the images

QEMU's -pflash argument is used to specify a file to use as the micro flash.
An image can be created by concatenating the boot and main firmware files,
like so:

truncate -s 64k tintin_boot.bin
cat tintin_boot.bin tintin_fw.bin > micro_flash.bin
truncate -s 512k micro_flash.bin

## Running
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`.

### More details about running QEMU

The generated executable is arm-softmmu/qemu-system-arm .

Example:

qemu-system-arm -rtc base=localtime -machine pebble-bb2 -cpu cortex-m3 -s \
-pflash qemu_micro_flash.bin -mtdblock qemu_spi_flash.bin

Adding `-S` to the commandline will have QEMU wait in the monitor at start;
the _c_ontinue command is necessary to start the virtual CPU.

## QEMU Docs
Read original the documentation in qemu-doc.html or on http://wiki.qemu.org

## QEMU Modifications
This emulator consists largely of new hardware device models; it includes
only minor changes to existing QEMU functionality.

The changes can be reviewed by running `git diff --diff-filter=M v1.5.0-backports`.

To list the added files, use `git diff --name-only --diff-filter=A v1.5.0-backports`.

## License

The following points clarify the QEMU license:

1. QEMU as a whole is released under the GNU General Public License

2. Parts of QEMU have specific licenses which are compatible with the
GNU General Public License. Hence each source file contains its own
licensing information.

Many hardware device emulation sources are released under the BSD license.

3. The Tiny Code Generator (TCG) is released under the BSD license
(see license headers in files).

4. QEMU is a trademark of Fabrice Bellard.
Binary file added assets/qemu-spalding-overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/qemu-spalding-overlay.psd
Binary file not shown.
11 changes: 11 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ tpm=""
libssh=""
live_block_migration="yes"
numa=""
mouse="yes"
tcmalloc="no"
jemalloc="no"
replication="yes"
Expand Down Expand Up @@ -1501,6 +1502,8 @@ for opt do
;;
--enable-libxml2) libxml2="yes"
;;
--disable-mouse) mouse="no"
;;
--disable-tcmalloc) tcmalloc="no"
;;
--enable-tcmalloc) tcmalloc="yes"
Expand Down Expand Up @@ -6251,6 +6254,13 @@ case "$slirp" in
esac


##########################################
# check for mouse support

if test "$mouse" = "no"; then
CFLAGS="-DNO_MOUSE $CFLAGS"
fi

##########################################
# End of CC checks
# After here, no more $cc or $ld runs
Expand Down Expand Up @@ -6733,6 +6743,7 @@ echo "default devices $default_devices"
echo "plugin support $plugins"
echo "fuzzing support $fuzzing"
echo "gdb $gdb_bin"
echo "Mouse support $mouse"

if test "$supported_cpu" = "no"; then
echo
Expand Down
39 changes: 39 additions & 0 deletions default-configs/arm-softmmu.mak
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,44 @@
# TODO: ARM_V7M is currently always required - make this more flexible!
CONFIG_ARM_V7M=y

# CONFIG_ISA_MMIO=y
# CONFIG_ECC=y
# CONFIG_SERIAL=y
# CONFIG_PTIMER=y
# CONFIG_SD=y
# CONFIG_MAX7310=y
# CONFIG_WM8750=y
# CONFIG_TWL92230=y
# CONFIG_TSC2005=y
# CONFIG_LM832X=y
# CONFIG_TMP105=y
# CONFIG_STELLARIS=y
# CONFIG_STELLARIS_INPUT=y
# CONFIG_STELLARIS_ENET=y
# CONFIG_STM32=y
# CONFIG_SSD0303=y
# CONFIG_SSD0323=y
# CONFIG_LS013B7DH01=y
# CONFIG_PEBBLE_SNOWY_DISPLAY=y
# CONFIG_ADS7846=y
# CONFIG_MAX111X=y
# CONFIG_SSI=y
# CONFIG_SSI_SD=y
# CONFIG_SSI_M25P80=y
# CONFIG_LAN9118=y
# CONFIG_SMC91C111=y
# CONFIG_ALLWINNER_EMAC=y
# CONFIG_IMX_FEC=y
# CONFIG_DS1338=y
# CONFIG_PFLASH_CFI01=y
# CONFIG_PFLASH_CFI02=y
# CONFIG_PFLASH_JEDEC_424=y
# CONFIG_MICRODRIVE=y
# CONFIG_USB=y
# CONFIG_USB_MUSB=y
# CONFIG_USB_EHCI_SYSBUS=y
# CONFIG_PLATFORM_BUS=y

# CONFIG_PCI_DEVICES=n
# CONFIG_TEST_DEVICES=n

Expand Down Expand Up @@ -42,3 +80,4 @@ CONFIG_FSL_IMX7=y
CONFIG_FSL_IMX6UL=y
CONFIG_SEMIHOSTING=y
CONFIG_ALLWINNER_H3=y
CONFIG_STM32=y
4 changes: 4 additions & 0 deletions hw/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,7 @@ config ARMSSE_CPUID

config ARMSSE_MHU
bool

config STM32
bool
select ARM_V7M
19 changes: 19 additions & 0 deletions hw/arm/Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,22 @@ obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o
obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o
obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o mcimx6ul-evk.o
obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o

obj-y += stm32.o stm32_rcc.o stm32_clktree.o stm32_p103.o
obj-y += stm32f1xx.o stm32f2xx.o stm32f4xx.o stm32f7xx.o stm32_flash.o
obj-y += stm32f1xx_rcc.o stm32f2xx_rcc.o
obj-y += stm32f2xx_gpio.o stm32f2xx_adc.o
obj-y += stm32_exti.o stm32f2xx_syscfg.o
obj-y += stm32f2xx_rtc.o
obj-y += stm32f2xx_flash.o
obj-y += stm32f2xx_dummy.o
obj-y += stm32f2xx_tim.o stm32f7xx_lptim.o
obj-y += stm32f2xx_i2c.o stm32f7xx_i2c.o
obj-y += stm32f2xx_crc.o
obj-y += stm32f2xx_dma.o
obj-y += stm32f2xx_pwr.o
obj-y += pebble.o
obj-y += pebble_control.o
obj-y += pebble_robert.o
obj-y += pebble_silk.o

Loading