* [PATCH v4 00/18] hw/avr: Introduce few Arduino boards
@ 2020-01-20 22:00 Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 01/18] MAINTAINERS: Move machine test to the machine section (not ARCH one) Philippe Mathieu-Daudé
` (19 more replies)
0 siblings, 20 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
Hi,
This series add the arduino boards, aiming at removing the
'sample' board that doesn't follow any specification.
Since v3:
- Rebased on Michael's v41
- Drop 'extram' unused field (Igor)
- Renamed devices AVR -> Atmel (Aleksandar)
(I haven't renamed structure names to ease review)
Since v2:
- rebased on Michael's v40
Since v1:
- Addressed Igor comments
- Addressed Aleksandar comments
- Fixed UART issue (was due to IRQ shifted by 2 in CPU)
Since Michael's work is not yet merged, Various of my patches
- which are trivials or simple renames - could be squashed
directly on his patches, if we ever care.
[I believe sending this patches is easier/quicker than keeping
asking Michael to respin his series infinitely].
Michael, do you mind testing it? The full series is available
here: https://gitlab.com/philmd/qemu/commits/arduino-v4
Regards,
Phil.
Obsoletes: <20191229224505.24466-1-f4bug@amsat.org>
Based-on: <20200118191416.19934-1-mrolnik@gmail.com>
https://www.mail-archive.com/qemu-devel@nongnu.org/msg671707.html
Philippe Mathieu-Daudé (18):
MAINTAINERS: Move machine test to the machine section (not ARCH one)
MAINTAINERS: Move the AVR machines in new section (not within ARM)
tests/acceptance: Do not set the machine type manually
tests/acceptance: Keep multilines comment consistent with other tests
hw/char/avr: Reduce USART I/O size
hw/timer/avr_timer16: Rename memory region debugging name
hw/misc/avr_mask: Remove unused include
hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
hw/char: Rename avr_usart -> atmel_usart
hw/timer: Rename avr_timer16 -> atmel_timer16
hw/misc: Rename avr_mask -> atmel_power
hw/avr: Introduce ATMEL_ATMEGA_MCU config
hw/avr: Add some ATmega microcontrollers
hw/avr: Add some Arduino boards
tests/boot-serial-test: Test some Arduino boards (AVR based)
tests/acceptance: Test the Arduino MEGA2560 board
hw/avr: Remove the unrealistic AVR 'sample' board
.travis.yml: Run the AVR acceptance tests
default-configs/avr-softmmu.mak | 2 +-
hw/avr/atmel_atmega.h | 48 ++
.../hw/char/{avr_usart.h => atmel_usart.h} | 10 +-
include/hw/misc/{avr_mask.h => atmel_power.h} | 11 +-
.../timer/{avr_timer16.h => atmel_timer16.h} | 10 +-
hw/avr/arduino.c | 175 +++++++
hw/avr/atmel_atmega.c | 464 ++++++++++++++++++
hw/avr/sample.c | 295 -----------
hw/char/{avr_usart.c => atmel_usart.c} | 6 +-
hw/misc/{avr_mask.c => atmel_power.c} | 4 +-
hw/timer/{avr_timer16.c => atmel_timer16.c} | 10 +-
tests/qtest/boot-serial-test.c | 3 +-
.travis.yml | 2 +-
MAINTAINERS | 29 +-
hw/avr/Kconfig | 11 +-
hw/avr/Makefile.objs | 3 +-
hw/char/Kconfig | 2 +-
hw/char/Makefile.objs | 2 +-
hw/misc/Kconfig | 2 +-
hw/misc/Makefile.objs | 2 +-
hw/timer/Kconfig | 2 +-
hw/timer/Makefile.objs | 2 +-
tests/acceptance/machine_avr6.py | 11 +-
23 files changed, 751 insertions(+), 355 deletions(-)
create mode 100644 hw/avr/atmel_atmega.h
rename include/hw/char/{avr_usart.h => atmel_usart.h} (93%)
rename include/hw/misc/{avr_mask.h => atmel_power.h} (89%)
rename include/hw/timer/{avr_timer16.h => atmel_timer16.h} (92%)
create mode 100644 hw/avr/arduino.c
create mode 100644 hw/avr/atmel_atmega.c
delete mode 100644 hw/avr/sample.c
rename hw/char/{avr_usart.c => atmel_usart.c} (99%)
rename hw/misc/{avr_mask.c => atmel_power.c} (97%)
rename hw/timer/{avr_timer16.c => atmel_timer16.c} (98%)
--
2.21.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 01/18] MAINTAINERS: Move machine test to the machine section (not ARCH one)
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 02/18] MAINTAINERS: Move the AVR machines in new section (not within ARM) Philippe Mathieu-Daudé
` (18 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
!squash
---
MAINTAINERS | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index c70d77b1ae..3fbac64b31 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -168,7 +168,6 @@ M: Michael Rolnik <mrolnik@gmail.com>
R: Sarah Harris <S.E.Harris@kent.ac.uk>
S: Maintained
F: target/avr/
-F: tests/acceptance/machine_avr6.py
F: default-configs/avr-softmmu.mak
F: gdb-xml/avr-cpu.xml
@@ -501,6 +500,7 @@ F: hw/timer/avr_timer16.c
F: include/hw/timer/avr_timer16.h
F: hw/misc/avr_mask.c
F: include/hw/misc/avr_mask.h
+F: tests/acceptance/machine_avr6.py
ARM PrimeCell and CMSDK devices
M: Peter Maydell <peter.maydell@linaro.org>
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 02/18] MAINTAINERS: Move the AVR machines in new section (not within ARM)
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 01/18] MAINTAINERS: Move machine test to the machine section (not ARCH one) Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 03/18] tests/acceptance: Do not set the machine type manually Philippe Mathieu-Daudé
` (17 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
!squash
---
MAINTAINERS | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 3fbac64b31..4998fee99a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -489,19 +489,6 @@ F: hw/*/allwinner*
F: include/hw/*/allwinner*
F: hw/arm/cubieboard.c
-AVR Machines
-M: Michael Rolnik <mrolnik@gmail.com>
-R: Sarah Harris <S.E.Harris@kent.ac.uk>
-S: Maintained
-F: hw/avr/
-F: hw/char/avr_usart.c
-F: include/hw/char/avr_usart.h
-F: hw/timer/avr_timer16.c
-F: include/hw/timer/avr_timer16.h
-F: hw/misc/avr_mask.c
-F: include/hw/misc/avr_mask.h
-F: tests/acceptance/machine_avr6.py
-
ARM PrimeCell and CMSDK devices
M: Peter Maydell <peter.maydell@linaro.org>
L: qemu-arm@nongnu.org
@@ -901,6 +888,22 @@ F: include/hw/*/nrf51*.h
F: include/hw/*/microbit*.h
F: tests/qtest/microbit-test.c
+AVR Machines
+-------------
+
+Atmel MCU
+M: Michael Rolnik <mrolnik@gmail.com>
+R: Sarah Harris <S.E.Harris@kent.ac.uk>
+S: Maintained
+F: hw/avr/
+F: hw/char/avr_usart.c
+F: include/hw/char/avr_usart.h
+F: hw/timer/avr_timer16.c
+F: include/hw/timer/avr_timer16.h
+F: hw/misc/avr_mask.c
+F: include/hw/misc/avr_mask.h
+F: tests/acceptance/machine_avr6.py
+
CRIS Machines
-------------
Axis Dev88
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 03/18] tests/acceptance: Do not set the machine type manually
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 01/18] MAINTAINERS: Move machine test to the machine section (not ARCH one) Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 02/18] MAINTAINERS: Move the AVR machines in new section (not within ARM) Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 04/18] tests/acceptance: Keep multilines comment consistent with other tests Philippe Mathieu-Daudé
` (16 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Philippe Mathieu-Daudé,
Michael Rolnik, Cleber Rosa, Aleksandar Markovic,
Richard Henderson
Since commit ba21bde93 we don't need to set the machine type
manually, the one set by the ":avocado: tags=machine" will be used.
Suggested-by: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
tests/acceptance/machine_avr6.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/acceptance/machine_avr6.py b/tests/acceptance/machine_avr6.py
index 43501b26a3..784c287d0b 100644
--- a/tests/acceptance/machine_avr6.py
+++ b/tests/acceptance/machine_avr6.py
@@ -41,7 +41,6 @@ class AVR6Machine(Test):
rom_hash = '7eb521f511ca8f2622e0a3c5e8dd686efbb911d4'
rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash)
- self.vm.set_machine('sample')
self.vm.add_args('-bios', rom_path)
self.vm.add_args('-nographic')
self.vm.launch()
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 04/18] tests/acceptance: Keep multilines comment consistent with other tests
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2020-01-20 22:00 ` [PATCH v4 03/18] tests/acceptance: Do not set the machine type manually Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 05/18] hw/char/avr: Reduce USART I/O size Philippe Mathieu-Daudé
` (15 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
note to maintainer: squash before merge?
---
tests/acceptance/machine_avr6.py | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/tests/acceptance/machine_avr6.py b/tests/acceptance/machine_avr6.py
index 784c287d0b..611f6a62a4 100644
--- a/tests/acceptance/machine_avr6.py
+++ b/tests/acceptance/machine_avr6.py
@@ -33,11 +33,9 @@ class AVR6Machine(Test):
https://github.com/seharris/qemu-avr-tests/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf
constantly prints out 'ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX'
"""
- rom_url = 'https://github.com/seharris/qemu-avr-tests'
- rom_sha1= '36c3e67b8755dcf37e06af6730ef5d477b8ed16d'
- rom_url += '/raw/'
- rom_url += rom_sha1
- rom_url += '/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf'
+ rom_url = ('https://github.com/seharris/qemu-avr-tests'
+ '/raw/36c3e67b8755dcf/free-rtos/Demo'
+ '/AVR_ATMega2560_GCC/demo.elf')
rom_hash = '7eb521f511ca8f2622e0a3c5e8dd686efbb911d4'
rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash)
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 05/18] hw/char/avr: Reduce USART I/O size
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2020-01-20 22:00 ` [PATCH v4 04/18] tests/acceptance: Keep multilines comment consistent with other tests Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 06/18] hw/timer/avr_timer16: Rename memory region debugging name Philippe Mathieu-Daudé
` (14 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Philippe Mathieu-Daudé,
Michael Rolnik, Paolo Bonzini, Marc-André Lureau,
Aleksandar Markovic, Richard Henderson
Per the datasheet the USART uses 7 consecutive 8-bit registers.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/char/avr_usart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/char/avr_usart.c b/hw/char/avr_usart.c
index cb307fe23d..becdb87847 100644
--- a/hw/char/avr_usart.c
+++ b/hw/char/avr_usart.c
@@ -280,7 +280,7 @@ static void avr_usart_init(Object *obj)
sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->rxc_irq);
sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->dre_irq);
sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->txc_irq);
- memory_region_init_io(&s->mmio, obj, &avr_usart_ops, s, TYPE_AVR_USART, 8);
+ memory_region_init_io(&s->mmio, obj, &avr_usart_ops, s, TYPE_AVR_USART, 7);
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio);
qdev_init_gpio_in(DEVICE(s), avr_usart_pr, 1);
s->enabled = true;
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 06/18] hw/timer/avr_timer16: Rename memory region debugging name
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2020-01-20 22:00 ` [PATCH v4 05/18] hw/char/avr: Reduce USART I/O size Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 07/18] hw/misc/avr_mask: Remove unused include Philippe Mathieu-Daudé
` (13 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
This device expose 3 different I/O regions. Name them differently
to have a clearer 'info mtree' output.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/timer/avr_timer16.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/timer/avr_timer16.c b/hw/timer/avr_timer16.c
index aea1bf009e..a27933a18a 100644
--- a/hw/timer/avr_timer16.c
+++ b/hw/timer/avr_timer16.c
@@ -563,11 +563,11 @@ static void avr_timer16_init(Object *obj)
sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->ovf_irq);
memory_region_init_io(&s->iomem, obj, &avr_timer16_ops,
- s, TYPE_AVR_TIMER16, 0xe);
+ s, "avr-timer16", 0xe);
memory_region_init_io(&s->imsk_iomem, obj, &avr_timer16_imsk_ops,
- s, TYPE_AVR_TIMER16, 0x1);
+ s, "avr-timer16-intmask", 0x1);
memory_region_init_io(&s->ifr_iomem, obj, &avr_timer16_ifr_ops,
- s, TYPE_AVR_TIMER16, 0x1);
+ s, "avr-timer16-intflag", 0x1);
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->imsk_iomem);
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 07/18] hw/misc/avr_mask: Remove unused include
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2020-01-20 22:00 ` [PATCH v4 06/18] hw/timer/avr_timer16: Rename memory region debugging name Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 08/18] hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable Philippe Mathieu-Daudé
` (12 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/misc/avr_mask.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/hw/misc/avr_mask.h b/include/hw/misc/avr_mask.h
index d3e21972d8..5f95e1081d 100644
--- a/include/hw/misc/avr_mask.h
+++ b/include/hw/misc/avr_mask.h
@@ -26,7 +26,6 @@
#define HW_avr_mask_H
#include "hw/sysbus.h"
-#include "chardev/char-fe.h"
#include "hw/hw.h"
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 08/18] hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2020-01-20 22:00 ` [PATCH v4 07/18] hw/misc/avr_mask: Remove unused include Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 09/18] hw/char: Rename avr_usart -> atmel_usart Philippe Mathieu-Daudé
` (11 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/avr/Makefile.objs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/avr/Makefile.objs b/hw/avr/Makefile.objs
index 626b7064b3..1eb4b53be6 100644
--- a/hw/avr/Makefile.objs
+++ b/hw/avr/Makefile.objs
@@ -1 +1 @@
-obj-y += sample.o
+obj-$(CONFIG_AVR_SAMPLE) += sample.o
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 09/18] hw/char: Rename avr_usart -> atmel_usart
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2020-01-20 22:00 ` [PATCH v4 08/18] hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 10/18] hw/timer: Rename avr_timer16 -> atmel_timer16 Philippe Mathieu-Daudé
` (10 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Philippe Mathieu-Daudé,
Michael Rolnik, Paolo Bonzini, Marc-André Lureau,
Aleksandar Markovic, Richard Henderson
AVR is the architecture, Atmel the manufacturer.
Suggested-by: Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
!squash
---
include/hw/char/{avr_usart.h => atmel_usart.h} | 10 +++++-----
hw/avr/sample.c | 2 +-
hw/char/{avr_usart.c => atmel_usart.c} | 4 ++--
MAINTAINERS | 4 ++--
hw/avr/Kconfig | 2 +-
hw/char/Kconfig | 2 +-
hw/char/Makefile.objs | 2 +-
7 files changed, 13 insertions(+), 13 deletions(-)
rename include/hw/char/{avr_usart.h => atmel_usart.h} (93%)
rename hw/char/{avr_usart.c => atmel_usart.c} (99%)
diff --git a/include/hw/char/avr_usart.h b/include/hw/char/atmel_usart.h
similarity index 93%
rename from include/hw/char/avr_usart.h
rename to include/hw/char/atmel_usart.h
index 467e97e8c0..fd35feac60 100644
--- a/include/hw/char/avr_usart.h
+++ b/include/hw/char/atmel_usart.h
@@ -1,5 +1,5 @@
/*
- * AVR USART
+ * Atmel AVR USART
*
* Copyright (c) 2018 University of Kent
* Author: Sarah Harris
@@ -19,8 +19,8 @@
* <http://www.gnu.org/licenses/lgpl-2.1.html>
*/
-#ifndef HW_AVR_USART_H
-#define HW_AVR_USART_H
+#ifndef HW_CHAR_ATMEL_USART_H
+#define HW_CHAR_ATMEL_USART_H
#include "hw/sysbus.h"
#include "chardev/char-fe.h"
@@ -56,7 +56,7 @@
#define USART_CSRC_CSZ1 (1 << 2)
#define USART_CSRC_CSZ0 (1 << 1)
-#define TYPE_AVR_USART "avr-usart"
+#define TYPE_AVR_USART "atmel-usart"
#define AVR_USART(obj) \
OBJECT_CHECK(AVRUsartState, (obj), TYPE_AVR_USART)
@@ -90,4 +90,4 @@ typedef struct {
qemu_irq dre_irq;
} AVRUsartState;
-#endif /* HW_AVR_USART_H */
+#endif /* HW_CHAR_ATMEL_USART_H */
diff --git a/hw/avr/sample.c b/hw/avr/sample.c
index 95094a8d6c..ca67c11233 100644
--- a/hw/avr/sample.c
+++ b/hw/avr/sample.c
@@ -44,7 +44,7 @@
#include "qemu/error-report.h"
#include "exec/address-spaces.h"
#include "include/hw/sysbus.h"
-#include "include/hw/char/avr_usart.h"
+#include "include/hw/char/atmel_usart.h"
#include "include/hw/timer/avr_timer16.h"
#include "include/hw/misc/avr_mask.h"
#include "elf.h"
diff --git a/hw/char/avr_usart.c b/hw/char/atmel_usart.c
similarity index 99%
rename from hw/char/avr_usart.c
rename to hw/char/atmel_usart.c
index becdb87847..a7004c212a 100644
--- a/hw/char/avr_usart.c
+++ b/hw/char/atmel_usart.c
@@ -1,5 +1,5 @@
/*
- * AVR USART
+ * Atmel AVR USART
*
* Copyright (c) 2018 University of Kent
* Author: Sarah Harris
@@ -20,7 +20,7 @@
*/
#include "qemu/osdep.h"
-#include "hw/char/avr_usart.h"
+#include "hw/char/atmel_usart.h"
#include "qemu/log.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index 4998fee99a..f2e01a6d16 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -896,8 +896,8 @@ M: Michael Rolnik <mrolnik@gmail.com>
R: Sarah Harris <S.E.Harris@kent.ac.uk>
S: Maintained
F: hw/avr/
-F: hw/char/avr_usart.c
-F: include/hw/char/avr_usart.h
+F: hw/char/atmel_usart.c
+F: include/hw/char/atmel_usart.h
F: hw/timer/avr_timer16.c
F: include/hw/timer/avr_timer16.h
F: hw/misc/avr_mask.c
diff --git a/hw/avr/Kconfig b/hw/avr/Kconfig
index 92aa1e6afb..8084a73176 100644
--- a/hw/avr/Kconfig
+++ b/hw/avr/Kconfig
@@ -1,6 +1,6 @@
config AVR_SAMPLE
bool
select AVR_TIMER16
- select AVR_USART
+ select ATMEL_USART
select AVR_MASK
select UNIMP
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
index 331b20983f..5a27681884 100644
--- a/hw/char/Kconfig
+++ b/hw/char/Kconfig
@@ -47,5 +47,5 @@ config SCLPCONSOLE
config TERMINAL3270
bool
-config AVR_USART
+config ATMEL_USART
bool
diff --git a/hw/char/Makefile.objs b/hw/char/Makefile.objs
index f05c1f5667..c23ad3b4a7 100644
--- a/hw/char/Makefile.objs
+++ b/hw/char/Makefile.objs
@@ -21,7 +21,7 @@ obj-$(CONFIG_PSERIES) += spapr_vty.o
obj-$(CONFIG_DIGIC) += digic-uart.o
obj-$(CONFIG_STM32F2XX_USART) += stm32f2xx_usart.o
obj-$(CONFIG_RASPI) += bcm2835_aux.o
-common-obj-$(CONFIG_AVR_USART) += avr_usart.o
+common-obj-$(CONFIG_ATMEL_USART) += atmel_usart.o
common-obj-$(CONFIG_CMSDK_APB_UART) += cmsdk-apb-uart.o
common-obj-$(CONFIG_ETRAXFS) += etraxfs_ser.o
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 10/18] hw/timer: Rename avr_timer16 -> atmel_timer16
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2020-01-20 22:00 ` [PATCH v4 09/18] hw/char: Rename avr_usart -> atmel_usart Philippe Mathieu-Daudé
@ 2020-01-20 22:00 ` Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 11/18] hw/misc: Rename avr_mask -> atmel_power Philippe Mathieu-Daudé
` (9 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:00 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
AVR is the architecture, Atmel the manufacturer.
Suggested-by: Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
!squash
---
include/hw/timer/{avr_timer16.h => atmel_timer16.h} | 10 +++++-----
hw/avr/sample.c | 2 +-
hw/timer/{avr_timer16.c => atmel_timer16.c} | 4 ++--
MAINTAINERS | 4 ++--
hw/avr/Kconfig | 2 +-
hw/timer/Kconfig | 2 +-
hw/timer/Makefile.objs | 2 +-
7 files changed, 13 insertions(+), 13 deletions(-)
rename include/hw/timer/{avr_timer16.h => atmel_timer16.h} (92%)
rename hw/timer/{avr_timer16.c => atmel_timer16.c} (99%)
diff --git a/include/hw/timer/avr_timer16.h b/include/hw/timer/atmel_timer16.h
similarity index 92%
rename from include/hw/timer/avr_timer16.h
rename to include/hw/timer/atmel_timer16.h
index 4ae0c64a34..f0516c41cf 100644
--- a/include/hw/timer/avr_timer16.h
+++ b/include/hw/timer/atmel_timer16.h
@@ -1,5 +1,5 @@
/*
- * AVR 16 bit timer
+ * Atmel AVR 16 bit timer
*
* Copyright (c) 2018 University of Kent
* Author: Ed Robbins
@@ -25,8 +25,8 @@
* On ATmega640/V-1280/V-1281/V-2560/V-2561/V timers 1, 3, 4 and 5 are 16 bit
*/
-#ifndef AVR_TIMER16_H
-#define AVR_TIMER16_H
+#ifndef HW_TIMER_ATMEL_TIMER16_H
+#define HW_TIMER_ATMEL_TIMER16_H
#include "hw/sysbus.h"
#include "qemu/timer.h"
@@ -40,7 +40,7 @@ enum NextInterrupt {
CAPT
};
-#define TYPE_AVR_TIMER16 "avr-timer16"
+#define TYPE_AVR_TIMER16 "atmel-timer16"
#define AVR_TIMER16(obj) \
OBJECT_CHECK(AVRTimer16State, (obj), TYPE_AVR_TIMER16)
@@ -91,4 +91,4 @@ typedef struct AVRTimer16State {
enum NextInterrupt next_interrupt;
} AVRTimer16State;
-#endif /* AVR_TIMER16_H */
+#endif /* HW_TIMER_ATMEL_TIMER16_H */
diff --git a/hw/avr/sample.c b/hw/avr/sample.c
index ca67c11233..19e9f56f3b 100644
--- a/hw/avr/sample.c
+++ b/hw/avr/sample.c
@@ -45,7 +45,7 @@
#include "exec/address-spaces.h"
#include "include/hw/sysbus.h"
#include "include/hw/char/atmel_usart.h"
-#include "include/hw/timer/avr_timer16.h"
+#include "include/hw/timer/atmel_timer16.h"
#include "include/hw/misc/avr_mask.h"
#include "elf.h"
#include "hw/misc/unimp.h"
diff --git a/hw/timer/avr_timer16.c b/hw/timer/atmel_timer16.c
similarity index 99%
rename from hw/timer/avr_timer16.c
rename to hw/timer/atmel_timer16.c
index a27933a18a..3b06d6e4e5 100644
--- a/hw/timer/avr_timer16.c
+++ b/hw/timer/atmel_timer16.c
@@ -1,5 +1,5 @@
/*
- * AVR 16 bit timer
+ * Atmel AVR 16 bit timer
*
* Copyright (c) 2018 University of Kent
* Author: Ed Robbins
@@ -32,7 +32,7 @@
*/
#include "qemu/osdep.h"
-#include "hw/timer/avr_timer16.h"
+#include "hw/timer/atmel_timer16.h"
#include "qemu/log.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index f2e01a6d16..a98d164bc1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -898,8 +898,8 @@ S: Maintained
F: hw/avr/
F: hw/char/atmel_usart.c
F: include/hw/char/atmel_usart.h
-F: hw/timer/avr_timer16.c
-F: include/hw/timer/avr_timer16.h
+F: hw/timer/atmel_timer16.c
+F: include/hw/timer/atmel_timer16.h
F: hw/misc/avr_mask.c
F: include/hw/misc/avr_mask.h
F: tests/acceptance/machine_avr6.py
diff --git a/hw/avr/Kconfig b/hw/avr/Kconfig
index 8084a73176..45c7025f09 100644
--- a/hw/avr/Kconfig
+++ b/hw/avr/Kconfig
@@ -1,6 +1,6 @@
config AVR_SAMPLE
bool
- select AVR_TIMER16
+ select ATMEL_TIMER16
select ATMEL_USART
select AVR_MASK
select UNIMP
diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
index 2521056dc8..cc66b60ef1 100644
--- a/hw/timer/Kconfig
+++ b/hw/timer/Kconfig
@@ -36,5 +36,5 @@ config CMSDK_APB_DUALTIMER
bool
select PTIMER
-config AVR_TIMER16
+config ATMEL_TIMER16
bool
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index af0913ca3b..08a8a5cee9 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -36,4 +36,4 @@ common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o
common-obj-$(CONFIG_MSF2) += mss-timer.o
common-obj-$(CONFIG_RASPI) += bcm2835_systmr.o
-obj-$(CONFIG_AVR_TIMER16) += avr_timer16.o
+obj-$(CONFIG_ATMEL_TIMER16) += atmel_timer16.o
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 11/18] hw/misc: Rename avr_mask -> atmel_power
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2020-01-20 22:00 ` [PATCH v4 10/18] hw/timer: Rename avr_timer16 -> atmel_timer16 Philippe Mathieu-Daudé
@ 2020-01-20 22:01 ` Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 12/18] hw/avr: Introduce ATMEL_ATMEGA_MCU config Philippe Mathieu-Daudé
` (8 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
AVR is the architecture, Atmel the manufacturer.
Suggested-by: Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
!squash
---
include/hw/misc/{avr_mask.h => atmel_power.h} | 10 +++++-----
hw/avr/sample.c | 2 +-
hw/misc/{avr_mask.c => atmel_power.c} | 4 ++--
MAINTAINERS | 4 ++--
hw/avr/Kconfig | 2 +-
hw/misc/Kconfig | 2 +-
hw/misc/Makefile.objs | 2 +-
7 files changed, 13 insertions(+), 13 deletions(-)
rename include/hw/misc/{avr_mask.h => atmel_power.h} (89%)
rename hw/misc/{avr_mask.c => atmel_power.c} (97%)
diff --git a/include/hw/misc/avr_mask.h b/include/hw/misc/atmel_power.h
similarity index 89%
rename from include/hw/misc/avr_mask.h
rename to include/hw/misc/atmel_power.h
index 5f95e1081d..5366e9693f 100644
--- a/include/hw/misc/avr_mask.h
+++ b/include/hw/misc/atmel_power.h
@@ -1,5 +1,5 @@
/*
- * AVR Power Reduction
+ * Atmel AVR Power Reduction Management
*
* Copyright (c) 2019 Michael Rolnik
*
@@ -22,14 +22,14 @@
* THE SOFTWARE.
*/
-#ifndef HW_avr_mask_H
-#define HW_avr_mask_H
+#ifndef HW_MISC_ATMEL_POWER_H
+#define HW_MISC_ATMEL_POWER_H
#include "hw/sysbus.h"
#include "hw/hw.h"
-#define TYPE_AVR_MASK "avr-mask"
+#define TYPE_AVR_MASK "atmel-power"
#define AVR_MASK(obj) OBJECT_CHECK(AVRMaskState, (obj), TYPE_AVR_MASK)
typedef struct {
@@ -43,4 +43,4 @@ typedef struct {
qemu_irq irq[8];
} AVRMaskState;
-#endif /* HW_avr_mask_H */
+#endif /* HW_MISC_ATMEL_POWER_H */
diff --git a/hw/avr/sample.c b/hw/avr/sample.c
index 19e9f56f3b..19b8c067e5 100644
--- a/hw/avr/sample.c
+++ b/hw/avr/sample.c
@@ -46,7 +46,7 @@
#include "include/hw/sysbus.h"
#include "include/hw/char/atmel_usart.h"
#include "include/hw/timer/atmel_timer16.h"
-#include "include/hw/misc/avr_mask.h"
+#include "include/hw/misc/atmel_power.h"
#include "elf.h"
#include "hw/misc/unimp.h"
diff --git a/hw/misc/avr_mask.c b/hw/misc/atmel_power.c
similarity index 97%
rename from hw/misc/avr_mask.c
rename to hw/misc/atmel_power.c
index 3af82ed9c1..adab729f66 100644
--- a/hw/misc/avr_mask.c
+++ b/hw/misc/atmel_power.c
@@ -1,5 +1,5 @@
/*
- * AVR Power Reduction
+ * Atmel AVR Power Reduction Management
*
* Copyright (c) 2019 Michael Rolnik
*
@@ -23,7 +23,7 @@
*/
#include "qemu/osdep.h"
-#include "hw/misc/avr_mask.h"
+#include "hw/misc/atmel_power.h"
#include "qemu/log.h"
#include "hw/qdev-properties.h"
#include "hw/irq.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index a98d164bc1..60634cebf4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -900,8 +900,8 @@ F: hw/char/atmel_usart.c
F: include/hw/char/atmel_usart.h
F: hw/timer/atmel_timer16.c
F: include/hw/timer/atmel_timer16.h
-F: hw/misc/avr_mask.c
-F: include/hw/misc/avr_mask.h
+F: hw/misc/atmel_power.c
+F: include/hw/misc/atmel_power.h
F: tests/acceptance/machine_avr6.py
CRIS Machines
diff --git a/hw/avr/Kconfig b/hw/avr/Kconfig
index 45c7025f09..516b89c849 100644
--- a/hw/avr/Kconfig
+++ b/hw/avr/Kconfig
@@ -2,5 +2,5 @@ config AVR_SAMPLE
bool
select ATMEL_TIMER16
select ATMEL_USART
- select AVR_MASK
+ select ATMEL_POWER
select UNIMP
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
index 74a1e9a241..3a3c32e1b0 100644
--- a/hw/misc/Kconfig
+++ b/hw/misc/Kconfig
@@ -131,7 +131,7 @@ config MAC_VIA
select MOS6522
select ADB
-config AVR_MASK
+config ATMEL_POWER
bool
source macio/Kconfig
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
index bbf17f651b..e605964f4b 100644
--- a/hw/misc/Makefile.objs
+++ b/hw/misc/Makefile.objs
@@ -86,4 +86,4 @@ obj-$(CONFIG_MAC_VIA) += mac_via.o
common-obj-$(CONFIG_GRLIB) += grlib_ahb_apb_pnp.o
-obj-$(CONFIG_AVR_MASK) += avr_mask.o
+obj-$(CONFIG_ATMEL_POWER) += atmel_power.o
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 12/18] hw/avr: Introduce ATMEL_ATMEGA_MCU config
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2020-01-20 22:01 ` [PATCH v4 11/18] hw/misc: Rename avr_mask -> atmel_power Philippe Mathieu-Daudé
@ 2020-01-20 22:01 ` Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 13/18] hw/avr: Add some ATmega microcontrollers Philippe Mathieu-Daudé
` (7 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/avr/Kconfig | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/hw/avr/Kconfig b/hw/avr/Kconfig
index 516b89c849..228eae7582 100644
--- a/hw/avr/Kconfig
+++ b/hw/avr/Kconfig
@@ -1,6 +1,9 @@
-config AVR_SAMPLE
+config ATMEL_ATMEGA_MCU
bool
select ATMEL_TIMER16
select ATMEL_USART
select ATMEL_POWER
+
+config AVR_SAMPLE
+ select ATMEL_ATMEGA_MCU
select UNIMP
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 13/18] hw/avr: Add some ATmega microcontrollers
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2020-01-20 22:01 ` [PATCH v4 12/18] hw/avr: Introduce ATMEL_ATMEGA_MCU config Philippe Mathieu-Daudé
@ 2020-01-20 22:01 ` Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 14/18] hw/avr: Add some Arduino boards Philippe Mathieu-Daudé
` (6 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Philippe Mathieu-Daudé,
Michael Rolnik, Igor Mammedov, Aleksandar Markovic,
Richard Henderson
Add some microcontrollers from the megaAVR family (ATmega series):
- middle range: ATmega168 and ATmega328
- high range: ATmega1280 and ATmega2560
For product comparison:
https://www.microchip.com/wwwproducts/ProductCompare/ATmega168P/ATmega328P
https://www.microchip.com/wwwproducts/ProductCompare/ATmega1280/ATmega2560
Datasheets:
http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v2:
- Reword description adding more information (Aleksandar)
- Use DEFINE_TYPES and memory_region_init_ram (Igor)
Cc: Igor Mammedov <imammedo@redhat.com>
---
hw/avr/atmel_atmega.h | 48 +++++
hw/avr/atmel_atmega.c | 464 ++++++++++++++++++++++++++++++++++++++++++
hw/avr/Makefile.objs | 1 +
3 files changed, 513 insertions(+)
create mode 100644 hw/avr/atmel_atmega.h
create mode 100644 hw/avr/atmel_atmega.c
diff --git a/hw/avr/atmel_atmega.h b/hw/avr/atmel_atmega.h
new file mode 100644
index 0000000000..391b8b1bf8
--- /dev/null
+++ b/hw/avr/atmel_atmega.h
@@ -0,0 +1,48 @@
+/*
+ * QEMU ATmega MCU
+ *
+ * Copyright (c) 2019 Philippe Mathieu-Daudé
+ *
+ * This work is licensed under the terms of the GNU GPLv2 or later.
+ * See the COPYING file in the top-level directory.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_AVR_ATMEL_ATMEGA_H
+#define HW_AVR_ATMEL_ATMEGA_H
+
+#include "hw/char/atmel_usart.h"
+#include "hw/timer/atmel_timer16.h"
+#include "hw/misc/atmel_power.h"
+#include "target/avr/cpu.h"
+
+#define TYPE_ATMEGA_MCU "ATmega"
+#define TYPE_ATMEGA168_MCU "ATmega168"
+#define TYPE_ATMEGA328_MCU "ATmega328"
+#define TYPE_ATMEGA1280_MCU "ATmega1280"
+#define TYPE_ATMEGA2560_MCU "ATmega2560"
+
+#define ATMEGA_MCU(obj) OBJECT_CHECK(AtmegaMcuState, (obj), TYPE_ATMEGA_MCU)
+
+#define POWER_MAX 2
+#define USART_MAX 4
+#define TIMER_MAX 6
+#define GPIO_MAX 12
+
+typedef struct AtmegaMcuState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ AVRCPU cpu;
+ MemoryRegion flash;
+ MemoryRegion eeprom;
+ MemoryRegion sram;
+ DeviceState *io;
+ AVRMaskState pwr[POWER_MAX];
+ AVRUsartState usart[USART_MAX];
+ AVRTimer16State timer[TIMER_MAX];
+ uint64_t xtal_freq_hz;
+} AtmegaMcuState;
+
+#endif /* HW_AVR_ATMEL_ATMEGA_H */
diff --git a/hw/avr/atmel_atmega.c b/hw/avr/atmel_atmega.c
new file mode 100644
index 0000000000..18ab0b7906
--- /dev/null
+++ b/hw/avr/atmel_atmega.c
@@ -0,0 +1,464 @@
+/*
+ * QEMU ATmega MCU
+ *
+ * Copyright (c) 2019 Philippe Mathieu-Daudé
+ *
+ * This work is licensed under the terms of the GNU GPLv2 or later.
+ * See the COPYING file in the top-level directory.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/module.h"
+#include "qemu/units.h"
+#include "qapi/error.h"
+#include "exec/memory.h"
+#include "exec/address-spaces.h"
+#include "sysemu/sysemu.h"
+#include "hw/qdev-properties.h"
+#include "hw/sysbus.h"
+#include "hw/boards.h" /* FIXME memory_region_allocate_system_memory for sram */
+#include "hw/misc/unimp.h"
+#include "atmel_atmega.h"
+
+enum AtmegaPeripheral {
+ POWER0, POWER1,
+ GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF,
+ GPIOG, GPIOH, GPIOI, GPIOJ, GPIOK, GPIOL,
+ USART0, USART1, USART2, USART3,
+ TIMER0, TIMER1, TIMER2, TIMER3, TIMER4, TIMER5,
+ PERIFMAX
+};
+
+#define GPIO(n) (n + GPIOA)
+#define USART(n) (n + USART0)
+#define TIMER(n) (n + TIMER0)
+#define POWER(n) (n + POWER0)
+
+typedef struct {
+ uint16_t addr;
+ enum AtmegaPeripheral power_index;
+ uint8_t power_bit;
+ /* timer specific */
+ uint16_t intmask_addr;
+ uint16_t intflag_addr;
+ bool is_timer16;
+} peripheral_cfg;
+
+typedef struct AtmegaMcuClass {
+ /*< private >*/
+ SysBusDeviceClass parent_class;
+ /*< public >*/
+ const char *uc_name;
+ const char *cpu_type;
+ size_t flash_size;
+ size_t eeprom_size;
+ size_t sram_size;
+ size_t io_size;
+ size_t gpio_count;
+ size_t adc_count;
+ const uint8_t *irq;
+ const peripheral_cfg *dev;
+} AtmegaMcuClass;
+
+#define ATMEGA_MCU_CLASS(klass) \
+ OBJECT_CLASS_CHECK(AtmegaMcuClass, (klass), TYPE_ATMEGA_MCU)
+#define ATMEGA_MCU_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(AtmegaMcuClass, (obj), TYPE_ATMEGA_MCU)
+
+static const peripheral_cfg dev168_328[PERIFMAX] = {
+ [USART0] = { 0xc0, POWER0, 1 },
+ [TIMER2] = { 0xb0, POWER0, 6, 0x70, 0x37, false },
+ [TIMER1] = { 0x80, POWER0, 3, 0x6f, 0x36, true },
+ [POWER0] = { 0x64 },
+ [TIMER0] = { 0x44, POWER0, 5, 0x6e, 0x35, false },
+ [GPIOD] = { 0x29 },
+ [GPIOC] = { 0x26 },
+ [GPIOB] = { 0x23 },
+}, dev1280_2560[PERIFMAX] = {
+ [USART3] = { 0x130, POWER1, 2 },
+ [TIMER5] = { 0x120, POWER1, 5, 0x73, 0x3a, true },
+ [GPIOL] = { 0x109 },
+ [GPIOK] = { 0x106 },
+ [GPIOJ] = { 0x103 },
+ [GPIOH] = { 0x100 },
+ [USART2] = { 0xd0, POWER1, 1 },
+ [USART1] = { 0xc8, POWER1, 0 },
+ [USART0] = { 0xc0, POWER0, 1 },
+ [TIMER2] = { 0xb0, POWER0, 6, 0x70, 0x37, false }, /* TODO async */
+ [TIMER4] = { 0xa0, POWER1, 4, 0x72, 0x39, true },
+ [TIMER3] = { 0x90, POWER1, 3, 0x71, 0x38, true },
+ [TIMER1] = { 0x80, POWER0, 3, 0x6f, 0x36, true },
+ [POWER1] = { 0x65 },
+ [POWER0] = { 0x64 },
+ [TIMER0] = { 0x44, POWER0, 5, 0x6e, 0x35, false },
+ [GPIOG] = { 0x32 },
+ [GPIOF] = { 0x2f },
+ [GPIOE] = { 0x2c },
+ [GPIOD] = { 0x29 },
+ [GPIOC] = { 0x26 },
+ [GPIOB] = { 0x23 },
+ [GPIOA] = { 0x20 },
+};
+
+enum AtmegaIrq {
+ USART0_RXC_IRQ, USART0_DRE_IRQ, USART0_TXC_IRQ,
+ USART1_RXC_IRQ, USART1_DRE_IRQ, USART1_TXC_IRQ,
+ USART2_RXC_IRQ, USART2_DRE_IRQ, USART2_TXC_IRQ,
+ USART3_RXC_IRQ, USART3_DRE_IRQ, USART3_TXC_IRQ,
+ TIMER0_CAPT_IRQ, TIMER0_COMPA_IRQ, TIMER0_COMPB_IRQ,
+ TIMER0_COMPC_IRQ, TIMER0_OVF_IRQ,
+ TIMER1_CAPT_IRQ, TIMER1_COMPA_IRQ, TIMER1_COMPB_IRQ,
+ TIMER1_COMPC_IRQ, TIMER1_OVF_IRQ,
+ TIMER2_CAPT_IRQ, TIMER2_COMPA_IRQ, TIMER2_COMPB_IRQ,
+ TIMER2_COMPC_IRQ, TIMER2_OVF_IRQ,
+ TIMER3_CAPT_IRQ, TIMER3_COMPA_IRQ, TIMER3_COMPB_IRQ,
+ TIMER3_COMPC_IRQ, TIMER3_OVF_IRQ,
+ TIMER4_CAPT_IRQ, TIMER4_COMPA_IRQ, TIMER4_COMPB_IRQ,
+ TIMER4_COMPC_IRQ, TIMER4_OVF_IRQ,
+ TIMER5_CAPT_IRQ, TIMER5_COMPA_IRQ, TIMER5_COMPB_IRQ,
+ TIMER5_COMPC_IRQ, TIMER5_OVF_IRQ,
+ IRQ_COUNT
+};
+
+#define USART_IRQ_COUNT 3
+#define USART_RXC_IRQ(n) (n * USART_IRQ_COUNT + USART0_RXC_IRQ)
+#define USART_DRE_IRQ(n) (n * USART_IRQ_COUNT + USART0_DRE_IRQ)
+#define USART_TXC_IRQ(n) (n * USART_IRQ_COUNT + USART0_TXC_IRQ)
+#define TIMER_IRQ_COUNT 5
+#define TIMER_CAPT_IRQ(n) (n * TIMER_IRQ_COUNT + TIMER0_CAPT_IRQ)
+#define TIMER_COMPA_IRQ(n) (n * TIMER_IRQ_COUNT + TIMER0_COMPA_IRQ)
+#define TIMER_COMPB_IRQ(n) (n * TIMER_IRQ_COUNT + TIMER0_COMPB_IRQ)
+#define TIMER_COMPC_IRQ(n) (n * TIMER_IRQ_COUNT + TIMER0_COMPC_IRQ)
+#define TIMER_OVF_IRQ(n) (n * TIMER_IRQ_COUNT + TIMER0_OVF_IRQ)
+
+static const uint8_t irq168_328[IRQ_COUNT] = {
+ [TIMER2_COMPA_IRQ] = 8,
+ [TIMER2_COMPB_IRQ] = 9,
+ [TIMER2_OVF_IRQ] = 10,
+ [TIMER1_CAPT_IRQ] = 11,
+ [TIMER1_COMPA_IRQ] = 12,
+ [TIMER1_COMPB_IRQ] = 13,
+ [TIMER1_OVF_IRQ] = 14,
+ [TIMER0_COMPA_IRQ] = 15,
+ [TIMER0_COMPB_IRQ] = 16,
+ [TIMER0_OVF_IRQ] = 17,
+ [USART0_RXC_IRQ] = 19,
+ [USART0_DRE_IRQ] = 20,
+ [USART0_TXC_IRQ] = 21,
+}, irq1280_2560[IRQ_COUNT] = {
+ [TIMER2_COMPA_IRQ] = 14,
+ [TIMER2_COMPB_IRQ] = 15,
+ [TIMER2_OVF_IRQ] = 16,
+ [TIMER1_CAPT_IRQ] = 17,
+ [TIMER1_COMPA_IRQ] = 18,
+ [TIMER1_COMPB_IRQ] = 19,
+ [TIMER1_COMPC_IRQ] = 20,
+ [TIMER1_OVF_IRQ] = 21,
+ [TIMER0_COMPA_IRQ] = 22,
+ [TIMER0_COMPB_IRQ] = 23,
+ [TIMER0_OVF_IRQ] = 24,
+ [USART0_RXC_IRQ] = 26,
+ [USART0_DRE_IRQ] = 27,
+ [USART0_TXC_IRQ] = 28,
+ [TIMER3_CAPT_IRQ] = 32,
+ [TIMER3_COMPA_IRQ] = 33,
+ [TIMER3_COMPB_IRQ] = 34,
+ [TIMER3_COMPC_IRQ] = 35,
+ [TIMER3_OVF_IRQ] = 36,
+ [USART1_RXC_IRQ] = 37,
+ [USART1_DRE_IRQ] = 38,
+ [USART1_TXC_IRQ] = 39,
+ [TIMER4_CAPT_IRQ] = 42,
+ [TIMER4_COMPA_IRQ] = 43,
+ [TIMER4_COMPB_IRQ] = 44,
+ [TIMER4_COMPC_IRQ] = 45,
+ [TIMER4_OVF_IRQ] = 46,
+ [TIMER5_CAPT_IRQ] = 47,
+ [TIMER5_COMPA_IRQ] = 48,
+ [TIMER5_COMPB_IRQ] = 49,
+ [TIMER5_COMPC_IRQ] = 50,
+ [TIMER5_OVF_IRQ] = 51,
+ [USART2_RXC_IRQ] = 52,
+ [USART2_DRE_IRQ] = 53,
+ [USART2_TXC_IRQ] = 54,
+ [USART3_RXC_IRQ] = 55,
+ [USART3_DRE_IRQ] = 56,
+ [USART3_TXC_IRQ] = 57,
+};
+
+static void connect_peripheral_irq(const AtmegaMcuClass *mc,
+ SysBusDevice *sbd,
+ DeviceState *dev, int n,
+ unsigned peripheral_irq)
+{
+ int irq = mc->irq[peripheral_irq];
+
+ if (!irq) {
+ return;
+ }
+ /* FIXME move that to avr_cpu_set_int() once 'sample' board is removed */
+ assert(irq >= 2);
+ irq -= 2;
+
+ sysbus_connect_irq(sbd, n, qdev_get_gpio_in(dev, irq));
+}
+
+static void connect_power_reduction_gpio(AtmegaMcuState *s,
+ const AtmegaMcuClass *mc,
+ DeviceState *dev,
+ int peripheral_index)
+{
+ unsigned power_index = mc->dev[peripheral_index].power_index;
+ assert(mc->dev[power_index].addr);
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->pwr[power_index - POWER0]),
+ mc->dev[peripheral_index].power_bit,
+ qdev_get_gpio_in(dev, 0));
+}
+
+static void atmega_realize(DeviceState *dev, Error **errp)
+{
+ AtmegaMcuState *s = ATMEGA_MCU(dev);
+ const AtmegaMcuClass *mc = ATMEGA_MCU_GET_CLASS(dev);
+ DeviceState *cpudev;
+ SysBusDevice *sbd;
+ Error *err = NULL;
+ char *devname;
+ size_t i;
+
+ assert(mc->io_size <= 0x200);
+
+ if (!s->xtal_freq_hz) {
+ error_setg(errp, "\"xtal-frequency-hz\" property must be provided.");
+ return;
+ }
+
+ /* CPU */
+ object_initialize_child(OBJECT(dev), "cpu", &s->cpu, sizeof(s->cpu),
+ mc->cpu_type, &err, NULL);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
+ object_property_set_bool(OBJECT(&s->cpu), true, "realized", &error_abort);
+ cpudev = DEVICE(&s->cpu);
+
+ /* SRAM */
+ memory_region_init_ram(&s->sram, OBJECT(dev), "sram", mc->sram_size,
+ &error_abort);
+ memory_region_add_subregion(get_system_memory(),
+ OFFSET_DATA + 0x200, &s->sram);
+
+ /* Flash */
+ memory_region_init_rom(&s->flash, OBJECT(dev),
+ "flash", mc->flash_size, &error_fatal);
+ memory_region_add_subregion(get_system_memory(), OFFSET_CODE, &s->flash);
+
+ /* I/O */
+ s->io = qdev_create(NULL, TYPE_UNIMPLEMENTED_DEVICE);
+ qdev_prop_set_string(s->io, "name", "I/O");
+ qdev_prop_set_uint64(s->io, "size", mc->io_size);
+ qdev_init_nofail(s->io);
+ sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s->io), 0, OFFSET_DATA, -1234);
+
+ /* Power Reduction */
+ for (i = 0; i < POWER_MAX; i++) {
+ int idx = POWER(i);
+ if (!mc->dev[idx].addr) {
+ continue;
+ }
+ devname = g_strdup_printf("power%zu", i);
+ object_initialize_child(OBJECT(dev), devname,
+ &s->pwr[i], sizeof(s->pwr[i]),
+ TYPE_AVR_MASK, &error_abort, NULL);
+ object_property_set_bool(OBJECT(&s->pwr[i]), true, "realized",
+ &error_abort);
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->pwr[i]), 0,
+ OFFSET_DATA + mc->dev[idx].addr);
+ g_free(devname);
+ }
+
+ /* GPIO */
+ for (i = 0; i < GPIO_MAX; i++) {
+ int idx = GPIO(i);
+ if (!mc->dev[idx].addr) {
+ continue;
+ }
+ devname = g_strdup_printf("avr-gpio-%c", 'a' + (char)i);
+ create_unimplemented_device(devname,
+ OFFSET_DATA + mc->dev[idx].addr, 3);
+ g_free(devname);
+ }
+
+ /* USART */
+ for (i = 0; i < USART_MAX; i++) {
+ int idx = USART(i);
+ if (!mc->dev[idx].addr) {
+ continue;
+ }
+ devname = g_strdup_printf("usart%zu", i);
+ object_initialize_child(OBJECT(dev), devname,
+ &s->usart[i], sizeof(s->usart[i]),
+ TYPE_AVR_USART, &error_abort, NULL);
+ qdev_prop_set_chr(DEVICE(&s->usart[i]), "chardev", serial_hd(i));
+ object_property_set_bool(OBJECT(&s->usart[i]), true, "realized",
+ &error_abort);
+ sbd = SYS_BUS_DEVICE(&s->usart[i]);
+ sysbus_mmio_map(sbd, 0, OFFSET_DATA + mc->dev[USART(i)].addr);
+ connect_peripheral_irq(mc, sbd, cpudev, 0, USART_RXC_IRQ(i));
+ connect_peripheral_irq(mc, sbd, cpudev, 1, USART_DRE_IRQ(i));
+ connect_peripheral_irq(mc, sbd, cpudev, 2, USART_TXC_IRQ(i));
+ connect_power_reduction_gpio(s, mc, DEVICE(&s->usart[i]), idx);
+ g_free(devname);
+ }
+
+ /* Timer */
+ for (i = 0; i < TIMER_MAX; i++) {
+ int idx = TIMER(i);
+ if (!mc->dev[idx].addr) {
+ continue;
+ }
+ if (!mc->dev[idx].is_timer16) {
+ create_unimplemented_device("avr-timer8",
+ OFFSET_DATA + mc->dev[idx].addr, 5);
+ create_unimplemented_device("avr-timer8-intmask",
+ OFFSET_DATA
+ + mc->dev[idx].intmask_addr, 1);
+ create_unimplemented_device("avr-timer8-intflag",
+ OFFSET_DATA
+ + mc->dev[idx].intflag_addr, 1);
+ continue;
+ }
+ devname = g_strdup_printf("timer%zu", i);
+ object_initialize_child(OBJECT(dev), devname,
+ &s->timer[i], sizeof(s->timer[i]),
+ TYPE_AVR_TIMER16, &error_abort, NULL);
+ object_property_set_uint(OBJECT(&s->timer[i]), s->xtal_freq_hz,
+ "cpu-frequency-hz", &error_abort);
+ object_property_set_bool(OBJECT(&s->timer[i]), true, "realized",
+ &error_abort);
+ sbd = SYS_BUS_DEVICE(&s->timer[i]);
+ sysbus_mmio_map(sbd, 0, OFFSET_DATA + mc->dev[idx].addr);
+ sysbus_mmio_map(sbd, 1, OFFSET_DATA + mc->dev[idx].intmask_addr);
+ sysbus_mmio_map(sbd, 2, OFFSET_DATA + mc->dev[idx].intflag_addr);
+ connect_peripheral_irq(mc, sbd, cpudev, 0, TIMER_CAPT_IRQ(i));
+ connect_peripheral_irq(mc, sbd, cpudev, 1, TIMER_COMPA_IRQ(i));
+ connect_peripheral_irq(mc, sbd, cpudev, 2, TIMER_COMPB_IRQ(i));
+ connect_peripheral_irq(mc, sbd, cpudev, 3, TIMER_COMPC_IRQ(i));
+ connect_peripheral_irq(mc, sbd, cpudev, 4, TIMER_OVF_IRQ(i));
+ connect_power_reduction_gpio(s, mc, DEVICE(&s->timer[i]), idx);
+ g_free(devname);
+ }
+
+ create_unimplemented_device("avr-twi", OFFSET_DATA + 0x0b8, 6);
+ create_unimplemented_device("avr-adc", OFFSET_DATA + 0x078, 8);
+ create_unimplemented_device("avr-ext-mem-ctrl", OFFSET_DATA + 0x074, 2);
+ create_unimplemented_device("avr-watchdog", OFFSET_DATA + 0x060, 1);
+ create_unimplemented_device("avr-spi", OFFSET_DATA + 0x04c, 3);
+ create_unimplemented_device("avr-eeprom", OFFSET_DATA + 0x03f, 3);
+}
+
+static Property atmega_props[] = {
+ DEFINE_PROP_UINT64("xtal-frequency-hz", AtmegaMcuState,
+ xtal_freq_hz, 0),
+ DEFINE_PROP_END_OF_LIST()
+};
+
+static void atmega_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ dc->realize = atmega_realize;
+ dc->props = atmega_props;
+ /* Reason: Mapped at fixed location on the system bus */
+ dc->user_creatable = false;
+}
+
+static void atmega168_class_init(ObjectClass *oc, void *data)
+{
+ AtmegaMcuClass *amc = ATMEGA_MCU_CLASS(oc);
+
+ amc->cpu_type = AVR_CPU_TYPE_NAME("avr5");
+ amc->flash_size = 16 * KiB;
+ amc->eeprom_size = 512;
+ amc->sram_size = 1 * KiB;
+ amc->io_size = 256;
+ amc->gpio_count = 23;
+ amc->adc_count = 6;
+ amc->irq = irq168_328;
+ amc->dev = dev168_328;
+};
+
+static void atmega328_class_init(ObjectClass *oc, void *data)
+{
+ AtmegaMcuClass *amc = ATMEGA_MCU_CLASS(oc);
+
+ amc->cpu_type = AVR_CPU_TYPE_NAME("avr5");
+ amc->flash_size = 32 * KiB;
+ amc->eeprom_size = 1 * KiB;
+ amc->sram_size = 2 * KiB;
+ amc->io_size = 256;
+ amc->gpio_count = 23;
+ amc->adc_count = 6;
+ amc->irq = irq168_328;
+ amc->dev = dev168_328;
+};
+
+static void atmega1280_class_init(ObjectClass *oc, void *data)
+{
+ AtmegaMcuClass *amc = ATMEGA_MCU_CLASS(oc);
+
+ amc->cpu_type = AVR_CPU_TYPE_NAME("avr6");
+ amc->flash_size = 128 * KiB;
+ amc->eeprom_size = 4 * KiB;
+ amc->sram_size = 8 * KiB;
+ amc->io_size = 512;
+ amc->gpio_count = 86;
+ amc->adc_count = 16;
+ amc->irq = irq1280_2560;
+ amc->dev = dev1280_2560;
+};
+
+static void atmega2560_class_init(ObjectClass *oc, void *data)
+{
+ AtmegaMcuClass *amc = ATMEGA_MCU_CLASS(oc);
+
+ amc->cpu_type = AVR_CPU_TYPE_NAME("avr6");
+ amc->flash_size = 256 * KiB;
+ amc->eeprom_size = 4 * KiB;
+ amc->sram_size = 8 * KiB;
+ amc->io_size = 512;
+ amc->gpio_count = 54;
+ amc->adc_count = 16;
+ amc->irq = irq1280_2560;
+ amc->dev = dev1280_2560;
+};
+
+static const TypeInfo atmega_mcu_types[] = {
+ {
+ .name = TYPE_ATMEGA168_MCU,
+ .parent = TYPE_ATMEGA_MCU,
+ .class_init = atmega168_class_init,
+ }, {
+ .name = TYPE_ATMEGA328_MCU,
+ .parent = TYPE_ATMEGA_MCU,
+ .class_init = atmega328_class_init,
+ }, {
+ .name = TYPE_ATMEGA1280_MCU,
+ .parent = TYPE_ATMEGA_MCU,
+ .class_init = atmega1280_class_init,
+ }, {
+ .name = TYPE_ATMEGA2560_MCU,
+ .parent = TYPE_ATMEGA_MCU,
+ .class_init = atmega2560_class_init,
+ }, {
+ .name = TYPE_ATMEGA_MCU,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(AtmegaMcuState),
+ .class_size = sizeof(AtmegaMcuClass),
+ .class_init = atmega_class_init,
+ .abstract = true,
+ }
+};
+
+DEFINE_TYPES(atmega_mcu_types)
diff --git a/hw/avr/Makefile.objs b/hw/avr/Makefile.objs
index 1eb4b53be6..696f855c74 100644
--- a/hw/avr/Makefile.objs
+++ b/hw/avr/Makefile.objs
@@ -1 +1,2 @@
+obj-$(CONFIG_ATMEL_ATMEGA_MCU) += atmel_atmega.o
obj-$(CONFIG_AVR_SAMPLE) += sample.o
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 14/18] hw/avr: Add some Arduino boards
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2020-01-20 22:01 ` [PATCH v4 13/18] hw/avr: Add some ATmega microcontrollers Philippe Mathieu-Daudé
@ 2020-01-20 22:01 ` Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 15/18] tests/boot-serial-test: Test some Arduino boards (AVR based) Philippe Mathieu-Daudé
` (5 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Philippe Mathieu-Daudé,
Michael Rolnik, Igor Mammedov, Aleksandar Markovic,
Richard Henderson
Arduino boards are build with AVR chipsets.
Add some of the popular boards:
- Arduino Duemilanove
- Arduino Uno
- Arduino Mega
For more information:
https://www.arduino.cc/en/Main/Products
https://store.arduino.cc/arduino-genuino/most-popular
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v4:
- Remove unused 'extram*' fields (Igor)
v2:
- Reword description adding more information (Aleksandar)
- Use DEFINE_TYPES (Igor)
---
default-configs/avr-softmmu.mak | 1 +
hw/avr/arduino.c | 175 ++++++++++++++++++++++++++++++++
hw/avr/Kconfig | 4 +
hw/avr/Makefile.objs | 1 +
4 files changed, 181 insertions(+)
create mode 100644 hw/avr/arduino.c
diff --git a/default-configs/avr-softmmu.mak b/default-configs/avr-softmmu.mak
index d1e1c28118..d8d1d8e6fe 100644
--- a/default-configs/avr-softmmu.mak
+++ b/default-configs/avr-softmmu.mak
@@ -2,4 +2,5 @@
# Boards:
#
+CONFIG_ARDUINO=y
CONFIG_AVR_SAMPLE=y
diff --git a/hw/avr/arduino.c b/hw/avr/arduino.c
new file mode 100644
index 0000000000..784246baba
--- /dev/null
+++ b/hw/avr/arduino.c
@@ -0,0 +1,175 @@
+/*
+ * QEMU Arduino boards
+ *
+ * Copyright (c) 2019 Philippe Mathieu-Daudé
+ *
+ * This work is licensed under the terms of the GNU GPLv2 or later.
+ * See the COPYING file in the top-level directory.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+/* TODO: Implement the use of EXTRAM */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qapi/error.h"
+#include "hw/boards.h"
+#include "hw/loader.h"
+#include "elf.h"
+#include "atmel_atmega.h"
+
+typedef struct ArduinoMachineState {
+ /*< private >*/
+ MachineState parent_obj;
+ /*< public >*/
+ AtmegaMcuState mcu;
+} ArduinoMachineState;
+
+typedef struct ArduinoMachineClass {
+ /*< private >*/
+ MachineClass parent_class;
+ /*< public >*/
+ const char *mcu_type;
+ uint64_t xtal_hz;
+} ArduinoMachineClass;
+
+#define TYPE_ARDUINO_MACHINE \
+ MACHINE_TYPE_NAME("arduino")
+#define ARDUINO_MACHINE(obj) \
+ OBJECT_CHECK(ArduinoMachineState, (obj), TYPE_ARDUINO_MACHINE)
+#define ARDUINO_MACHINE_CLASS(klass) \
+ OBJECT_CLASS_CHECK(ArduinoMachineClass, (klass), TYPE_ARDUINO_MACHINE)
+#define ARDUINO_MACHINE_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(ArduinoMachineClass, (obj), TYPE_ARDUINO_MACHINE)
+
+static void load_firmware(const char *firmware, uint64_t flash_size)
+{
+ const char *filename;
+ int bytes_loaded;
+
+ /* Load firmware (contents of flash) trying to auto-detect format */
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware);
+ if (filename == NULL) {
+ error_report("Unable to find %s", firmware);
+ exit(1);
+ }
+
+ bytes_loaded = load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL,
+ 0, EM_NONE, 0, 0);
+ if (bytes_loaded < 0) {
+ bytes_loaded = load_image_targphys(filename, OFFSET_CODE, flash_size);
+ }
+ if (bytes_loaded < 0) {
+ error_report("Unable to load firmware image %s as ELF or raw binary",
+ firmware);
+ exit(1);
+ }
+}
+
+static void arduino_machine_init(MachineState *machine)
+{
+ ArduinoMachineClass *amc = ARDUINO_MACHINE_GET_CLASS(machine);
+ ArduinoMachineState *ams = ARDUINO_MACHINE(machine);
+
+ sysbus_init_child_obj(OBJECT(machine), "mcu", &ams->mcu, sizeof(ams->mcu),
+ amc->mcu_type);
+ object_property_set_uint(OBJECT(&ams->mcu), amc->xtal_hz,
+ "xtal-frequency-hz", &error_abort);
+ object_property_set_bool(OBJECT(&ams->mcu), true, "realized",
+ &error_abort);
+
+ if (machine->firmware) {
+ load_firmware(machine->firmware, memory_region_size(&ams->mcu.flash));
+ }
+}
+
+static void arduino_machine_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+
+ mc->init = arduino_machine_init;
+ mc->default_cpus = 1;
+ mc->min_cpus = mc->default_cpus;
+ mc->max_cpus = mc->default_cpus;
+ mc->no_floppy = 1;
+ mc->no_cdrom = 1;
+ mc->no_parallel = 1;
+}
+
+static void arduino_duemilanove_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ ArduinoMachineClass *amc = ARDUINO_MACHINE_CLASS(oc);
+
+ /* https://www.arduino.cc/en/Main/ArduinoBoardDuemilanove */
+ mc->desc = "Arduino Duemilanove (ATmega168)",
+ mc->alias = "2009";
+ amc->mcu_type = TYPE_ATMEGA168_MCU;
+ amc->xtal_hz = 16 * 1000 * 1000;
+};
+
+static void arduino_uno_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ ArduinoMachineClass *amc = ARDUINO_MACHINE_CLASS(oc);
+
+ /* https://store.arduino.cc/arduino-uno-rev3 */
+ mc->desc = "Arduino UNO (ATmega328P)";
+ mc->alias = "uno";
+ amc->mcu_type = TYPE_ATMEGA328_MCU;
+ amc->xtal_hz = 16 * 1000 * 1000;
+};
+
+static void arduino_mega_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ ArduinoMachineClass *amc = ARDUINO_MACHINE_CLASS(oc);
+
+ /* https://www.arduino.cc/en/Main/ArduinoBoardMega */
+ mc->desc = "Arduino Mega (ATmega1280)";
+ mc->alias = "mega";
+ amc->mcu_type = TYPE_ATMEGA1280_MCU;
+ amc->xtal_hz = 16 * 1000 * 1000;
+};
+
+static void arduino_mega2560_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+ ArduinoMachineClass *amc = ARDUINO_MACHINE_CLASS(oc);
+
+ /* https://store.arduino.cc/arduino-mega-2560-rev3 */
+ mc->desc = "Arduino Mega 2560 (ATmega2560)";
+ mc->alias = "mega2560";
+ mc->is_default = true;
+ amc->mcu_type = TYPE_ATMEGA2560_MCU;
+ amc->xtal_hz = 16 * 1000 * 1000; /* CSTCE16M0V53-R0 */
+};
+
+static const TypeInfo arduino_machine_types[] = {
+ {
+ .name = MACHINE_TYPE_NAME("arduino-duemilanove"),
+ .parent = TYPE_ARDUINO_MACHINE,
+ .class_init = arduino_duemilanove_class_init,
+ }, {
+ .name = MACHINE_TYPE_NAME("arduino-uno"),
+ .parent = TYPE_ARDUINO_MACHINE,
+ .class_init = arduino_uno_class_init,
+ }, {
+ .name = MACHINE_TYPE_NAME("arduino-mega"),
+ .parent = TYPE_ARDUINO_MACHINE,
+ .class_init = arduino_mega_class_init,
+ }, {
+ .name = MACHINE_TYPE_NAME("arduino-mega-2560-v3"),
+ .parent = TYPE_ARDUINO_MACHINE,
+ .class_init = arduino_mega2560_class_init,
+ }, {
+ .name = TYPE_ARDUINO_MACHINE,
+ .parent = TYPE_MACHINE,
+ .instance_size = sizeof(ArduinoMachineState),
+ .class_size = sizeof(ArduinoMachineClass),
+ .class_init = arduino_machine_class_init,
+ .abstract = true,
+ }
+};
+
+DEFINE_TYPES(arduino_machine_types)
diff --git a/hw/avr/Kconfig b/hw/avr/Kconfig
index 228eae7582..7907584ac7 100644
--- a/hw/avr/Kconfig
+++ b/hw/avr/Kconfig
@@ -4,6 +4,10 @@ config ATMEL_ATMEGA_MCU
select ATMEL_USART
select ATMEL_POWER
+config ARDUINO
+ select ATMEL_ATMEGA_MCU
+ select UNIMP
+
config AVR_SAMPLE
select ATMEL_ATMEGA_MCU
select UNIMP
diff --git a/hw/avr/Makefile.objs b/hw/avr/Makefile.objs
index 696f855c74..b36ca77cf0 100644
--- a/hw/avr/Makefile.objs
+++ b/hw/avr/Makefile.objs
@@ -1,2 +1,3 @@
obj-$(CONFIG_ATMEL_ATMEGA_MCU) += atmel_atmega.o
+obj-$(CONFIG_ARDUINO) += arduino.o
obj-$(CONFIG_AVR_SAMPLE) += sample.o
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 15/18] tests/boot-serial-test: Test some Arduino boards (AVR based)
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2020-01-20 22:01 ` [PATCH v4 14/18] hw/avr: Add some Arduino boards Philippe Mathieu-Daudé
@ 2020-01-20 22:01 ` Philippe Mathieu-Daudé
2020-01-21 6:11 ` Thomas Huth
2020-01-20 22:01 ` [PATCH v4 16/18] tests/acceptance: Test the Arduino MEGA2560 board Philippe Mathieu-Daudé
` (4 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Thomas Huth, Sarah Harris,
Philippe Mathieu-Daudé,
Michael Rolnik, Paolo Bonzini, Aleksandar Markovic,
Richard Henderson
The Arduino Duemilanove is based on a AVR5 CPU, while the
Arduino MEGA2560 on a AVR6 CPU.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
tests/qtest/boot-serial-test.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
index e556f09db8..582a497963 100644
--- a/tests/qtest/boot-serial-test.c
+++ b/tests/qtest/boot-serial-test.c
@@ -113,6 +113,8 @@ typedef struct testdef {
static testdef_t tests[] = {
{ "alpha", "clipper", "", "PCI:" },
{ "avr", "sample", "", "T", sizeof(bios_avr), NULL, bios_avr },
+ { "avr", "arduino-duemilanove", "", "T", sizeof(bios_avr), NULL, bios_avr },
+ { "avr", "arduino-mega-2560-v3", "", "T", sizeof(bios_avr), NULL, bios_avr},
{ "ppc", "ppce500", "", "U-Boot" },
{ "ppc", "40p", "-vga none -boot d", "Trying cd:," },
{ "ppc", "g3beige", "", "PowerPC,750" },
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 16/18] tests/acceptance: Test the Arduino MEGA2560 board
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2020-01-20 22:01 ` [PATCH v4 15/18] tests/boot-serial-test: Test some Arduino boards (AVR based) Philippe Mathieu-Daudé
@ 2020-01-20 22:01 ` Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 17/18] hw/avr: Remove the unrealistic AVR 'sample' board Philippe Mathieu-Daudé
` (3 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Sarah Harris, Michael Rolnik, Philippe Mathieu-Daudé,
Aleksandar Markovic, Richard Henderson
As the path name demonstrates, the FreeRTOS tests target a
board based on a ATMega2560 MCU. We have one, the Arduino
MEGA2560.
Complementary documentation:
https://feilipu.me/2012/01/15/ethermega-arduino-mega-2560-and-freertos/
https://feilipu.me/2015/11/24/arduino_freertos/ (see 'Compatibility')
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
tests/acceptance/machine_avr6.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/acceptance/machine_avr6.py b/tests/acceptance/machine_avr6.py
index 611f6a62a4..b644d2a81c 100644
--- a/tests/acceptance/machine_avr6.py
+++ b/tests/acceptance/machine_avr6.py
@@ -27,7 +27,7 @@ class AVR6Machine(Test):
def test_freertos(self):
"""
:avocado: tags=arch:avr
- :avocado: tags=machine:sample
+ :avocado: tags=machine:arduino-mega-2560-v3
"""
"""
https://github.com/seharris/qemu-avr-tests/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 17/18] hw/avr: Remove the unrealistic AVR 'sample' board
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2020-01-20 22:01 ` [PATCH v4 16/18] tests/acceptance: Test the Arduino MEGA2560 board Philippe Mathieu-Daudé
@ 2020-01-20 22:01 ` Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 18/18] .travis.yml: Run the AVR acceptance tests Philippe Mathieu-Daudé
` (2 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Thomas Huth, Sarah Harris,
Philippe Mathieu-Daudé,
Michael Rolnik, Paolo Bonzini, Aleksandar Markovic,
Richard Henderson
The 'arduino-mega-2560-v3' board fully replace the 'sample'
board.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
!squash?
---
default-configs/avr-softmmu.mak | 1 -
hw/avr/sample.c | 295 --------------------------------
tests/qtest/boot-serial-test.c | 1 -
hw/avr/Kconfig | 4 -
hw/avr/Makefile.objs | 1 -
5 files changed, 302 deletions(-)
delete mode 100644 hw/avr/sample.c
diff --git a/default-configs/avr-softmmu.mak b/default-configs/avr-softmmu.mak
index d8d1d8e6fe..80218add98 100644
--- a/default-configs/avr-softmmu.mak
+++ b/default-configs/avr-softmmu.mak
@@ -3,4 +3,3 @@
# Boards:
#
CONFIG_ARDUINO=y
-CONFIG_AVR_SAMPLE=y
diff --git a/hw/avr/sample.c b/hw/avr/sample.c
deleted file mode 100644
index 19b8c067e5..0000000000
--- a/hw/avr/sample.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * QEMU AVR CPU
- *
- * Copyright (c) 2019 Michael Rolnik
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see
- * <http://www.gnu.org/licenses/lgpl-2.1.html>
- */
-
-/*
- * NOTE:
- * This is not a real AVR board, this is an example!
- * The CPU is an approximation of an ATmega2560, but is missing various
- * built-in peripherals.
- *
- * This example board loads provided binary file into flash memory and
- * executes it from 0x00000000 address in the code memory space.
- *
- * Currently used for AVR CPU validation
- *
- */
-
-#include "qemu/osdep.h"
-#include "qapi/error.h"
-#include "qemu-common.h"
-#include "cpu.h"
-#include "hw/hw.h"
-#include "sysemu/sysemu.h"
-#include "sysemu/qtest.h"
-#include "ui/console.h"
-#include "hw/boards.h"
-#include "hw/loader.h"
-#include "qemu/error-report.h"
-#include "exec/address-spaces.h"
-#include "include/hw/sysbus.h"
-#include "include/hw/char/atmel_usart.h"
-#include "include/hw/timer/atmel_timer16.h"
-#include "include/hw/misc/atmel_power.h"
-#include "elf.h"
-#include "hw/misc/unimp.h"
-
-#define SIZE_FLASH 0x00040000
-#define SIZE_SRAM 0x00002000
-/*
- * Size of additional "external" memory, as if the AVR were configured to use
- * an external RAM chip.
- * Note that the configuration registers that normally enable this feature are
- * unimplemented.
- */
-#define SIZE_EXMEM 0x00000000
-
-/* Offsets of peripherals in emulated memory space (i.e. not host addresses) */
-#define PRR0_BASE 0x64
-#define PRR1_BASE 0x65
-#define USART_BASE 0xc0
-#define TIMER1_BASE 0x80
-#define TIMER1_IMSK_BASE 0x6f
-#define TIMER1_IFR_BASE 0x36
-
-/* Interrupt numbers used by peripherals */
-#define USART_RXC_IRQ 24
-#define USART_DRE_IRQ 25
-#define USART_TXC_IRQ 26
-
-#define TIMER1_CAPT_IRQ 15
-#define TIMER1_COMPA_IRQ 16
-#define TIMER1_COMPB_IRQ 17
-#define TIMER1_COMPC_IRQ 18
-#define TIMER1_OVF_IRQ 19
-
-/* Power reduction */
-#define PRR1_BIT_PRTIM5 0x05 /* Timer/Counter5 */
-#define PRR1_BIT_PRTIM4 0x04 /* Timer/Counter4 */
-#define PRR1_BIT_PRTIM3 0x03 /* Timer/Counter3 */
-#define PRR1_BIT_PRUSART3 0x02 /* USART3 */
-#define PRR1_BIT_PRUSART2 0x01 /* USART2 */
-#define PRR1_BIT_PRUSART1 0x00 /* USART1 */
-
-#define PRR0_BIT_PRTWI 0x06 /* TWI */
-#define PRR0_BIT_PRTIM2 0x05 /* Timer/Counter2 */
-#define PRR0_BIT_PRTIM0 0x04 /* Timer/Counter0 */
-#define PRR0_BIT_PRTIM1 0x03 /* Timer/Counter1 */
-#define PRR0_BIT_PRSPI 0x02 /* Serial Peripheral Interface */
-#define PRR0_BIT_PRUSART0 0x01 /* USART0 */
-#define PRR0_BIT_PRADC 0x00 /* ADC */
-
-#define configCPU_CLOCK_HZ ((unsigned long)16000000)
-
-typedef struct {
- MachineClass parent;
-} SampleMachineClass;
-
-typedef struct {
- MachineState parent;
- MemoryRegion *ram;
- MemoryRegion *flash;
- AVRUsartState *usart0;
- AVRTimer16State *timer1;
- AVRMaskState *prr[2];
-} SampleMachineState;
-
-#define TYPE_SAMPLE_MACHINE MACHINE_TYPE_NAME("sample")
-
-#define SAMPLE_MACHINE(obj) \
- OBJECT_CHECK(SampleMachineState, obj, TYPE_SAMPLE_MACHINE)
-#define SAMPLE_MACHINE_GET_CLASS(obj) \
- OBJECT_GET_CLASS(SampleMachineClass, obj, TYPE_SAMPLE_MACHINE)
-#define SAMPLE_MACHINE_CLASS(klass) \
- OBJECT_CLASS_CHECK(SampleMachineClass, klass, TYPE_SAMPLE_MACHINE)
-
-static void sample_init(MachineState *machine)
-{
- SampleMachineState *sms = SAMPLE_MACHINE(machine);
- MemoryRegion *system_memory = get_system_memory();
- AVRCPU *cpu;
- const char *firmware = NULL;
- const char *filename = NULL;
- const char *cpu_type = NULL;
- uint32_t e_flags;
- int bytes_loaded;
- SysBusDevice *busdev;
- DeviceState *cpudev;
-
- system_memory = get_system_memory();
- sms->ram = g_new(MemoryRegion, 1);
- sms->flash = g_new(MemoryRegion, 1);
-
- /* if ELF file is provided, determine CPU type reading ELF e_flags */
- cpu_type = machine->cpu_type;
- firmware = machine->firmware;
- if (firmware != NULL) {
- filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware);
- if (filename == NULL) {
- error_report("Unable to find %s", firmware);
- exit(1);
- }
-
- bytes_loaded = load_elf_ram_sym(filename, NULL, NULL, NULL, NULL, NULL,
- NULL, &e_flags, 0, EM_AVR, 0, 0, NULL, 0, 0);
- if (bytes_loaded > 0) {
- cpu_type = avr_flags_to_cpu_type(e_flags, cpu_type);
- }
- }
-
- cpu = AVR_CPU(cpu_create(cpu_type));
- cpudev = DEVICE(cpu);
-
- memory_region_init_rom(sms->flash, NULL, "avr.flash", SIZE_FLASH,
- &error_fatal);
- memory_region_add_subregion(system_memory, OFFSET_CODE, sms->flash);
-
- /* following are atmel2560 device */
- create_unimplemented_device("usart 3", OFFSET_DATA + 0x0130, 0x0007);
- create_unimplemented_device("timer-counter-16bit 5",
- OFFSET_DATA + 0x0120, 0x000e);
- create_unimplemented_device("gpio L", OFFSET_DATA + 0x0109, 0x0003);
- create_unimplemented_device("gpio K", OFFSET_DATA + 0x0106, 0x0003);
- create_unimplemented_device("gpio J", OFFSET_DATA + 0x0103, 0x0003);
- create_unimplemented_device("gpio H", OFFSET_DATA + 0x0100, 0x0003);
- create_unimplemented_device("usart 2", OFFSET_DATA + 0x00d0, 0x0007);
- create_unimplemented_device("usart 1", OFFSET_DATA + 0x00c8, 0x0007);
- create_unimplemented_device("twi", OFFSET_DATA + 0x00b8, 0x0006);
- create_unimplemented_device("timer-counter-async-8bit 2",
- OFFSET_DATA + 0x00b0, 0x0007);
- create_unimplemented_device("timer-counter-16bit 4",
- OFFSET_DATA + 0x00a0, 0x000e);
- create_unimplemented_device("timer-counter-16bit 3",
- OFFSET_DATA + 0x0090, 0x000e);
- create_unimplemented_device("ac / adc",
- OFFSET_DATA + 0x0078, 0x0008);
- create_unimplemented_device("ext-mem-iface",
- OFFSET_DATA + 0x0074, 0x0002);
- create_unimplemented_device("int-controller",
- OFFSET_DATA + 0x0068, 0x0006);
- create_unimplemented_device("sys",
- OFFSET_DATA + 0x0060, 0x0007);
- create_unimplemented_device("spi",
- OFFSET_DATA + 0x004c, 0x0003);
- create_unimplemented_device("ext-mem-iface",
- OFFSET_DATA + 0x004a, 0x0002);
- create_unimplemented_device("timer-counter-pwm-8bit 0",
- OFFSET_DATA + 0x0044, 0x0005);
- create_unimplemented_device("ext-mem-iface",
- OFFSET_DATA + 0x003e, 0x0005);
- create_unimplemented_device("int-controller",
- OFFSET_DATA + 0x0035, 0x0009);
- create_unimplemented_device("gpio G", OFFSET_DATA + 0x0032, 0x0003);
- create_unimplemented_device("gpio F", OFFSET_DATA + 0x002f, 0x0003);
- create_unimplemented_device("gpio E", OFFSET_DATA + 0x002c, 0x0003);
- create_unimplemented_device("gpio D", OFFSET_DATA + 0x0029, 0x0003);
- create_unimplemented_device("gpio C", OFFSET_DATA + 0x0026, 0x0003);
- create_unimplemented_device("gpio B", OFFSET_DATA + 0x0023, 0x0003);
- create_unimplemented_device("gpio A", OFFSET_DATA + 0x0020, 0x0003);
-
- memory_region_allocate_system_memory(
- sms->ram, NULL, "avr.ram", SIZE_SRAM + SIZE_EXMEM);
- memory_region_add_subregion(system_memory, OFFSET_DATA + 0x200, sms->ram);
-
- /* Power Reduction built-in peripheral */
- sms->prr[0] = AVR_MASK(sysbus_create_simple(TYPE_AVR_MASK,
- OFFSET_DATA + PRR0_BASE, NULL));
- sms->prr[1] = AVR_MASK(sysbus_create_simple(TYPE_AVR_MASK,
- OFFSET_DATA + PRR1_BASE, NULL));
-
- /* USART 0 built-in peripheral */
- sms->usart0 = AVR_USART(object_new(TYPE_AVR_USART));
- busdev = SYS_BUS_DEVICE(sms->usart0);
- qdev_prop_set_chr(DEVICE(sms->usart0), "chardev", serial_hd(0));
- object_property_set_bool(OBJECT(sms->usart0), true, "realized",
- &error_fatal);
- sysbus_mmio_map(busdev, 0, OFFSET_DATA + USART_BASE);
- /*
- * These IRQ numbers don't match the datasheet because we're counting from
- * zero and not including reset.
- */
- sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(cpudev, USART_RXC_IRQ));
- sysbus_connect_irq(busdev, 1, qdev_get_gpio_in(cpudev, USART_DRE_IRQ));
- sysbus_connect_irq(busdev, 2, qdev_get_gpio_in(cpudev, USART_TXC_IRQ));
- sysbus_connect_irq(SYS_BUS_DEVICE(sms->prr[1]), PRR1_BIT_PRUSART1,
- qdev_get_gpio_in(DEVICE(sms->usart0), 0));
-
- /* Timer 1 built-in periphal */
- sms->timer1 = AVR_TIMER16(object_new(TYPE_AVR_TIMER16));
- object_property_set_uint(OBJECT(sms->timer1), 1, "id", &error_abort);
- object_property_set_uint(OBJECT(sms->timer1), configCPU_CLOCK_HZ,
- "cpu-frequency-hz", &error_abort);
- object_property_set_bool(OBJECT(sms->timer1), true, "realized",
- &error_fatal);
- busdev = SYS_BUS_DEVICE(sms->timer1);
- sysbus_mmio_map(busdev, 0, OFFSET_DATA + TIMER1_BASE);
- sysbus_mmio_map(busdev, 1, OFFSET_DATA + TIMER1_IMSK_BASE);
- sysbus_mmio_map(busdev, 2, OFFSET_DATA + TIMER1_IFR_BASE);
- sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(cpudev, TIMER1_CAPT_IRQ));
- sysbus_connect_irq(busdev, 1, qdev_get_gpio_in(cpudev, TIMER1_COMPA_IRQ));
- sysbus_connect_irq(busdev, 2, qdev_get_gpio_in(cpudev, TIMER1_COMPB_IRQ));
- sysbus_connect_irq(busdev, 3, qdev_get_gpio_in(cpudev, TIMER1_COMPC_IRQ));
- sysbus_connect_irq(busdev, 4, qdev_get_gpio_in(cpudev, TIMER1_OVF_IRQ));
- sysbus_connect_irq(SYS_BUS_DEVICE(sms->prr[0]), PRR0_BIT_PRTIM1,
- qdev_get_gpio_in(DEVICE(sms->timer1), 0));
-
- /* Load firmware (contents of flash) trying to auto-detect format */
- if (filename != NULL) {
- bytes_loaded = load_elf(
- filename, NULL, NULL, NULL, NULL, NULL, NULL, 0, EM_NONE, 0, 0);
- if (bytes_loaded < 0) {
- bytes_loaded = load_image_targphys(
- filename, OFFSET_CODE, SIZE_FLASH);
- }
- if (bytes_loaded < 0) {
- error_report(
- "Unable to load firmware image %s as ELF or raw binary",
- firmware);
- exit(1);
- }
- }
-}
-
-static void sample_class_init(ObjectClass *oc, void *data)
-{
- MachineClass *mc = MACHINE_CLASS(oc);
-
- mc->desc = "AVR sample/example board (ATmega2560)";
- mc->init = sample_init;
- mc->default_cpus = 1;
- mc->min_cpus = mc->default_cpus;
- mc->max_cpus = mc->default_cpus;
- mc->default_cpu_type = AVR_CPU_TYPE_NAME("avr5");
- mc->is_default = 1;
-}
-
-static const TypeInfo sample_info = {
- .name = TYPE_SAMPLE_MACHINE,
- .parent = TYPE_MACHINE,
- .instance_size = sizeof(SampleMachineState),
- .class_size = sizeof(SampleMachineClass),
- .class_init = sample_class_init,
-};
-
-static void sample_machine_init(void)
-{
- type_register_static(&sample_info);
-}
-
-type_init(sample_machine_init);
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
index 582a497963..07067b76a2 100644
--- a/tests/qtest/boot-serial-test.c
+++ b/tests/qtest/boot-serial-test.c
@@ -112,7 +112,6 @@ typedef struct testdef {
static testdef_t tests[] = {
{ "alpha", "clipper", "", "PCI:" },
- { "avr", "sample", "", "T", sizeof(bios_avr), NULL, bios_avr },
{ "avr", "arduino-duemilanove", "", "T", sizeof(bios_avr), NULL, bios_avr },
{ "avr", "arduino-mega-2560-v3", "", "T", sizeof(bios_avr), NULL, bios_avr},
{ "ppc", "ppce500", "", "U-Boot" },
diff --git a/hw/avr/Kconfig b/hw/avr/Kconfig
index 7907584ac7..59d9649d27 100644
--- a/hw/avr/Kconfig
+++ b/hw/avr/Kconfig
@@ -7,7 +7,3 @@ config ATMEL_ATMEGA_MCU
config ARDUINO
select ATMEL_ATMEGA_MCU
select UNIMP
-
-config AVR_SAMPLE
- select ATMEL_ATMEGA_MCU
- select UNIMP
diff --git a/hw/avr/Makefile.objs b/hw/avr/Makefile.objs
index b36ca77cf0..f6aab1438d 100644
--- a/hw/avr/Makefile.objs
+++ b/hw/avr/Makefile.objs
@@ -1,3 +1,2 @@
obj-$(CONFIG_ATMEL_ATMEGA_MCU) += atmel_atmega.o
obj-$(CONFIG_ARDUINO) += arduino.o
-obj-$(CONFIG_AVR_SAMPLE) += sample.o
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v4 18/18] .travis.yml: Run the AVR acceptance tests
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2020-01-20 22:01 ` [PATCH v4 17/18] hw/avr: Remove the unrealistic AVR 'sample' board Philippe Mathieu-Daudé
@ 2020-01-20 22:01 ` Philippe Mathieu-Daudé
2020-01-20 23:30 ` [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
2020-01-21 19:25 ` Michael Rolnik
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Fam Zheng, Sarah Harris, Philippe Mathieu-Daudé,
Philippe Mathieu-Daudé,
Michael Rolnik, Alex Bennée, Aleksandar Markovic,
Richard Henderson
We have one test so far, and it is very fast:
$ avocado --show=app run -t arch:avr tests/acceptance/
(1/1) tests/acceptance/machine_avr6.py:AVR6Machine.test_freertos: PASS (2.13 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME : 2.30 s
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 6c1038a0f1..2301c9221e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -268,7 +268,7 @@ matrix:
# Acceptance (Functional) tests
- env:
- - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc-softmmu,ppc64-softmmu,m68k-softmmu,sparc-softmmu"
+ - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc-softmmu,ppc64-softmmu,m68k-softmmu,sparc-softmmu,avr-softmmu"
- TEST_CMD="make check-acceptance"
after_script:
- python3 -c 'import json; r = json.load(open("tests/results/latest/results.json")); [print(t["logfile"]) for t in r["tests"] if t["status"] not in ("PASS", "SKIP")]' | xargs cat
--
2.21.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v4 00/18] hw/avr: Introduce few Arduino boards
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2020-01-20 22:01 ` [PATCH v4 18/18] .travis.yml: Run the AVR acceptance tests Philippe Mathieu-Daudé
@ 2020-01-20 23:30 ` Philippe Mathieu-Daudé
2020-01-21 19:25 ` Michael Rolnik
19 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-20 23:30 UTC (permalink / raw)
To: qemu-devel@nongnu.org Developers, Paolo Bonzini
Cc: Sarah Harris, Michael Rolnik, Aleksandar Markovic, Richard Henderson
On Mon, Jan 20, 2020 at 11:01 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Hi,
>
> This series add the arduino boards, aiming at removing the
> 'sample' board that doesn't follow any specification.
>
> Since v3:
> - Rebased on Michael's v41
> - Drop 'extram' unused field (Igor)
> - Renamed devices AVR -> Atmel (Aleksandar)
> (I haven't renamed structure names to ease review)
>
> Since v2:
> - rebased on Michael's v40
>
> Since v1:
> - Addressed Igor comments
> - Addressed Aleksandar comments
> - Fixed UART issue (was due to IRQ shifted by 2 in CPU)
>
> Since Michael's work is not yet merged, Various of my patches
> - which are trivials or simple renames - could be squashed
> directly on his patches, if we ever care.
> [I believe sending this patches is easier/quicker than keeping
> asking Michael to respin his series infinitely].
>
> Michael, do you mind testing it? The full series is available
> here: https://gitlab.com/philmd/qemu/commits/arduino-v4
>
> Regards,
>
> Phil.
>
> Obsoletes: <20191229224505.24466-1-f4bug@amsat.org>
Argh the correct tag is:
Supersedes: <20191229224505.24466-1-f4bug@amsat.org>
Paolo: will this work? (replying to the cover)
> Based-on: <20200118191416.19934-1-mrolnik@gmail.com>
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg671707.html
>
> Philippe Mathieu-Daudé (18):
> MAINTAINERS: Move machine test to the machine section (not ARCH one)
> MAINTAINERS: Move the AVR machines in new section (not within ARM)
> tests/acceptance: Do not set the machine type manually
> tests/acceptance: Keep multilines comment consistent with other tests
> hw/char/avr: Reduce USART I/O size
> hw/timer/avr_timer16: Rename memory region debugging name
> hw/misc/avr_mask: Remove unused include
> hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
> hw/char: Rename avr_usart -> atmel_usart
> hw/timer: Rename avr_timer16 -> atmel_timer16
> hw/misc: Rename avr_mask -> atmel_power
> hw/avr: Introduce ATMEL_ATMEGA_MCU config
> hw/avr: Add some ATmega microcontrollers
> hw/avr: Add some Arduino boards
> tests/boot-serial-test: Test some Arduino boards (AVR based)
> tests/acceptance: Test the Arduino MEGA2560 board
> hw/avr: Remove the unrealistic AVR 'sample' board
> .travis.yml: Run the AVR acceptance tests
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 15/18] tests/boot-serial-test: Test some Arduino boards (AVR based)
2020-01-20 22:01 ` [PATCH v4 15/18] tests/boot-serial-test: Test some Arduino boards (AVR based) Philippe Mathieu-Daudé
@ 2020-01-21 6:11 ` Thomas Huth
0 siblings, 0 replies; 25+ messages in thread
From: Thomas Huth @ 2020-01-21 6:11 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Laurent Vivier, Sarah Harris, Michael Rolnik, Paolo Bonzini,
Aleksandar Markovic, Richard Henderson
On 20/01/2020 23.01, Philippe Mathieu-Daudé wrote:
> The Arduino Duemilanove is based on a AVR5 CPU, while the
> Arduino MEGA2560 on a AVR6 CPU.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> tests/qtest/boot-serial-test.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
> index e556f09db8..582a497963 100644
> --- a/tests/qtest/boot-serial-test.c
> +++ b/tests/qtest/boot-serial-test.c
> @@ -113,6 +113,8 @@ typedef struct testdef {
> static testdef_t tests[] = {
> { "alpha", "clipper", "", "PCI:" },
> { "avr", "sample", "", "T", sizeof(bios_avr), NULL, bios_avr },
> + { "avr", "arduino-duemilanove", "", "T", sizeof(bios_avr), NULL, bios_avr },
> + { "avr", "arduino-mega-2560-v3", "", "T", sizeof(bios_avr), NULL, bios_avr},
> { "ppc", "ppce500", "", "U-Boot" },
> { "ppc", "40p", "-vga none -boot d", "Trying cd:," },
> { "ppc", "g3beige", "", "PowerPC,750" },
>
Acked-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 00/18] hw/avr: Introduce few Arduino boards
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2020-01-20 23:30 ` [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
@ 2020-01-21 19:25 ` Michael Rolnik
2020-01-21 21:23 ` Philippe Mathieu-Daudé
19 siblings, 1 reply; 25+ messages in thread
From: Michael Rolnik @ 2020-01-21 19:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Sarah Harris, QEMU Developers, Aleksandar Markovic, Richard Henderson
[-- Attachment #1: Type: text/plain, Size: 4852 bytes --]
Hi Philippe.
1. I cannot access https://gitlab.com/philmd/qemu/commits/arduino-v4
2. I merged your series into my workspace using patchwork
3. I payed attention that that you don't use automatic CPU detection (as
suggested by Aleksandar) by reading elf.
4. There is difference between -bios and -kernel (arduino boars crash when
-bios is used, but this seems because I run avr6 on avr5 CPU). I would be
happy if you explained what is the difference between these two arguments.
5. make check-acceptance pass correctly
6. make check-qtest-avr pass correctly
On Tue, Jan 21, 2020 at 12:01 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:
> Hi,
>
> This series add the arduino boards, aiming at removing the
> 'sample' board that doesn't follow any specification.
>
> Since v3:
> - Rebased on Michael's v41
> - Drop 'extram' unused field (Igor)
> - Renamed devices AVR -> Atmel (Aleksandar)
> (I haven't renamed structure names to ease review)
>
> Since v2:
> - rebased on Michael's v40
>
> Since v1:
> - Addressed Igor comments
> - Addressed Aleksandar comments
> - Fixed UART issue (was due to IRQ shifted by 2 in CPU)
>
> Since Michael's work is not yet merged, Various of my patches
> - which are trivials or simple renames - could be squashed
> directly on his patches, if we ever care.
> [I believe sending this patches is easier/quicker than keeping
> asking Michael to respin his series infinitely].
>
> Michael, do you mind testing it? The full series is available
> here: https://gitlab.com/philmd/qemu/commits/arduino-v4
>
> Regards,
>
> Phil.
>
> Obsoletes: <20191229224505.24466-1-f4bug@amsat.org>
> Based-on: <20200118191416.19934-1-mrolnik@gmail.com>
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg671707.html
>
> Philippe Mathieu-Daudé (18):
> MAINTAINERS: Move machine test to the machine section (not ARCH one)
> MAINTAINERS: Move the AVR machines in new section (not within ARM)
> tests/acceptance: Do not set the machine type manually
> tests/acceptance: Keep multilines comment consistent with other tests
> hw/char/avr: Reduce USART I/O size
> hw/timer/avr_timer16: Rename memory region debugging name
> hw/misc/avr_mask: Remove unused include
> hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
> hw/char: Rename avr_usart -> atmel_usart
> hw/timer: Rename avr_timer16 -> atmel_timer16
> hw/misc: Rename avr_mask -> atmel_power
> hw/avr: Introduce ATMEL_ATMEGA_MCU config
> hw/avr: Add some ATmega microcontrollers
> hw/avr: Add some Arduino boards
> tests/boot-serial-test: Test some Arduino boards (AVR based)
> tests/acceptance: Test the Arduino MEGA2560 board
> hw/avr: Remove the unrealistic AVR 'sample' board
> .travis.yml: Run the AVR acceptance tests
>
> default-configs/avr-softmmu.mak | 2 +-
> hw/avr/atmel_atmega.h | 48 ++
> .../hw/char/{avr_usart.h => atmel_usart.h} | 10 +-
> include/hw/misc/{avr_mask.h => atmel_power.h} | 11 +-
> .../timer/{avr_timer16.h => atmel_timer16.h} | 10 +-
> hw/avr/arduino.c | 175 +++++++
> hw/avr/atmel_atmega.c | 464 ++++++++++++++++++
> hw/avr/sample.c | 295 -----------
> hw/char/{avr_usart.c => atmel_usart.c} | 6 +-
> hw/misc/{avr_mask.c => atmel_power.c} | 4 +-
> hw/timer/{avr_timer16.c => atmel_timer16.c} | 10 +-
> tests/qtest/boot-serial-test.c | 3 +-
> .travis.yml | 2 +-
> MAINTAINERS | 29 +-
> hw/avr/Kconfig | 11 +-
> hw/avr/Makefile.objs | 3 +-
> hw/char/Kconfig | 2 +-
> hw/char/Makefile.objs | 2 +-
> hw/misc/Kconfig | 2 +-
> hw/misc/Makefile.objs | 2 +-
> hw/timer/Kconfig | 2 +-
> hw/timer/Makefile.objs | 2 +-
> tests/acceptance/machine_avr6.py | 11 +-
> 23 files changed, 751 insertions(+), 355 deletions(-)
> create mode 100644 hw/avr/atmel_atmega.h
> rename include/hw/char/{avr_usart.h => atmel_usart.h} (93%)
> rename include/hw/misc/{avr_mask.h => atmel_power.h} (89%)
> rename include/hw/timer/{avr_timer16.h => atmel_timer16.h} (92%)
> create mode 100644 hw/avr/arduino.c
> create mode 100644 hw/avr/atmel_atmega.c
> delete mode 100644 hw/avr/sample.c
> rename hw/char/{avr_usart.c => atmel_usart.c} (99%)
> rename hw/misc/{avr_mask.c => atmel_power.c} (97%)
> rename hw/timer/{avr_timer16.c => atmel_timer16.c} (98%)
>
> --
> 2.21.1
>
>
--
Best Regards,
Michael Rolnik
[-- Attachment #2: Type: text/html, Size: 6343 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 00/18] hw/avr: Introduce few Arduino boards
2020-01-21 19:25 ` Michael Rolnik
@ 2020-01-21 21:23 ` Philippe Mathieu-Daudé
2020-01-22 20:46 ` Richard Henderson
0 siblings, 1 reply; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-21 21:23 UTC (permalink / raw)
To: Michael Rolnik, Peter Maydell, Paolo Bonzini
Cc: Sarah Harris, QEMU Developers, Aleksandar Markovic, Richard Henderson
On Tue, Jan 21, 2020 at 8:26 PM Michael Rolnik <mrolnik@gmail.com> wrote:
>
> Hi Philippe.
>
> 1. I cannot access https://gitlab.com/philmd/qemu/commits/arduino-v4
Oops I pushed to GitHub instead =) Now it is on GitLab too.
> 2. I merged your series into my workspace using patchwork
> 3. I payed attention that that you don't use automatic CPU detection (as suggested by Aleksandar) by reading elf.
I see, I based my work on your v38, and missed the later changes:
changes since v38
- fix elf loader function bug introduced by prev version
And probably:
changes since v39
- add frequency parameter to AVR timer
I'll look at Aleksandar suggestion and your last your changes, and update.
> 4. There is difference between -bios and -kernel (arduino boars crash when -bios is used, but this seems because I run avr6 on avr5 CPU). I would be happy if you explained what is the difference between these two arguments.
qemu man page is not very helpful...
-bios file
Set the filename for the BIOS.
-kernel bzImage
Use bzImage as kernel image. The kernel can be either a
Linux kernel or in multiboot format.
Paolo, Peter, do you have a simple explanation?
> 5. make check-acceptance pass correctly
> 6. make check-qtest-avr pass correctly
>
>
> On Tue, Jan 21, 2020 at 12:01 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>> Hi,
>>
>> This series add the arduino boards, aiming at removing the
>> 'sample' board that doesn't follow any specification.
>>
>> Since v3:
>> - Rebased on Michael's v41
>> - Drop 'extram' unused field (Igor)
>> - Renamed devices AVR -> Atmel (Aleksandar)
>> (I haven't renamed structure names to ease review)
>>
>> Since v2:
>> - rebased on Michael's v40
>>
>> Since v1:
>> - Addressed Igor comments
>> - Addressed Aleksandar comments
>> - Fixed UART issue (was due to IRQ shifted by 2 in CPU)
>>
>> Since Michael's work is not yet merged, Various of my patches
>> - which are trivials or simple renames - could be squashed
>> directly on his patches, if we ever care.
>> [I believe sending this patches is easier/quicker than keeping
>> asking Michael to respin his series infinitely].
>>
>> Michael, do you mind testing it? The full series is available
>> here: https://gitlab.com/philmd/qemu/commits/arduino-v4
>>
>> Regards,
>>
>> Phil.
>>
>> Obsoletes: <20191229224505.24466-1-f4bug@amsat.org>
>> Based-on: <20200118191416.19934-1-mrolnik@gmail.com>
>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg671707.html
>>
>> Philippe Mathieu-Daudé (18):
>> MAINTAINERS: Move machine test to the machine section (not ARCH one)
>> MAINTAINERS: Move the AVR machines in new section (not within ARM)
>> tests/acceptance: Do not set the machine type manually
>> tests/acceptance: Keep multilines comment consistent with other tests
>> hw/char/avr: Reduce USART I/O size
>> hw/timer/avr_timer16: Rename memory region debugging name
>> hw/misc/avr_mask: Remove unused include
>> hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable
>> hw/char: Rename avr_usart -> atmel_usart
>> hw/timer: Rename avr_timer16 -> atmel_timer16
>> hw/misc: Rename avr_mask -> atmel_power
>> hw/avr: Introduce ATMEL_ATMEGA_MCU config
>> hw/avr: Add some ATmega microcontrollers
>> hw/avr: Add some Arduino boards
>> tests/boot-serial-test: Test some Arduino boards (AVR based)
>> tests/acceptance: Test the Arduino MEGA2560 board
>> hw/avr: Remove the unrealistic AVR 'sample' board
>> .travis.yml: Run the AVR acceptance tests
>>
>> default-configs/avr-softmmu.mak | 2 +-
>> hw/avr/atmel_atmega.h | 48 ++
>> .../hw/char/{avr_usart.h => atmel_usart.h} | 10 +-
>> include/hw/misc/{avr_mask.h => atmel_power.h} | 11 +-
>> .../timer/{avr_timer16.h => atmel_timer16.h} | 10 +-
>> hw/avr/arduino.c | 175 +++++++
>> hw/avr/atmel_atmega.c | 464 ++++++++++++++++++
>> hw/avr/sample.c | 295 -----------
>> hw/char/{avr_usart.c => atmel_usart.c} | 6 +-
>> hw/misc/{avr_mask.c => atmel_power.c} | 4 +-
>> hw/timer/{avr_timer16.c => atmel_timer16.c} | 10 +-
>> tests/qtest/boot-serial-test.c | 3 +-
>> .travis.yml | 2 +-
>> MAINTAINERS | 29 +-
>> hw/avr/Kconfig | 11 +-
>> hw/avr/Makefile.objs | 3 +-
>> hw/char/Kconfig | 2 +-
>> hw/char/Makefile.objs | 2 +-
>> hw/misc/Kconfig | 2 +-
>> hw/misc/Makefile.objs | 2 +-
>> hw/timer/Kconfig | 2 +-
>> hw/timer/Makefile.objs | 2 +-
>> tests/acceptance/machine_avr6.py | 11 +-
>> 23 files changed, 751 insertions(+), 355 deletions(-)
>> create mode 100644 hw/avr/atmel_atmega.h
>> rename include/hw/char/{avr_usart.h => atmel_usart.h} (93%)
>> rename include/hw/misc/{avr_mask.h => atmel_power.h} (89%)
>> rename include/hw/timer/{avr_timer16.h => atmel_timer16.h} (92%)
>> create mode 100644 hw/avr/arduino.c
>> create mode 100644 hw/avr/atmel_atmega.c
>> delete mode 100644 hw/avr/sample.c
>> rename hw/char/{avr_usart.c => atmel_usart.c} (99%)
>> rename hw/misc/{avr_mask.c => atmel_power.c} (97%)
>> rename hw/timer/{avr_timer16.c => atmel_timer16.c} (98%)
>>
>> --
>> 2.21.1
>>
>
>
> --
> Best Regards,
> Michael Rolnik
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 00/18] hw/avr: Introduce few Arduino boards
2020-01-21 21:23 ` Philippe Mathieu-Daudé
@ 2020-01-22 20:46 ` Richard Henderson
2020-01-22 21:56 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 25+ messages in thread
From: Richard Henderson @ 2020-01-22 20:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé,
Michael Rolnik, Peter Maydell, Paolo Bonzini
Cc: Sarah Harris, QEMU Developers, Aleksandar Markovic
On 1/21/20 11:23 AM, Philippe Mathieu-Daudé wrote:
>> 4. There is difference between -bios and -kernel (arduino boars crash when -bios is used, but this seems because I run avr6 on avr5 CPU). I would be happy if you explained what is the difference between these two arguments.
>
> qemu man page is not very helpful...
>
> -bios file
> Set the filename for the BIOS.
>
> -kernel bzImage
> Use bzImage as kernel image. The kernel can be either a
> Linux kernel or in multiboot format.
>
> Paolo, Peter, do you have a simple explanation?
It depends on your target board. They *can* do very different things.
E.g. for "pc" (x86) machine, -bios sets the seabios image to use, and -kernel
loads a kernel image that seabios will invoke.
E.g. for "dp264" (alpha) machine, -bios sets the palcode image to use and
-kernel loads a kernel image. Note that in this case, the alpha kernel relies
on palcode services, so both must be present for the system to work.
E.g. for "virt" (arm) machine, -bios loads a raw image at which the reset
vector will be pointed, whereas -kernel loads a linux kernel image and follows
the arm-linux kernel boot protocol. In other words the images are treated very
differently.
I don't know what, if anything, an avr kernel would require from boot services.
I suspect the two options *could* be treated identically.
r~
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 00/18] hw/avr: Introduce few Arduino boards
2020-01-22 20:46 ` Richard Henderson
@ 2020-01-22 21:56 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 25+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-22 21:56 UTC (permalink / raw)
To: Richard Henderson, Philippe Mathieu-Daudé,
Michael Rolnik, Peter Maydell, Paolo Bonzini
Cc: Sarah Harris, QEMU Developers, Aleksandar Markovic
On 1/22/20 9:46 PM, Richard Henderson wrote:
> On 1/21/20 11:23 AM, Philippe Mathieu-Daudé wrote:
>>> 4. There is difference between -bios and -kernel (arduino boars crash when -bios is used, but this seems because I run avr6 on avr5 CPU). I would be happy if you explained what is the difference between these two arguments.
>>
>> qemu man page is not very helpful...
>>
>> -bios file
>> Set the filename for the BIOS.
>>
>> -kernel bzImage
>> Use bzImage as kernel image. The kernel can be either a
>> Linux kernel or in multiboot format.
>>
>> Paolo, Peter, do you have a simple explanation?
>
> It depends on your target board. They *can* do very different things.
>
> E.g. for "pc" (x86) machine, -bios sets the seabios image to use, and -kernel
> loads a kernel image that seabios will invoke.
>
> E.g. for "dp264" (alpha) machine, -bios sets the palcode image to use and
> -kernel loads a kernel image. Note that in this case, the alpha kernel relies
> on palcode services, so both must be present for the system to work.
>
> E.g. for "virt" (arm) machine, -bios loads a raw image at which the reset
> vector will be pointed, whereas -kernel loads a linux kernel image and follows
> the arm-linux kernel boot protocol. In other words the images are treated very
> differently.
>
> I don't know what, if anything, an avr kernel would require from boot services.
> I suspect the two options *could* be treated identically.
I think -bios used to be dumb, and originally it would only load a
binary blob at a fixed memory address (like mapping a ROM or a parallel
flash).
And -kernel was a bit smarter, understanding ELF format. It can set
(Linux) arch-specific registers, in particular when used with -append
(cmdline) and -dtb (device tree).
At some point -bios got to understand ELF too, so QEMU could load ROMs
mapped at different base address (and not force a default one).
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2020-01-22 21:57 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 22:00 [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 01/18] MAINTAINERS: Move machine test to the machine section (not ARCH one) Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 02/18] MAINTAINERS: Move the AVR machines in new section (not within ARM) Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 03/18] tests/acceptance: Do not set the machine type manually Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 04/18] tests/acceptance: Keep multilines comment consistent with other tests Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 05/18] hw/char/avr: Reduce USART I/O size Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 06/18] hw/timer/avr_timer16: Rename memory region debugging name Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 07/18] hw/misc/avr_mask: Remove unused include Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 08/18] hw/avr/Makefile: Use CONFIG_AVR_SAMPLE variable Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 09/18] hw/char: Rename avr_usart -> atmel_usart Philippe Mathieu-Daudé
2020-01-20 22:00 ` [PATCH v4 10/18] hw/timer: Rename avr_timer16 -> atmel_timer16 Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 11/18] hw/misc: Rename avr_mask -> atmel_power Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 12/18] hw/avr: Introduce ATMEL_ATMEGA_MCU config Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 13/18] hw/avr: Add some ATmega microcontrollers Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 14/18] hw/avr: Add some Arduino boards Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 15/18] tests/boot-serial-test: Test some Arduino boards (AVR based) Philippe Mathieu-Daudé
2020-01-21 6:11 ` Thomas Huth
2020-01-20 22:01 ` [PATCH v4 16/18] tests/acceptance: Test the Arduino MEGA2560 board Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 17/18] hw/avr: Remove the unrealistic AVR 'sample' board Philippe Mathieu-Daudé
2020-01-20 22:01 ` [PATCH v4 18/18] .travis.yml: Run the AVR acceptance tests Philippe Mathieu-Daudé
2020-01-20 23:30 ` [PATCH v4 00/18] hw/avr: Introduce few Arduino boards Philippe Mathieu-Daudé
2020-01-21 19:25 ` Michael Rolnik
2020-01-21 21:23 ` Philippe Mathieu-Daudé
2020-01-22 20:46 ` Richard Henderson
2020-01-22 21:56 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).