USER MANUAL RK3399-Q7 System-on-Module Hexa-Core ARM Cortex-A72/A53 featuring the Rockchip RK3399 application processor

Document revision: Release vs.ü Issue date: Apr ss, ó+sÌ

Contents

Ô Introduction Ô Ô.Ô Device Overview...... Ô

ò First Steps ò ò.Ô Required Tools...... ò ò.ò Insert the Module...... ò ò.ç Mount the Heatsink...... ç ò.¥ Mount the Fan (optional)...... ¥ ò. Power Up......

ç Using the EVK Þ ç.Ô Evaluation Board Overview...... Þ ç.ò Power Supply...... À ç.ç Control Buttons and Switches...... À ç.¥ CPU Fan...... Ôþ ç. Boot Order...... Ôþ ç.â USB Serial Console...... ÔÔ ç.Þ RS-òçò and RS-¥— ...... Ôò ç.— TTL UART...... Ôç ç.À Ethernet...... Ôç ç.Ôþ USB Interfaces...... Ô¥ ç.ÔÔ Video...... Ôâ ç.Ôò RTC...... ÔÀ ç.Ôç SPI, IòC and Ô-Wire...... ÔÀ ç.Ô¥ GPIOs...... òÔ ç.Ô Audio...... òç ç.Ôâ CAN Bus...... ò¥ ç.ÔÞ MISC Connector...... ò ç.ԗ RF-Module...... òâ

¥ SoŸware Guide òÞ ¥.Ô Architecture Overview...... òÞ ¥.ò Prerequisites...... òÞ ¥.ç Compile the Cortex-Mþ power management rmware...... ò— ¥.¥ Compile the ATF...... òÀ

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page i ¥. Compile U-Boot...... òÀ ¥.â Compile the Boot Script...... çþ ¥.Þ Compile the Linux Kernel...... çÔ ¥.— Building the root lesystem...... çÔ ¥.À Deploy on SD Card...... çç ¥.Ôþ Deploy on SPI NOR-žash...... çâ ¥.ÔÔ Deploy on On-Board eMMC storage...... çÞ ¥.Ôò Compiling Linux Applications...... çÞ ¥.Ôç Serial Number...... çÞ ¥.Ô¥ MAC Address...... ç—

Hardware Guide çÀ .Ô Qseven Implementation...... çÀ .ò QÞ Connector Pinout...... ¥Ô .ç Signal Details...... ¥¥ .¥ On-board Devices...... Ô . USB...... ¥ .â Using Qseven Signals as GPIO...... â .Þ Electrical Specication...... — .— Mechanical Specication...... À

â Revision History âþ

Release vs.ü Page ii s Introduction

Congratulations for acquiring our new žagship product, combining best-in-class performance with a rich set of peripherals.

Note: e latest version of this manual and related resources can always be found on our website at the following address: https://www.theobroma-systems.com/rkççÀÀ-qÞ/ s.s Device Overview

e RKççÀÀ is a low power, high performance processor for computing, personal mobile internet devices and other smart device applications. Based on a big.LITTLE architecture, it integrates a dual-core Cortex-AÞò and a quad-core Cortex-A ç. ese â¥bit-capable ARMv— processors support both the ARM Crypographic Extension (e.g. for wire-rate AES encryption) and AdvSIMD vector processing. A dual-channel memory interface sustains the memory bandwidths required by even the most demanding embedded applications.

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page s ó First Steps

is chapter provides instructions for getting the RKççÀÀ-QÞ EVK running aŸer opening the box.

ó.sR equired Tools

• PZÔ (Pozidriv) screwdriver

ó.ó Insert the Module

Insert the RKççÀÀ-QÞ module at a çþ-degree angle into the connector in the base board. Once fully inserted , push it down until it rests on the standošs and check alignment of the mounting holes.

Note: e module springs back into the çþ-degree angle once released. is is expected, and alignment will be kept. e module will be secured into place together with the heatsink.

30°

Fig. Ô: Module mounting

Release vs.ü Page ó ó.æ Mount the Heatsink

e heatsink has the thermal pad attached on the bottom. Peel oš the red protective foil.

Fig. ò: ermal pad protective foil

Push the module down žat and place the heatsink spacer on the module with the smooth side facing up. Make sure the orientation is correct by checking alignment of the mounting holes. Place the heatsink on the spacer and screw it down gently using the four included Mò. screws.

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page æ Fig. ç: Heatsink mounting

ó.ü Mount the Fan (optional)

e fan is only necessary in exceptionally high ambient temperatures. Under normal conditions, the RKççÀÀ-QÞ operates passively cooled. Place the fan on the heatsink and clip it into place using the provided holder. Connect the cable to the header labeled FAN on the baseboard.

Release vs.ü Page ü ó.ð Power Up

e EVK modules comes preloaded with soŸware that boots into a full desktop environment on the HDMI output. For bootloader conguration and Linux console the serial interface can be used. Connect either a Micro-USB or RS-òçò cable to the corresponding port. Select the correct UART with UART selector slider (Ô). For Micro-USB the slider has to be in the right position to route the default console UARTþ to the USB UART bridge. For RS-òçò the slider has to be in the leŸ position and the protocol slider (ò) has to be in the RS-òçò position. Connect the power supply and verify the sliders are in the position Normal Boot (¥) and Normally Off ( ). Press the Power Button (â) to power the board. You will see the boot progress and later on a login prompt on the serial interface. If a HDMI display is connected video output will follow shortly aŸer.

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ð HDMI USB UART Power

RS232

2

1

6

4 5

Release vs.ü Page Ì æ Using the EVK

is chapter provides instructions for using the EVK, such as booting and how to congure and use I/O peripherals (e.g. serial console, Ethernet).

æ.s Evaluation Board Overview

An overview of the available connectors and devices on the EVK is shown below.

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page  +12V Power

Audio Buzzer I2S

Ethernet Power FAN Battery

2x USB 3.0 Reset JTAG CAN

USB 2.0 Wake USB UART Sleep GPIO SMBus Batlow USB OTG Power Mode CTRL I/O SPI+I2C+1-wire HDMI BOOT SW e base board for to RKççÀÀ-QÞ module.  Misc I/O LID SW

Display Connector Fig. Ô: RS 232

PCIe x4 Slot SD-Card ü s. v e s Ì e ea l g e a P R æ.ó Power Supply

e baseboard can operate with a single ÔòV DC power supply.

Fig. ò: ÔòV Power connector

Power can be controlled manually from the board using the Power control buttons and switches, located on the lower right side of the board (see ç.Ô Evaluation Board Overview). Depending on the setting of Normally On / Normally Off switch the board will boot as soon as it receives power.

æ.æ Control Buttons and Switches

e control buttons provide the following functionality: • Power toggles the module power supply • Reset triggers a module reset • Batlow, Sleep and Wake are routed to GPIOs on the QÞ module Several slide switches are located on the lower leŸ: • LID is routed to a GPIO on the module, simulates lid open/close. • Normally On / Normally Off, as described above, sets the state aŸer power loss. • BIOS Disable / Normal Boot forces SD card boot or the normal boot order, respectively.

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page O æ.üC PU Fan

Operation in high environmental temperatures may require a CPU fan. e fan connector is located next to the bottom right corner of the QÞ expansion area (see board overview). FAN_PWMOUT FAN_TACHON GND +12V .

Fig. ç: Fan connector

Note: e fan is only necessary in high ambient temperatures. Under normal conditions, the RKççÀÀ-QÞ operates passively cooled.

æ.ðB oot Order

e used boot order of the RKççÀÀ-QÞ module depends on the value of the BIOS_DISABLE# signal. On the Haikou base- board, this signal can be set using a slider switch, with the two positions labeled Normal Boot, and BIOS Disable. As shown in the table below, the BIOS Disable position disables both on-module storage devices:

Release vs.ü Page s+ Normal Boot BIOS Disable Ô SPI NOR žash SD card ò eMMC storage USB loader ç SD card ¥ USB loader

If no bootloader is found on any storage device, the RKççÀÀ-QÞ module will go into USB loader mode where it shows up as a USB device on the USB-OTG port. e electrical state of the BIOS_DISABLE# signal for both slider positions is shown below:

Slider Position BIOS_DISABLE# signal Normal Boot Floating (on-module pull-up to Ô.—V) BIOS Disable GND

æ.ÌUS B Serial Console

e evaluation board contains an on-board Silicon Labs CPòÔþòN USB-serial converter. Connect the included Micro-USB cable to the Micro-USB jack labeled USB-UART Bridge:

Fig. ¥: USB UART

