Dev/OPi/OPiZero: Difference between revisions

From Embeded Linux (and more) Wiki by Nathael
< Dev‎ | OPi
Jump to navigation Jump to search
No edit summary
Line 6: Line 6:


The OrangePi Zero board is an Open-source Single Board Computer (SBC) of 48x46mm created and sold by Xunlong.
The OrangePi Zero board is an Open-source Single Board Computer (SBC) of 48x46mm created and sold by Xunlong.
It has either an H2 or an H3 Quad-core ARM Cortex-A7 MPCore processor (ARMv7 32 bits) and 256 or 512Mo of RAM.


== Base system ==
== Base system ==
Line 43: Line 45:


== Use ==
== Use ==
As for most of my systems I'm using a µSD card to store the images and rootfs.
=== Connection and startup ===
This board only has an optionnal 2MB SPI Flash but needs a µSD card to start.
 
==== USB-UART serial console connection ====
[[File:OPi_Zero_UART.jpg|150px|thumbnail|UART debug port]]
 
On the J3 connector (3 pins male 2.54mm, next to the Ethernet connector, pin 1 on the board edge) :
: pin 1 - GND : Black
: pin 2 - UART RX : Orange
: pin 3 : UART TX : Yellow
 
=== SD Card creation ===
=== SD Card creation ===
Original information from [http://linux-sunxi.org/Bootable_SD_card linux-sunxi wiki]
Original information from [http://linux-sunxi.org/Bootable_SD_card linux-sunxi wiki]
The OrangePi Zero board boots from the SD card which has to be prepared following specific steps.


You will need a DOS partition table as GUID partition tables (GPT) will go further than 8k and erase the initial SPL loader.
You will need a DOS partition table as GUID partition tables (GPT) will go further than 8k and erase the initial SPL loader.
Line 75: Line 89:
  dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8
  dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8


=== First partition ===
==== First partition : kernel images ====
The first partition must start at +1Mo, and be a few Mo (50 Mo should be OK) and be formated using ext2/3/4<br />
The first partition must start at +1Mo, and be a few Mo (50 Mo should be OK) and be formated using ext2/3/4<br />
Place the Linux kernel image (zImage), the device tree (sun8i-h2-plus-orangepi-zero-ed3l.dtb) and the boot script (boot.scr) on this first partition.
Place the Linux kernel image (zImage), the device tree (sun8i-h2-plus-orangepi-zero-ed3l.dtb) and the boot script (boot.scr) on this first partition.
Line 84: Line 98:
If you want to use an initramfs or an initrd, it will also go on this partition.
If you want to use an initramfs or an initrd, it will also go on this partition.


=== Second partition ===
==== Second partition : rootfs ====
The second partition must be formated using ext4 and starts right after the first one. It can take all the remaining size unless you have other specific needs.
This partition holds the root filesystem (rootfs). It must be formated using ext4 and starts right after the first one. It can take all the remaining size unless you have other specific needs.


This partition holds the root filesystem (rootfs).
== Rootfs ==
This board uses an ARM processor with hardfloat support, thus the root filesystem should be built using "arm-linux-gnueabihf-" cross-toolchain or use the armhf architecture for Devuan or other Debian based distribution.
This board uses an ARM processor with hardfloat support, thus the root filesystem should be built using "arm-linux-gnueabihf-" cross-toolchain or use the armhf architecture for Devuan or other Debian based distribution.


Refer to [[Dev/Embedded/Rootfs|the rootfs creation page]] for more information.
Refer to [[Dev/Embedded/Rootfs|the rootfs creation page]] for more information.


== Connection and startup ==
==== USB-UART serial console connection ====
[[File:OPi_Zero_UART.jpg|150px|thumbnail|UART debug port]]
On the J3 connector (3 pins male 2.54mm, next to the Ethernet connector, pin 1 on the board edge) :
: pin 1 - GND : Black
: pin 2 - UART RX : Orange
: pin 3 : UART TX : Yellow
==== SD card boot ====
The OrangePi Zero board boots from the SD card which has to be prepared following specific steps. Follow the "SD card creation" section from the [[Dev/OPi/OPiZero/From_Scratch|"from scratch" page]]


== Extension ports ==
== Extension ports ==

Revision as of 14:53, 9 December 2024


Description

Official website : http://www.orangepi.org/orangepizero/ (Backup)
New one : https://orangepi.com/index.php?route=product/product&product_id=844

The OrangePi Zero board is an Open-source Single Board Computer (SBC) of 48x46mm created and sold by Xunlong.

It has either an H2 or an H3 Quad-core ARM Cortex-A7 MPCore processor (ARMv7 32 bits) and 256 or 512Mo of RAM.

Base system

You can get the detailed information on the Create initial system from scratch (sources) page. Here are only the specific parts or options.

Specific options

  • Compiler :

Compile using "arm-linux-gnueabihf-" toolchain prefix

  • Devuan architecture :

Devuan architecture is "armhf"

Sources and versions

U-Boot

  • u-boot sources :

Use official git "git://git.denx.de/u-boot.git" - checkout tag "v2019.07".

  • u-boot config :

Use "orangepi_zero_defconfig"

  • u-boot environment :

You can get my example boot.cmd file

Linux Kernel

  • Linux kernel sources :

Use Kernel 5.3 from kernel.org

  • Linux kernel configuration :

Use "sunxi_defconfig" or my own Linux kernel configuration.

  • Linux kernel device tree :

Use the "sun8i-h2-plus-orangepi-zero" device-tree or my own orangepi-zero device tree.

Results

  • u-boot result image :

Compilation should produce the file "u-boot-sunxi-with-spl.bin" which seems to be an aggregate of spl/u-boot-spl.bin and u-boot.bin with the proper offset for u-boot image.

  • Linux kernel image :

Compilation results are arch/arm/boot/zImage and arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero-ed3l.dtb plus the associated modules.

  • Download :

You can get my own images from my server : results_opizero_ed3l_2021-09-11.tar.bz2


Use

Connection and startup

This board only has an optionnal 2MB SPI Flash but needs a µSD card to start.

USB-UART serial console connection

UART debug port

On the J3 connector (3 pins male 2.54mm, next to the Ethernet connector, pin 1 on the board edge) :

pin 1 - GND : Black
pin 2 - UART RX : Orange
pin 3 : UART TX : Yellow

SD Card creation

Original information from linux-sunxi wiki

The OrangePi Zero board boots from the SD card which has to be prepared following specific steps.

You will need a DOS partition table as GUID partition tables (GPT) will go further than 8k and erase the initial SPL loader.

  • SD card architecture :
start sector size usage
0KB 0 8KB Unused, available for a DOS MBR or (limited) GPT partition table
8KB 16 32KB Initial SPL loader
40KB 80 - U-Boot proper

Typically partitions start at 1MB (which is the default setting of most partitioning tools), but there is no hard requirement for this, so U-Boot can grow bigger than 984KB, if needed.

The 8KB offset is dictated by the Boot ROM which will check for a valid eGON/TOC0 header at this location. The 40KB offset for U-Boot proper is the default U-Boot setting and can be changed at build time using the CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR configuration variable.

  • Cleaning :

Erase the first Mo of the SD card while keeping the partition table:

dd if=/dev/zero of=${card} bs=1k count=1016 seek=8

(Use count=1024 and remove "seek" option to also erase the partition table)

  • Write Bootloader :

Copy uboot images (u-boot-sunxi-with-spl.bin, found in u-boot main directory after compilation) to the SD card:

dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8

First partition : kernel images

The first partition must start at +1Mo, and be a few Mo (50 Mo should be OK) and be formated using ext2/3/4
Place the Linux kernel image (zImage), the device tree (sun8i-h2-plus-orangepi-zero-ed3l.dtb) and the boot script (boot.scr) on this first partition.

Create file "boot.scr" from "boot.cmd" file (you can use my example boot.cmd file) using mkimage after updating file names to your needs :

mkimage -C none -A arm -T script -d boot.cmd boot.scr

If you want to use an initramfs or an initrd, it will also go on this partition.

Second partition : rootfs

This partition holds the root filesystem (rootfs). It must be formated using ext4 and starts right after the first one. It can take all the remaining size unless you have other specific needs.

This board uses an ARM processor with hardfloat support, thus the root filesystem should be built using "arm-linux-gnueabihf-" cross-toolchain or use the armhf architecture for Devuan or other Debian based distribution.

Refer to the rootfs creation page for more information.


Extension ports

The OrangePi Zero board has two extension ports using common 2.54mm (0.1inch) pitch:

  • con4 : 2x13
  • con5 : 1x13
Orange Pi Zero Expansion Header
con4 : 2x13 Header
1 3.3V 2 5V
3 TWI0_SDA / PA12 / GPIO12 4 5V
5 TWI0_SCK / PA11 / GPIO11 6 GND
7 PWM1 / PA06 / GPIO6 8 UART1_TX / PG06 / GPIO198
9 GND 10 UART1_RX / PG07 / GPIO199
11 UART2_RX / PA01 / GPIO1 12 SIM_CLK/PA_EINT7 / PA07 / GPIO7
13 UART2_TX / PA00 / GPIO0 14 GND
15 UART2_CTS / PA03 / GPIO3 16 TWI1-SDA / PA19 / GPIO19
17 3.3V 18 TWI1-SCK / PA18 / GPIO18
19 SPI1_MOSI / PA15 / GPIO15 20 GND
21 SPI1_MISO / PA16 / GPIO16 22 UART2_RTS / PA02 / GPIO2
23 SPI1_CLK / PA14 / GPIO14 24 SPI1_CS / PA13 / GPIO13
25 GND 26 SIM_DET/PA_EINT10 / PA10 / GPIO10


con5 1x13 Header
1 5V
2 GND
3 USB-DM2
4 USB-DP2
5 USB-DM3
6 USB-DP3
7 LINEOUTR
8 LINEOUTL
9 TV-OUT
10 MIC-BIAS
11 MIC1P
12 MIC1N
13 CIR-RX

External links

(Pseudo)random list of links to pages with information to compile u-boot, the Linux kernel, and create a root filesystem.