From: Thomas Huth <thuth@redhat.com>
To: "Steffen Görtz" <contrib@steffen-goertz.de>, qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
Joel Stanley <joel@jms.id.au>,
Jim Mussared <jim@groklearning.com>,
Julia Suvorova <jusual@mail.ru>,
Peter Maydell <peter.maydell@linaro.org>,
Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5 07/14] tests: Add bbc:microbit / nRF51 test suite
Date: Tue, 13 Nov 2018 07:40:09 +0100 [thread overview]
Message-ID: <3b9c8331-c84a-414a-8ff3-905a9e4b3779@redhat.com> (raw)
In-Reply-To: <20181112214224.31560-8-contrib@steffen-goertz.de>
On 2018-11-12 22:42, Steffen Görtz wrote:
> The microbit-test includes tests for the nRF51 NVMC
> peripheral and will host future nRF51 peripheral tests
> and board-level bbc:microbit tests.
>
> Signed-off-by: Steffen Görtz <contrib@steffen-goertz.de>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> tests/Makefile.include | 2 +
> tests/microbit-test.c | 133 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 135 insertions(+)
> create mode 100644 tests/microbit-test.c
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index f77a495109..602346eeed 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -274,6 +274,7 @@ check-qtest-sparc64-y += tests/boot-serial-test$(EXESUF)
> check-qtest-arm-y += tests/tmp105-test$(EXESUF)
> check-qtest-arm-y += tests/pca9552-test$(EXESUF)
> check-qtest-arm-y += tests/ds1338-test$(EXESUF)
> +check-qtest-arm-y += tests/microbit-test$(EXESUF)
> check-qtest-arm-y += tests/m25p80-test$(EXESUF)
> check-qtest-arm-y += tests/virtio-blk-test$(EXESUF)
> check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF)
> @@ -695,6 +696,7 @@ tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o $(libqos-obj-y)
> tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
> tests/pca9552-test$(EXESUF): tests/pca9552-test.o $(libqos-omap-obj-y)
> tests/ds1338-test$(EXESUF): tests/ds1338-test.o $(libqos-imx-obj-y)
> +tests/microbit-test$(EXESUF): tests/microbit-test.o
> tests/m25p80-test$(EXESUF): tests/m25p80-test.o
> tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
> tests/q35-test$(EXESUF): tests/q35-test.o $(libqos-pc-obj-y)
> diff --git a/tests/microbit-test.c b/tests/microbit-test.c
> new file mode 100644
> index 0000000000..40b8b4bc64
> --- /dev/null
> +++ b/tests/microbit-test.c
> @@ -0,0 +1,133 @@
> + /*
> + * QTest testcase for Microbit board using the Nordic Semiconductor nRF51 SoC.
> + *
> + * nRF51:
> + * Reference Manual: http://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.pdf
> + * Product Spec: http://infocenter.nordicsemi.com/pdf/nRF51822_PS_v3.1.pdf
> + *
> + * Microbit Board: http://microbit.org/
> + *
> + * Copyright 2018 Steffen Görtz <contrib@steffen-goertz.de>
> + *
> + * This code is licensed under the GPL version 2 or later. See
> + * the COPYING file in the top-level directory.
> + */
> +
> +
> +#include "qemu/osdep.h"
> +#include "exec/hwaddr.h"
> +#include "libqtest.h"
> +
> +#include "hw/arm/nrf51.h"
> +#include "hw/nvram/nrf51_nvm.h"
> +
> +#define FLASH_SIZE (256 * NRF51_PAGE_SIZE)
> +
> +static void fill_and_erase(hwaddr base, hwaddr size, uint32_t address_reg)
> +{
> + hwaddr i;
> +
> + /* Erase Page */
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x02);
> + writel(NRF51_NVMC_BASE + address_reg, base);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> +
> + /* Check memory */
> + for (i = 0; i < size / 4; i++) {
> + g_assert_cmpuint(readl(base + i * 4), ==, 0xFFFFFFFF);
> + }
> +
> + /* Fill memory */
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x01);
> + for (i = 0; i < size / 4; i++) {
> + writel(base + i * 4, i);
> + g_assert_cmpuint(readl(base + i * 4), ==, i);
> + }
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> +}
> +
> +static void test_nrf51_nvmc(void)
> +{
> + uint32_t value;
> + hwaddr i;
> +
> + /* Test always ready */
> + value = readl(NRF51_NVMC_BASE + NRF51_NVMC_READY);
> + g_assert_cmpuint(value & 0x01, ==, 0x01);
> +
> + /* Test write-read config register */
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x03);
> + g_assert_cmpuint(readl(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG), ==, 0x03);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> + g_assert_cmpuint(readl(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG), ==, 0x00);
> +
> + /* Test PCR0 */
> + fill_and_erase(NRF51_FLASH_BASE, NRF51_PAGE_SIZE, NRF51_NVMC_ERASEPCR0);
> + fill_and_erase(NRF51_FLASH_BASE + NRF51_PAGE_SIZE,
> + NRF51_PAGE_SIZE, NRF51_NVMC_ERASEPCR0);
> +
> + /* Test PCR1 */
> + fill_and_erase(NRF51_FLASH_BASE, NRF51_PAGE_SIZE, NRF51_NVMC_ERASEPCR1);
> + fill_and_erase(NRF51_FLASH_BASE + NRF51_PAGE_SIZE,
> + NRF51_PAGE_SIZE, NRF51_NVMC_ERASEPCR1);
> +
> + /* Erase all */
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x02);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_ERASEALL, 0x01);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> +
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x01);
> + for (i = 0; i < FLASH_SIZE / 4; i++) {
> + writel(NRF51_FLASH_BASE + i * 4, i);
> + g_assert_cmpuint(readl(NRF51_FLASH_BASE + i * 4), ==, i);
> + }
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> +
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x02);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_ERASEALL, 0x01);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> +
> + for (i = 0; i < FLASH_SIZE / 4; i++) {
> + g_assert_cmpuint(readl(NRF51_FLASH_BASE + i * 4), ==, 0xFFFFFFFF);
> + }
> +
> + /* Erase UICR */
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x02);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_ERASEUICR, 0x01);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> +
> + for (i = 0; i < NRF51_UICR_SIZE / 4; i++) {
> + g_assert_cmpuint(readl(NRF51_UICR_BASE + i * 4), ==, 0xFFFFFFFF);
> + }
> +
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x01);
> + for (i = 0; i < NRF51_UICR_SIZE / 4; i++) {
> + writel(NRF51_UICR_BASE + i * 4, i);
> + g_assert_cmpuint(readl(NRF51_UICR_BASE + i * 4), ==, i);
> + }
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> +
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x02);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_ERASEUICR, 0x01);
> + writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
> +
> + for (i = 0; i < NRF51_UICR_SIZE / 4; i++) {
> + g_assert_cmpuint(readl(NRF51_UICR_BASE + i * 4), ==, 0xFFFFFFFF);
> + }
> +}
> +
> +int main(int argc, char **argv)
> +{
> + int ret;
> +
> + g_test_init(&argc, &argv, NULL);
> +
> + global_qtest = qtest_initf("-machine microbit");
> +
> + qtest_add_func("/microbit/nrf51/nvmc", test_nrf51_nvmc);
> +
> + ret = g_test_run();
> +
> + qtest_quit(global_qtest);
> + return ret;
> +}
If you could do me a big favour, then please try to write new qtests
without the global_qtest variable. I.e. move the qtest_initf into the
test_nrf51_nvmc function and pass around the local test state variable
there to qtest_writel() and friends. I just started yet another clean up
attempt for some other files, e.g. see here:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg02196.html
(but if this is too much cumbersome right now for you, I also won't
object this patch in the current shape - we can still clean this up later)
Thomas
next prev parent reply other threads:[~2018-11-13 6:40 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-12 21:42 [Qemu-devel] [PATCH v5 00/14] arm: nRF51 Devices and Microbit Support Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 01/14] qtest: Add set_irq_in command to set IRQ/GPIO level Steffen Görtz
2018-11-13 6:30 ` Thomas Huth
2018-11-13 9:38 ` Laurent Vivier
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 02/14] arm: Add header to host common definition for nRF51 SOC peripherals Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 03/14] hw/misc/nrf51_rng: Add NRF51 random number generator peripheral Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 04/14] arm: Instantiate NRF51 random number generator Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 05/14] hw/nvram/nrf51_nvm: Add nRF51 non-volatile memories Steffen Görtz
2018-11-16 16:24 ` Peter Maydell
2018-11-26 0:24 ` Steffen Görtz
2018-11-26 17:43 ` Peter Maydell
2018-12-16 6:20 ` Stefan Hajnoczi
2018-12-16 12:40 ` Peter Maydell
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 06/14] arm: Instantiate NRF51 special NVM's and NVMC Steffen Görtz
2018-11-16 16:25 ` Peter Maydell
2018-11-16 18:04 ` Stefan Hajnoczi
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 07/14] tests: Add bbc:microbit / nRF51 test suite Steffen Görtz
2018-11-13 6:40 ` Thomas Huth [this message]
2018-11-26 0:35 ` Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 08/14] hw/gpio/nrf51_gpio: Add nRF51 GPIO peripheral Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 09/14] arm: Instantiate NRF51 general purpose I/O Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 10/14] tests/microbit-test: Add Tests for nRF51 GPIO Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 11/14] hw/timer/nrf51_timer: Add nRF51 Timer peripheral Steffen Görtz
2018-11-16 16:37 ` Peter Maydell
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 12/14] arm: Instantiate NRF51 Timers Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 13/14] tests/microbit-test: Add Tests for nRF51 Timer Steffen Görtz
2018-11-16 18:19 ` Stefan Hajnoczi
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 14/14] arm: Add Clock peripheral stub to NRF51 SOC Steffen Görtz
2018-11-13 19:45 ` [Qemu-devel] [PATCH v5 00/14] arm: nRF51 Devices and Microbit Support no-reply
2018-11-13 19:55 ` no-reply
2018-11-16 16:07 ` Peter Maydell
2018-11-19 13:02 ` Stefan Hajnoczi
2018-11-20 18:01 ` Steffen Görtz
2018-12-16 6:22 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3b9c8331-c84a-414a-8ff3-905a9e4b3779@redhat.com \
--to=thuth@redhat.com \
--cc=contrib@steffen-goertz.de \
--cc=eblake@redhat.com \
--cc=jim@groklearning.com \
--cc=joel@jms.id.au \
--cc=jusual@mail.ru \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).