arm: Add nRF51 SoC and micro:bit machine
v2 cover arm: Add nRF51 SoC and micro:bit machine
This short series implements a minimal definition of the Nordic Semiconductor nRF51, a Cortex-M0 ARM SoC, and the BBC micro:bit, a machine that will use this SoC.
This work will serve as the base for our Google Summer of Code and Outreachy interns who will work on implementing a number of features on top of this base.
I've tested this with a microbit micropython firmware, and checked that it starts running by looking at it with gdb.
I chose to keep the nrf51 and the microbit seperate, to not confuse the peripherals that are on the microbit but are not part of the nrf51, and vice versa.
v2: Addresses review from Peter and Stefan
Joel Stanley (3):
arm: Add Nordic Semiconductor nRF51 SoC
arm: Add BBC micro:bit machine
MAINTAINERS: Add NRF51 entry
MAINTAINERS | 8 +++ default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/microbit.c | 56 +++++++++++++++ hw/arm/nrf51_soc.c | 116 ++++++++++++++++++++++++++++++++ include/hw/arm/nrf51_soc.h | 41 +++++++++++ 6 files changed, 223 insertions(+) create mode 100644 hw/arm/microbit.c create mode 100644 hw/arm/nrf51_soc.c create mode 100644 include/hw/arm/nrf51_soc.h
Signature · 1 line
2.17.1
PATCH v2 1/3 arm: Add Nordic Semiconductor nRF51 SoC
The nRF51 is a Cortex-M0 microcontroller with an on-board radio module, plus other common ARM SoC peripherals.
http://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.pdf
This defines a basic model of the CPU and memory, with no peripherals implemented at this stage.
---
v2:
put memory as struct fileds in state structure
pass OBJECT(s) as owner, not NULL
Add missing addresses for ficr
Fix flash and sram sizes for microbit
Embed cpu object in state object an initalise it without use of armv7m_init Link to datasheet
--- default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/nrf51_soc.c | 116 ++++++++++++++++++++++++++++++++ include/hw/arm/nrf51_soc.h | 41 +++++++++++ 4 files changed, 159 insertions(+) create mode 100644 hw/arm/nrf51_soc.c create mode 100644 include/hw/arm/nrf51_soc.h
default-configs/arm-softmmu.mak +1 -0
@@ -101,6 +101,7 @@ CONFIG_STM32F2XX_SYSCFG=y CONFIG_STM32F2XX_ADC=y CONFIG_STM32F2XX_SPI=y CONFIG_STM32F205_SOC=y +CONFIG_NRF51_SOC=y CONFIG_CMSDK_APB_TIMER=y CONFIG_CMSDK_APB_UART=y
hw/arm/Makefile.objs +1 -0
@@ -36,3 +36,4 @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o obj-$(CONFIG_IOTKIT) += iotkit.o obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o +obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o
hw/arm/nrf51_soc.c new file +116 -0
116 lines not on this page · raw message
include/hw/arm/nrf51_soc.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v2 1/3] arm: Add Nordic Semiconductor nRF51 SoC
hw/arm/nrf51_soc.c line 38
Quoted 7 lines · Joel Stanley
hw/arm/nrf51_soc.c new file +7
-0+/* TODO: Flash size should be defined by the board. Microbit uses 256KB */ +#define FLASH_BASE 0x00000000 +#define FLASH_SIZE (256 * 1024) + +/* TODO: Flash size should be defined by the board. Microbit uses 16KB */ +#define SRAM_BASE 0x20000000 +#define SRAM_SIZE (16 * 1024)
Making FLASH_SIZE and SRAM_SIZE properties of the NRF51State object. Then microbit.c can set them.
hw/arm/nrf51_soc.c line 82
Quoted 7 lines
hw/arm/nrf51_soc.c new file +7
-0+static void nrf51_soc_init (Object *obj) +{ +NRF51State *s =NRF51_SOC (obj); + +memory_region_init (&s->container, obj,"nrf51-container" ,UINT64_MAX ); + +/* TODO: implement a cortex m0 and update this */
Please see "[PATCH v2 0/3] arm: add skeleton Cortex M0 CPU model". It should work with TYPE_ARMV7M -> TYPE_ARMV6M and "cortex-m3" -> "cortex-m0".
Julia is currently completing the Cortex M0 emulation but at this point guest software may already run successfully. If not, then the patches she sends over the next week or two ought to do the trick.
include/hw/arm/nrf51_soc.h line 26
Quoted 6 lines
include/hw/arm/nrf51_soc.h new file +6
-0+typedef struct NRF51State { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + char *kernel_filename;
Is this used by anything?
Re: [Qemu-arm] [PATCH v2 1/3] arm: Add Nordic Semiconductor nRF51 SoC
Quoted 11 lines · Stefan Hajnoczi
hw/arm/nrf51_soc.c line 38
Quoted 7 lines · Joel Stanley
hw/arm/nrf51_soc.c new file +7
-0+/* TODO: Flash size should be defined by the board. Microbit uses 256KB */ +#define FLASH_BASE 0x00000000 +#define FLASH_SIZE (256 * 1024) + +/* TODO: Flash size should be defined by the board. Microbit uses 16KB */ +#define SRAM_BASE 0x20000000 +#define SRAM_SIZE (16 * 1024)Making
FLASH_SIZEandSRAM_SIZEproperties of the NRF51State object. Thenmicrobit.ccan set them.
I chose not to do this, as they are properties of the SoC, not of the microbit machine.
If in the future someone wanted to support more than the NRF51822, they could make them properties and set them in a sub-class the NRF51.
I don't think this complexity is warranted while the only implemented machine is the NRF51822.
Quoted 9 lines
include/hw/arm/nrf51_soc.h line 26
Quoted 7 lines
include/hw/arm/nrf51_soc.h new file +6
-0+typedef struct NRF51State { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + char *kernel_filename;Is this used by anything?
I removed it in v3.
PATCH v2 2/3 arm: Add BBC micro:bit machine
In reply to Joel StanleyThis adds the base for a machine model of the BBC micro:bit:
https://en.wikipedia.org/wiki/Micro_Bit
This is a system with a nRF51 SoC containing the main processor, with various peripherals on board.
---
v2:
- Instead of setting kernel filename property, load the image directly
- Add link to hardware overview website
--- hw/arm/Makefile.objs | 2 +- hw/arm/microbit.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 hw/arm/microbit.c
hw/arm/Makefile.objs +1 -1
@@ -36,4 +36,4 @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o obj-$(CONFIG_IOTKIT) += iotkit.o obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o -obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o +obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o microbit.o
hw/arm/microbit.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v2 2/3] arm: Add BBC micro:bit machine
Quoted 15 lines · Joel Stanley
hw/arm/microbit.c new file +9
-0@@ -0,0 +1,56 @@ +/* +* BBC micro:bit machine +* http://tech.microbit.org/hardware/ +* +* Copyright 2018 Joel Stanley <[email protected]> +* +* This code is licensed under the GPL version 2 or later. See +* the COPYING file in the top-level directory. +*/
hw/arm/microbit.c line 19
Quoted 10 lines
hw/arm/microbit.c new file +10
-0+ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/boards.h" +#include "hw/arm/arm.h" +#include "exec/address-spaces.h" + +#include "hw/arm/nrf51_soc.h" + +#define FLASH_BASE 0x00000000
Unused, please remove.
Aside from that:
PATCH v2 3/3 MAINTAINERS: Add NRF51 entry
In reply to Joel StanleyThis contains the NRF51, and the machine that uses it, the BBC micro:bit.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -656,6 +656,14 @@ F: include/hw/*/*aspeed* F: hw/net/ftgmac100.c F: include/hw/net/ftgmac100.h +NRF51 +M: Joel Stanley <[email protected]> +L: [email protected] +S: Maintained +F: hw/arm/nrf51_soc.c +F: hw/arm/microbit.c +F: include/hw/arm/nrf51_soc.h + CRIS Machines ------------- Axis Dev88
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v2 3/3] MAINTAINERS: Add NRF51 entry
Quoted 13 lines · Joel Stanley
This contains the NRF51, and the machine that uses it, the BBC micro:bit.
Signed-off-by Joel Stanley <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0
MAINTAINERS F: include/hw/*/*aspeed* · line 661
Quoted 6 lines
MAINTAINERS +3
-0@@ -656,6 +656,14 @@ F: include/hw/*/*aspeed* F: hw/net/ftgmac100.c F: include/hw/net/ftgmac100.h +NRF51 +M: Joel Stanley <[email protected]> +L: [email protected]
s/nognu/nongnu/
Aside from that: