1Banana Pi BPI-M2U (``bpim2u``) 2^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 4Banana Pi BPI-M2 Ultra is a quad-core mini single board computer built with 5Allwinner A40i/R40/V40 SoC. It features 2GB of RAM and 8GB eMMC. It also 6has onboard WiFi and BT. On the ports side, the BPI-M2 Ultra has 2 USB A 72.0 ports, 1 USB OTG port, 1 HDMI port, 1 audio jack, a DC power port, 8and last but not least, a SATA port. 9 10Supported devices 11""""""""""""""""" 12 13The Banana Pi M2U machine supports the following devices: 14 15 * SMP (Quad Core Cortex-A7) 16 * Generic Interrupt Controller configuration 17 * SRAM mappings 18 * SDRAM controller 19 * Timer device (re-used from Allwinner A10) 20 * UART 21 * SD/MMC storage controller 22 * EMAC ethernet 23 * GMAC ethernet 24 * Clock Control Unit 25 * SATA 26 * TWI (I2C) 27 * USB 2.0 28 * Hardware Watchdog 29 30Limitations 31""""""""""" 32 33Currently, Banana Pi M2U does *not* support the following features: 34 35- Graphical output via HDMI, GPU and/or the Display Engine 36- Audio output 37- Real Time Clock 38 39Also see the 'unimplemented' array in the Allwinner R40 SoC module 40for a complete list of unimplemented I/O devices: ``./hw/arm/allwinner-r40.c`` 41 42Boot options 43"""""""""""" 44 45The Banana Pi M2U machine can start using the standard -kernel functionality 46for loading a Linux kernel or ELF executable. Additionally, the Banana Pi M2U 47machine can also emulate the BootROM which is present on an actual Allwinner R40 48based SoC, which loads the bootloader from a SD card, specified via the -sd 49argument to qemu-system-arm. 50 51Running mainline Linux 52"""""""""""""""""""""" 53 54To build a Linux mainline kernel that can be booted by the Banana Pi M2U machine, 55simply configure the kernel using the sunxi_defconfig configuration: 56 57.. code-block:: bash 58 59 $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make mrproper 60 $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make sunxi_defconfig 61 62To boot the newly build linux kernel in QEMU with the Banana Pi M2U machine, use: 63 64.. code-block:: bash 65 66 $ qemu-system-arm -M bpim2u -nographic \ 67 -kernel /path/to/linux/arch/arm/boot/zImage \ 68 -append 'console=ttyS0,115200' \ 69 -dtb /path/to/linux/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb 70 71Banana Pi M2U images 72"""""""""""""""""""" 73 74Note that the mainline kernel does not have a root filesystem. You can choose 75to build you own image with buildroot using the bananapi_m2_ultra_defconfig. 76Also see https://buildroot.org for more information. 77 78Another possibility is to run an OpenWrt image for Banana Pi M2U which 79can be downloaded from: 80 81 https://downloads.openwrt.org/releases/22.03.3/targets/sunxi/cortexa7/ 82 83When using an image as an SD card, it must be resized to a power of two. This can be 84done with the ``qemu-img`` command. It is recommended to only increase the image size 85instead of shrinking it to a power of two, to avoid loss of data. For example, 86to prepare a downloaded Armbian image, first extract it and then increase 87its size to one gigabyte as follows: 88 89.. code-block:: bash 90 91 $ qemu-img resize \ 92 openwrt-22.03.3-sunxi-cortexa7-sinovoip_bananapi-m2-ultra-ext4-sdcard.img \ 93 1G 94 95Instead of providing a custom Linux kernel via the -kernel command you may also 96choose to let the Banana Pi M2U machine load the bootloader from SD card, just like 97a real board would do using the BootROM. Simply pass the selected image via the -sd 98argument and remove the -kernel, -append, -dbt and -initrd arguments: 99 100.. code-block:: bash 101 102 $ qemu-system-arm -M bpim2u -nic user -nographic \ 103 -sd openwrt-22.03.3-sunxi-cortexa7-sinovoip_bananapi-m2-ultra-ext4-sdcard.img 104 105Running U-Boot 106"""""""""""""" 107 108U-Boot mainline can be build and configured using the Bananapi_M2_Ultra_defconfig 109using similar commands as describe above for Linux. Note that it is recommended 110for development/testing to select the following configuration setting in U-Boot: 111 112 Device Tree Control > Provider for DTB for DT Control > Embedded DTB 113 114The BootROM of allwinner R40 loading u-boot from the 8KiB offset of sdcard. 115Let's create an bootable disk image: 116 117.. code-block:: bash 118 119 $ dd if=/dev/zero of=sd.img bs=32M count=1 120 $ dd if=u-boot-sunxi-with-spl.bin of=sd.img bs=1k seek=8 conv=notrunc 121 122And then boot it. 123 124.. code-block:: bash 125 126 $ qemu-system-arm -M bpim2u -nographic -sd sd.img 127 128Banana Pi M2U integration tests 129""""""""""""""""""""""""""""""" 130 131The Banana Pi M2U machine has several integration tests included. 132To run the whole set of tests, build QEMU from source and simply 133provide the following command: 134 135.. code-block:: bash 136 137 $ cd qemu-build-dir 138 $ AVOCADO_ALLOW_LARGE_STORAGE=yes tests/venv/bin/avocado \ 139 --verbose --show=app,console run -t machine:bpim2u \ 140 ../tests/avocado/boot_linux_console.py 141