orangepi.rst 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. Orange Pi PC (``orangepi-pc``)
  2. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  3. The Xunlong Orange Pi PC is an Allwinner H3 System on Chip
  4. based embedded computer with mainline support in both U-Boot
  5. and Linux. The board comes with a Quad Core Cortex-A7 @ 1.3GHz,
  6. 1GiB RAM, 100Mbit ethernet, USB, SD/MMC, USB, HDMI and
  7. various other I/O.
  8. Supported devices
  9. """""""""""""""""
  10. The Orange Pi PC machine supports the following devices:
  11. * SMP (Quad Core Cortex-A7)
  12. * Generic Interrupt Controller configuration
  13. * SRAM mappings
  14. * SDRAM controller
  15. * Real Time Clock
  16. * Timer device (re-used from Allwinner A10)
  17. * UART
  18. * SD/MMC storage controller
  19. * EMAC ethernet
  20. * USB 2.0 interfaces
  21. * Clock Control Unit
  22. * System Control module
  23. * Security Identifier device
  24. * TWI (I2C)
  25. * Watchdog timer
  26. Limitations
  27. """""""""""
  28. Currently, Orange Pi PC does *not* support the following features:
  29. - Graphical output via HDMI, GPU and/or the Display Engine
  30. - Audio output
  31. - Hardware Watchdog
  32. Also see the 'unimplemented' array in the Allwinner H3 SoC module
  33. for a complete list of unimplemented I/O devices: ``./hw/arm/allwinner-h3.c``
  34. Boot options
  35. """"""""""""
  36. The Orange Pi PC machine can start using the standard -kernel functionality
  37. for loading a Linux kernel or ELF executable. Additionally, the Orange Pi PC
  38. machine can also emulate the BootROM which is present on an actual Allwinner H3
  39. based SoC, which loads the bootloader from a SD card, specified via the -sd argument
  40. to qemu-system-arm.
  41. Machine-specific options
  42. """"""""""""""""""""""""
  43. The following machine-specific options are supported:
  44. - allwinner-rtc.base-year=YYYY
  45. The Allwinner RTC device is automatically created by the Orange Pi PC machine
  46. and uses a default base year value which can be overridden using the 'base-year' property.
  47. The base year is the actual represented year when the RTC year value is zero.
  48. This option can be used in case the target operating system driver uses a different
  49. base year value. The minimum value for the base year is 1900.
  50. - allwinner-sid.identifier=abcd1122-a000-b000-c000-12345678ffff
  51. The Security Identifier value can be read by the guest.
  52. For example, U-Boot uses it to determine a unique MAC address.
  53. The above machine-specific options can be specified in qemu-system-arm
  54. via the '-global' argument, for example:
  55. .. code-block:: bash
  56. $ qemu-system-arm -M orangepi-pc -sd mycard.img \
  57. -global allwinner-rtc.base-year=2000
  58. Running mainline Linux
  59. """"""""""""""""""""""
  60. Mainline Linux kernels from 4.19 up to latest master are known to work.
  61. To build a Linux mainline kernel that can be booted by the Orange Pi PC machine,
  62. simply configure the kernel using the sunxi_defconfig configuration:
  63. .. code-block:: bash
  64. $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make mrproper
  65. $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make sunxi_defconfig
  66. To be able to use USB storage, you need to manually enable the corresponding
  67. configuration item. Start the kconfig configuration tool:
  68. .. code-block:: bash
  69. $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make menuconfig
  70. Navigate to the following item, enable it and save your configuration:
  71. Device Drivers > USB support > USB Mass Storage support
  72. Build the Linux kernel with:
  73. .. code-block:: bash
  74. $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make
  75. To boot the newly build linux kernel in QEMU with the Orange Pi PC machine, use:
  76. .. code-block:: bash
  77. $ qemu-system-arm -M orangepi-pc -nic user -nographic \
  78. -kernel /path/to/linux/arch/arm/boot/zImage \
  79. -append 'console=ttyS0,115200' \
  80. -dtb /path/to/linux/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dtb
  81. Orange Pi PC images
  82. """""""""""""""""""
  83. Note that the mainline kernel does not have a root filesystem. You may provide it
  84. with an official Orange Pi PC image from the official website:
  85. http://www.orangepi.org/html/serviceAndSupport/index.html
  86. Another possibility is to run an Armbian image for Orange Pi PC which
  87. can be downloaded from:
  88. https://www.armbian.com/orange-pi-pc/
  89. Alternatively, you can also choose to build you own image with buildroot
  90. using the orangepi_pc_defconfig. Also see https://buildroot.org for more information.
  91. When using an image as an SD card, it must be resized to a power of two. This can be
  92. done with the ``qemu-img`` command. It is recommended to only increase the image size
  93. instead of shrinking it to a power of two, to avoid loss of data. For example,
  94. to prepare a downloaded Armbian image, first extract it and then increase
  95. its size to one gigabyte as follows:
  96. .. code-block:: bash
  97. $ qemu-img resize Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img 1G
  98. You can choose to attach the selected image either as an SD card or as USB mass storage.
  99. For example, to boot using the Orange Pi PC Debian image on SD card, simply add the -sd
  100. argument and provide the proper root= kernel parameter:
  101. .. code-block:: bash
  102. $ qemu-system-arm -M orangepi-pc -nic user -nographic \
  103. -kernel /path/to/linux/arch/arm/boot/zImage \
  104. -append 'console=ttyS0,115200 root=/dev/mmcblk0p2' \
  105. -dtb /path/to/linux/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dtb \
  106. -sd OrangePi_pc_debian_stretch_server_linux5.3.5_v1.0.img
  107. To attach the image as an USB mass storage device to the machine,
  108. simply append to the command:
  109. .. code-block:: bash
  110. -drive if=none,id=stick,file=myimage.img \
  111. -device usb-storage,bus=usb-bus.0,drive=stick
  112. Instead of providing a custom Linux kernel via the -kernel command you may also
  113. choose to let the Orange Pi PC machine load the bootloader from SD card, just like
  114. a real board would do using the BootROM. Simply pass the selected image via the -sd
  115. argument and remove the -kernel, -append, -dbt and -initrd arguments:
  116. .. code-block:: bash
  117. $ qemu-system-arm -M orangepi-pc -nic user -nographic \
  118. -sd Armbian_19.11.3_Orangepipc_buster_current_5.3.9.img
  119. Note that both the official Orange Pi PC images and Armbian images start
  120. a lot of userland programs via systemd. Depending on the host hardware and OS,
  121. they may be slow to emulate, especially due to emulating the 4 cores.
  122. To help reduce the performance slow down due to emulating the 4 cores, you can
  123. give the following kernel parameters via U-Boot (or via -append):
  124. .. code-block:: bash
  125. => setenv extraargs 'systemd.default_timeout_start_sec=9000 loglevel=7 nosmp console=ttyS0,115200'
  126. Running U-Boot
  127. """"""""""""""
  128. U-Boot mainline can be build and configured using the orangepi_pc_defconfig
  129. using similar commands as describe above for Linux. Note that it is recommended
  130. for development/testing to select the following configuration setting in U-Boot:
  131. Device Tree Control > Provider for DTB for DT Control > Embedded DTB
  132. To start U-Boot using the Orange Pi PC machine, provide the
  133. u-boot binary to the -kernel argument:
  134. .. code-block:: bash
  135. $ qemu-system-arm -M orangepi-pc -nic user -nographic \
  136. -kernel /path/to/uboot/u-boot -sd disk.img
  137. Use the following U-boot commands to load and boot a Linux kernel from SD card:
  138. .. code-block:: bash
  139. => setenv bootargs console=ttyS0,115200
  140. => ext2load mmc 0 0x42000000 zImage
  141. => ext2load mmc 0 0x43000000 sun8i-h3-orangepi-pc.dtb
  142. => bootz 0x42000000 - 0x43000000
  143. Running NetBSD
  144. """"""""""""""
  145. The NetBSD operating system also includes support for Allwinner H3 based boards,
  146. including the Orange Pi PC. NetBSD 9.0 is known to work best for the Orange Pi PC
  147. board and provides a fully working system with serial console, networking and storage.
  148. For the Orange Pi PC machine, get the 'evbarm-earmv7hf' based image from:
  149. https://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.0/evbarm-earmv7hf/binary/gzimg/armv7.img.gz
  150. The image requires manually installing U-Boot in the image. Build U-Boot with
  151. the orangepi_pc_defconfig configuration as described in the previous section.
  152. Next, unzip the NetBSD image and write the U-Boot binary including SPL using:
  153. .. code-block:: bash
  154. $ gunzip armv7.img.gz
  155. $ dd if=/path/to/u-boot-sunxi-with-spl.bin of=armv7.img bs=1024 seek=8 conv=notrunc
  156. Finally, before starting the machine the SD image must be extended such
  157. that the size of the SD image is a power of two and that the NetBSD kernel
  158. will not conclude the NetBSD partition is larger than the emulated SD card:
  159. .. code-block:: bash
  160. $ qemu-img resize armv7.img 2G
  161. Start the machine using the following command:
  162. .. code-block:: bash
  163. $ qemu-system-arm -M orangepi-pc -nic user -nographic \
  164. -sd armv7.img -global allwinner-rtc.base-year=2000
  165. At the U-Boot stage, interrupt the automatic boot process by pressing a key
  166. and set the following environment variables before booting:
  167. .. code-block:: bash
  168. => setenv bootargs root=ld0a
  169. => setenv kernel netbsd-GENERIC.ub
  170. => setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb
  171. => setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; fdt addr ${fdt_addr_r}; bootm ${kernel_addr_r} - ${fdt_addr_r}'
  172. Optionally you may save the environment variables to SD card with 'saveenv'.
  173. To continue booting simply give the 'boot' command and NetBSD boots.
  174. Orange Pi PC functional tests
  175. """""""""""""""""""""""""""""
  176. The Orange Pi PC machine has several functional tests included.
  177. To run the whole set of tests, build QEMU from source and simply
  178. provide the following command from the build directory:
  179. .. code-block:: bash
  180. $ QEMU_TEST_ALLOW_LARGE_STORAGE=1 \
  181. pyvenv/bin/meson test --suite thorough func-arm-arm_orangepi