Sunchip CX-A99

This board is used in at least five similar Android TV box products. So far all known products with this board use eMMC as storage, but the board is prepared for use of NAND flash instead of eMMC.

= Identification =

In FEL mode, the device show up as "1f3a:efe8 Onda (unverified) V972 tablet in flashing mode" in lsusb.

In android, under Settings->About Tablet, you will find:
 * Model Number: 
 * Build Number: 

After opening the case, a sticker with the text CX-A99 becomes visible on the Ethernet connector. The main PCB has "A99-V1.1" and "2014-12-15" printed on it next to the Ethernet connector.

= Sunxi support =

Sunxi/Legacy kernel and U-Boot
Like all A80 based devices, there is no support in u-boot-sunxi. Like all A80 based devices, there is no support in our sunxi kernel.

Mainline kernel and U-Boot
Device Tree file and some of the missing drivers are in progress. The table below generally refers to what is supported in the development branch, possibly with WIP patches as explained in the section «Manual build».

Manual build
First of all, you should read the Mainline U-Boot and Mainline Kernel Howto. For example, the instructions below assume that you know what to add to the commands if you're cross-compiling.

Where the instructions below say «curl», you can use «wget -O -» instead. Both commands will download the given URL and output it to stdout.

V2016.11 release
This is the first usable release on A80 devices. However, support is limited to serial console, eMMC, SD card and 2 GB of DRAM.

git clone --origin denx --branch v2016.11 git://git.denx.de/u-boot.git cd u-boot git checkout -b v2016.11-cx-a99

Development branch
This is where support for more parts of the board will appear first.

git clone --origin denx-sunxi --branch next git://git.denx.de/u-boot-sunxi.git cd u-boot-sunxi git branch --move next next-cx-a99

Experimental SMP support
There is experimental support for using all four Cortex-A7 cores:

git remote add -f wens https://github.com/wens/u-boot-sunxi.git git cherry-pick 29e0cfb4f77f7aa369136302cee14a91e22dca71..45777442bdb03337a1d8337ea0e57ca9181dfd08 git cherry-pick 2d9a3452e8d83f38e0d891f3e769bde387c1f429..f205e09885fea23622e0c1aac43b531fa6795607

Device tree file (U-Boot)
The mmc1 port used for the SDIO Wifi module is missing from the A80 device tree file, so the board's device tree won't compile. Apply the patch for it:

curl https://patchwork.kernel.org/patch/9401759/mbox/ | git am -p4 --directory arch/arm

Add the device tree file for the board:

curl https://patchwork.kernel.org/patch/9563791/mbox/ | git am -C0 -p4 --directory arch/arm

U-Boot configuration
The configuration is very simple at the moment because so few devices are supported:

cat <<'end-of-config' >configs/Sunchip_CX-A99_defconfig CONFIG_ARM=y CONFIG_ARCH_SUNXI=y CONFIG_MACH_SUN9I=y CONFIG_DRAM_CLK=600 CONFIG_DRAM_ZQ=3881915 CONFIG_DRAM_ODT_EN=y CONFIG_MMC0_CD_PIN="PH17" CONFIG_MMC_SUNXI_SLOT_EXTRA=2 CONFIG_DEFAULT_DEVICE_TREE="sun9i-a80-cx-a99" CONFIG_SPL=y end-of-config
 * 1) CONFIG_CMD_IMLS is not set
 * 2) CONFIG_CMD_FLASH is not set
 * 3) CONFIG_CMD_FPGA is not set

make Sunchip_CX-A99_defconfig

U-Boot build
make all

Stable series 4.9
Get yourself a copy of the Linux 4.9.9 (or later) release.

git clone --origin stable --branch linux-4.9.y git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git cd linux-stable git branch --move master stable-4.9-cx-a99

The mmc1 port used for the SDIO Wifi module was missing from the A80 device tree file. Apply the patch for it:

curl https://patchwork.kernel.org/patch/9401759/mbox/ | git am

Note: Releases before 4.9.9 need a patch to prevent damage to the DRAM chips through over-voltage.

curl https://patchwork.kernel.org/patch/9530319/mbox/ | git am

Proceed to adding the device tree file and kernel configuration.

Mainline series 4.10
Get yourself a copy of the Linux 4.10-rc7 (or later) release.

git clone --origin mainline git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-mainline cd linux-mainline git branch --move master mainline-4.10-cx-a99

Note: Releases before 4.10-rc7 need a patch to prevent damage to the DRAM chips through over-voltage.

curl https://patchwork.kernel.org/patch/9530319/mbox/ | git am

Proceed to adding the device tree file and kernel configuration.

Development series
You should use the sunxi-next branch in the linux-sunxi repository. If you're starting from scratch, this will get you started:

git clone --origin sunxi --branch sunxi-next https://github.com/linux-sunxi/linux-sunxi.git cd linux-sunxi git branch --move master cx-a99

