File:  [NetBSD Developer Wiki] / wikisrc / ports / evbarm / allwinner.mdwn
Revision 1.57: download - view: text, annotated - select for diffs
Thu Dec 10 22:31:14 2015 UTC (6 years, 1 month ago) by leot
Branches: MAIN
CVS tags: HEAD
Use filecontent template instead of programlisting where appropriate.

[[!meta title="NetBSD/evbarm on Allwinner Technology SoCs"]]

NetBSD 7.0 has support for A20 and A31 SoCs. NetBSD -current adds support for A80 SoCs.

[[!toc levels=2]]

# Supported boards
 - [Banana Pi]( (BPI)
 - Cubieboard 2 (CUBIEBOARD)
 - [Cubieboard 4]( (ALLWINNER_A80) *NetBSD-current*
 - Cubietruck (CUBIETRUCK)
 - [Merrii Hummingbird A31]( (HUMMINGBIRD_A31)

# Supported hardware
 - SoCs
   - Cortex-A7: A20 (2-core), A31 (4-core), A80
   - Cortex-A7/A15: A80 (4-core A7 + 4-core A15)
 - SD/MMC controller (DMA)
 - DMA controller
   - Configuration using FEX scripts is supported
 - I2C
 - P2WI (A31) / RSB (A80)
 - PMU
   - AXP209 (A20)
   - AXP221 (A31)
   - AXP806 (A80)
   - AXP809 (A80)
 - Watchdog timer
 - RTC
   - A20/A31: integrated RTC, PCF8563
   - A80: AC100
 - Audio codec (A20/A31)
 - USB host
   - OHCI
   - EHCI
   - OTG (A20)
 - SATA (A10/A20)
 - Gigabit Ethernet (GMAC)
   - DDC / EDID mode detection (A20/A31)
   - Audio support (A20/A31)
 - Framebuffer (A20/A31/A80)
 - IR receiver (A20/A31/A80)

 - A10
   - Interrupt controller
   - EMAC
 - A31
   - OTG
   - IR transmitter
   - 3G module
   - TV input
 - A80
   - MP
   - big.LITTLE support
   - USB3 (OTG and XHCI)
   - IR transmitter
   - HDMI (DDC and mode setting; currently relies on U-Boot for setup)
   - Audio codec
 - All
   - USB device mode
   - SDIO (Bluetooth / WiFi)
   - NAND
   - VGA (Cubietruck, Hummingbird A31, Cubieboard4)

# Installation

## A20 / A31 based boards

* Start with an ARMv7 image from *evbarm-earmv7hf/binary/gzimg/armv7.img.gz* from
NetBSD 7.0
* Download a U-Boot build for your board
  * Download the correct build from the linux-sunxi web site <>.
* Decompress the image via [[!template id=man name="gunzip" section="1"]]:
[[!template  id=programlisting text="""
# gunzip armv7.img.gz
* Write the *u-boot-sunxi-with-spl.bin* loader to the empty space at the start of the base image:
[[!template  id=programlisting text="""
# dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1k seek=8 conv=notrunc
* Write the image to an SD card (e.g.: if the SD card is recognised as *sd0* -
please check the [[!template id=man name="dmesg" section="8"]] output to be
[[!template  id=programlisting text="""
# dd if=armv7.img of=/dev/rsd0d bs=1m
* Copy the kernel (*netbsd.ub*) for your board to the root of the MS-DOS
partition on the SD card
* Prepare a *boot.cmd* file for U-Boot boot loader containing the needed
instructions regarding how to boot the kernel (basically the *bootargs* that are
passed to the kernel and how to load the kernel from a device to the RAM and
then boot it from the memory address):
[[!template  id=filecontent name="boot.cmd" text="""
setenv kernel_addr      82000000
setenv kernel           netbsd.ub
setenv bootargs         "root=ld0a"

fatload mmc 0:1 ${kernel_addr} ${kernel}
bootm ${kernel_addr}
* The *boot.cmd* text file should be converted in a script image - *boot.scr*
for U-Boot via [[!template id=man name="mkubootimage" section="1"]]:
[[!template  id=programlisting text="""
# mkubootimage -A arm -n armv7 -T script boot.cmd boot.scr
* Copy the *boot.scr* to the MS-DOS partition of the SD card

## A80 based boards

* Cubieboard 4 U-Boot for SD card: <>
[[!template  id=programlisting text="""
# dd if=u-boot-spl.bin of=/dev/sdd bs=1k seek=8
# dd if=u-boot-sun9iw1p1.bin of=/dev/sdd bs=1k seek=19096
* First partition needs to be at +20MB offset. Format it as MSDOS, copy 'netbsd.ub' to it as 'uImage'.

# Big (endian) fun

You can run this boards with a little endian (this is the default and implied by above install instructions)
or with a big endian kernel and userland. However, kernel and userland endianness needs to match.

To build a big endian release (or sets) use 
[[!template  id=programlisting text="""
./ -m evbearmv7hf-eb 
where -eb means endianness big, hf is hardware floating point support, and earm is the modern "extended" ABI for ARM CPUs, and finally v7 is version 7 of the supported instruction set.

# FEX scripts

Board configuration scripts can be found here: <>. You can compile them with the "fex2bin" tool found here: <>.

To use, copy the compiled FEX to your MS-DOS partition, load it with U-Boot, and then tell the kernel where to find it with the "sysconfig=" boot option. For example, uEnv.txt on a Cubieboard2 might look like this:

[[!template  id=filecontent name="uEnv.txt" text="""
bootargs=root=ld0a sysconfig=0x43000000
uenvcmd=mmc dev 0; mmc rescan; fatload mmc 0:1 43000000 cubieboard2.bin; fatload mmc 0:1 82000000 netbsd.ub; bootm 82000000

Some pre-compiled .bin files can be found here: <>

# Framebuffer console

To use HDMI for the console device, add *console=fb* to bootargs in uEnv.txt.

If the connected display does not let you disable overscan, you can add a margin to the framebuffer by with the *fb.margin* bootargs option. For example, to set a 25-pixel margin around the screen, add *fb.margin=25* to uEnv.txt

# HDMI audio

The default audio device is the analog audio codec. To change the default device, use the *audiocfg* command:

[[!template  id=programlisting text="""
a31# audiocfg list
0: [*] audio0 @ awinac0: Allwinner CODEC A31, 2 playback channels
1: [ ] audio1 @ awinhdmiaudio0: Allwinner HDMI 1.4, 2 playback channels
a31# audiocfg default 1
setting default audio device to audio1
a31# audiocfg list
0: [ ] audio0 @ awinac0: Allwinner CODEC A31, 2 playback channels
1: [*] audio1 @ awinhdmiaudio0: Allwinner HDMI 1.4, 2 playback channels

# MAC address

On boards where the ethernet MAC address cannot be determmined, a random MAC address will be generated every boot. You can override this behaviour by specifying a MAC address in *uEnv.txt*:
[[!template  id=filecontent name="uEnv.txt" text="""
bootargs=root=ld0a awge0.mac-address=02:a0:3d:88:1a:1e

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb