Skip to contentSkip to conversation

hw/arm/cubieboard: Few cleanups, add acceptance tests

PATCH In review Philippe Mathieu-Daudé 5 participants 19 messages Dec 30, 2019 – Jan 6, 2020 Arm/Allwinner sunXi SoC support

lore
Share & tools
lore
#0 lore raw

cover hw/arm/cubieboard: Few cleanups, add acceptance tests

After looking at Niek Linnenbank implementation of the Allwinner H3 [1], I looked what is common in the A10 [2].

Add some tests before modifying the code further.

[1] https://www.mail-archive.com/[email protected]/msg665532.html
[2] https://www.mail-archive.com/[email protected]/msg666809.html

Philippe Mathieu-Daudé (6):
tests/boot_linux_console: Add initrd test for the CubieBoard tests/boot_linux_console: Add a SD card test for the CubieBoard hw/arm/allwinner-a10: Move SoC definitions out of header hw/arm/allwinner-a10: Simplify by passing IRQs with qdev_pass_gpios() hw/arm/allwinner-a10: Remove local qemu_irq variables hw/arm/cubieboard: Disable unsupported M-USB in device tree blob [RFC]

 include/hw/arm/allwinner-a10.h         |  7 ---
 hw/arm/allwinner-a10.c                 | 39 ++++++------
 hw/arm/cubieboard.c                    | 24 ++++++++
 tests/acceptance/boot_linux_console.py | 85 ++++++++++++++++++++++++++
 4 files changed, 130 insertions(+), 25 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/6 tests/boot_linux_console: Add initrd test for the CubieBoard

This test boots a Linux kernel on a CubieBoard and verify the serial output is working.

The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://docs.armbian.com/Developer-Guide_Build-Preparation/

The cpio image used comes from the linux-build-test project:
https://github.com/groeck/linux-build-test

If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags.

Alternatively, this test can be run using:

  $ avocado --show=console run -t machine:cubieboard tests/acceptance/boot_linux_console.py
  console: Uncompressing Linux... done, booting the kernel.
  console: Booting Linux on physical CPU 0x0
  console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019
  console: CPU: ARMv7 Processor [410fc080] revision 0 (ARMv7), cr=50c5387d
  console: CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
  console: OF: fdt: Machine model: Cubietech Cubieboard
  [...]
  console: Boot successful.
  console: cat /proc/cpuinfo
  console: / # cat /proc/cpuinfo
  console: processor      : 0
  console: model name     : ARMv7 Processor rev 0 (v7l)
  console: BogoMIPS       : 832.51
  [...]
  console: Hardware       : Allwinner sun4i/sun5i Families
  console: Revision       : 0000
  console: Serial         : 0000000000000000
  console: cat /proc/iomem
  console: / # cat /proc/iomem
  console: 01c00000-01c0002f : system-control@1c00000
  console: 01c02000-01c02fff : dma-controller@1c02000
  console: 01c05000-01c05fff : spi@1c05000
  console: 01c0b080-01c0b093 : mdio@1c0b080
  console: 01c0c000-01c0cfff : lcd-controller@1c0c000
  console: 01c0d000-01c0dfff : lcd-controller@1c0d000
  console: 01c0f000-01c0ffff : mmc@1c0f000
  [...]
  PASS (54.35 s)
---
 tests/acceptance/boot_linux_console.py | 41 ++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
tests/acceptance/boot_linux_console.py +41 -0
index 9c6aa2040a..4643f60e37 100644
@@ -400,6 +400,47 @@ class BootLinuxConsole(Test):
         self.wait_for_console_pattern('Boot successful.')
         # TODO user command, for now the uart is stuck
 
+    def test_arm_cubieboard_initrd(self):
+        """
+        :avocado: tags=arch:arm
+        :avocado: tags=machine:cubieboard
+        """
+        deb_url = ('https://apt.armbian.com/pool/main/l/'
+                   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+        deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        kernel_path = self.extract_from_deb(deb_path,
+                                            '/boot/vmlinuz-4.20.7-sunxi')
+        dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
+        dtb_path = self.extract_from_deb(deb_path, dtb_path)
+        initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
+                      '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
+                      'arm/rootfs-armv5.cpio.gz')
+        initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
+        initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
+        initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
+        archive.gzip_uncompress(initrd_path_gz, initrd_path)
+
+        self.vm.set_console()
+        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+                               'console=ttyS0,115200 '
+                               'usbcore.nousb '
+                               'panic=-1 noreboot')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-initrd', initrd_path,
+                         '-append', kernel_command_line,
+                         '-no-reboot')
+        self.vm.launch()
+        self.wait_for_console_pattern('Boot successful.')
+
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                                'Allwinner sun4i/sun5i')
+        exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
+                                                'system-control@1c00000')
+        exec_command_and_wait_for_pattern(self, 'reboot',
+                                                'reboot: Restarting system')
+
     def test_s390x_s390_ccw_virtio(self):
         """
         :avocado: tags=arch:s390x
Signature · 1 line
2.21.0
Tested-by Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] tests/boot_linux_console: Add initrd test for the CubieBoard

Quoted 55 lines · Philippe Mathieu-Daudé

This test boots a Linux kernel on a CubieBoard and verify the serial output is working.

The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://docs.armbian.com/Developer-Guide_Build-Preparation/

The cpio image used comes from the linux-build-test project:
https://github.com/groeck/linux-build-test

If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags.

Alternatively, this test can be run using:

   $ avocado --show=console run -t machine:cubieboard tests/acceptance/boot_linux_console.py
   console: Uncompressing Linux... done, booting the kernel.
   console: Booting Linux on physical CPU 0x0
   console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019
   console: CPU: ARMv7 Processor [410fc080] revision 0 (ARMv7), cr=50c5387d
   console: CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
   console: OF: fdt: Machine model: Cubietech Cubieboard
   [...]
   console: Boot successful.
   console: cat /proc/cpuinfo
   console: / # cat /proc/cpuinfo
   console: processor      : 0
   console: model name     : ARMv7 Processor rev 0 (v7l)
   console: BogoMIPS       : 832.51
   [...]
   console: Hardware       : Allwinner sun4i/sun5i Families
   console: Revision       : 0000
   console: Serial         : 0000000000000000
   console: cat /proc/iomem
   console: / # cat /proc/iomem
   console: 01c00000-01c0002f : system-control@1c00000
   console: 01c02000-01c02fff : dma-controller@1c02000
   console: 01c05000-01c05fff : spi@1c05000
   console: 01c0b080-01c0b093 : mdio@1c0b080
   console: 01c0c000-01c0cfff : lcd-controller@1c0c000
   console: 01c0d000-01c0dfff : lcd-controller@1c0d000
   console: 01c0f000-01c0ffff : mmc@1c0f000
   [...]
   PASS (54.35 s)
---
  tests/acceptance/boot_linux_console.py | 41 ++++++++++++++++++++++++++
  1 file changed, 41 insertions(+)
tests/acceptance/boot_linux_console.py +0 -0
index 9c6aa2040a..4643f60e37 100644

tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 403

Quoted 4 lines
tests/acceptance/boot_linux_console.py +1 -0
@@ -400,6 +400,47 @@ class BootLinuxConsole(Test):
          self.wait_for_console_pattern('Boot successful.')
          # TODO user command, for now the uart is stuck
 
+    def test_arm_cubieboard_initrd(self):

Unless you have two tests, one with and without initrd (not the case though) the suffix '_initrd' is useless. So I suggest to remove it.

Quoted 29 lines
tests/acceptance/boot_linux_console.py +29 -0
+        """
+        :avocado: tags=arch:arm
+        :avocado: tags=machine:cubieboard
+        """
+        deb_url = ('https://apt.armbian.com/pool/main/l/'
+                   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+        deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        kernel_path = self.extract_from_deb(deb_path,
+                                            '/boot/vmlinuz-4.20.7-sunxi')
+        dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
+        dtb_path = self.extract_from_deb(deb_path, dtb_path)
+        initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
+                      '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
+                      'arm/rootfs-armv5.cpio.gz')
+        initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
+        initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
+        initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
+        archive.gzip_uncompress(initrd_path_gz, initrd_path)
+
+        self.vm.set_console()
+        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+                               'console=ttyS0,115200 '
+                               'usbcore.nousb '
+                               'panic=-1 noreboot')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-initrd', initrd_path,
+                         '-append', kernel_command_line,

tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 442

Quoted 10 lines
tests/acceptance/boot_linux_console.py +10 -0
+                         '-no-reboot')
+        self.vm.launch()
+        self.wait_for_console_pattern('Boot successful.')
+
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                                'Allwinner sun4i/sun5i')
+        exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
+                                                'system-control@1c00000')
+        exec_command_and_wait_for_pattern(self, 'reboot',
+                                                'reboot: Restarting system')

I ran this test case with success, so:

With the comment regarding the _initrd suffix:

Quoted 4 lines
tests/acceptance/boot_linux_console.py +1 -0
+
      def test_s390x_s390_ccw_virtio(self):
          """
          :avocado: tags=arch:s390x
