1.. zephyr:board:: hsdk4xd
2
3Overview
4********
5
6The ARC HS4x/HS4xD Development Kit is the next revision of :zephyr:board:`Synopsys HSDK board <hsdk>`.
7It includes a multicore ARC HS4xD-based chip that integrates a wide range of interfaces
8including Ethernet, HDMI, WiFi, Bluetooth, USB, SDIO, I2C, SPI, UART, I2S, ADC, PWM and GPIO,
9as well as a Think Silicon GPU.
10
11For details about the board, see: `ARC HS4x/HS4xD Development Kit
12(HSDK4xD) <https://www.synopsys.com/dw/ipdir.php?ds=arc-hs-development-kit>`__
13
14Hardware
15********
16
17The ARC HSDK4xD has 24 general GPIOs, which divided into 8 groups named from ``GPIO_SEL_0`` to ``GPIO_SEL_7``.
18Each sel can configured for different functions, such as: GPIO, UART, SPI, I2C and PWM. We can program
19``CREG_GPIO_MUX`` register to do configuration for each sel. Tables below show the bit definition for
20``CREG_GPIO_MUX`` register and the details configuration for each pin.
21
22+--------+-------------+---------+--------------+---------------------------------+
23| Bit    | Name        | Access  | Reset value  | Description                     |
24+--------+-------------+---------+--------------+---------------------------------+
25| 2:0    | GPIO_SEL_0  | RW      | 0x0          | GPIO mux select for gpio[3:0]   |
26+--------+-------------+---------+--------------+---------------------------------+
27| 5:3    | GPIO_SEL_1  | RW      | 0x0          | GPIO mux select for gpio[7:4]   |
28+--------+-------------+---------+--------------+---------------------------------+
29| 8:6    | GPIO_SEL_2  | RW      | 0x0          | GPIO mux select for gpio[11:8]  |
30+--------+-------------+---------+--------------+---------------------------------+
31| 11:9   | GPIO_SEL_3  | RW      | 0x0          | GPIO mux select for gpio[15:12] |
32+--------+-------------+---------+--------------+---------------------------------+
33| 14:12  | GPIO_SEL_4  | RW      | 0x0          | GPIO mux select for gpio[17:16] |
34+--------+-------------+---------+--------------+---------------------------------+
35| 17:15  | GPIO_SEL_5  | RW      | 0x0          | GPIO mux select for gpio[19:18] |
36+--------+-------------+---------+--------------+---------------------------------+
37| 20:18  | GPIO_SEL_6  | RW      | 0x0          | GPIO mux select for gpio[21:20] |
38+--------+-------------+---------+--------------+---------------------------------+
39| 23:21  | GPIO_SEL_7  | RW      | 0x0          | GPIO mux select for gpio[23:22] |
40+--------+-------------+---------+--------------+---------------------------------+
41
42+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
43| SELS | GPIO PINS | FUN0     | FUN1      | FUN2       | FUN3     | FUN4      | FUN5        | FUN6      | FUN7        |
44+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
45| SEL0 | 0         | gpio[0]  | uart0_cts | spi1_cs[0] | gpio[0]  | gpio[0]   | pwm_ch[6]   | pwm_ch[6] | pwm_ch[1]   |
46|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
47|      | 1         | gpio[1]  | uart0_txd | spi1_mosi  | gpio[1]  | pwm_ch[0] | gpio[1]     | pwm_ch[0] | pwm_ch[0]   |
48|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
49|      | 2         | gpio[2]  | uart0_rxd | spi1 _miso | i2c1_scl | gpio[2]   | gpio[2]     | gpio[2]   | gpio[2]     |
50|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
51|      | 3         | gpio[3]  | uart0_rts | spi1_clk   | i2c1_sda | gpio[3]   | gpio[3]     | gpio[3]   | gpio[3]     |
52+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
53| SEL1 | 4         | gpio[4]  | uart1_cts | spi2_cs[0] | gpio[4]  | gpio[4]   | pwm_ch[4]   | pwm_ch[4] | pwm_ch[3]   |
54|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
55|      | 5         | gpio[5]  | uart1_txd | spi2_mosi  | gpio[5]  | pwm_ch[2] | gpio[5]     | pwm_ch[2] | pwm_ch[2]   |
56|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
57|      | 6         | gpio[6]  | uart1_rxd | spi2_miso  | i2c2_scl | gpio[6]   | gpio[6]     | gpio[6]   | gpio[6]     |
58|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
59|      | 7         | gpio[7]  | uart1_rts | spi2_clk   | i2c2_sda | gpio[7]   | gpio[7]     | gpio[7]   | gpio[7]     |
60+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
61| SEL2 | 8         | gpio[8]  | uart2_cts | spi1_cs[1] | gpio[8]  | gpio[8]   | pwm_ch[2]   | pwm_ch[2] | pwm_ch[5]   |
62|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
63|      | 9         | gpio[9]  | uart2_txd | spi1_mosi  | gpio[9]  | pwm_ch[4] | gpio[9]     | pwm_ch[4] | pwm_ch[4]   |
64|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
65|      | 10        | gpio[10] | uart2_rxd | spi1_miso  | i2c1_scl | gpio[10]  | gpio[10]    | gpio[10]  | gpio[10]    |
66|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
67|      | 11        | gpio[11] | uart2_rts | spi1_clk   | i2c1_sda | gpio[11]  | gpio[11]    | gpio[11]  | gpio[11]    |
68+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
69| SEL3 | 12        | gpio[12] | uart0_cts | spi2_cs[1] | gpio[12] | gpio[12]  | pwm_ch[0]   | pwm_ch[0] | pwm_ch[7]   |
70|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
71|      | 13        | gpio[13] | uart0_txd | spi2_mosi  | gpio[13] | pwm_ch[6] | gpio[13]    | pwm_ch[6] | pwm_ch[6]   |
72|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
73|      | 14        | gpio[14] | uart0_rxd | spi2_miso  | i2c2_scl | gpio[14]  | gpio[14]    | gpio[14]  | gpio[14]    |
74|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
75|      | 15        | gpio[15] | uart0_rts | spi2_clk   | i2c2_sda | gpio[15]  | gpio[15]    | gpio[15]  | gpio[15]    |
76+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
77| SEL4 | 16        | gpio[16] | uart1_txd | spi1_cs[2] | i2c1_scl | gpio[16]  | pwm_fault_0 | gpio[16]  | pwm_fault_0 |
78|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
79|      | 17        | gpio[17] | uart1_rxd | spi1_mosi  | i2c1_sda | pwm_ch[0] | pwm_ch[0]   | pwm_ch[5] | pwm_ch[5]   |
80+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
81| SEL5 | 18        | gpio[18] | uart2_txd | spi1_miso  | i2c2_scl | gpio[18]  | gpio[18]    | gpio[18]  | gpio[18]    |
82|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
83|      | 19        | gpio[19] | uart2_rxd | spi1_clk   | i2c2_sda | gpio[19]  | gpio[19]    | gpio[19]  | gpio[19]    |
84+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
85| SEL6 | 20        | gpio[20] | uart0_txd | spi2_cs[2] | i2c1_scl | gpio[20]  | pwm_fault_1 | gpio[20]  | pwm_fault_1 |
86|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
87|      | 21        | gpio[21] | uart0_rxd | spi2_mosi  | i2c1_sda | pwm_ch[6] | pwm_ch[6]   | pwm_ch[3] | pwm_ch[3]   |
88+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
89| SEL7 | 22        | gpio[22] | uart2_txd | spi2_miso  | i2c2_scl | gpio[22]  | gpio[22]    | gpio[22]  | gpio[22]    |
90|      +-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
91|      | 23        | gpio[23] | uart2_rxd | spi2_clk   | i2c2_sda | gpio[23]  | gpio[23]    | gpio[23]  | gpio[23]    |
92+------+-----------+----------+-----------+------------+----------+-----------+-------------+-----------+-------------+
93
94Digilent Pmod
95=============
96
97The ARC HSDK4xD features two 12-pin Pmod connectors ``Pmod_A`` and ``Pmod_B`` and one 6-pin Pmod connector ``Pmod_C``.
98The functionality of the Pmod connectors is programmable and includes GPIO, UART, SPI, I2C and PWM.
99The location of the pins on the Pmod connectors is shown in Figure below. Detailed pin descriptions
100depending on the pin multiplexer settings are provided in the subsequent sections.
101
102.. image:: pinout_diagram_of_the_pmod.jpg
103   :align: center
104   :alt: Pinout Diagram of the Pmod
105
106Pmod_A Connector
107----------------
108
109Table below lists the pin assignment of valid protocols that can be multiplexed on the ``Pmod_A``
110connector. The GPIO column is the default assignment after Reset.
111
112+------+-----------+------------+-------------+-----------+------------+-----------+
113| Pin  | GPIO      | UART       | SPI         | I2C       | PWM_1      | PWM_2     |
114+------+-----------+------------+-------------+-----------+------------+-----------+
115| A1   | gpio[8]   | uart2_cts  | spi1_cs[1]  | gpio[8]   | gpio[8]    | pwm_ch[2] |
116+------+-----------+------------+-------------+-----------+------------+-----------+
117| A2   | gpio[9]   | uart2_txd  | spi1_mosi   | gpio[9]   | pwm_ch[4]  | gpio[9]   |
118+------+-----------+------------+-------------+-----------+------------+-----------+
119| A3   | gpio[10]  | uart2_rxd  | spi1_miso   | i2c1_scl  | gpio[10]   | gpio[10]  |
120+------+-----------+------------+-------------+-----------+------------+-----------+
121| A4   | gpio[11]  | uart2_rts  | spi1_clk    | i2c1_sda  | gpio[11]   | gpio[11]  |
122+------+-----------+------------+-------------+-----------+------------+-----------+
123| A5   | GND       | GND        | GND         | GND       | GND        | GND       |
124+------+-----------+------------+-------------+-----------+------------+-----------+
125| A6   | 3V3       | 3V3        | 3V3         | 3V3       | 3V3        | 3V3       |
126+------+-----------+------------+-------------+-----------+------------+-----------+
127| A7   | gpio[20]  | gpio[20]   | gpio[20]    | gpio[20]  | gpio[20]   | gpio[20]  |
128+------+-----------+------------+-------------+-----------+------------+-----------+
129| A8   | gpio[21]  | gpio[21]   | gpio[21]    | gpio[21]  | gpio[21]   | gpio[21]  |
130+------+-----------+------------+-------------+-----------+------------+-----------+
131| A9   | n.c.      | n.c.       | n.c.        | n.c.      | n.c.       | n.c.      |
132+------+-----------+------------+-------------+-----------+------------+-----------+
133| A10  | n.c.      | n.c.       | n.c.        | n.c.      | n.c.       | n.c.      |
134+------+-----------+------------+-------------+-----------+------------+-----------+
135| A11  | GND       | GND        | GND         | GND       | GND        | GND       |
136+------+-----------+------------+-------------+-----------+------------+-----------+
137| A12  | 3V3       | 3V3        | 3V3         | 3V3       | 3V3        | 3V3       |
138+------+-----------+------------+-------------+-----------+------------+-----------+
139
140Pmod_B Connector
141----------------
142
143Table below lists the pin assignment of valid protocols that can be multiplexed on the ``Pmod_B``
144connector. The GPIO column is the default assignment after Reset.
145
146+------+-----------+------------+-------------+-----------+------------+-----------+
147| Pin  | GPIO      | UART       | SPI         | I2C       | PWM_1      | PWM_2     |
148+------+-----------+------------+-------------+-----------+------------+-----------+
149| B1   | gpio[12]  | uart0_cts  | spi2_cs[1]  | gpio[12]  | gpio[12]   | pwm_ch[0] |
150+------+-----------+------------+-------------+-----------+------------+-----------+
151| B2   | gpio[13]  | uart0_txd  | spi2_mosi   | gpio[13]  | pwm_ch[6]  | gpio[13]  |
152+------+-----------+------------+-------------+-----------+------------+-----------+
153| B3   | gpio[14]  | uart0_rxd  | spi2_miso   | i2c2_scl  | gpio[14]   | gpio[14]  |
154+------+-----------+------------+-------------+-----------+------------+-----------+
155| B4   | gpio[15]  | uart0_rts  | spi2_clk    | i2c2_sda  | gpio[15]   | gpio[15]  |
156+------+-----------+------------+-------------+-----------+------------+-----------+
157| B5   | GND       | GND        | GND         | GND       | GND        | GND       |
158+------+-----------+------------+-------------+-----------+------------+-----------+
159| B6   | 3V3       | 3V3        | 3V3         | 3V3       | 3V3        | 3V3       |
160+------+-----------+------------+-------------+-----------+------------+-----------+
161| B7   | gpio[22]  | gpio[22]   | gpio[22]    | gpio[22]  | gpio[22]   | gpio[22]  |
162+------+-----------+------------+-------------+-----------+------------+-----------+
163| B8   | gpio[23]  | gpio[23]   | gpio[23]    | gpio[23]  | gpio[23]   | gpio[23]  |
164+------+-----------+------------+-------------+-----------+------------+-----------+
165| B9   | n.c.      | n.c.       | n.c.        | n.c.      | n.c.       | n.c.      |
166+------+-----------+------------+-------------+-----------+------------+-----------+
167| B10  | n.c.      | n.c.       | n.c.        | n.c.      | n.c.       | n.c.      |
168+------+-----------+------------+-------------+-----------+------------+-----------+
169| B11  | GND       | GND        | GND         | GND       | GND        | GND       |
170+------+-----------+------------+-------------+-----------+------------+-----------+
171| B12  | 3V3       | 3V3        | 3V3         | 3V3       | 3V3        | 3V3       |
172+------+-----------+------------+-------------+-----------+------------+-----------+
173
174Pmod_C Connector
175----------------
176
177Table below lists the pin assignment of valid protocols that can be multiplexed on the ``Pmod_C``
178connector. The GPIO column is the default assignment after Reset.
179
180+------+-----------+------------+-------------+-----------+-----------+
181| Pin  | GPIO      | UART       | SPI         | I2C       | PWM       |
182+------+-----------+------------+-------------+-----------+-----------+
183| C1   | gpio[16]  | uart1_txd  | spi1_cs[2]  | i2c1_scl  | gpio[16]  |
184+------+-----------+------------+-------------+-----------+-----------+
185| C2   | gpio[17]  | uart1_rxd  | spi1_mosi   | i2c1_sda  | pwm_ch[0] |
186+------+-----------+------------+-------------+-----------+-----------+
187| C3   | gpio[18]  | uart2_txd  | spi1_miso   | i2c2_scl  | gpio[18]  |
188+------+-----------+------------+-------------+-----------+-----------+
189| C4   | gpio[19]  | uart2_rxd  | spi1_clk    | i2c2_sda  | gpio[19]  |
190+------+-----------+------------+-------------+-----------+-----------+
191| C5   | GND       | GND        | GND         | GND       | GND       |
192+------+-----------+------------+-------------+-----------+-----------+
193| C6   | 3V3       | 3V3        | 3V3         | 3V3       | 3V3       |
194+------+-----------+------------+-------------+-----------+-----------+
195
196Mikrobus
197========
198
199The ARC HSDK4xD features a set of MikroBUS headers. Figure below shows the relevant function assignments,
200fully compatible with the MikroBUS standard. Table below shows the pin assignment on the I/O Multiplexer.
201
202.. image:: mikrobus_header.jpg
203   :align: center
204   :alt: mikrobus header
205
206+-------+-----------------+------+-----------+
207| Pin   | I/O             | Pin  | I/O       |
208+-------+-----------------+------+-----------+
209| AN    | ADC VIN6*       | PWM  | pwm_ch[0] |
210+-------+-----------------+------+-----------+
211| RST   | GPX_Port0_bit1  | INT  | gpio[16]  |
212+-------+-----------------+------+-----------+
213| CS    | spi2_cs[1]      | RX   | uart2_rxd |
214+-------+-----------------+------+-----------+
215| SCK   | spi2_clk        | TX   | uart2_txd |
216+-------+-----------------+------+-----------+
217| MISO  | spi2_miso       | SCL  | i2c2_scl  |
218+-------+-----------------+------+-----------+
219| MOSI  | spi2_mosi       | SDA  | i2c2_sda  |
220+-------+-----------------+------+-----------+
221
222.. note::
223    ADC VIN6 is available through the on-board ADC and is
224    read though SPI0 using SPI chip select 1.
225
226Arduino
227=======
228
229The ARC HSDK4xD provides an Arduino shield interface. Figure below shows the relevant
230function assignments. The Arduino shield interface is compatible with the Arduino UNO
231R3 with the following exceptions: 5 Volt shields are not supported, the IOREF voltage on
232the ARC HSDK4xD board is fixed to 3V3. Note that the ICSP header is also not available. Most
233shields do not require this ICSP header as the SPI master interface on this ICSP header
234is also available on the ``IO10`` to ``IO13`` pins.
235
236.. image:: arduino_shield_interface.jpg
237   :align: center
238   :alt: arduino shield interface
239
240Table below shows the pin assignment on the I/O Multiplexer. Multiplexing is controlled by software
241using the ``CREG_GPIO_MUX`` register (see Pinmux ). After a reset, all ports are configured as GPIO inputs.
242
243+-------+------------+-----------------+------------+
244| Pin   | I/O-1      | I/O-2           | I/O-3      |
245+-------+------------+-----------------+------------+
246| AD0   | ADC VIN0*  | GPX_port0_bit2  | -          |
247+-------+------------+-----------------+------------+
248| AD1   | ADC VIN1*  | GPX_port0_bit3  | -          |
249+-------+------------+-----------------+------------+
250| AD2   | ADC VIN2*  | GPX_port0_bit4  | -          |
251+-------+------------+-----------------+------------+
252| AD3   | ADC VIN3*  | GPX_port0_bit5  | -          |
253+-------+------------+-----------------+------------+
254| AD4   | ADC VIN4*  | gpio[18]        | i2c2_sda   |
255+-------+------------+-----------------+------------+
256| AD5   | ADC VIN5*  | gpio[19]        | i2c2_scl   |
257+-------+------------+-----------------+------------+
258| IO0   | gpio[23]   | uart2_rxd       | -          |
259+-------+------------+-----------------+------------+
260| IO1   | gpio[22]   | uart2_txd       | -          |
261+-------+------------+-----------------+------------+
262| IO2   | gpio[16]   | -               | -          |
263+-------+------------+-----------------+------------+
264| IO3   | gpio[17]   | pwm_ch[5]       | -          |
265+-------+------------+-----------------+------------+
266| IO4   | gpio[11]   | -               |            |
267+-------+------------+-----------------+------------+
268| IO5   | gpio[9]    | pwm_ch[4]       | -          |
269+-------+------------+-----------------+------------+
270| IO6   | gpio[21]   | pwm_ch[3]       | -          |
271+-------+------------+-----------------+------------+
272| IO7   | gpio[20]   | -               | -          |
273+-------+------------+-----------------+------------+
274| IO8   | gpio[10]   | -               | -          |
275+-------+------------+-----------------+------------+
276| IO9   | gpio[8]    | pwm_ch[2]       | -          |
277+-------+------------+-----------------+------------+
278| IO10  | gpio[12]   | pwm_ch[0]       | spi2_cs[1] |
279+-------+------------+-----------------+------------+
280| IO11  | gpio[13]   | pwm_ch[6]       | spi2_mosi  |
281+-------+------------+-----------------+------------+
282| IO12  | gpio[14]   | -               | spi2_miso  |
283+-------+------------+-----------------+------------+
284| IO13  | gpio[15]   | -               | spi2_clk   |
285+-------+------------+-----------------+------------+
286
287I/O expander
288============
289
290The ARC HSDK4xD board includes a CY8C9520A I/O expander from `Cypress CY8C9520A
291<https://www.cypress.com/file/37971/download>`__. The I/O
292expander offers additional GPIO signals and board control signals and can be accessed
293through the on-board I2C bus, we have implemented a basic driver for it.
294Tables below shows an overview of relevant I/O signals.
295
296+------------+---------------------------------------------+
297| Pins       | Usage                                       |
298+------------+---------------------------------------------+
299| port0_bit0 | RS9113 Bluetooth I2S RX enable (active low) |
300+------------+---------------------------------------------+
301| port0_bit1 | mikroBUS Reset (active low)                 |
302+------------+---------------------------------------------+
303| port0_bit2 | GPIO for Arduino AD0                        |
304+------------+---------------------------------------------+
305| port0_bit3 | GPIO for Arduino AD1                        |
306+------------+---------------------------------------------+
307| port0_bit4 | GPIO for Arduino AD2                        |
308+------------+---------------------------------------------+
309| port0_bit5 | GPIO for Arduino AD3                        |
310+------------+---------------------------------------------+
311| port1_bit4 | On-board user LED0                          |
312+------------+---------------------------------------------+
313| port1_bit5 | On-board user LED1                          |
314+------------+---------------------------------------------+
315| port1_bit6 | On-board user LED2                          |
316+------------+---------------------------------------------+
317| port1_bit7 | On-board user LED3                          |
318+------------+---------------------------------------------+
319
320On-board user LEDS
321==================
322
323The ARC HSDK4xD includes 4 user LEDs(active high), which can be controlled through the I/O expander pins.
324
325+-------+-----------------+
326| LEDs  | PINs            |
327+-------+-----------------+
328| LED0  | GPX_port1_bit4  |
329+-------+-----------------+
330| LED1  | GPX_port1_bit5  |
331+-------+-----------------+
332| LED2  | GPX_port1_bit6  |
333+-------+-----------------+
334| LED3  | GPX_port1_bit7  |
335+-------+-----------------+
336
337For hardware feature details, refer to : `Designware HS4x/HS4xD Development Kit website
338<https://www.synopsys.com/dw/ipdir.php?ds=arc-hs-development-kit>`__.
339
340Programming and Debugging
341*************************
342
343Required Hardware and Software
344==============================
345
346To use Zephyr RTOS applications on the HS4x/HS4xD Development Kit board, a few
347additional pieces of hardware are required.
348
349* A micro USB cable provides USB-JTAG debug and USB-UART communication
350  to the board
351
352* A universal switching power adaptor (110-240V
353  AC to 12V DC), provided in the package, provides power to the board.
354
355* :ref:`The Zephyr SDK <toolchain_zephyr_sdk>`
356
357* Terminal emulator software for use with the USB-UART. Suggestion:
358  `Putty Website`_.
359
360* (optional) A collection of Pmods, Arduino modules, or Mikro modules.
361  See `Digilent Pmod Modules`_ or develop your custom interfaces to attach
362  to the Pmod connector.
363
364Set up the ARC HS4x/HS4xD Development Kit
365=========================================
366
367To run Zephyr application on ARC HS4x/HS4xD Development Kit, you need to
368set up the board correctly.
369
370* Connect the digilent USB cable from your host to the board.
371
372* Connect the 12V DC power supply to your board
373
374Set up Zephyr Software
375======================
376
377Building Sample Applications
378==============================
379
380You can try many of the :zephyr:code-sample-category:`sample applications and demos <samples>`.
381We'll use :zephyr:code-sample:`hello_world`, found in :zephyr_file:`samples/hello_world` as an example.
382
383Configuring
384-----------
385
386You may need to write a ``prj.conf`` file if the sample doesn't have one.
387Next, you can use the menuconfig rule to configure the target. By specifying
388``hsdk4xd`` as the board configuration, you can select the ARC HS4x/HS4xD Development
389Kit board support for Zephyr.
390
391.. zephyr-app-commands::
392   :board: hsdk4xd
393   :zephyr-app: samples/hello_world
394   :goals: menuconfig
395
396
397Building
398--------
399
400You can build an application in the usual way.  Refer to
401:ref:`build_an_application` for more details. Here is an example for
402:zephyr:code-sample:`hello_world`.
403
404.. zephyr-app-commands::
405   :board: hsdk4xd
406   :zephyr-app: samples/hello_world
407   :maybe-skip-config:
408   :goals: build
409
410
411Connecting Serial Output
412=========================
413
414In the default configuration, Zephyr's HS4x/HS4xD Development Kit images support
415serial output via the USB-UART on the board.  To enable serial output:
416
417* Open a serial port emulator (i.e. on Linux minicom, putty, screen, etc)
418
419* Specify the tty driver name, for example, on Linux this may be
420  :file:`/dev/ttyUSB0`
421
422* Set the communication settings to:
423
424
425========= =====
426Parameter Value
427========= =====
428Baud:     115200
429Data:     8 bits
430Parity:    None
431Stopbits:  1
432========= =====
433
434Debugging
435==========
436
437Using the latest version of Zephyr SDK(>=0.15.2), you can debug and
438flash (run) HS4x/HS4xD Development Kit directly.
439
440One option is to build and debug the application using the usual
441Zephyr build system commands.
442
443.. zephyr-app-commands::
444   :board: hsdk4xd
445   :app: <my app>
446   :goals: debug
447
448At this point you can do your normal debug session. Set breakpoints and then
449:kbd:`c` to continue into the program.
450
451The other option is to launch a debug server, as follows.
452
453.. zephyr-app-commands::
454   :board: hsdk4xd
455   :app: <my app>
456   :goals: debugserver
457
458Then connect to the debug server at the HS4x/HS4xD Development Kit from a second
459console, from the build directory containing the output :file:`zephyr.elf`.
460
461.. code-block:: console
462
463   $ cd <my app>
464   $ $ZEPHYR_SDK_INSTALL_DIR/arc-zephyr-elf/arc-zephyr-elf-gdb zephyr.elf
465   (gdb) target remote localhost:3333
466   (gdb) load
467   (gdb) b main
468   (gdb) c
469
470Flashing
471========
472
473If you just want to download the application to the HS4x/HS4xD Development Kit's DDR
474and run, you can do so in the usual way.
475
476.. zephyr-app-commands::
477   :board: hsdk4xd
478   :app: <my app>
479   :goals: flash
480
481This command still uses openocd and gdb to load the application elf file to
482HS4x/HS4xD Development Kit, but it will load the application and immediately run. If
483power is removed, the application will be lost since it wasn't written to flash.
484
485Most of the time you will not be flashing your program but will instead debug
486it using openocd and gdb. The program can be download via the USB cable into
487the code and data memories.
488
489The HS4x/HS4xD Development Kit also supports flashing the Zephyr application
490with the U-Boot bootloader, a powerful and flexible tool for loading
491an executable from different sources and running it on the target platform.
492
493The U-Boot implementation for the HS4x/HS4xD Development Kit was further extended with
494additional functionality that allows users to better manage the broad
495configurability of the HS4x/HS4xD Development Kit
496
497When you are ready to deploy the program so that it boots up automatically on
498reset or power-up, you can follow the steps to place the program on SD card.
499
500For details, see: `Uboot-HS4x/HS4xD-Command-Reference
501<https://github.com/foss-for-synopsys-dwc-arc-processors/linux/wiki/Uboot-HSDK-4xD-Command-Reference#launching-baremetal-application-on-hsdk-4xd>`__
502
503Supported peripheral
504====================
505
506The following list indicates the state of HS4x/HS4xD Development Kit peripherals’ support
507
508+------------+---------+
509| Peripheral | Support |
510+------------+---------+
511| ADC        | No      |
512+------------+---------+
513| Bluetooth  | No      |
514+------------+---------+
515| Ethernet   | No      |
516+------------+---------+
517| GPIO       | No      |
518+------------+---------+
519| GPU        | No      |
520+------------+---------+
521| HDMI       | No      |
522+------------+---------+
523| I2C        | No      |
524+------------+---------+
525| I2S        | No      |
526+------------+---------+
527| PWM        | No      |
528+------------+---------+
529| SDIO       | No      |
530+------------+---------+
531| SPI        | No      |
532+------------+---------+
533| UART       | Yes     |
534+------------+---------+
535| USB        | No      |
536+------------+---------+
537| WiFi       | No      |
538+------------+---------+
539
540References
541**********
542
543.. target-notes::
544
545.. _embARC website: https://www.embarc.org
546
547.. _Designware HS Development Kit website: https://www.synopsys.com/dw/ipdir.php?ds=arc-hs-development-kit
548
549.. _Digilent Pmod Modules: http://store.digilentinc.com/pmod-modules
550
551.. _Putty website: http://www.putty.org
552