1.. _em_starterkit:
2
3DesignWare(R) ARC(R) EM Starter Kit
4###################################
5
6Overview
7********
8
9The DesignWare(R) ARC(R) EM Starter Kit is a low-cost, versatile solution
10enabling rapid software development and software debugging, and profiling
11for the ARC EM Family of processors. The EM Family includes the EM4, EM6,
12EM5D, EM7D, EM9D, and EM11D cores. The Zephyr RTOS can be used with the
13EM Starter Kit.
14
15.. image:: em_starterkit.jpg
16   :align: center
17   :alt: DesignWare(R) ARC(R) EM Starter Kit (synopsys.com)
18
19The ARC EM Starter Kit consists of a hardware platform, including pre-installed
20FPGA images of different ARC EM processor configurations with peripherals.
21Documentation for this board can be found at `embARC website`_.
22
23See also this URL for details about the board:
24`Designware ARC EM Starter Kit website`_ .
25
26The latest version of EM Starter Kit is 2.3, developer can upgrade from
272.0/2.1/2.2 to 2.3 using latest firmware.
28The default configuration for EM Starter Kit boards can be found in
29:zephyr_file:`boards/snps/em_starterkit/em_starterkit_defconfig`.
30
31The default SoC for this board supported in Zephyr is the EM9D.
32This configuration is a Harvard Architecture, with a separate
33instruction bus and data bus. Instruction memory is called ICCM
34and data memory is called DCCM. The configuration file for EM9D
35is found in :zephyr_file:`soc/snps/emsk/Kconfig.defconfig.em9d`.
36
37If you have a larger program, you can select the EM7D or EM11D, which gives
38access to 128KB DRAM with i-cache and d-cache. The configuration file for EM7D
39is found in :zephyr_file:`soc/snps/emsk/Kconfig.defconfig.em7d` and EM11D is
40found in :zephyr_file:`soc/snps/emsk/Kconfig.defconfig.em11d`.
41
42
43Hardware
44********
45Board Layout
46============
47
48The ARC EM Starter Kit main board has 6 Pmod connectors. These can be configured
49to support attachment of GPIO, I2C, UART or SPI devices.
50
51The board also has a 16MB SPI-FLASH and an SDCard for storage. There are 9 LEDs,
523 buttons, and 4 dip switches that can be used with GPIO.
53
54The Xilinx Spartan(R)-6 LX150 FPGA can auto-load one of 3 FPGA SoC bit files
55which have the EM7D, EM9D, or EM11D SoC.
56
57Documentation and general information for the board can be found at the
58`embARC website`_, which also includes some free sample software.
59
60
61Supported Firmware Versions
62===========================
63
64The EM Starter Kit has different versions, such as 1.0, 1.1, 2.0, 2.1,
652.2 and 2.3.
66In Zephyr, only firmware versions 2.2 and 2.3 are supported.
67
68Supported Features
69==================
70
71The Zephyr kernel supports multiple hardware features on the EM Starter Kit
72through the use of device drivers.
73
74The EM Starter Kit supports 6 Digilent Pmod(TM) Interfaces, which enables the
75use of a large variety of pluggable modules for storage, communications,
76sensors, displays, etc. With the Pmod interface, you can prototype your
77applications using the Zephyr RTOS.
78
79The table below shows which drivers are supported and which functionality can
80be found on which architectures:
81
82+-----------+------------+-----+-------+-----------------------+
83| Interface | Controller |EM9D | EM11D | Driver/Component      |
84+===========+============+=====+=======+=======================+
85| INT       | on-chip    | Y   | Y     | interrupt_controller  |
86+-----------+------------+-----+-------+-----------------------+
87| UART      | usb +      | Y   | Y     | serial port-polling;  |
88|           | 2 Pmods    |     |       | serial port-interrupt |
89+-----------+------------+-----+-------+-----------------------+
90| SPI       | 2 Pmods    | Y   | Y     | spi                   |
91+-----------+------------+-----+-------+-----------------------+
92| ADC       | n/a        | N   | N     | adc (can add via Pmod)|
93+-----------+------------+-----+-------+-----------------------+
94| I2C       | 2 Pmods    | Y   | Y     | i2c                   |
95+-----------+------------+-----+-------+-----------------------+
96| GPIO      | 6 Pmods    | Y   | Y     | gpio                  |
97+-----------+------------+-----+-------+-----------------------+
98| PWM       | n/a        | N   | N     | pwm                   |
99+-----------+------------+-----+-------+-----------------------+
100
101The board has 3 (debounced and interrupting) buttons for use with GPIO, 4 dip
102switches, 9 LEDs, SDCard on SPI, and a 16MB SPI-Flash memory.
103
104The SPI-FLASH driver is supported with sample, which can be found in
105``samples/drivers/spi_flash``.
106
107The SPI-Flash also holds 3 (or 4) separate FPGA CPU bit files, selectable via
108dip switch.
109
110The SPI-Flash is also programmed with a bootloader. The bootloader can copy a
111program image from SPI-Flash into executable memory. Zephyr initialization will
112copy the initialized data section to the data memory if CONFIG_XIP is used.
113
114
115Programming and Debugging
116*************************
117
118Required Hardware and Software
119==============================
120
121To use Zephyr RTOS applications on the EM Starter Kit board, a few additional
122pieces of hardware are required.
123
124* USB Cable (delivered as part of the ARC EM Starter Kit)
125
126* The USB cable provides power to the board; however, if the board is to run
127  standalone, the universal switching power adaptor (110-240V AC to 5V DC),
128  provided in the package, can be used to power the board.
129
130* :ref:`The Zephyr SDK <toolchain_zephyr_sdk>`
131
132* Terminal emulator software for use with the USB-UART. Suggestion:
133  `Putty Website`_.
134
135* (optional) A collection of Pmods.
136  See `Digilent Pmod Modules`_ or develop your custom interfaces to attach
137  to the Pmod connector.
138
139Set up the ARC EM Starter Kit
140=============================
141
142To run Zephyr application on correct arc core of EM Starter Kit, you need to
143setup the board correctly.
144
145* Connect the digilent usb cable from your host to the board.
146
147* Connect the 5V DC power supply to your board.
148
149* Select the core configuration of the board by choosing correct dip switch
150  SW1 settings, then press then FPGA configure button located above the letter
151  'C' of the ARC logo on the board.
152
153* Then the board will be reconfigured with selected core configuration, you
154  can download and debug Zephyr application now.
155
156* If you want to know more about how to use this board, you can take a look
157  at the `ARC EM Starter Kit User Guide`_.
158
159Set up Zephyr Software
160======================
161
162Since there are different firmware versions of EM Starter Kit, you need to
163choose the proper firmware version supported in Zephyr.
164
165Three different configurations exist for this board:
166
167* EM7D: em_starterkit_em7d_defconfig
168* EM9D: em_starterkit_defconfig
169* EM11D: em_starterkit_em11d_defconfig
170
171
172Building Sample Applications
173==============================
174
175You can try many of the sample applications or tests, but let us discuss
176the one called :ref:`hello_world`.
177It is found in :zephyr_file:`samples/hello_world`.
178
179Configuring
180-----------
181
182You may need to write a prj_arc.conf file if the sample doesn't have one.
183Next, you can use the menuconfig rule to configure the target. By
184specifying ``em_starterkit`` as the board configuration, you can select the ARC
185EM Starter Kit board support for Zephyr.
186
187.. zephyr-app-commands::
188   :board: em_starterkit
189   :zephyr-app: samples/hello_world
190   :goals: menuconfig
191
192On this board you will also need to consider the "ARC SoC Selection" and set
193it either to EM9D or EM11D. To boot up the EM9D on the board, all dip
194switches should be UP except for switch 1. Other configuration choices
195are made in the normal way. To boot up the EM11D on the board,
196all dip switches should be UP except for switch 2. Next press the button
197above the letter C in the "ARC" logo on the silkscreen.
198
199Building
200--------
201
202You can build application in the usual way.  Refer to
203:ref:`build_an_application` for more details. Here is an example for
204:ref:`hello_world`.
205
206.. zephyr-app-commands::
207   :board: em_starterkit
208   :zephyr-app: samples/hello_world
209   :maybe-skip-config:
210   :goals: build
211
212Connecting Serial Output
213=========================
214
215In the default configuration, Zephyr's EM Starter Kit images support
216serial output via the UART1 on the board.  To enable serial output:
217
218On your development environment, you will need to:
219
220* Open a serial port emulator (i.e. on Linux minicom, putty, screen, etc)
221* Specify the tty driver name, for example, on Linux this may be :file:`/dev/ttyUSB1`
222* Set the communication settings to:
223
224
225========= =====
226Parameter Value
227========= =====
228Baud:     115200
229Data:     8 bits
230Parity:    None
231Stopbits:  1
232========= =====
233
234Debugging
235==========
236
237Using the latest version of Zephyr SDK(>=0.9), you can debug and flash
238EM Starterkit directly.
239
240One option is to build and debug the application using the usual
241Zephyr build system commands.
242
243.. zephyr-app-commands::
244   :board: em_starterkit
245   :app: <my app>
246   :goals: debug
247
248At this point you can do your normal debug session. Set breakpoints and then
249'c' to continue into the program.
250
251The other option is to launch a debug server, as follows.
252
253.. zephyr-app-commands::
254   :board: em_starterkit
255   :app: <my app>
256   :goals: debugserver
257
258Then connect to the debug server at the EM Starter Kit from a second
259console, from the build directory containing the output :file:`zephyr.elf`.
260
261.. code-block:: console
262
263   $ cd <my app>
264   $ $ZEPHYR_SDK_INSTALL_DIR/arc-zephyr-elf/bin/arc-zephyr-elf-gdb zephyr.elf
265   (gdb) target remote localhost:3333
266   (gdb) load
267   (gdb) b main
268   (gdb) c
269
270Flashing
271========
272
273If you just want to download the application to the EM Starter Kit's CCM
274or DDR and run, you can do so in the usual way.
275
276.. zephyr-app-commands::
277   :board: em_starterkit
278   :goals: flash
279
280This command still uses openocd and gdb to load application elf file
281to EM Starter Kit, but it will load application and then run immediately.
282If power is lost, the application will also lost due to power loss.
283
284Most of the time you will not be flashing your program but will instead
285debug it using openocd and gdb. The program can be download via the USB
286cable into the code and data memories.
287
288When you are ready to deploy the program so that it boots up automatically
289on reset or power-up, you can follow the steps to place the program on
290SPI-FLASH.
291
292For instructions on how to write your program to SPI-FLASH,
293refer to the documentation on the ARC EM Starter Kit at the
294`embARC website`_, which includes instructions for how to place an
295executable image onto the SPI-FLASH in such a way that it is understood
296by the bootloader.
297
298Release Notes
299*************
300
301The following is a list of TODO items:
302
303* ``GH-2647``: Zephyr needs i-cache API (all targets)
304* ``GH-2230``: Zephyr ARC port doesn't yet support nested regular interrupts.
305* pinmux driver: Possibly it can be written to configure PMods too.
306
307References
308**********
309
310.. _embARC website: https://www.embarc.org
311
312.. _Designware ARC EM Starter Kit website: https://www.synopsys.com/dw/ipdir.php?ds=arc_em_starter_kit
313
314.. _Digilent Pmod Modules: http://store.digilentinc.com/pmod-modules
315
316.. _Putty website: http://www.putty.org
317
318.. _ARC EM Starter Kit User Guide: https://www.synopsys.com/dw/ipdir.php?ds=arc_em_starter_kit
319