#3 lore raw

Re: [PATCH 1/6] tests/boot_linux_console: Add initrd test for the CubieBoard

Quoted 51 lines · Wainer dos Santos Moschetta
Quoted 50 lines · Philippe Mathieu-Daudé

This test boots a Linux kernel on a CubieBoard and verify the serial output is working.

The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://docs.armbian.com/Developer-Guide_Build-Preparation/

The cpio image used comes from the linux-build-test project:
https://github.com/groeck/linux-build-test

If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags.

Alternatively, this test can be run using:

   $ avocado --show=console run -t machine:cubieboard tests/acceptance/boot_linux_console.py
   console: Uncompressing Linux... done, booting the kernel.
   console: Booting Linux on physical CPU 0x0
   console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019
   console: CPU: ARMv7 Processor [410fc080] revision 0 (ARMv7), cr=50c5387d
   console: CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
   console: OF: fdt: Machine model: Cubietech Cubieboard
   [...]
   console: Boot successful.
   console: cat /proc/cpuinfo
   console: / # cat /proc/cpuinfo
   console: processor      : 0
   console: model name     : ARMv7 Processor rev 0 (v7l)
   console: BogoMIPS       : 832.51
   [...]
   console: Hardware       : Allwinner sun4i/sun5i Families
   console: Revision       : 0000
   console: Serial         : 0000000000000000
   console: cat /proc/iomem
   console: / # cat /proc/iomem
   console: 01c00000-01c0002f : system-control@1c00000
   console: 01c02000-01c02fff : dma-controller@1c02000
   console: 01c05000-01c05fff : spi@1c05000
   console: 01c0b080-01c0b093 : mdio@1c0b080
   console: 01c0c000-01c0cfff : lcd-controller@1c0c000
   console: 01c0d000-01c0dfff : lcd-controller@1c0d000
   console: 01c0f000-01c0ffff : mmc@1c0f000
   [...]
   PASS (54.35 s)

---
  tests/acceptance/boot_linux_console.py | 41 ++++++++++++++++++++++++++

  1 file changed, 41 insertions(+)
Quoted 10 lines

tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 402

Quoted 8 lines
tests/acceptance/boot_linux_console.py +1 -0
index 9c6aa2040a..4643f60e37 100644
@@ -400,6 +400,47 @@ class BootLinuxConsole(Test):
           self.wait_for_console_pattern('Boot successful.')
           # TODO user command, for now the uart is stuck
+    def test_arm_cubieboard_initrd(self):

Unless you have two tests, one with and without initrd (not the case though) the suffix '_initrd' is useless. So I suggest to remove it.

The next patch adds a SD card test:
https://www.mail-archive.com/[email protected]/msg667628.html

If one developer has other tests in progress, but one done, I think it might sense to add the full test name when the first patch is merged, so next tests don't have to modify the first test name.

Quoted 49 lines
Quoted 41 lines
tests/acceptance/boot_linux_console.py +11 -0
+        """
+        :avocado: tags=arch:arm
+        :avocado: tags=machine:cubieboard
+        """
+        deb_url = ('https://apt.armbian.com/pool/main/l/'
+                   
 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+        deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        kernel_path = self.extract_from_deb(deb_path,
+                                            
 '/boot/vmlinuz-4.20.7-sunxi')
+        dtb_path = 

'/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
+        dtb_path = self.extract_from_deb(deb_path, dtb_path) +        initrd_url = ('https://github.com/groeck/linux-build-test/raw/' +                      '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' +                      'arm/rootfs-armv5.cpio.gz')
+        initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' +        initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
+        initrd_path = os.path.join(self.workdir, 'rootfs.cpio') +        archive.gzip_uncompress(initrd_path_gz, initrd_path)

tests/acceptance/boot_linux_console.py +18 -0
+
+        self.vm.set_console()
+        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+                               'console=ttyS0,115200 '
+                               'usbcore.nousb '
+                               'panic=-1 noreboot')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-initrd', initrd_path,
+                         '-append', kernel_command_line,
+                         '-no-reboot')
+        self.vm.launch()
+        self.wait_for_console_pattern('Boot successful.')
+
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                                'Allwinner sun4i/sun5i')
+        exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
+                                                
Quoted 4 lines

