|
| 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. |
0 commit comments