If you already have another linux kernel repository cloned, you can just add the linux-sunxi one:

git remote add -f sunxi https://github.com/linux-sunxi/linux-sunxi.git git checkout -b cx-a99 remotes/sunxi/sunxi-next

In both cases, you should now have a local branch cx-a99 which tracks the upstream sunxi-next branch and you should have all the source code checked out.

Next step is to apply the patches to support the AXP808 power management IC on the board:

curl https://patchwork.kernel.org/patch/9563795/mbox/ | git am curl https://patchwork.kernel.org/patch/9563781/mbox/ | git am  curl https://patchwork.kernel.org/patch/9563787/mbox/ | git am  curl https://patchwork.kernel.org/patch/9563789/mbox/ | git am

Device tree file
This part is common to the Linux 4.9, 4.10 and development series (4.11) kernels.

curl https://patchwork.kernel.org/patch/9563791/mbox/ | git am -C2

Kernel configuration
The kernel includes two configurations that are useful as a starting point.


 * multi_v7_defconfig</tt>
 * This is probably the best bet for beginners as it is intended for OS distributions to use and includes many commonly used drivers, file system and so on.
 * make multi_v7_defconfig</tt>


 * sunxi_defconfig</tt>
 * This is a somewhat minimalistic configuration where you definitely will want to add more options yourself.
 * make sunxi_defconfig</tt>

Two configuration fixes need to be applied. multi_v7_defconfig</tt> builds the RSB bus driver and consequently the regulator support as modules. They should instead be built into the kernel. Also, neither configuration enables the driver for the AC100 real-time clock by default. This will be fixed in the Linux 4.12 series.

sed -i -e 's/\(CONFIG_\(SUNXI_RSB\|REGULATOR_AXP20X\|MFD_AXP20X.*\)=\)m/\1y/' .config echo -e 'CONFIG_MFD_AC100=y\nCONFIG_RTC_DRV_AC100=y' >> .config

make menuconfig # or xconfig or whatever you prefer

Finish off by building the kernel, modules and device tree blob:

make zImage modules dtbs

= Tips, Tricks, Caveats =

FEL mode
The button on the underside of the board triggers FEL mode. This button can be accessed through a hole in the bottom of the case (i.e. without disassembling the device). See vendor instructions.

Use the file FES    _FES_1-0000000000</tt> from the manufacturer image for SPL</tt>/boot0</tt> when booting over USB.

Note: To turn off power to the board, you will need to unplug the cable from the USB OTG port in addition to disconnecting the 12 V supply. Otherwise, the board may well continue to run on just the 5 V supplied through the USB connector.

Device disassembly
Unscrew each of the four screws under the rubber pad in each corner of the bottom of the case. The case can now be opened carefully.

Unscrew the screw holding the small board with red/blue led and IR receiver to the top part of the case.

Unscrew the screw holding the ground wire to the top part of the case.

Unscrew the four screws holding the main PCB to the top part of the case.

Carefully unplug the antenna cable from the main PCB. The main PCB can now be removed from the case.

Locating the UART (serial console port)
Opposite of the SD or micro-SD card slot, there is a 5-pin header, with a small, white triangle pointing to pin 1. The pinout is:


 * 1	Ground.
 * 2	Ground.
 * 3	+3.3 V.
 * 4	UART0 RX input (GPIO pin PH13) with 3.3 V levels.
 * 5	UART0 TX output (GPIO pin PH12) with 3.3 V levels.

TIP: When logged into the console, use the stty command to set a terminal size that matches that of your terminal window, e.g. "stty columns 262 rows 78", so your screen will not become messed up.

Wifi firmware
You need firmware and a data file for the firmware. The data file is on the Android root partition:

# mkdir --parents /mnt/android-root # mkdir --parents /lib/firmware/brcm # mount --read-only /dev/disk/by-path/platform-1c11000.mmc-part7 /mnt/android-root # cp -p /mnt/android-root/vendor/modules/nvram_ap6335.txt /lib/firmware/brcm/brcmfmac4339-sdio.txt # umount /mnt/android-root

The firmware can be downloaded from the kernel.org firmware repository:

# cd /lib/firmware/brcm # curl --xattr --remote-time --remote-name https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4339-sdio.bin or # wget --timestamping https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4339-sdio.bin

A/V cable
There are reports that you need an A/V cable with a plug length of 17 mm instead of the usual 14 mm. The ground ring is 3 mm longer than usual. Pinout is as usual: Tip is composite video, ring 1 and ring 2 are analog audio and ring 4 is ground.

= Hardware details =