'system-control@1c00000')
+        exec_command_and_wait_for_pattern(self, 'reboot', +                                                'reboot: Restarting system')

I ran this test case with success, so:

Quoted 1 line

Thanks Wainer!

Quoted 12 lines

With the comment regarding the _initrd suffix:

Quoted 4 lines

+
      def test_s390x_s390_ccw_virtio(self):
          """
          :avocado: tags=arch:s390x

#4 lore raw

Re: [PATCH 1/6] tests/boot_linux_console: Add initrd test for the CubieBoard

Quoted 64 lines · Philippe Mathieu-Daudé
Quoted 52 lines · Wainer dos Santos Moschetta
Quoted 51 lines · Philippe Mathieu-Daudé

This test boots a Linux kernel on a CubieBoard and verify the serial output is working.

The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://docs.armbian.com/Developer-Guide_Build-Preparation/

The cpio image used comes from the linux-build-test project:
https://github.com/groeck/linux-build-test

If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags.

Alternatively, this test can be run using:

   $ avocado --show=console run -t machine:cubieboard tests/acceptance/boot_linux_console.py
   console: Uncompressing Linux... done, booting the kernel.
   console: Booting Linux on physical CPU 0x0
   console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019
   console: CPU: ARMv7 Processor [410fc080] revision 0 (ARMv7), cr=50c5387d
   console: CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
   console: OF: fdt: Machine model: Cubietech Cubieboard
   [...]
   console: Boot successful.
   console: cat /proc/cpuinfo
   console: / # cat /proc/cpuinfo
   console: processor      : 0
   console: model name     : ARMv7 Processor rev 0 (v7l)
   console: BogoMIPS       : 832.51
   [...]
   console: Hardware       : Allwinner sun4i/sun5i Families
   console: Revision       : 0000
   console: Serial         : 0000000000000000
   console: cat /proc/iomem
   console: / # cat /proc/iomem
   console: 01c00000-01c0002f : system-control@1c00000
   console: 01c02000-01c02fff : dma-controller@1c02000
   console: 01c05000-01c05fff : spi@1c05000
   console: 01c0b080-01c0b093 : mdio@1c0b080
   console: 01c0c000-01c0cfff : lcd-controller@1c0c000
   console: 01c0d000-01c0dfff : lcd-controller@1c0d000
   console: 01c0f000-01c0ffff : mmc@1c0f000
   [...]
   PASS (54.35 s)

---
  tests/acceptance/boot_linux_console.py | 41
++++++++++++++++++++++++++

  1 file changed, 41 insertions(+)
Quoted 10 lines

tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 402

Quoted 8 lines
tests/acceptance/boot_linux_console.py +1 -0
index 9c6aa2040a..4643f60e37 100644
@@ -400,6 +400,47 @@ class BootLinuxConsole(Test):
           self.wait_for_console_pattern('Boot successful.')
           # TODO user command, for now the uart is stuck
+    def test_arm_cubieboard_initrd(self):

Unless you have two tests, one with and without initrd (not the case though) the suffix '_initrd' is useless. So I suggest to remove it.

Quoted 4 lines

The next patch adds a SD card test:
https://www.mail-archive.com/[email protected]/msg667628.html

If one developer has other tests in progress, but one done, I think it might sense to add the full test name when the first patch is merged, so next tests don't have to modify the first test name.

That's right. Disregard my comment.

- Wainer

Quoted 66 lines
Quoted 49 lines
Quoted 39 lines
tests/acceptance/boot_linux_console.py +11 -0
+        """
+        :avocado: tags=arch:arm
+        :avocado: tags=machine:cubieboard
+        """
+        deb_url = ('https://apt.armbian.com/pool/main/l/'
+ 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+        deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        kernel_path = self.extract_from_deb(deb_path,
+ '/boot/vmlinuz-4.20.7-sunxi')
+        dtb_path = 

'/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' +        dtb_path = self.extract_from_deb(deb_path, dtb_path) +        initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
+ '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
+                      'arm/rootfs-armv5.cpio.gz')
+        initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' +        initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
+        initrd_path = os.path.join(self.workdir, 'rootfs.cpio') +        archive.gzip_uncompress(initrd_path_gz, initrd_path)

tests/acceptance/boot_linux_console.py +16 -0
+
+        self.vm.set_console()
+        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+                               'console=ttyS0,115200 '
+                               'usbcore.nousb '
+                               'panic=-1 noreboot')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-initrd', initrd_path,
+                         '-append', kernel_command_line,
+                         '-no-reboot')
+        self.vm.launch()
+        self.wait_for_console_pattern('Boot successful.')
+
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                                'Allwinner 
Quoted 6 lines

sun4i/sun5i')
+        exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
+ 'system-control@1c00000')
+        exec_command_and_wait_for_pattern(self, 'reboot', +                                                'reboot: Restarting system')

I ran this test case with success, so:

Quoted 1 line

Thanks Wainer!

Quoted 12 lines

With the comment regarding the _initrd suffix:

Quoted 4 lines

+
      def test_s390x_s390_ccw_virtio(self):
          """
          :avocado: tags=arch:s390x

#5 lore raw

PATCH 2/6 tests/boot_linux_console: Add a SD card test for the CubieBoard

In reply to Philippe Mathieu-Daudé

The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://docs.armbian.com/Developer-Guide_Build-Preparation/

The cpio image used comes from the linux-build-test project:
https://github.com/groeck/linux-build-test

If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags.