e serial converter does not require additional drivers on Windows and Linux. For Mac OS, drivers are available from Silicon Labs: http://www.silabs.com/products/development-tools/soŸware/ usb-to-uart-bridge-vcp-drivers

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ss e QÞ modules has two external UARTs: • UARTþ is, by default, used for the serial console for interactive login. • UARTÔ is unused by default and can be freely used for machine-to-machine communications or other purposes. e switch UART0 / UART1 cross-switches UARTþ and UARTÔ between the RS232 / RS485 jack and the onboard USB- serial converter:

Switch Position RS232 / RS485 jack connected to: USB-serial converter connected to: UART0 UARTþ (interactive console) UARTÔ UART1 UARTÔ UARTþ (interactive console)

For interactive login through the USB-serial converter, make sure the switch is on the UART1 position Picocom can be used to connect via the serial line (assuming the USB-serial converter is USBþ): picocom-b 115200/dev/ttyUSB0

Note: Make sure to disable soŸware žow-control (XON/XOFF). Otherwise serial input may not be recognized.

AŸer system bootup, the login console appears on the terminal: rk3399-q7 login:

You can log in as root with password root or as user user with password user.

æ. RS-óæó and RS-üÌð

To connect via RS-òçò or RS-¥— , connect to the RS232 / RS485 jack on the base board.

Release vs.ü Page só UART1 UART0

RS232/ Full/Half Duplex RS485

Fig. : RS-òçò connector

e switch labeled RS-232 / RS-485 selects between RS-òçò and RS-¥— mode on the jack. In RS-¥— mode, the switch labeled Full Duplex / Half Duplex selects full- or half-duplex mode, respectively. It has no ešect in RS-òçò mode, which is always full-duplex.

æ.Ì TTL UART

UARTþ and UARTÔ are also available through the pin headers P12 UART0 and P30 UART1 next to the RS232 / RS485 jack. e signal level is ç.çV.

æ.O Ethernet

e RKççÀÀ-QÞ has built-in Gigabit Ethernet routed to a standard jack on the evaluation board.

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page sæ Fig. â: Ethernet jack

e SD card that is shipped with the EVK is congures to automatically retrieve an IP via DHCP and provides SSH login on port òò.

æ.s+ USB Interfaces

e RKççÀÀ-QÞ provides four USB ports: • Ôx USB ç.þ OTG • òx USB ç.þ Host • Ôx USB ò.þ Host

Fig. Þ: USB ç.þ OTG port (dual-role port: can be used as a host or device interface)

Release vs.ü Page sü Fig. —: USB ç.þ host ports

Fig. À: USB ò.þ host port

æ.s+.s Connecting an External USBDrive

To connect a USB drive, plug it into one of the USB ports. e system should recognize the drive immediately. Check the kernel log to nd the device name: journalctl-k-10

You will be able to mount its partitions (assuming mapping to /dev/sdb1):

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page sð mkdir/mnt/usb1 mount/dev/sdb1/mnt/usb1 ls/mnt/usb1

æ.ss Video

e RKççÀÀ-QÞ supports video output on HDMI, eDP and MIPI-DSI. Some of these interfaces are muxed on the module.

RK3399-Q7 Module Baseboard

GPIO2_A2

eDP 1 LVDS A MIPI_TX0 0 Video Conn- RK3399 ector SoC MIPI_TX1/RX1 LVDS B

HDMI HDMI TMDS Jack

Fig. Ôþ: RKççÀÀ-QÞ video muxing

e EVK soŸware will use HDMI as the default video output. Connect a display to the HDMI port and a desktop envi- ronment will be shown once booting has nished. Screen resolution will be set based on the display EDID information. Resolutions up to 痥þxòÔâþ are supported.

Release vs.ü Page sÌ Fig. ÔÔ: HDMI port

For eDP and MIPI-DSI the Qseven LVDS pins are used which are routed to the Display connect. is expansion slot uses a PCIe connector as mechanical connection, which allows easy development of adapter boards for various dišerent display types.

Qseven Port Function Alternate Function LVDS A MIPI-DSI eDP LVDS B MIPI-DSI MIPI-CSI

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page s NC GND GND LVDS_B_CLK_N LVDS_A3_N LVDS_B_CLK_P LVDS_A3_P GND GND LVDS_B3_N GND LVDS_B3_P LVDS_A2_N GND LVDS_A2_P GND GND LVDS_B2_N GND LVDS_B2_P LVDS_A1_N GND LVDS_A1_P GND GND LVDS_B1_N NC LVDS_B1_P GND GND LVDS_A0_N DP_HPD# LVDS_A0_P GND GND LVDS_B0_N LVDS_A_CLK_N LVDS_B0_P LVDS_A_CLK_P GND GND NC

LVDS_PPEN LVDS_BLC_DAT 3V3 NC 3V3 LVDS_BLC_CLK LVDS_BLT_CTRL 3V3 LVDS_BLEN GND NC LVDS_DID_DAT GPO0 LVDS_DID_CLK GND GND 12V 12V 12V 12V GND 12V

Fig. Ôò: Display connector pinout

e kernel devicetree denes the used display conguration. Example device trees for various output congurations are provided with the EVK soŸware package. To congure the bootloader which devicetree to load, edit the conguration variable fdtfile in the le /boot/ puma_rk3399/userEnv.txt. For example to enable DisplayPort write: fdtfile=rk3399--edp.dtb

Filename Display s Display ó rkççÀÀ-puma.dtb HDMI rkççÀÀ-puma-edp.dtb Display Port on LVDS A rkççÀÀ-puma-mipidsi.dtb MIPI-DSI on LVDS A rkççÀÀ-puma-+edp.dtb HDMI Display Port on LVDS A rkççÀÀ-puma-hdmi+mipidsi.dtb HDMI MIPI-DSI on LVDS A

See https://git.theobroma-systems.com/som-hardware.git/ for video adapter reference designs.

Release vs.ü Page sÌ æ.sóRT C the RKççÀÀ-QÞ contain a real-time clock (RTC) on-module. e RTC is read by the kernel on bootup and used to set the system clock. To check the RTC value, use hwclock: hwclock Thu 30 Apr 2015 03:51:20 PM CEST-0.826662 seconds

e RTC will be set automatically to the system clock on shutdown, so you can set the system clock using the date command and reboot to update the RTC: date--set 2015-04-20 date--set 03:51:30

You can also update the RTC immediately, again with hwclock: hwclock-v

You can set up an NTP client so the time will always be updated from the Internet. Install the client rst: apt-get install ntp

Feel free to change the /etc/ntp.conf le to use more local time sources (change servers from pool.ntp.org to use a server from your country, such as at.pool.ntp.org).

æ.sæ SPI, IóC and s-Wire