Power routing
Default voltages are taken from sys_config1.fex, which also provides most of the information in this section.


 * 12 V from DC input jack
 * SATA connector 12 V
 * NX5AA ? 5 V switching mode regulator (always on)
 * SATA connector 5 V
 * 3 * AT6280B switch
 * 3 * USB connector
 * X-Powers AXP808 switching mode (dcdcN) and linear (XldoN) regulators
 * aldo1 (default: 3.0 V, on)
 * aldo2 (default: 1.8 V, on)
 * Pin group G
 * Pin group M
 * Audio (supply "aldo2")
 * Wireless Ethernet/Bluetooth I/O (supply 2)
 * aldo3 (default: 2.5 V, on)
 * Pin group A
 * Wired Ethernet (supply 1)
 * bldo1 (default: 1.8 V, on)
 * DLLs and PLLs? (system hangs if turned off)
 * bldo2 (default: 0.9 V, on)
 * CPUS? (system hangs if turned off)
 * bldo3 (default: 1.2 V, off)
 * USB HSIC port
 * bldo4 (default: 1.1 V, on)
 * DWC HDMI Controller
 * cldo1 (default: 3.3 V, on)
 * Pin group L (controls regulators for USB 2.0 ports and Cortex-A15 cores)
 * LEDs
 * cldo2 (default: 3.3 V, off) (wired in parallel with cldo3)
 * Wireless Ethernet/Bluetooth supply 0
 * cldo3 (default: 3.3 V, off) (wired in parallel with cldo2)
 * Wireless Ethernet/Bluetooth supply 1
 * dcdca (default: 0.9 V, on)
 * 4 * ARM Cortex-A7 cores
 * dcdcb (default: 1.5 V, on)
 * DRAM
 * dcdcc (default: 0.9 V, off)
 * PowerVR GPU?
 * dcdcd (default: 0.9 V, on)
 * SYS? (system hangs immediately if turned off)
 * dcdce (default: 3.3 V, on)
 * Pin group B
 * Pin group C
 * Pin group D
 * Pin group E
 * Pin group F
 * Pin group H
 * eMMC
 * SD card slot power pin
 * Serial console port power pin
 * SPDIF
 * sw0 (default: off)
 * Audio (supply "sw0")
 * Composite video output (GM7122)
 * Wired Ethernet (supply 0)
 * OZ80120 switching mode regulator (default: 0.9 V, on)
 * 4 * ARM Cortex-A15 cores
 * AMS1117 3.3 V linear regulator (always on) (Datasheet link but site down as of 2016-07-04)
 * JM20329 pins 5 VCCO, 10 AVDDH, 16 AVDDH, 18 AVDDH, 42 VCCO.
 * JM20329 pin 9 AVREG output (internal 1.8 V regulator) connected to pins 23 AVDDL, 36 VCCK, 44 VCCK.

A80 pins
The following information was mainly extracted from the vendor's sys_config.fex file.

= Pictures =

= Also known as =

Products using eMMC as storage:


 * Instabox Fantasy A8 (site down as of 2016-08-09) (no external antenna)
 * Jesurun CS-Q8 (ships with larger remote control)
 * Jesurun Maxone
 * Rikomagic (RKM) MK80/MK80LE
 * Tronsmart Draco AW80 Meta/Telos

= See also =

Manufacturer images
The archives can be extraced with e.g. The Unarchiver. You can then use awimage</tt> from awutils to unpack the image.

Extracting sys_config.fex
(Note: This is only of interest if you want to construct a Device Tree file for e.g. mainline U-Boot and mainline kernel.)

It is easy to extract it from one of the manufacturer images. Note that the Ubuntu image made by Tronsmart does not contain a correct version of this file.

Once you have root on the Android system, you can also extract the file from eMMC card partition 10:

sed -n -e '/;A80 PAD/ s/.*;A80 PAD/;A80 PAD/' -e '/^;A80 PAD/,/^cpu7/ p' /dev/mmcblk2p10 >sys_config.fex

Booting from (micro)SD card
The A80 Boot ROM will look for a boot loader at offset 8 kB into the card, load 32 kB of that into memory and execute it. You can install a boot loader from the files in a manufacturer image file. Replace $1 in the commands below with the device which holds your SD card - consider using /dev/disks/by-id</tt> to avoid mistakes.

dd bs=1024 seek=8 if='12345678_1234567890BOOT_0' of="$1" dd bs=1024 seek=19096 if='12345678_UBOOT_0000000000' of="$1"

This requires your partitions to stay clear of the two areas above, and you should also keep the legacy and mainline U-Boot card layout in mind. You can create a suitable partition table with GNU Parted:

parted --script "$1" -- mklabel msdos mkpart primary fat32 1024kiB 19096kiB mkpart primary ext2 24MiB -1s quit

This gives you a 17 MB /boot</tt> partition for e.g. kernel images and the remaining part of the card above 24 MiB as root</tt> partition.

(Partitions should be aligned to an SD card allocation unit for good write speed. 24 MB will work for allocation units of 1 MB, 2 MB, 3 MB, 4 MB, 6 MB, 8 MB, 12 MB and 24 MB. Write speed on the /boot</tt> partition is not important, however, so it need not be aligned.)