Alternatively, this test can be run using:

  $ avocado --show=console run -t machine:cubieboard tests/acceptance/boot_linux_console.py
  console: Uncompressing Linux... done, booting the kernel.
  console: Booting Linux on physical CPU 0x0
  console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019
  [...]
  console: ahci-sunxi 1c18000.sata: Linked as a consumer to regulator.4
  console: ahci-sunxi 1c18000.sata: controller can't do 64bit DMA, forcing 32bit
  console: ahci-sunxi 1c18000.sata: AHCI 0001.0000 32 slots 1 ports 1.5 Gbps 0x1 impl platform mode
  console: ahci-sunxi 1c18000.sata: flags: ncq only
  console: scsi host0: ahci-sunxi
  console: ata1: SATA max UDMA/133 mmio [mem 0x01c18000-0x01c18fff] port 0x100 irq 27
  console: of_cfs_init
  console: of_cfs_init: OK
  console: vcc3v0: disabling
  console: vcc5v0: disabling
  console: usb1-vbus: disabling
  console: usb2-vbus: disabling
  console: ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
  console: ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100
  console: ata1.00: 40960 sectors, multi 16: LBA48 NCQ (depth 32)
  console: ata1.00: applying bridge limits
  console: ata1.00: configured for UDMA/100
  console: scsi 0:0:0:0: Direct-Access     ATA      QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
  console: sd 0:0:0:0: Attached scsi generic sg0 type 0
  console: sd 0:0:0:0: [sda] 40960 512-byte logical blocks: (21.0 MB/20.0 MiB)
  console: sd 0:0:0:0: [sda] Write Protect is off
  console: sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
  console: sd 0:0:0:0: [sda] Attached SCSI disk
  console: EXT4-fs (sda): mounting ext2 file system using the ext4 subsystem
  console: EXT4-fs (sda): mounted filesystem without journal. Opts: (null)
  console: VFS: Mounted root (ext2 filesystem) readonly on device 8:0.
  [...]
  console: cat /proc/partitions
  console: / # cat /proc/partitions
  console: major minor  #blocks  name
  console: 1        0       4096 ram0
  console: 1        1       4096 ram1
  console: 1        2       4096 ram2
  console: 1        3       4096 ram3
  console: 8        0      20480 sda
  console: reboot
  console: / # reboot
  [...]
  console: sd 0:0:0:0: [sda] Synchronizing SCSI cache
  console: reboot: Restarting system
  PASS (48.39 s)
---
 tests/acceptance/boot_linux_console.py | 44 ++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
tests/acceptance/boot_linux_console.py +44 -0
index 4643f60e37..e40b84651b 100644
@@ -441,6 +441,50 @@ class BootLinuxConsole(Test):
         exec_command_and_wait_for_pattern(self, 'reboot',
                                                 'reboot: Restarting system')
 