IòC, Ô-wire-bus and SPI interfaces are both available on the connector labeled SPI+I2C+1-Wire.

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page sO P R peripherals. power and sensors connecting for  SM æ.sæ.ó Guide). SoŸware (see card SD the to it deploy and kernel the recompile must You to Navigate menuconfig make via enable is driver kernel Linux the sure Make  Ió æ.sæ.s i2c-tools install apt-get Debian: in available iòc-tools package the is there IòC, For a e g l ea or rvdscmuiaintruhSBs ti aial ieICwt nadtoa iefritrutadi used is and interrupt for line additional an with IòC like basically is It SMBus. through communication provides board e datasheet). (see keyboard touch AT¥òQTòÔâþ Atmel the uses example is e ó s e + v s. ü E C eieDies- nu eiespot- Keyboards -> support device Input -> Drivers Device B us x a mpl e Using - a Tou c K h e i.Ô:ICadSIheader SPI and IòC Ôç: Fig. menucong y b o a r d :

n hc the check and

SPICS0#

. SPICS1#

SPIMOSI TE TòTÔþTuhSno Chip Sensor Touch AT¥òQTòÔâþ ATMEL SPICLK

1-Wire SPIMOSI

I2C_DAT I2C_CLK

GND 3V3 . © Us RKææOO-Q  labeled header pin the on provided are GPIOs Eight æ.s  number. bus a header. EVK using and bus number IòC each identies Linux Linu æ.sæ.æ Th oaino h or sdslydbelow: displayed is board the on location e by reported (as buses IòC other e e ü o b rom GPIOs a e S M r y st x a e nu ms B a sNum us De l inun sign C d

be

nutn Gm onsulting

SMB_ALERT#

. DID_CLK

LVDS_BLC LVDS_DID / GPò_IòC GPÔ_IòC / SMB GPþ_IòC n QÂ ring

DID_DAT SMB_DAT

BLC_CLK a SMB_CLK

òdtc -l iòcdetect

m

BLC_DAT

e 3V_VCC_RTC b

H GND 3V3 r nenlt h oueadntrue oteQ connector. QÞ the to routed not and module the to internal are ) i.Ô:SBSheader SMBUS Ô¥: Fig. GPIO  al eo hw h apn ewe Þnms iu bus Linux names, QÞ between mapping the shows below table e Þ Ô ò ¥ Linu . x b s# us ipa connector Display connector Display SMBus SPI+IòC+Ô-Wire E V H K eade r R e l ea P s a e g e v s. ós ü P R index + ) 8 * (sub_block_number Where: + 32) * (block_number = n GPIO Linux the calculate To  via Linux in used ones  a e g l ea apn ssoni h olwn table: following the in specication. shown Qseven is mapping the e in used numbers to refer board the on printed numbers GPIO e e boknme:idxo h lc number block the of index block_number: • óó s e v s. ü /sys/class/gpio

k GPIO0

. GPIO1

o P ista r o itdi hstbe s h olwn formula: following the use table, this in listed not are that pins CPU for

GPIO3 GPIO2

GPIO5 GPIO4

.

GPIOÞ GPIOâ GPIO GPIO¥ GPIOç GPIOò GPIOÔ GPIOþ Qs GPIO6 GPIO7

e

GND v 3V3 e sign n i.Ô:GI header GPIO Ô : Fig. a l GPIO¥_Dç GPIO¥_Cç GPIO¥_C¥ GPIO¥_Dò GPIO¥_D GPIO¥_Dþ GPIO¥_DÔ GPIO¥_D¥ C Upin PU Ô Ô¥Þ Ô¥— Ô ¥ Ô Þ Ô ò Ô ç Ô â Linu x PO# GPIO  yaedšrn hnthe than dišerent are ey • sub_block_number: the alphabetical index of the block name, minus Ô • index: the pin number within the block Example:

GPIO4_D4->(4* 32)+(3*8)+4= 156

To enable a GPIO, write the Linux GPIO k to the special export le: echo 156>/sys/class/gpio/export ls/sys/class/gpio/gpio156 cat/sys/class/gpio/gpio156/direction in cat/sys/class/gpio/gpio156/value 0

To set the direction to output, write out in the GPIO’s direction le: echo out>/sys/class/gpio/gpio156/direction echo1>/sys/class/gpio/gpio156/value

e GPIO will be set to a value of Ô (high at ç.çV).

æ.sðA udio

e board provides two audio connectors for input and output. Line-in is on top and Headphones is on bottom of the audio connector.

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page óæ Fig. Ôâ: Audio input/output port

Additionally, an expansion connector for IòS audio is available on the bottom row of the board: 3V3 . 3V3 LDO GND I2S_RST# I2S_CLK I2S_WS I2S_SDO I2S_SDI I2S_DAT I2C_CLK

Fig. ÔÞ: Connecting to the audio expansion connector

æ.sÌ CAN Bus

e board provides a CAN connector on the bottom row.

Release vs.ü Page óü © Us RKææOO-Q  MIS æ.s Th or rvdssgasfrtemloeha fetra adaeadtepoesr tlt inl o DadGPIOþ. and SD for signals utility processor, the and hardware external of overheat thermal for signals provides board e e o b rom a e S M r y st C C a e nu ms a onn De l inun sign ec C d tor nutn Gm onsulting b

H

GND CAN low level low CAN i.Ô:CNheader CAN ԗ: Fig. . level high CAN R e l ea P a s e g e v s. ó ü ð P R æ.s nadtoa FMdl o ieescmuiaincnb odrdo h otmrgto h baseboard. the of https://www.theobroma-systems.com/rf-modules-ç—Ô right visit: bottom information the more on For soldered be can communication wireless for RF-Module additional An a e g l ea e Ì óÌ s e v s. R ü F -Mo d ul e

i.Ô:MS header MISC ÔÀ: Fig.

THRM_TRIP#

. THRM#

SDIO_PWR# SDIOWP

BLEN GPIO0

PCIE_WALE# BLT_CTRL

GND 3V3 ü Software Guide

is chapter provides instructions for compiling and deploying the BSP (Board Support Package) soŸware to the QÞ mod- ule.

ü.s Architecture Overview

e BSP consists of several parts. ey run on dišerent parts of the CPU and each play their role in the boot process. Because the CPU contains cores running dišerent instruction sets (ARMvâ-M and ARMv—-A), two dišerent compilers are needed. e table below list the parts and their instruction set.

BSP Part Architecture Cortex-Mþ power management rmware ARMvâ-M ATF (ARM Trusted Firmware) ARMv—-A U-Boot bootloader ARMv—-A e Linux kernel ARMv—-A Debian user-space ARMv—-A

e next section explains how to install suitable cross-compilers for both instruction sets. e section “Compiling Linux Applications” provides guidance for compiling user-space applications for the RKççÀÀ.

ü.ó Prerequisites

You need a recent x—â_⥠Linux installation to run the cross-compiler on and at least ÔþGB of disk space. e cross-compiler requires libc version ò.ò. . Distributions shipping this version are, among others: • Ubuntu Ôâ.þ¥ “Xenial” • Debian — “Jessie” • Debian À “Stretch” We recommend Debian À “Stretch” or Ubuntu Ôâ.þ¥ “Xenial”. Please install the following packages to set up the common build infrastructure:

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page óÂ sudo apt install device-tree-compiler u-boot-tools build-essential git bc debootstrap qemu-user-

↪static libssl-dev

ü.ó.s ARMvÌ-M Compiler

e “GNU Embedded Toolchain for ARM” is suitable for compiling the Cortex-Mþ power management rmware. It can be downloaded from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads. For this manual, it is assumed that version 6-2017-q1 is used. Direct link to the le: https://developer.arm.com/-/media/Files/downloads/gnu-rm/â_Ô-òþÔÞqÔ/gcc-arm-none-eabi-â-òþÔÞ-qÔ-update-linux. tar.bzò Extract the tar.bzò archive to /opt: sudo tar-xf gcc-arm-none-eabi-6-2017-q1-update-linux.tar.bz2-C/opt

ü.ó.ó ARMvÌ-ACompiler

e Linaro aarchâ¥-linux-gnu toolchain is suitable for compiling all other parts of the BSP. It is also suitable for compiling user-space applications. You can download ready-to-use binaries from Linaro: https://releases.linaro.org/components/ toolchain/binaries/â.ç-òþÔÞ.þò/aarchâ¥-linux-gnu/. Direct link to the le: https://releases.linaro.org/components/toolchain/binaries/â.ç-òþÔÞ.þò/aarchâ¥-linux-gnu/gcc-linaro-â.ç.Ô-òþÔÞ.þò-x—â_ â¥_aarchâ¥-linux-gnu.tar.xz Extract the tar.xz archive to /opt: sudo tar-xf gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu.tar.xz-C/opt

ü.æ Compile the Cortex-M+ power management írmware

e Cortex-Mþ rmware runs inside a embedded in the CPU IC. It implements power-management func- tionality and helpers (e.g. DRAM frequency switching support). Set up environment variables to make use of the ARMvâ-M compiler, then download the source code and compile:

Release vs.ü Page óÌ export ARCH=arm64 export CROSS_COMPILE=/opt/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi- git clone https://git.theobroma-systems.com/rk3399-cortex-m0.git cd rk3399-cortex-m0 make cd..

ü.æ.s Optional:Compile the cross-compiler

As an alternative to using a ready-made compiler, the rmware repository has a mechanism to compile the ARMvâ-M- compiler as a part of the build process. is is called “internal toolchain”. If you want to use the internal toolchain instead you will also need the following packages: sudo apt install libssl-dev autoconf gperf bison flex texinfo help2man gawk libncurses5-dev

en to use the internal toolchain, specify “USE_INTERNAL_TOOLCHAIN=Ô” as part of your invocation to make.: make USE_INTERNAL_TOOLCHAIN=1

ü.üC ompile the ATF

Download the source code and compile using: export CROSS_COMPILE=/opt/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- git clone https://git.theobroma-systems.com/arm-trusted-firmware.git cd arm-trusted-firmware make PLAT=rk3399 bl31 cd..

ü.ðC ompile U-Boot

U-Boot is used as the bootloader on the RKççÀÀ-QÞ module. Download the source code using:

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page óO git clone https://git.theobroma-systems.com/puma-u-boot.git

e U-Boot build process uses the les generated in the previous steps Copy the previously generated les rk3399m0.bin from the Cortex-Mþ rmware and bl31.bin from the ATF to the puma-u-boot directory. Recent U-Boot releases expect the bl31.bin le under the name bl31-rk3399.bin. To support all variants, the le is copied twice: cp rk3399-cortex-m0/rk3399m0.bin puma-u-boot cp arm-trusted-firmware/build/rk3399/release/bl31.bin puma-u-boot/bl31.bin cp arm-trusted-firmware/build/rk3399/release/bl31.bin puma-u-boot/bl31-rk3399.bin

en you are ready to compile U-Boot: cd puma-u-boot export ARCH=arm64 export CROSS_COMPILE=/opt/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- make puma-rk3399_defconfig make-j4 tools/mkimage-n rk3399-T rksd-d spl/u-boot-spl.bin spl_sd.img tools/mkimage-n rk3399-T rkspi-d spl/u-boot-spl.bin spl_spi.img make u-boot.itb cd..

e resulting bootloader consists of three les: spl_sd.img, spl_spi.img and u-boot.itb, but only one of the spl les is used at a time. e le spl_sd.img is only used when booting from SD-card or eMMC, while spl_spi.img is only used when booting from SPI NOR žash.

ü.Ì Compile the Boot Script

e U-Boot boot sequence is controlled by a le called boot.scr. is le is generated from a plain-text le called boot. cmd. Download the repository and generate boot.scr using: git clone https://git.theobroma-systems.com/som-tools.git cd som-tools make-C boot-script cd..

Release vs.ü Page æ+ ü. Compile the Linux Kernel

e kernel source code can be cloned with: git clone https://git.theobroma-systems.com/puma-linux.git

Compile using: cd puma-linux export ARCH=arm64 export CROSS_COMPILE=/opt/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- make puma-rk3399_defconfig make-j4 rockchip/rk3399-puma.dtb Image

is will create the two les needed for booting with U-Boot (paths are relative to the puma-linux directory): • e device tree: arch/arm64/boot/dts/rockchip/rk3399-puma.dtb • e kernel image: arch/arm64/boot/Image

ü.ÌB uilding the root ílesystem

A lesystem can be created using Debootstrap, specifying arm⥠as architecture in the command line. Supposing the target dir is called rk3399-rootfs and the chosen distribution is Debian À “Stretch” (recommended): export targetdir=/opt/rk3399-rootfs sudo mkdir -p $targetdir sudo debootstrap --arch=arm64 --foreign stretch $targetdir http://deb.debian.org/debian/

Next, copy the qemu-arm-static binary into the right place for the binfmt packages to nd it and copy the resolv.conf le from the host system: sudo cp /usr/bin/qemu-aarch64-static $targetdir/usr/bin/ sudo cp /etc/resolv.conf $targetdir/etc

is will provide a very basic arm⥠rootfs in the targetdir. For the next stages, we chroot to the target dir: sudo chroot $targetdir

Second stage of debootstrap inside the new root dir:

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page æs /debootstrap/debootstrap--second-stage

Set up the apt package sources: cat << EOT>/etc/apt/sources.list deb http://deb.debian.org/debian stretch main contrib non-free deb http://deb.debian.org/debian stretch-updates main contrib non-free deb http://security.debian.org/ stretch/updates main contrib non-free EOT

We can now pull the latest apt database from the Debian mirrors and install locales: apt update apt install locales echo"en_US.UTF-8 UTF-8">/etc/locale.gen locale-gen

Install any additional packages inside the chroot. An ssh server and sudo are recommended: apt install openssh-server sudo

Set the root password for logging in via serial console: passwd

To log in over ssh, create another user besides root (root login over ssh is not permitted by default): adduser user

Add the new user to the sudo group so you can switch to root privileges if needed: adduser user sudo

Set up a basic network conguration le with DHCP via ethþ and enable automatic DNS conguration through systemd- resolved: cat << EOT>/etc/systemd/network/eth0.network [Match] Name=eth0 [Network] DHCP=yes EOT (continues on next page)

Release vs.ü Page æó (continued from previous page) systemctl enable systemd-networkd systemctl enable systemd-resolved ln-f-s/lib/systemd/resolv.conf/etc/resolv.conf

When executing systemctl enable you may get the message qemu: Unsupported syscall: 278. e operation still succeeds and the message can be safely ignored. Set the hostname and exit from the chroot: echo rk3399-q7>/etc/hostname exit

We now have a root lesystem which can be deployed to the SD card.

ü.O Deploy on SD Card

ü.O.sP artition Setup

Both U-Boot and Linux will be located on the same SD card. e layout of the card aŸer setup is as follows:

Oéset Contents Files þ Partition table çòkiB U-Boot SPL spl_sd.img ò¥þkiB U-Boot environment ò âkiB U-Boot + ATF + Cortex-Mþ rmware u-boot.itb òMiB Partition Ô (ext¥ - Linux root fs) boot.scr, Image, rkççÀÀ-puma.dtb, defaultEnv.txt and rootfs

To setup a SD card for booting you rst need to create partitions. Partitions can be created using fdisk (assuming the SD card is mapped to /dev/sd‘‘X‘‘ , where X should be replaced with your corresponding device-letter) and has no partitions (this can be checked using the p command): sudo fdisk/dev/sdX >p

is should show an empty partition table, for example:

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ææ Disk/dev/sdX: 3980 MB, 3980394496 bytes 123 heads, 62 sectors/track, 1019 cylinders, total 7774208 sectors Units= sectors of1* 512= 512 bytes Sector size (logical/physical): 512 bytes/ 512 bytes I/O size (minimum/optimal): 512 bytes/ 512 bytes Disk identifier: 0xdbbd45c7

Device Boot Start End Blocks Id System

If there are partitions on the sdcard, they can be deleted with o. e required partition can be created with the command n, then accepting the defaults, except for First sector, where we use ¥þÀâ:

>n Partition type: p primary (0 primary,0 extended,4 free) e extended Select (default p): Partition number (1-4, default1): First sector (2048-7774207, default 2048): 4096 Last sector,+sectors or+size{K,M,G} (...):

is will create a primary partition at ošset òMiB. Enter w to write the new partition table to the disk:

> w The partition table has been altered!

Calling ioctl() to re-read partition table. Syncing disks.

Now we format the partition as ext¥: sudo/sbin/mkfs.ext4-E lazy_itable_init=0/dev/sdX1

e option lazy_itable_init=0 speeds up the rst boot because it initializes the inode tables in advance. e SD card is now ready to have the U-Boot bootloader and Linux deployed.

ü.O.ó Deploy U-Boot

e U-Boot images spl_sd.img and u-boot.itb are written to the SD card. Assuming the SD card is mapped to /dev/sdX:

Release vs.ü Page æü sudo dd if=puma-u-boot/spl_sd.img of=/dev/sdX bs=1k seek=32 conv=nocreat sudo dd if=puma-u-boot/u-boot.itb of=/dev/sdX bs=1k seek=256 conv=nocreat

ü.O.æ Deploy the Linux Kernel and the Root Filesystem

Mount the SD card partition and copy the rootfs (assuming that the rootfs is located at /opt/rk3399-rootfs and the sd card at /dev/sdX1): sudo mkdir-p/mnt/sdcard sudo mount/dev/sdX1/mnt/sdcard sudo cp-av/opt/rk3399-rootfs/*/mnt/sdcard

Copy kernel image, device tree and boot script into the boot directory: sudo cp-r som-tools/boot-script/boot/{boot.scr,puma_rk3399}/mnt/sdcard/boot sudo cp puma-linux/arch/arm64/boot/dts/rockchip/rk3399-puma.dtb/mnt/sdcard/boot/puma_rk3399 sudo cp puma-linux/arch/arm64/boot/Image/mnt/sdcard/boot/puma_rk3399

Finally, unmount the SD card: sudo umount/mnt/sdcard

e SD card is ready for booting.

ü.O.ü U-Boot Customization

e boot script /boot/boot.scr handles the boot sequence. Unless you want to customize the sequence, no further action is required. If you want to step through the sequence manually or customize it, you can execute the following commands on the U-Boot prompt: setenv bootargs root=/dev/mmcblk0p1 rw rootwait ext4load mmc 1:1 $kernel_addr_r boot/puma_rk3399/Image ext4load mmc 1:1 $fdt_addr_r boot/puma_rk3399/rk3399-puma.dtb booti $kernel_addr_r - $fdt_addr_r

Optionally, these commands can be compiled together in a single command and saved so it is performed on every subse- quent boot:

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page æð setenv bootargs root=/dev/mmcblk0p1 rw rootwait setenv boot_sd"ext4load mmc 1:1 $kernel_addr_r boot/puma_rk3399/Image &&\ ext4load mmc 1:1 $fdt_addr_r boot/puma_rk3399/rk3399-puma.dtb &&\ booti $kernel_addr_r - $fdt_addr_r" setenv bootcmd run boot_sd saveenv

To reset the U-Boot settings to default, execute: env default-f-a saveenv

Note: root=/dev/mmcblk0p1 and ext4load mmc 1:1 refer to the SD Card. Use root=/dev/mmcblk1p1 and ext4load mmc 0:1 instead to boot from eMMC.

ü.s+ Deploy on SPI NOR-÷ash

To have a reliable boot sequence even if eMMC and/or SD-card fail, U-Boot can be written in to the onboard NOR-žash. While u-boot.itb is used for both SD-card and SPI-žash boot, spl_spi.img is used instead of spl_sd.img. From U-boot: sf probe load mmc 1 $kernel_addr_r root/spl_spi.img sf erase 0 +$filesize sf write $kernel_addr_r 0 $filesize load mmc 1 $kernel_addr_r root/u-boot.itb sf erase 0x40000 +$filesize sf write $kernel_addr_r 0x40000 $filesize

From Linux: dd if=spl_spi.img of=/dev/mtdblock0 bs=256k seek=0 conv=nocreat dd if=u-boot.itb of=/dev/mtdblock0 bs=256k seek=1 conv=nocreat

Release vs.ü Page æÌ ü.ss Deploy on On-Board eMMC storage

As the eMMC storage is only accessible from the module itself, you must rst boot the RKççÀÀ-QÞ from SD card. Partition and format the eMMC storage as described in ¥.À.Ô Partition Setup, but using the device /dev/mmcblk1. Mount the eMMC partition and copy the contents of the SD card to the eMMC storage. e copy process will take about çþ seconds: sudo mkdir-p/mnt/emmc sudo mount/dev/mmcblk1p1/mnt/emmc sudo cp-ax//mnt/emmc sudo umount/mnt/emmc

e nal step is copying the bootloader to the eMMC: dd if=/boot/puma_rk3399/spl_sd.img of=/dev/mmcblk1 bs=1k seek=32 conv=nocreat dd if=/boot/puma_rk3399/u-boot.itb of=/dev/mmcblk1 bs=1k seek=256 conv=nocreat

Shut down the board (poweroff command) and remove the SD card. Make sure the boot selector switch is set to “Normal Boot”. e next boot will run U-Boot oš the internal eMMC storage.

ü.só Compiling Linux Applications

e easiest option is to compile your applications directly on a running RKççÀÀ-QÞ module. Just install the gcc package and related utilities and you are good to go: sudo apt-get install build-essential

e second option is to cross-compile your applications. e ARMv—-A compiler that was installed earlier is suitable to compile applications for the RKççÀÀ-QÞ.

ü.sæS erial Number

Each RKççÀÀ-QÞ module has a unique serial number that can be read by soŸware. In U-Boot, the serial number is contained in the environment variable serial#. You can print it using the command:

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page æ printenv serial#

Under Linux, it is represented by a simple text le in /sys: cat/sys/firmware/devicetree/base/serial-number

e serial number is xed in hardware (derived from the SoC CPU ID) and cannot be modied.

ü.sü MAC Address

By default, the MAC address of each RKççÀÀ-QÞ module is a random value derived from the serial number. e properties of this default MAC address are: • It is a Locally Administered Address: e U/L bit of the MAC address is set to Ô • It is not guaranteed to be globally unique • e address is xed for each RKççÀÀ-QÞ module. It stays constant across reboots as it is deterministically derived from the serial number To set your own Universally Administered Address, you overwrite the U-Boot environment variable ethaddr. On the U- Boot prompt, with XX:XX:XX:XX:XX:XX replaced by your MAC address: setenv ethaddr XX:XX:XX:XX:XX:XX saveenv

e MAC address can be queried from the U-Boot prompt using: printenv ethaddr

To reset the MAC address to the default value, run: env delete ethaddr saveenv

Release vs.ü Page æÌ ð Hardware Guide

is Hardware Guide provides information about the features, connectors and signals available on the RKççÀÀ-QÞ module.

ð.s Qseven Implementation

Qseven has mandatory and optional features. Following table shows the feature set of the RKççÀÀ-QÞ module compared to the minimum ARM/RISC based and maximum conguration according to the QÞ standard.

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page æO System I/O Interface Q Minimum RKææOO-Q Q Maximum PCI Express lanes þ ¥ ¥ Serial ATA channels þ þ ò USB ò.þ ports Ô Ô — USB ç.þ ports þ ç ç LVDS channels þ þ ò Embedded DisplayPort þ Ô Ô MIPI_CSI þ ò ò HDMI þ Ô Ô High Denition Audio / AC‘ÀÞ / IòS þ Ô Ô Ethernet Ôþ/Ôþþ/Gigabit þ Ôx Gigabit Ôx Gigabit UART þ Ô Ô GPIO þ — — Secure Digital I/O þ Ô Ô System Management Bus þ Ô Ô IòC Bus Ô ¥ ¥ SPI Bus þ Ô Ô CAN Bus þ Ô Ô Watchdog Trigger Ô Ô Ô Power Button Ô Ô Ô Power Good Ô Ô Ô Reset Button Ô Ô Ô LID Button þ Ô Ô Sleep Button þ Ô Ô Suspend to RAM (Sç mode) þ Ô Ô Wake þ Ô Ô Battery low alarm þ Ô Ô ermal control þ Ô Ô FAN control þ Ô Ô

Note: e RKççÀÀ-QÞ module is available in dišerent variants. is document describes the maximum conguration. For details about orderable variants please refer to the order-code document.

Release vs.ü Page ü+ ð.óQÂ Connector Pinout

e following table shows the signals on the edge connector of the RKççÀÀ-QÞ module. Empty cells are not connected (NC) pins.

Pin Signal Pin Signal Ô GND ò GND ç GBE_MDIç- ¥ GBE_MDIò- GBE_MDIç+ â GBE_MDIò+ Þ GBE_LINKÔþþk — GBE_LINKÔþþþk À GBE_MDIÔ- Ôþ GBE_MDIOþ- ÔÔ GBE_MDIÔ+ Ôò GBE_MDIOþ+ Ôç GBE_LINKk Ô¥ GBE_ACTk Ô Ôâ SUS_S k ÔÞ WAKEk ԗ SUS_Sçk ÔÀ GPþ òþ PWRBTNk òÔ SLP_BTNk òò LID_BTNk òç GND ò¥ GND ò GND òâ PWGIN òÞ BATLOWk ò— RSTBTNk òÀ çþ çÔ çò çç ç¥ GND ç çâ çÞ ç— çÀ GND ¥þ GND ¥Ô BIOS_DISABLEk / BOOT_ALTk ¥ò SDIO_CLKk ¥ç SDIO_CDk ¥¥ SDIO_LED ¥ SDIO_CMD ¥â SDIO_WP ¥Þ SDIO_PWRk ¥— SDIO_DATÔ ¥À SDIO_DATþ þ SDIO_DATç Ô SDIO_DATò ò ç ¥ â USB_OTG_PEN Þ GND — GND À IòS_WS âþ SMB_CLK / GPÔ_IòC_CLK Continued on next page

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page üs Table s – continued from previous page Pin Signal Pin Signal âÔ IòS_RSTk âò SMB_DAT / GPÔ_IòC_DAT âç IòS_CLK ⥠SMB_ALERTk â IòS_SDI ââ GPþ_IòC_CLK âÞ IòS_SDO ◠GPþ_IòC_DAT âÀ THRMk Þþ WDTRIGk ÞÔ THRMTRIPk Þò WDOUT Þç GND Þ¥ GND Þ USB_SSTXþ- Þâ USB_SSRXþ- ÞÞ USB_SSTXþ+ ޗ USB_SSRXþ+ ÞÀ —þ —Ô USB_SSTXò- —ò USB_SSRXò- —ç USB_SSTXò+ —¥ USB_SSRXò+ — USB_ò_ç_OCk —â USB_þ_Ô_OCk —Þ USB_Pç- —— USB_Pò- —À USB_Pç+ Àþ USB_Pò+ ÀÔ USB_CC Àò USB_ID Àç USB_PÔ- À¥ USB_Pþ- À USB_PÔ+ Àâ USB_Pþ+ ÀÞ GND À— GND ÀÀ LVDS_Aþ+ Ôþþ LVDS_Bþ+ ÔþÔ LVDS_Aþ- Ôþò LVDS_Bþ- Ôþç LVDS_AÔ+ Ôþ¥ LVDS_BÔ+ Ôþ LVDS_AÔ- Ôþâ LVDS_BÔ- ÔþÞ LVDS_Aò+ Ôþ— LVDS_Bò+ ÔþÀ LVDS_Aò- ÔÔþ LVDS_Bò- ÔÔÔ LVDS_PPEN ÔÔò LVDS_BLEN ÔÔç LVDS_Aç+ ÔÔ¥ LVDS_Bç+ ÔÔ LVDS_Aç- ÔÔâ LVDS_Bç- ÔÔÞ GND Ôԗ GND ÔÔÀ LVDS_A_CLK+ Ôòþ LVDS_B_CLK+ ÔòÔ LVDS_A_CLK- Ôòò LVDS_B_CLK- Ôòç LVDS_BLT_CTRL / GP_PWM_OUTþ Ôò¥ GP_Ô-Wire_Bus Ôò GPò_IòC_DAT / LVDS_DID_DAT Ôòâ LVDS_BLC_DAT / eDPþ_HPDk ÔòÞ GPò_IòC_CLK / LVDS_DID_CLK Ôò— LVDS_BLC_CLK ÔòÀ CANþ_TX Ôçþ CANþ_RX ÔçÔ TMDS_CLK+ Ôçò USB_SSTXÔ- Continued on next page

Release vs.ü Page üó Table s – continued from previous page Pin Signal Pin Signal Ôçç TMDS_CLK- Ôç¥ USB_SSTXÔ+ Ôç GND Ôçâ GND ÔçÞ TMDS_LANEÔ+ Ôç— ÔçÀ TMDS_LANEÔ- Ô¥þ Ô¥Ô GND Ô¥ò GND Ô¥ç TMDS_LANEþ+ Ô¥¥ USB_SSRXÔ- Ô¥ TMDS_LANEþ- Ô¥â USB_SSRXÔ+ Ô¥Þ GND Ô¥— GND Ô¥À TMDS_LANEò+ Ô þ HDMI_CTRL_DAT Ô Ô TMDS_LANEò- Ô ò HDMI_CTRL_CLK Ô ç DP_HDMI_HPDk Ô ¥ Ô PCIE_CLK_REF+ Ô â PCIE_WAKEk Ô Þ PCIE_CLK_REF- Ô — PCIE_RSTk Ô À GND Ôâþ GND ÔâÔ PCIEç_TX+ Ôâò PCIEç_RX+ Ôâç PCIEç_TX- Ô⥠PCIEç_RX- Ôâ GND Ôââ GND ÔâÞ PCIEò_TX+ Ô◠PCIEò_RX+ ÔâÀ PCIEò_TX- ÔÞþ PCIEò_RX- ÔÞÔ UARTþ_TX ÔÞò UARTþ_RTSk ÔÞç PCIEÔ_TX+ ÔÞ¥ PCIEÔ_RX+ ÔÞ PCIEÔ_TX- ÔÞâ PCIEÔ_RX- ÔÞÞ UARTþ_RX Ôޗ UARTþ_CTSk ÔÞÀ PCIEþ_TX+ ԗþ PCIEþ_RX+ Ô—Ô PCIEþ_TX- ԗò PCIEþ_RX- ԗç GND ԗ¥ GND ԗ GPIOþ ԗâ GPIOÔ Ô—Þ GPIOò ԗ— GPIOç ԗÀ GPIO¥ ÔÀþ GPIO ÔÀÔ GPIOâ ÔÀò GPIOÞ ÔÀç VCC_BAT ÔÀ¥ SPKR / GP_PWM_OUTò ÔÀ FAN_TACHOIN / GP_TIMER_IN ÔÀâ FAN_PWMOUT / GP_PWM_OUTÔ ÔÀÞ GND ÔÀ— GND ÔÀÀ SPI_MOSI òþþ SPI_CSþk òþÔ SPI_MISO òþò SPI_CSÔk òþç SPI_SCK òþ¥ Continued on next page

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page üæ Table s – continued from previous page Pin Signal Pin Signal òþ òþâ òþÞ òþ— òþÀ òÔþ òÔÔ òÔò òÔç òÔ¥ òÔ òÔâ òÔÞ òԗ òÔÀ VCC òòþ VCC òòÔ VCC òòò VCC òòç VCC òò¥ VCC òò VCC òòâ VCC òòÞ VCC òò— VCC òòÀ VCC òçþ VCC

ð.æ Signal Details

ð.æ.s Ethernet

Signal Type Signal Description Level GBE_MDI[þ:ç]+ I/O Analog Gigabit Ethernet Controller: Media Dependent Interface Dišerential GBE_MDI[þ:ç]- Pairs þ,Ô,ò,ç. e MDI can operate in Ôþþþ, Ôþþ and Ôþ Mbit/sec modes GBE_ACTk OC ç.çV Gigabit Ethernet Controller activity indicator, active low GBE_LINKk OC ç.çV Gigabit Ethernet Controller link indicator, active low GBE_LINKÔþþk OC ç.çV Internally connected to GBE_LINKk GBE_LINKÔþþþk OC ç.çV Internally connected to GBE_LINKk GBE_CTREF REF Analog Center Tap Voltage

Release vs.ü Page üü ð.æ.óUS B

Signal Type Signal Description Level USB_P[þ:ò]+ I/O USB High speed universal Serial Bus Port þ, Ô, ò dišerential pairs USB_P[þ:ò]- USB_SSTX[þ:ò]+ I/O USB Super speed universal Serial Bus Port þ, Ô, ò transmit dišerential pairs USB_SSTX[þ:ò]- USB_SSRX[þ:ò]+ I/O USB Super speed universal Serial Bus Port þ, Ô, ò receive dišerential pairs USB_SSRX[þ:ò]- USB_þ_Ô_OCk I ç.çV Over current detect input Ô. is pin is used to monitor the USB power over current of the USB Ports þ and Ô USB_ò_ç_OCk I ç.çV Over current detect input Ô. is pin is used to monitor the USB power over current of the USB Ports ò and ç USB_ID I ç.çV Congures the mode of the USB Port Ô. If the signal is active high the Port will be congured as USB Client USB_VBUS I .þV USB VBUS pin, V tolerant USB_OTG_PEN O ç.çV USB Power enable for OTG port USB Ô

ð.æ.æS DIO

Signal Type Signal Description Level SDIO_CDk I ç.çV SDIO Card Detect. is signal indicates when a SDIO/MMC card is present SDIO_CLK O ç.çV SDIO Clock SDIO_CMD I/O ç.çV SDIO Command/Response SDIO_LED O ç.çV SDIO LED. Used to drive an external LED to indicate transfers on the bus SDIO_WP I ç.çV SDIO Write Protect SDIO_PWRk O ç.çV SDIO Power Enable. is signal is used to enable the power being sup- plied to a SD/MMC card device SDIO_DATþ-¥ I/O ç.çV SDIO Data lines

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page üð ð.æ.ü IóC

Signal Type Signal Description Level QÞ_IòC_CLK O ç.çV IòC bus clock line connected to RKççÀÀ QÞ_IòC_DAT I/O ç.çV IòC bus data line connected to RKççÀÀ LVDS_DID_CLK O ç.çV IòC bus clock line connected to RKççÀÀ /GPò_IòC_CLK LVDS_DID_DAT I/O ç.çV IòC bus data line connected to RKççÀÀ /GPò_IòC_DAT SMB_CLK O ç.çV Clock line of System Management Bus. Alternate function IòC Bus GPÔ_IòC_CLK clock line SMB_DAT I/O ç.çV Data line of System Management Bus. Alternate function IòC Bus data GPÔ_IòC_DAT line LVDS_BLC_DAT O ç.çV IòC bus clock line connected to RKççÀÀ, Kerkey and baseboard EEP- ROM LVDS_BLC_CLK I/O ç.çV IòC bus data line connected to RKççÀÀ, Kerkey and baseboard EEP- ROM

ð.æ.ð IóS

Signal Type Signal Description Level IòS_RSTk O ç.çV IòS Codec Reset IòS_WS O ç.çV IòS Word Select IòS_CLK O ç.çV IòS Serial Data Clock IòS_SDO O ç.çV IòS Serial Data Output IòS_SDI I ç.çV IòS Serial Data Input

Release vs.ü Page üÌ ð.æ.ÌH DMI

Signal Type Signal Description Level TMDS_CLK+ O TMDS TMDS dišerential pair clock lines TMDS_CLK- TMDS_LANE[þ:ò]+ O TMDS TMDS dišerential pair lanes þ, Ô, ò TMDS_LANE[þ:ò]- HDMI_CTRL_CLK O ç.çV DDC based control signal (clock) for HDMI device HDMI_CTRL_DAT I/O ç.çV DDC based control signal (data) for HDMI device HDMI_HPDk I ç.çV Hot plug detection signal

ð.æ. Video

e RKççÀÀ-QÞ does not feature LVDS as the CPU lacks this interface. Instead the Qseven LVDS pins are used for MIDI- DSI. ese signals are electrical compatible but are not dened in the Qseven standard.

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ü Q Pin Function Alternate Function LVDS_Aþ_P MIPI_TXþ_DþP EDP_TXþ_P LVDS_Aþ_N MIPI_TXþ_DþN EDP_TXþ_N LVDS_AÔ_P MIPI_TXþ_DÔP EDP_TXÔ_P LVDS_AÔ_N MIPI_TXþ_DÔN EDP_TXÔ_N LVDS_Aò_P MIPI_TXþ_DòP EDP_TXò_P LVDS_Aò_N MIPI_TXþ_DòN EDP_TXò_N LVDS_Aç_P MIPI_TXþ_DçP EDP_TXç_P LVDS_Aç_N MIPI_TXþ_DçN EDP_TXç_N LVDS_A_CLK_P MIPI_TXþ_CLKP EDP_AUX_P LVDS_A_CLK_N MIPI_TXþ_CLKN EDP_AUX_N LVDS_Bþ_P MIPI_TXÔ/RXÔ_DþP LVDS_Bþ_N MIPI_TXÔ/RXÔ_DþN LVDS_BÔ_P MIPI_TXÔ/RXÔ_DÔP LVDS_BÔ_N MIPI_TXÔ/RXÔ_DÔN LVDS_Bò_P MIPI_TXÔ/RXÔ_DòP LVDS_Bò_N MIPI_TXÔ/RXÔ_DòN LVDS_Bç_P MIPI_TXÔ/RXÔ_DçP LVDS_Bç_N MIPI_TXÔ/RXÔ_DçN LVDS_B_CLK_P MIPI_TXÔ/RXÔ_CLKP LVDS_B_CLK_N MIPI_TXÔ/RXÔ_CLKN

e LVDS A pins are muxed between MIPI_TXþ and eDP on the Module. e active function is selected with a GPIO pin.

Function CPU Pin Linux GPIO # LVDS A Mux GPIOò_Aò ç¥

LVDS A Mux Function þ MIPI Ô eDP

Release vs.ü Page üÌ ð.æ.Ì GPIO

Signal Type Signal Description Level GPIO[þ-Þ] I/O ç.çV General purpose inputs/outputs þ to Þ

ð.æ.O CAN

Signal Type Signal Description Level CANþ_TX O ç.çV CAN (Controller Area Network) TX output for CAN Bus channel þ CANþ_RX I ç.çV CAN (Controller Area Network) RX input for CAN Bus channel þ

ð.æ.s+ SPI

Signal Type Signal Description Level SPI_MOSI O ç.çV Master serial output/Slave serial input signal SPI_MISO I ç.çV Master serial input/Slave serial output signal SPI_SCK O ç.çV SPI clock output SPI_CSþk O ç.çV SPI select þ output SPI_CSÔk O ç.çV SPI chip select Ô output (used when two devices are connected)

ð.æ.ssU ART

Signal Type Signal Description Level UARTþ_TX O ç.çV Serial data transmit UARTþ_RX I ç.çV Serial data receive UARTþ_CTSk I ç.çV Handshake signal: ready to send data UARTþ_RTSk O ç.çV Handshake signal: ready to receive data

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page üO ð.æ.só Misc

Signal Type Signal Description Level WDTRIGk I ç.çV Watchdog trigger signal WDOUT O ç.çV Watchdog event indicator SMB_CLK O ç.çV Clock line of System Management Bus. Alternate function IòC Bus GPÔ_IòC_CLK clock line SMB_DAT I/O ç.çV Data line of System Management Bus. Alternate function IòC Bus data GPÔ_IòC_DAT line SMB_ALERTk I ç.çV System Management Bus Alert input SPKR O ç.çV PC speaker (buzzer) output. Alternate function general purpose PWM GP_PWM_OUTò output BIOS_DISABLEk I ç.çV Disables the onboard bootloader and uses the one the SD card instead. /BOOT_ALTk If no bootloader is available on the SD card it falls back to USB recovery mode GP_Ô-Wire_Bus I/O ç.çV General Purpose Ô-Wire bus interface THRMk I ç.çV ermal Alarm active low signal generated by the external hardware to indicate an over temperature situation. is signal can be used to initiate thermal throttling THRMTRIPk O ç.çV ermal Trip indicates an overheating condition of the processor. If ‘THRMTRIPk’ goes active the system immediately transitions to the S State (SoŸ Oš) FAN_PWMOUT O ç.çV PWM output for fan speed control. Alternate function general purpose /GP_PWM_OUTÔ PWM output. Function based on microcontroller rmware FAN_TACHOIN I ç.çV Fan tachometer input. Alternate function general purpose timer input. /GP_TIMER_IN Function based on microcontroller rmware

Release vs.ü Page ð+ ð.æ.sæ Power Management

Signal Type Signal Description Level RSTBTNk I ç.çV Reset button input. An active low signal resets the module BATLOWk I ç.çV Battery low input WAKEk I ç.çV External system wake event. An active low signal wakes the module from a sleep state SUS_Sçk O ç.çV Indicated that the system is in suspend to ram (Sç) SUS_S k O ç.çV Indicated that the system is in soŸ-oš state (S ) SLP_BTNk I ç.çV Sleep button. Signals the system with an falling edge to transition into sleep or wake from a sleep state LID_BTNk I ç.çV LID button. Low active signal to detect a LID switch to transition into sleep or wake from a sleep state

ð.æ.sü Power

Signal Nominal Input Description VCC V Main supply for the module VCC_RTC çV Backup supply for the RTC. If not used it can be leŸ unconnected

ð.ü On-board Devices

ð.ü.s Power-Manager

e Rockchip RK—þ— is connected to the CPU via RSB and an interrupt line:

RKÌ+Ì Pin Function CPU Pin ÔÀ SCL IòCþ_SCL_u (ball Nçþ) ԗ SDA IòCþ_SDA_u (ball Mòâ) ¥À IRQ GPIOÔ_Câ (ball Lò )

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ðs ð.ü.ó DDRæ

• ¥GB RAM of DDRç-Ôâþþ (ò independent channels, each çò-bit wide)

ð.ü.æ eMMC

• eMMC connected through the —-bit wide SDIO interface EMMC_D on the CPU.

Signal CPU Pin Linux GPIO # RESET GPIOþ_A

ð.ü.ü NOR Flash

• çò MiB serial NOR žash • Connected to the CPU via SPIÔ:

Signal CPU Pin CLK GPIO_BÔ (ball Pò—) MOSI GPIO_Bþ (ball RçÔ) MISO GPIÔ_AÞ (ball PòÞ) CS GPIO_Bò (ball PòÀ)

ð.ü.ðC ompanion Controller

e on-board microcontroller provides additional features to the CPU, exposed via IòC and USB. It emulates standard ICs and does not need custom drivers in Linux.

Feature CPU Connection Emulated IC Qseven Pins RTC IòC ISLÔòþ— none Temperature sensor and fan controller IòC AMCâ—òÔ FAN_TACHOIN, FAN_PWMOUT CAN USB UCAN CANþ_TX, CANþ_RX

e STMçò-microcontroller can be žashed from the CPU by taking it into DFU mode (USB recovery). Pull BOOTþ low and cycle reset (GPIOs listed below). e microcontroller will appear as a new USB device in Linux.

Release vs.ü Page ðó Function CPU Pin Linux GPIO # NRST GPIOÔ_Dþ â BOOTþ GPIOò_B¥ Þâ

ð.ü.Ì Ethernet PHY

e Micrel KSZÀþçÔRNX is connected to the CPU via RGMII and MDIO. Further connections are shown below.

PHY signal Connected to Linux GPIO # RESET CPU pin GPIOç_Cþ ÔÔò MDIO CPU pin GPIOç_B ÔþÞ MDC CPU pin GPIOç_Bþ Ôþò LEDÔ Qseven GBE_LINKÔþþþ and GBE_LINKÔþþ and GBE_LINK (tied together) LEDò Qseven GBE_ACT

ð.ü.ÂT est points

Test point Connected to TPÔ STMçò USARTò TX TPò STMçò USARTò RX TPç GND

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ðæ ð.ð USB

e RKççÀÀ CPU has two USB ç.þ SuperSpeed controllers. e Genesys Logic, Inc. GLç òç USB hub provides two addi- tional USB ç.þ super-speed ports. e routing of Qseven signals to CPU and/or hub port is shown below. e Linux Port k column shows the identier that is used in Linux dmesg output. e format is: “usb BUSk-Ô.HUBPORTk”

Qseven Port # Speed Connected to Linux Port # Notes USB_Pþ USB ò.þ Hi-Speed Hub usb Þ-Ô.Ô USB_PÔ USB ò.þ Hi-Speed CPU usb -Ô OTG Port USB_Pò USB ò.þ Hi-Speed Hub usb Þ-Ô.ò USB_Pç USB ò.þ Hi-Speed Hub usb Þ-Ô.ç USB_SSTXþ / USB_SSRXþ USB ç.þ SuperSpeed Hub usb —-Ô.Ô Use together with USB_Pþ USB_SSTXÔ / USB_SSRXÔ USB ç.þ SuperSpeed CPU usb â-Ô Use together with USB_PÔ USB_SSTXò / USB_SSRXò USB ç.þ SuperSpeed Hub usb —-Ô.ò Use together with USB_Pò

e lsusb -t command shows the USB topology in a tree view and is highly recommended. It’s output is discussed below, for a RKççÀÀ-QÞ module without additional devices connected: Bus 07 and Bus 08 are connected to the GLç òç hub. e CAN controller is connected to Port 4 on the hub: lsusb-t /: Bus 08.Port1: Dev1, Class=root_hub, Driver=xhci-hcd/1p, 5000M |__ Port1: Dev2, If0, Class=Hub, Driver=hub/4p, 5000M /: Bus 07.Port1: Dev1, Class=root_hub, Driver=xhci-hcd/1p, 480M |__ Port1: Dev2, If0, Class=Hub, Driver=hub/4p, 480M |__ Port4: Dev3, If0, Class=, Driver=uCAN, 12M

Linux Bus 05 and Bus 06 are routed directly to the Qseven ports USB_P1 and USB_SSTX1 / USB_SSRX1:

/: Bus 06.Port1: Dev1, Class=root_hub, Driver=xhci-hcd/1p, 5000M /: Bus 05.Port1: Dev1, Class=root_hub, Driver=xhci-hcd/1p, 480M

Additional internal USB ò.þ busses, currently unused:

/: Bus 04.Port1: Dev1, Class=root_hub, Driver=ohci-platform/1p, 12M /: Bus 03.Port1: Dev1, Class=root_hub, Driver=ohci-platform/1p, 12M /: Bus 02.Port1: Dev1, Class=root_hub, Driver=ehci-platform/1p, 480M /: Bus 01.Port1: Dev1, Class=root_hub, Driver=ehci-platform/1p, 480M

Release vs.ü Page ðü e USB hub can be held in reset, if required. is disables all USB ports connected to the hub. e reset signal routing is shown below:

Hub signal CPU Pin Linux GPIO # USBHUB_RESETn GPIO¥_Aç ÔçÔ

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ðð ð.Ì Using Qseven Signals as GPIO

Most Qseven signals can be reused as general purpose pin. Following table shows the mapping and the possible direction between the edge connector and the SoC.

Qseven Signal CPU Pin Linux Direction Pin GPIO # Ôâ SUS_S k GPIOÔ_AÔ çç Output ÔÞ WAKEk GPIOþ_BÔ À Input ԗ SUS_Sçk GPIOÔ_Aþ çò Output ÔÀ GPOþ GPIOò_Bç Þ Output òÔ SLP_BTNk GPIOþ_Bç ÔÔ Input òò LID_BTNk GPIOþ_A¥ ¥ Input òÞ BATLOWk GPIOþ_Bò Ôþ Input ¥ò SDIO_CLKk GPIO¥_B¥ Ô¥þ Bidirectional ¥ç SDIO_CDk GPIOþ_AÞ Þ Input ¥¥ SDIO_LED GPIOÔ_Aò ç¥ Output ¥ SDIO_CMD GPIO¥_B Ô¥Ô Bidirectional ¥â SDIO_WP GPIOþ_B Ôç Input ¥Þ SDIO_PWRk GPIOÔ_CÔ ¥À Output ¥— SDIO_DATÔ GPIO¥_BÔ ÔçÞ Bidirectional ¥À SDIO_DATþ GPIO¥_Bþ Ôçâ Bidirectional þ SDIO_DATç GPIO¥_Bç ÔçÀ Bidirectional Ô SDIO_DATò GPIO¥_Bò Ôç— Bidirectional â USB_OTG_PEN GPIOþ_Aò ò Output À IòS_WS GPIOç_Dò Ôòò Output âþ SMB_CLK / GPÔ_IòC_CLK GPIOò_AÔ â Bidirectional âÔ IòS_RSTk GPIO¥_A Ôçç Output âò SMB_DAT / GPÔ_IòC_DAT GPIOò_Aþ ⥠Bidirectional âç IòS_CLK GPIOç_Dþ Ôòþ Output ⥠SMB_ALERTk GPIOþ_B¥ Ôò Input â IòS_SDI GPIOç_Dç Ôòç Input ââ GPþ_IòC_CLK GPIOÔ_B¥ ¥¥ Bidirectional âÞ IòS_SDO GPIOç_DÞ ÔòÞ Output ◠GPþ_IòC_DAT GPIOÔ_Bç ¥ç Bidirectional âÀ THRMk GPIOþ_Aç ç Input ÞÔ THRMTRIPk GPIOÔ_Aç ç Output Continued on next page

Release vs.ü Page ðÌ Table ó – continued from previous page Qseven Signal CPU Pin Linux Direction Pin GPIO # ÔÔÔ LVDS_PPEN GPIO¥_Dâ Ô — Output ÔÔò LVDS_BLEN GPIOÔ_CÞ Bidirectional Ôòç LVDS_BLT_CTRL / GP_PWM_OUTþ GPIO¥_Cò Ô¥â Output Ôò¥ GP_Ô-Wire_Bus GPIO¥_CÞ Ô Ô Bidirectional Ôò GPò_IòC_DAT / LVDS_DID_DAT GPIO¥_AÔ ÔòÀ Bidirectional ÔòÞ GPò_IòC_CLK / LVDS_DID_CLK GPIO¥_Aò Ôçþ Bidirectional Ô þ HDMI_CTRL_DAT GPIO¥_Cþ Ô¥¥ Bidirectional Ô ò HDMI_CTRL_CLK GPIO¥_CÔ Ô¥ Bidirectional Ô â PCIE_WAKEk GPIOò_Dò Àþ Input Ô — PCIE_RSTk GPIO¥_Câ Ô þ Output ÔÞÔ UARTþ_TX GPIOò_CÔ —Ô Output ÔÞò UARTþ_RTSk GPIOò_Cç —ç Output ÔÞÞ UARTþ_RX GPIOò_Cþ —þ Input Ôޗ UARTþ_CTSk GPIOò_Cò —ò Input ԗ GPIOþ GPIO¥_D¥ Ô â Bidirectional ԗâ GPIOÔ GPIO¥_DÔ Ô ç Bidirectional Ô—Þ GPIOò GPIO¥_Dþ Ô ò Bidirectional ԗ— GPIOç GPIO¥_D Ô Þ Bidirectional ԗÀ GPIO¥ GPIO¥_Dò Ô ¥ Bidirectional ÔÀþ GPIO GPIO¥_C¥ Ô â Bidirectional ÔÀÔ GPIOâ GPIO¥_Cç Ô¥Þ Bidirectional ÔÀò GPIOÞ GPIO¥_Dç Ô Bidirectional ÔÀÀ SPI_MOSI GPIOò_C — Output òþþ SPI_CSþk GPIOò_CÞ —Þ Output òþÔ SPI_MISO GPIOò_C¥ —¥ Input òþò SPI_CSÔk GPIOò_Dþ —— Output òþç SPI_SCK GPIOò_C⠗â Output

RKææOO-Q User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ð ð. Electrical Speciícation

ð.Â.s Power Supply

e power supply requirements are listed in the table below and are identical to the Qseven specication.

Rail Description Nominal voltage Tolerance VCC Main power supply V ¥.Þ ... .ò V VCC_RTC Backup battery çV ò.¥ ... ç.çV

Release vs.ü Page ðÌ ð.Ì Mechanical Speciícation

ð.Ì.s Module Dimensions

e mechanical dimensions of the module are shown below.

Fig. Ô: Module dimensions (all values in mm)

ð.Ì.ó Baseboard Dimensions

e mechanical dimensions of the baseboard are conform with the form factor for Mini-ITX and it can be mounted in a standard Mini-ITX PC Case.

RKææOO-QÂ User Manual Release vs.ü © Theobroma Systems Design und Consulting GmbH Page ðO ÌR evision History

Date Revision Changes Apr ÔÔ, òþԗ vÔ.¥ Add heatsink spacer instructions Clarify U-Boot deployment on SD card Jan òò, òþԗ vÔ.ç Improve image readability, add Linux GPIOk column Oct çÔ, òþÔÞ vÔ.ò Describe Linux USB bus number mapping Oct ò, òþÔÞ vÔ.Ô Add IòC number mapping table Update SPL and BLçÔ le names Jul Ôç, òþÔÞ vÔ.þ Adapt debootstrap instructions for Debian À “Stretch” Add GPIO Pin Muxing section Jul Ôþ, òþÔÞ vþ.ç Complete soŸware guide chapter Add video mux information Jun ò, òþÔÞ vþ.ò Preliminary public release May çþ, òþÔÞ vþ.Ô First internal release

Release vs.ü Page Ì+