xref: /qemu/docs/system/arm/bananapi_m2u.rst (revision 527dede083d3e3e5a13ee996776926e0a0c4e258)
18d7f954aSqianfan ZhaoBanana Pi BPI-M2U (``bpim2u``)
28d7f954aSqianfan Zhao^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38d7f954aSqianfan Zhao
48d7f954aSqianfan ZhaoBanana Pi BPI-M2 Ultra is a quad-core mini single board computer built with
58d7f954aSqianfan ZhaoAllwinner A40i/R40/V40 SoC. It features 2GB of RAM and 8GB eMMC. It also
68d7f954aSqianfan Zhaohas onboard WiFi and BT. On the ports side, the BPI-M2 Ultra has 2 USB A
78d7f954aSqianfan Zhao2.0 ports, 1 USB OTG port, 1 HDMI port, 1 audio jack, a DC power port,
88d7f954aSqianfan Zhaoand last but not least, a SATA port.
98d7f954aSqianfan Zhao
108d7f954aSqianfan ZhaoSupported devices
118d7f954aSqianfan Zhao"""""""""""""""""
128d7f954aSqianfan Zhao
138d7f954aSqianfan ZhaoThe Banana Pi M2U machine supports the following devices:
148d7f954aSqianfan Zhao
158d7f954aSqianfan Zhao * SMP (Quad Core Cortex-A7)
168d7f954aSqianfan Zhao * Generic Interrupt Controller configuration
178d7f954aSqianfan Zhao * SRAM mappings
188d7f954aSqianfan Zhao * SDRAM controller
198d7f954aSqianfan Zhao * Timer device (re-used from Allwinner A10)
208d7f954aSqianfan Zhao * UART
218d7f954aSqianfan Zhao * SD/MMC storage controller
228d7f954aSqianfan Zhao * EMAC ethernet
238d7f954aSqianfan Zhao * GMAC ethernet
248d7f954aSqianfan Zhao * Clock Control Unit
252a02da74SGuenter Roeck * SATA
268d7f954aSqianfan Zhao * TWI (I2C)
2743eef24fSGuenter Roeck * USB 2.0
282af71d28SGuenter Roeck * Hardware Watchdog
298d7f954aSqianfan Zhao
308d7f954aSqianfan ZhaoLimitations
318d7f954aSqianfan Zhao"""""""""""
328d7f954aSqianfan Zhao
338d7f954aSqianfan ZhaoCurrently, Banana Pi M2U does *not* support the following features:
348d7f954aSqianfan Zhao
358d7f954aSqianfan Zhao- Graphical output via HDMI, GPU and/or the Display Engine
368d7f954aSqianfan Zhao- Audio output
378d7f954aSqianfan Zhao- Real Time Clock
388d7f954aSqianfan Zhao
398d7f954aSqianfan ZhaoAlso see the 'unimplemented' array in the Allwinner R40 SoC module
408d7f954aSqianfan Zhaofor a complete list of unimplemented I/O devices: ``./hw/arm/allwinner-r40.c``
418d7f954aSqianfan Zhao
428d7f954aSqianfan ZhaoBoot options
438d7f954aSqianfan Zhao""""""""""""
448d7f954aSqianfan Zhao
458d7f954aSqianfan ZhaoThe Banana Pi M2U machine can start using the standard -kernel functionality
468d7f954aSqianfan Zhaofor loading a Linux kernel or ELF executable. Additionally, the Banana Pi M2U
478d7f954aSqianfan Zhaomachine can also emulate the BootROM which is present on an actual Allwinner R40
488d7f954aSqianfan Zhaobased SoC, which loads the bootloader from a SD card, specified via the -sd
498d7f954aSqianfan Zhaoargument to qemu-system-arm.
508d7f954aSqianfan Zhao
518d7f954aSqianfan ZhaoRunning mainline Linux
528d7f954aSqianfan Zhao""""""""""""""""""""""
538d7f954aSqianfan Zhao
548d7f954aSqianfan ZhaoTo build a Linux mainline kernel that can be booted by the Banana Pi M2U machine,
558d7f954aSqianfan Zhaosimply configure the kernel using the sunxi_defconfig configuration:
568d7f954aSqianfan Zhao
578d7f954aSqianfan Zhao.. code-block:: bash
588d7f954aSqianfan Zhao
598d7f954aSqianfan Zhao  $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make mrproper
608d7f954aSqianfan Zhao  $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make sunxi_defconfig
618d7f954aSqianfan Zhao
628d7f954aSqianfan ZhaoTo boot the newly build linux kernel in QEMU with the Banana Pi M2U machine, use:
638d7f954aSqianfan Zhao
648d7f954aSqianfan Zhao.. code-block:: bash
658d7f954aSqianfan Zhao
668d7f954aSqianfan Zhao  $ qemu-system-arm -M bpim2u -nographic \
678d7f954aSqianfan Zhao      -kernel /path/to/linux/arch/arm/boot/zImage \
688d7f954aSqianfan Zhao      -append 'console=ttyS0,115200' \
698d7f954aSqianfan Zhao      -dtb /path/to/linux/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb
708d7f954aSqianfan Zhao
718d7f954aSqianfan ZhaoBanana Pi M2U images
728d7f954aSqianfan Zhao""""""""""""""""""""
738d7f954aSqianfan Zhao
748d7f954aSqianfan ZhaoNote that the mainline kernel does not have a root filesystem. You can choose
758d7f954aSqianfan Zhaoto build you own image with buildroot using the bananapi_m2_ultra_defconfig.
768d7f954aSqianfan ZhaoAlso see https://buildroot.org for more information.
778d7f954aSqianfan Zhao
788d7f954aSqianfan ZhaoAnother possibility is to run an OpenWrt image for Banana Pi M2U which
798d7f954aSqianfan Zhaocan be downloaded from:
808d7f954aSqianfan Zhao
818d7f954aSqianfan Zhao   https://downloads.openwrt.org/releases/22.03.3/targets/sunxi/cortexa7/
828d7f954aSqianfan Zhao
838d7f954aSqianfan ZhaoWhen using an image as an SD card, it must be resized to a power of two. This can be
848d7f954aSqianfan Zhaodone with the ``qemu-img`` command. It is recommended to only increase the image size
858d7f954aSqianfan Zhaoinstead of shrinking it to a power of two, to avoid loss of data. For example,
868d7f954aSqianfan Zhaoto prepare a downloaded Armbian image, first extract it and then increase
878d7f954aSqianfan Zhaoits size to one gigabyte as follows:
888d7f954aSqianfan Zhao
898d7f954aSqianfan Zhao.. code-block:: bash
908d7f954aSqianfan Zhao
918d7f954aSqianfan Zhao  $ qemu-img resize \
928d7f954aSqianfan Zhao    openwrt-22.03.3-sunxi-cortexa7-sinovoip_bananapi-m2-ultra-ext4-sdcard.img \
938d7f954aSqianfan Zhao    1G
948d7f954aSqianfan Zhao
958d7f954aSqianfan ZhaoInstead of providing a custom Linux kernel via the -kernel command you may also
968d7f954aSqianfan Zhaochoose to let the Banana Pi M2U machine load the bootloader from SD card, just like
978d7f954aSqianfan Zhaoa real board would do using the BootROM. Simply pass the selected image via the -sd
988d7f954aSqianfan Zhaoargument and remove the -kernel, -append, -dbt and -initrd arguments:
998d7f954aSqianfan Zhao
1008d7f954aSqianfan Zhao.. code-block:: bash
1018d7f954aSqianfan Zhao
1028d7f954aSqianfan Zhao  $ qemu-system-arm -M bpim2u -nic user -nographic \
1038d7f954aSqianfan Zhao    -sd openwrt-22.03.3-sunxi-cortexa7-sinovoip_bananapi-m2-ultra-ext4-sdcard.img
1048d7f954aSqianfan Zhao
1058d7f954aSqianfan ZhaoRunning U-Boot
1068d7f954aSqianfan Zhao""""""""""""""
1078d7f954aSqianfan Zhao
1088d7f954aSqianfan ZhaoU-Boot mainline can be build and configured using the Bananapi_M2_Ultra_defconfig
1098d7f954aSqianfan Zhaousing similar commands as describe above for Linux. Note that it is recommended
1108d7f954aSqianfan Zhaofor development/testing to select the following configuration setting in U-Boot:
1118d7f954aSqianfan Zhao
1128d7f954aSqianfan Zhao  Device Tree Control > Provider for DTB for DT Control > Embedded DTB
1138d7f954aSqianfan Zhao
1148d7f954aSqianfan ZhaoThe BootROM of allwinner R40 loading u-boot from the 8KiB offset of sdcard.
1158d7f954aSqianfan ZhaoLet's create an bootable disk image:
1168d7f954aSqianfan Zhao
1178d7f954aSqianfan Zhao.. code-block:: bash
1188d7f954aSqianfan Zhao
1198d7f954aSqianfan Zhao  $ dd if=/dev/zero of=sd.img bs=32M count=1
1208d7f954aSqianfan Zhao  $ dd if=u-boot-sunxi-with-spl.bin of=sd.img bs=1k seek=8 conv=notrunc
1218d7f954aSqianfan Zhao
1228d7f954aSqianfan ZhaoAnd then boot it.
1238d7f954aSqianfan Zhao
1248d7f954aSqianfan Zhao.. code-block:: bash
1258d7f954aSqianfan Zhao
1268d7f954aSqianfan Zhao  $ qemu-system-arm -M bpim2u -nographic -sd sd.img
1278d7f954aSqianfan Zhao
128*a6836b6dSThomas HuthBanana Pi M2U functional tests
129*a6836b6dSThomas Huth""""""""""""""""""""""""""""""
1308d7f954aSqianfan Zhao
131*a6836b6dSThomas HuthThe Banana Pi M2U machine has several functional tests included.
1328d7f954aSqianfan ZhaoTo run the whole set of tests, build QEMU from source and simply
1338d7f954aSqianfan Zhaoprovide the following command:
1348d7f954aSqianfan Zhao
1358d7f954aSqianfan Zhao.. code-block:: bash
1368d7f954aSqianfan Zhao
1378d7f954aSqianfan Zhao  $ cd qemu-build-dir
13815ef93ddSThomas Huth  $ QEMU_TEST_ALLOW_LARGE_STORAGE=1 \
139cef6da5bSThomas Huth    pyvenv/bin/meson test --suite thorough func-arm-arm_bpim2u
140