+    def test_arm_cubieboard_sata(self):
+        """
+        :avocado: tags=arch:arm
+        :avocado: tags=machine:cubieboard
+        """
+        deb_url = ('https://apt.armbian.com/pool/main/l/'
+                   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+        deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        kernel_path = self.extract_from_deb(deb_path,
+                                            '/boot/vmlinuz-4.20.7-sunxi')
+        dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
+        dtb_path = self.extract_from_deb(deb_path, dtb_path)
+        rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
+                      '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
+                      'arm/rootfs-armv5.ext2.gz')
+        rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
+        rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
+        rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
+        archive.gzip_uncompress(rootfs_path_gz, rootfs_path)
+
+        self.vm.set_console()
+        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+                               'console=ttyS0,115200 '
+                               'usbcore.nousb '
+                               'root=/dev/sda ro '
+                               'panic=-1 noreboot')
+        self.vm.add_args('-kernel', kernel_path,
+                         '-dtb', dtb_path,
+                         '-drive', 'if=none,format=raw,id=disk0,file='
+                                   + rootfs_path,
+                         '-device', 'ide-hd,bus=ide.0,drive=disk0',
+                         '-append', kernel_command_line,
+                         '-no-reboot')
+        self.vm.launch()
+        self.wait_for_console_pattern('Boot successful.')
+
+        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
+                                                'Allwinner sun4i/sun5i')
+        exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
+                                                'sda')
+        exec_command_and_wait_for_pattern(self, 'reboot',
+                                                'reboot: Restarting system')
+
     def test_s390x_s390_ccw_virtio(self):
         """
         :avocado: tags=arch:s390x
Signature · 1 line
2.21.0
#6 lore raw

PATCH 3/6 hw/arm/allwinner-a10: Move SoC definitions out of header

In reply to Philippe Mathieu-Daudé

These definitions are specific to the A10 SoC and don't need to be exported to the different Allwinner peripherals.

---
 include/hw/arm/allwinner-a10.h | 6 ------
 hw/arm/allwinner-a10.c         | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)
include/hw/arm/allwinner-a10.h +0 -6
index 7d2d215630..941c61e533 100644
@@ -12,12 +12,6 @@
 #include "target/arm/cpu.h"
 
 
-#define AW_A10_PIC_REG_BASE     0x01c20400
-#define AW_A10_PIT_REG_BASE     0x01c20c00
-#define AW_A10_UART0_REG_BASE   0x01c28000
-#define AW_A10_EMAC_BASE        0x01c0b000
-#define AW_A10_SATA_BASE        0x01c18000
-
 #define AW_A10_SDRAM_BASE       0x40000000
 
 #define TYPE_AW_A10 "allwinner-a10"
hw/arm/allwinner-a10.c +6 -0
index 118032c8c7..0f1af5a880 100644
@@ -25,6 +25,12 @@
 #include "hw/misc/unimp.h"
 #include "sysemu/sysemu.h"
 
+#define AW_A10_PIC_REG_BASE     0x01c20400
+#define AW_A10_PIT_REG_BASE     0x01c20c00
+#define AW_A10_UART0_REG_BASE   0x01c28000
+#define AW_A10_EMAC_BASE        0x01c0b000
+#define AW_A10_SATA_BASE        0x01c18000
+
 static void aw_a10_init(Object *obj)
 {
     AwA10State *s = AW_A10(obj);
Signature · 1 line
2.21.0
Reviewed-by on v1 3/6
#7 lore raw

Re: [PATCH 3/6] hw/arm/allwinner-a10: Move SoC definitions out of header

Quoted 9 lines · Philippe Mathieu-Daudé

These definitions are specific to the A10 SoC and don't need to be exported to the different Allwinner peripherals.

---
 include/hw/arm/allwinner-a10.h | 6 ------
 hw/arm/allwinner-a10.c         | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)

thanks
-- PMM

#8 lore raw

PATCH 4/6 hw/arm/allwinner-a10: Simplify by passing IRQs with qdev_pass_gpios()

In reply to Philippe Mathieu-Daudé

By calling qdev_pass_gpios() we don't need to hold a copy of the IRQs from the INTC into the SoC state.
Instead of filling an array of qemu_irq and passing it around, we can now directly call qdev_get_gpio_in() on the SoC.

---
 include/hw/arm/allwinner-a10.h |  1 -
 hw/arm/allwinner-a10.c         | 24 +++++++++++-------------
 2 files changed, 11 insertions(+), 14 deletions(-)
include/hw/arm/allwinner-a10.h +0 -1
index 941c61e533..40d0b1d9c0 100644
@@ -23,7 +23,6 @@ typedef struct AwA10State {
     /*< public >*/
 
     ARMCPU cpu;
-    qemu_irq irq[AW_A10_PIC_INT_NR];
     AwA10PITState timer;
     AwA10PICState intc;
     AwEmacState emac;
hw/arm/allwinner-a10.c +11 -13
index 0f1af5a880..966fbd4a6e 100644
@@ -55,7 +55,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
 {
     AwA10State *s = AW_A10(dev);
     SysBusDevice *sysbusdev;
-    uint8_t i;
     qemu_irq fiq, irq;
     Error *err = NULL;
 
@@ -76,9 +75,7 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
     sysbus_mmio_map(sysbusdev, 0, AW_A10_PIC_REG_BASE);
     sysbus_connect_irq(sysbusdev, 0, irq);
     sysbus_connect_irq(sysbusdev, 1, fiq);
-    for (i = 0; i < AW_A10_PIC_INT_NR; i++) {
-        s->irq[i] = qdev_get_gpio_in(DEVICE(&s->intc), i);
-    }
+    qdev_pass_gpios(DEVICE(&s->intc), dev, NULL);
 
     object_property_set_bool(OBJECT(&s->timer), true, "realized", &err);
     if (err != NULL) {
@@ -87,12 +84,12 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
     }
     sysbusdev = SYS_BUS_DEVICE(&s->timer);
     sysbus_mmio_map(sysbusdev, 0, AW_A10_PIT_REG_BASE);
-    sysbus_connect_irq(sysbusdev, 0, s->irq[22]);
-    sysbus_connect_irq(sysbusdev, 1, s->irq[23]);
-    sysbus_connect_irq(sysbusdev, 2, s->irq[24]);
-    sysbus_connect_irq(sysbusdev, 3, s->irq[25]);
-    sysbus_connect_irq(sysbusdev, 4, s->irq[67]);
-    sysbus_connect_irq(sysbusdev, 5, s->irq[68]);
+    sysbus_connect_irq(sysbusdev, 0, qdev_get_gpio_in(dev, 22));
+    sysbus_connect_irq(sysbusdev, 1, qdev_get_gpio_in(dev, 23));
+    sysbus_connect_irq(sysbusdev, 2, qdev_get_gpio_in(dev, 24));
+    sysbus_connect_irq(sysbusdev, 3, qdev_get_gpio_in(dev, 25));
+    sysbus_connect_irq(sysbusdev, 4, qdev_get_gpio_in(dev, 67));
+    sysbus_connect_irq(sysbusdev, 5, qdev_get_gpio_in(dev, 68));
 
     memory_region_init_ram(&s->sram_a, OBJECT(dev), "sram A", 48 * KiB,
                            &error_fatal);
@@ -111,7 +108,7 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
     }
     sysbusdev = SYS_BUS_DEVICE(&s->emac);
     sysbus_mmio_map(sysbusdev, 0, AW_A10_EMAC_BASE);
-    sysbus_connect_irq(sysbusdev, 0, s->irq[55]);
+    sysbus_connect_irq(sysbusdev, 0, qdev_get_gpio_in(dev, 55));
 
     object_property_set_bool(OBJECT(&s->sata), true, "realized", &err);
     if (err) {
@@ -119,10 +116,11 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, AW_A10_SATA_BASE);
-    sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, s->irq[56]);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, qdev_get_gpio_in(dev, 56));
 
     /* FIXME use a qdev chardev prop instead of serial_hd() */
-    serial_mm_init(get_system_memory(), AW_A10_UART0_REG_BASE, 2, s->irq[1],
+    serial_mm_init(get_system_memory(), AW_A10_UART0_REG_BASE, 2,
+                   qdev_get_gpio_in(dev, 1),
                    115200, serial_hd(0), DEVICE_NATIVE_ENDIAN);
 }
 
Signature · 1 line
2.21.0
Reviewed-by on v1 4/6
#9 lore raw

Re: [PATCH 4/6] hw/arm/allwinner-a10: Simplify by passing IRQs with qdev_pass_gpios()

Quoted 6 lines · Philippe Mathieu-Daudé

By calling qdev_pass_gpios() we don't need to hold a copy of the IRQs from the INTC into the SoC state.
Instead of filling an array of qemu_irq and passing it around, we can now directly call qdev_get_gpio_in() on the SoC.

Quoted 6 lines
---
 include/hw/arm/allwinner-a10.h |  1 -
 hw/arm/allwinner-a10.c         | 24 +++++++++++-------------
 2 files changed, 11 insertions(+), 14 deletions(-)

thanks
-- PMM

#10 lore raw

PATCH 5/6 hw/arm/allwinner-a10: Remove local qemu_irq variables

In reply to Philippe Mathieu-Daudé

We won't reuse the CPU IRQ/FIQ variables. Simplify by calling qdev_get_gpio_in() in place.

---
 hw/arm/allwinner-a10.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/arm/allwinner-a10.c +4 -5
index 966fbd4a6e..1cde165611 100644
@@ -55,7 +55,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
 {
     AwA10State *s = AW_A10(dev);
     SysBusDevice *sysbusdev;
-    qemu_irq fiq, irq;
     Error *err = NULL;
 
     object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
@@ -63,8 +62,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
         error_propagate(errp, err);
         return;
     }
-    irq = qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ);
-    fiq = qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ);
 
     object_property_set_bool(OBJECT(&s->intc), true, "realized", &err);
     if (err != NULL) {
@@ -73,8 +70,10 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
     }
     sysbusdev = SYS_BUS_DEVICE(&s->intc);
     sysbus_mmio_map(sysbusdev, 0, AW_A10_PIC_REG_BASE);
-    sysbus_connect_irq(sysbusdev, 0, irq);
-    sysbus_connect_irq(sysbusdev, 1, fiq);
+    sysbus_connect_irq(sysbusdev, 0,
+                       qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
+    sysbus_connect_irq(sysbusdev, 1,
+                       qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
     qdev_pass_gpios(DEVICE(&s->intc), dev, NULL);
 
     object_property_set_bool(OBJECT(&s->timer), true, "realized", &err);
Signature · 1 line
2.21.0
#12 lore raw

RFC PATCH 6/6 hw/arm/cubieboard: Disable unsupported M-USB in device tree blob

In reply to Philippe Mathieu-Daudé

We do not model the Sunxi Multipoint USB.
The Linux kernel OOPS when booting:

  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 144 at drivers/usb/musb/sunxi.c:400 sunxi_musb_ep_offset+0x39/0x3c
  sunxi_musb_ep_offset called with non 0 offset
  Modules linked in:
  CPU: 0 PID: 144 Comm: kworker/0:2 Not tainted 4.20.7-sunxi #5.75
  Hardware name: Allwinner sun4i/sun5i Families
  Workqueue: events deferred_probe_work_func
  [<c010d77d>] (unwind_backtrace) from [<c010a425>] (show_stack+0x11/0x14)
  [<c010a425>] (show_stack) from [<c08d9141>] (dump_stack+0x69/0x78)
  [<c08d9141>] (dump_stack) from [<c011b161>] (__warn+0xa1/0xb4)
  [<c011b161>] (__warn) from [<c011b1a7>] (warn_slowpath_fmt+0x33/0x48)
  [<c011b1a7>] (warn_slowpath_fmt) from [<c0725c81>] (sunxi_musb_ep_offset+0x39/0x3c)
  [<c0725c81>] (sunxi_musb_ep_offset) from [<c071b481>] (ep_config_from_hw+0x99/0x104)
  [<c071b481>] (ep_config_from_hw) from [<c071c8d9>] (musb_probe+0x765/0xa0c)
  [<c071c8d9>] (musb_probe) from [<c063fa4f>] (platform_drv_probe+0x33/0x68)
  [<c063fa4f>] (platform_drv_probe) from [<c063e4ef>] (really_probe+0x16f/0x1e0)
  [<c063e4ef>] (really_probe) from [<c063e67f>] (driver_probe_device+0x43/0x11c)
  [<c063e67f>] (driver_probe_device) from [<c063d0cf>] (bus_for_each_drv+0x37/0x70)
  [<c063d0cf>] (bus_for_each_drv) from [<c063e32f>] (__device_attach+0x83/0xc8)
  [<c063e32f>] (__device_attach) from [<c063da8b>] (bus_probe_device+0x5b/0x60)
  [<c063da8b>] (bus_probe_device) from [<c063b7a5>] (device_add+0x2f5/0x474)
  [<c063b7a5>] (device_add) from [<c063f8ef>] (platform_device_add+0xb7/0x184)
  [<c063f8ef>] (platform_device_add) from [<c06400df>] (platform_device_register_full+0xb3/0xc4)
  [<c06400df>] (platform_device_register_full) from [<c0725a2f>] (sunxi_musb_probe+0x1d7/0x2f4)
  [<c0725a2f>] (sunxi_musb_probe) from [<c063fa4f>] (platform_drv_probe+0x33/0x68)
  [<c063fa4f>] (platform_drv_probe) from [<c063e4ef>] (really_probe+0x16f/0x1e0)
  [<c063e4ef>] (really_probe) from [<c063e67f>] (driver_probe_device+0x43/0x11c)
  [<c063e67f>] (driver_probe_device) from [<c063d0cf>] (bus_for_each_drv+0x37/0x70)
  [<c063d0cf>] (bus_for_each_drv) from [<c063e32f>] (__device_attach+0x83/0xc8)
  [<c063e32f>] (__device_attach) from [<c063da8b>] (bus_probe_device+0x5b/0x60)
  [<c063da8b>] (bus_probe_device) from [<c063ddcf>] (deferred_probe_work_func+0x4b/0x6c)
  [<c063ddcf>] (deferred_probe_work_func) from [<c012e38b>] (process_one_work+0x167/0x384)
  [<c012e38b>] (process_one_work) from [<c012f07d>] (worker_thread+0x251/0x3fc)
  [<c012f07d>] (worker_thread) from [<c0132949>] (kthread+0xfd/0x104)
  [<c0132949>] (kthread) from [<c01010f9>] (ret_from_fork+0x11/0x38)
  Exception stack(0xc6999fb0 to 0xc6999ff8)
  9fa0:                                     00000000 00000000 00000000 00000000
  9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
  ---[ end trace b309edbca98c7de2 ]---
  musb-sunxi 1c13000.usb: Error unknown readb offset 128
  musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -22
  musb-hdrc: probe of musb-hdrc.1.auto failed with error -22

This is not critical but confusing. To avoid the Linux kernel to probe this device, mark it disabled in the device tree blob.

---
I'm not sure if this is a QEMU anti-pattern or bad practice. I know we prefer to be as close to the hardware as possible, but here the hardware is not changed, the dtb is. However this makes the guest behave differently. At least we don't have to manually edit the dts. If this is only annoying for acceptance testing, we might consider manually editing the dts in the tests setup().

---
 hw/arm/cubieboard.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
hw/arm/cubieboard.c +24 -0
index 6dc2f1d6b6..dd10577696 100644
@@ -22,10 +22,34 @@
 #include "hw/sysbus.h"
 #include "hw/boards.h"
 #include "hw/arm/allwinner-a10.h"
+#include <libfdt.h>
+
+static void cubieboard_modify_dtb(const struct arm_boot_info *info, void *fdt)
+{
+    static const char unsupported_compat[] = "allwinner,sun4i-a10-musb";
+    char node_path[72];
+    int offset;
+
+    offset = fdt_node_offset_by_compatible(fdt, -1, unsupported_compat);
+    while (offset >= 0) {
+        int r = fdt_get_path(fdt, offset, node_path, sizeof(node_path));
+        assert(r >= 0);
+        r = fdt_setprop_string(fdt, offset, "status", "disabled");
+        if (r < 0) {
+            error_report("%s: Couldn't disable %s: %s", __func__,
+                         unsupported_compat, fdt_strerror(r));
+            exit(1);
+        }
+        warn_report("cubieboard: disabled unsupported node %s (%s) "
+                    "in device tree", node_path, unsupported_compat);
+        offset = fdt_node_offset_by_compatible(fdt, offset, unsupported_compat);
+    }
+}
 
 static struct arm_boot_info cubieboard_binfo = {
     .loader_start = AW_A10_SDRAM_BASE,
     .board_id = 0x1008,
+    .modify_dtb = cubieboard_modify_dtb,
 };
 
 typedef struct CubieBoardState {
Signature · 1 line
2.21.0
#13 lore raw

Re: [RFC PATCH 6/6] hw/arm/cubieboard: Disable unsupported M-USB in device tree blob

Hello Philippe,

I have a suggestion: probably you can apply (almost) the same patch to get USB
working for A10 as I did in the Allwinner H3, in patch #4 "add USB host controller" [1]
That way you can avoid the DTB modifications and with low effort get USB working as well for this board.
As far as I can see, in Section 21.1 in the A10 user manual [2] has the same description
as for the H3. It basically has the standard EHCI and OHCI interfaces.

[1] https://lists.gnu.org/archive/html/qemu-devel/2019-12/msg03266.html
[2] https://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf

Regards,
Niek

Quoted 133 lines · Philippe Mathieu-Daudé

We do not model the Sunxi Multipoint USB.
The Linux kernel OOPS when booting:

  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 144 at drivers/usb/musb/sunxi.c:400
sunxi_musb_ep_offset+0x39/0x3c
  sunxi_musb_ep_offset called with non 0 offset
  Modules linked in:
  CPU: 0 PID: 144 Comm: kworker/0:2 Not tainted 4.20.7-sunxi #5.75
  Hardware name: Allwinner sun4i/sun5i Families
  Workqueue: events deferred_probe_work_func
  [<c010d77d>] (unwind_backtrace) from [<c010a425>] (show_stack+0x11/0x14)
  [<c010a425>] (show_stack) from [<c08d9141>] (dump_stack+0x69/0x78)
  [<c08d9141>] (dump_stack) from [<c011b161>] (__warn+0xa1/0xb4)
  [<c011b161>] (__warn) from [<c011b1a7>] (warn_slowpath_fmt+0x33/0x48)
  [<c011b1a7>] (warn_slowpath_fmt) from [<c0725c81>]
(sunxi_musb_ep_offset+0x39/0x3c)
  [<c0725c81>] (sunxi_musb_ep_offset) from [<c071b481>]
(ep_config_from_hw+0x99/0x104)
  [<c071b481>] (ep_config_from_hw) from [<c071c8d9>]
(musb_probe+0x765/0xa0c)
  [<c071c8d9>] (musb_probe) from [<c063fa4f>]
(platform_drv_probe+0x33/0x68)
  [<c063fa4f>] (platform_drv_probe) from [<c063e4ef>]
(really_probe+0x16f/0x1e0)
  [<c063e4ef>] (really_probe) from [<c063e67f>]
(driver_probe_device+0x43/0x11c)
  [<c063e67f>] (driver_probe_device) from [<c063d0cf>]
(bus_for_each_drv+0x37/0x70)
  [<c063d0cf>] (bus_for_each_drv) from [<c063e32f>]
(__device_attach+0x83/0xc8)
  [<c063e32f>] (__device_attach) from [<c063da8b>]
(bus_probe_device+0x5b/0x60)
  [<c063da8b>] (bus_probe_device) from [<c063b7a5>]
(device_add+0x2f5/0x474)
  [<c063b7a5>] (device_add) from [<c063f8ef>]
(platform_device_add+0xb7/0x184)
  [<c063f8ef>] (platform_device_add) from [<c06400df>]
(platform_device_register_full+0xb3/0xc4)
  [<c06400df>] (platform_device_register_full) from [<c0725a2f>]
(sunxi_musb_probe+0x1d7/0x2f4)
  [<c0725a2f>] (sunxi_musb_probe) from [<c063fa4f>]
(platform_drv_probe+0x33/0x68)
  [<c063fa4f>] (platform_drv_probe) from [<c063e4ef>]
(really_probe+0x16f/0x1e0)
  [<c063e4ef>] (really_probe) from [<c063e67f>]
(driver_probe_device+0x43/0x11c)
  [<c063e67f>] (driver_probe_device) from [<c063d0cf>]
(bus_for_each_drv+0x37/0x70)
  [<c063d0cf>] (bus_for_each_drv) from [<c063e32f>]
(__device_attach+0x83/0xc8)
  [<c063e32f>] (__device_attach) from [<c063da8b>]
(bus_probe_device+0x5b/0x60)
  [<c063da8b>] (bus_probe_device) from [<c063ddcf>]
(deferred_probe_work_func+0x4b/0x6c)
  [<c063ddcf>] (deferred_probe_work_func) from [<c012e38b>]
(process_one_work+0x167/0x384)
  [<c012e38b>] (process_one_work) from [<c012f07d>]
(worker_thread+0x251/0x3fc)
  [<c012f07d>] (worker_thread) from [<c0132949>] (kthread+0xfd/0x104)
  [<c0132949>] (kthread) from [<c01010f9>] (ret_from_fork+0x11/0x38)
  Exception stack(0xc6999fb0 to 0xc6999ff8)
  9fa0:                                     00000000 00000000 00000000

00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000

  ---[ end trace b309edbca98c7de2 ]---
  musb-sunxi 1c13000.usb: Error unknown readb offset 128
  musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -22
  musb-hdrc: probe of musb-hdrc.1.auto failed with error -22

This is not critical but confusing. To avoid the Linux kernel to probe this device, mark it disabled in the device tree blob.

---
I'm not sure if this is a QEMU anti-pattern or bad practice. I know we prefer to be as close to the hardware as possible, but here the hardware is not changed, the dtb is. However this makes the guest behave differently. At least we don't have to manually edit the dts. If this is only annoying for acceptance testing, we might consider manually editing the dts in the tests setup().

---
 hw/arm/cubieboard.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
hw/arm/cubieboard.c +24 -0
index 6dc2f1d6b6..dd10577696 100644
@@ -22,10 +22,34 @@
 #include "hw/sysbus.h"
 #include "hw/boards.h"
 #include "hw/arm/allwinner-a10.h"
+#include <libfdt.h>
+
+static void cubieboard_modify_dtb(const struct arm_boot_info *info, void
 *fdt)
+{
+    static const char unsupported_compat[] = "allwinner,sun4i-a10-musb";
+    char node_path[72];
+    int offset;
+
+    offset = fdt_node_offset_by_compatible(fdt, -1, unsupported_compat);
+    while (offset >= 0) {
+        int r = fdt_get_path(fdt, offset, node_path, sizeof(node_path));
+        assert(r >= 0);
+        r = fdt_setprop_string(fdt, offset, "status", "disabled");
+        if (r < 0) {
+            error_report("%s: Couldn't disable %s: %s", __func__,
+                         unsupported_compat, fdt_strerror(r));
+            exit(1);
+        }
+        warn_report("cubieboard: disabled unsupported node %s (%s) "
+                    "in device tree", node_path, unsupported_compat);
+        offset = fdt_node_offset_by_compatible(fdt, offset,
 unsupported_compat);
+    }
+}
 
 static struct arm_boot_info cubieboard_binfo = {
     .loader_start = AW_A10_SDRAM_BASE,
     .board_id = 0x1008,
+    .modify_dtb = cubieboard_modify_dtb,
 };

typedef struct CubieBoardState {
--
2.21.0

Signature · 1 line
Niek Linnenbank
#14 lore raw

Re: [RFC PATCH 6/6] hw/arm/cubieboard: Disable unsupported M-USB in device tree blob

Quoted 7 lines · Niek Linnenbank

Hello Philippe,

I have a suggestion: probably you can apply (almost) the same patch to get USB
working for A10 as I did in the Allwinner H3, in patch #4 "add USB host controller" [1] That way you can avoid the DTB modifications and with low effort get USB working as well for this board. As far as I can see, in Section 21.1 in the A10 user manual [2] has the same description as for the H3. It basically has the standard EHCI and OHCI interfaces.

Oh good news. I guess in the long term we want a AllwinnerSoc parent class where all common blocks are mapped, and A10/H3 children with the differences. But we'll worry about that after your H3 series get merged.

Quoted 5 lines

[1] https://lists.gnu.org/archive/html/qemu-devel/2019-12/msg03266.html
[2] https://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf

Regards,
Niek

#15 lore raw

Re: [RFC PATCH 6/6] hw/arm/cubieboard: Disable unsupported M-USB in device tree blob

Hey Philippe,

I took a second look at this and, it seems my previous suggestion was only partly valid.
The kernel error you reported came from the driver in drivers/usb/musb/sunxi.c. Apparently, this
is an Allwinner specific driver for M-USB. And I don't see it documented in the A10 user manual.

On the other hand, the USB host interfaces EHCI/OHCI do apply for the A10 SoC and this board.
Linux has them defined in the DTB in arch/arm/boot/dts/sun4i-a10.dtsi (ehci0/1, ohci0/1).
But probably that is for another patch/commit.

Regards,
Niek

Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Niek Linnenbank

Hello Philippe,

I have a suggestion: probably you can apply (almost) the same patch to get USB
working for A10 as I did in the Allwinner H3, in patch #4 "add USB host controller" [1]
That way you can avoid the DTB modifications and with low effort get USB working as well for this board.
As far as I can see, in Section 21.1 in the A10 user manual [2] has the same description
as for the H3. It basically has the standard EHCI and OHCI interfaces.

Oh good news. I guess in the long term we want a AllwinnerSoc parent class where all common blocks are mapped, and A10/H3 children with the differences. But we'll worry about that after your H3 series get merged.

Quoted 5 lines

[1] https://lists.gnu.org/archive/html/qemu-devel/2019-12/msg03266.html
[2] https://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf

Regards,
Niek

Signature · 1 line
Niek Linnenbank
#16 lore raw

Re: [RFC PATCH 6/6] hw/arm/cubieboard: Disable unsupported M-USB in device tree blob

In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

We do not model the Sunxi Multipoint USB.
The Linux kernel OOPS when booting:

This is not critical but confusing. To avoid the Linux kernel to probe this device, mark it disabled in the device tree blob.

Quoted 8 lines

---
I'm not sure if this is a QEMU anti-pattern or bad practice. I know we prefer to be as close to the hardware as possible, but here the hardware is not changed, the dtb is. However this makes the guest behave differently. At least we don't have to manually edit the dts. If this is only annoying for acceptance testing, we might consider manually editing the dts in the tests setup().

In general I'd definitely prefer it if we avoided editing the DTB for things like this (we have very few boards that edit the DTB and none of them do it as workarounds for buggy/missing device emulation). Is it possible to have at least a dummy implementation of the controller that's enough to make the probe function fail more cleanly?

thanks
-- PMM

#17 lore raw

Re: [RFC PATCH 6/6] hw/arm/cubieboard: Disable unsupported M-USB in device tree blob

Quoted 18 lines · Peter Maydell
Quoted 8 lines · Philippe Mathieu-Daudé

We do not model the Sunxi Multipoint USB.
The Linux kernel OOPS when booting:

This is not critical but confusing. To avoid the Linux kernel to probe this device, mark it disabled in the device tree blob.

Quoted 8 lines

---
I'm not sure if this is a QEMU anti-pattern or bad practice. I know we prefer to be as close to the hardware as possible, but here the hardware is not changed, the dtb is. However this makes the guest behave differently. At least we don't have to manually edit the dts. If this is only annoying for acceptance testing, we might consider manually editing the dts in the tests setup().

Quoted 4 lines

In general I'd definitely prefer it if we avoided editing the DTB for things like this (we have very few boards that edit the DTB and none of them do it as workarounds for buggy/missing device emulation).

Yes I understand (I was expecting this answer, but better to have it explicit).

Quoted 3 lines

Is it possible to have
at least a dummy implementation of the controller that's enough to make the probe function fail more cleanly?

Niek gave some pointers. Anyway The kernel is not crashing, it is just oopsing, so this is not fatal (the VM is still usable).

Thanks!

Phil.

#18 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

After looking at Niek Linnenbank implementation of the Allwinner H3 [1], I looked what is common in the A10 [2].

Add some tests before modifying the code further.

[1] https://www.mail-archive.com/[email protected]/msg665532.html
[2] https://www.mail-archive.com/[email protected]/msg666809.html

Quoted 7 lines

Philippe Mathieu-Daudé (6):
tests/boot_linux_console: Add initrd test for the CubieBoard tests/boot_linux_console: Add a SD card test for the CubieBoard hw/arm/allwinner-a10: Move SoC definitions out of header hw/arm/allwinner-a10: Simplify by passing IRQs with qdev_pass_gpios() hw/arm/allwinner-a10: Remove local qemu_irq variables hw/arm/cubieboard: Disable unsupported M-USB in device tree blob [RFC]

I've added patches 1-5 to target-arm.next (but not the RFC patch 6, which I've replied with my view on.)

thanks
-- PMM