1 |
786 |
skrzyp |
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
Actel Smartfusion Board Support
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
Actel Smartfusion Board Support
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
Overview
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
Overview
|
52 |
|
|
Actel Smartfusion Board Support
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
Overview
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
The Actel Smartfusion evaluation kit uses the A2F200 microcontroller from the
|
59 |
|
|
Actel smartfusion family. The SmartFusion devices are a mix of programmable
|
60 |
|
|
logic around a ARM cortex-M3 based processor. The SmartFusion has 3 variants:
|
61 |
|
|
A2F060, A2F200, A2F500. The main difference between parts are the amount of
|
62 |
|
|
RAM, FLASH as well as programmable logic. In addition, the A2F060 does not
|
63 |
|
|
include the Ethernet controller peripheral.
|
64 |
|
|
The A2F200 device includes 256KB of internal FLASH (also called Embedded
|
65 |
|
|
Non-volatile Memory, ENVM) and 64KB of internal SRAM.
|
66 |
|
|
The device has various peripherals such as UART, I2C, SPI, Ethernet MAC, ADC or
|
67 |
|
|
DAC as well as the FPGA fabric.
|
68 |
|
|
The kit features an OLED graphical display and UART0 is accessible via the
|
69 |
|
|
on-board USB to UART converter. The kit also includes a serial flash, the Atmel
|
70 |
|
|
AT25DF641 part (8MB memory).
|
71 |
|
|
The FPGA fabric uses a non-volatile technology thus removing the
|
72 |
|
|
need of additional flash memory for storing the FPGA programming matrix.
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
The eCos port targets standalone ROM application. The eCos device drivers include
|
77 |
|
|
support for the I2C and SPI buses as well as UART and Ethernet Controller. No
|
78 |
|
|
device driver is currently available for the ADC/DAC or the In-Application
|
79 |
|
|
Programming feature that allows the application to re-program the FLASH or the
|
80 |
|
|
FPGA fabric.
|
81 |
|
|
The Smartfusion (A2Fxxx) HAL includes a timer test application and the A2F200 evaluation
|
82 |
|
|
board flash device package includes a test application for the SPI serial flash.
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
Tools
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
For compilation, the official eCos ARM toolchain is required (gcc version 4.3.2).
|
92 |
|
|
For debugging, while the board offers a JTAG interface, the HAL was developed using
|
93 |
|
|
the SoftConsole IDE supplied from Actel. SoftConsole is an Eclipse based IDE
|
94 |
|
|
installed along with the CodeSourcery ARM compiler / debugger. The ARM GDB and Sprite
|
95 |
|
|
utilities from CodeSourcery are used to debug the target. The target includes an on-board
|
96 |
|
|
debugger and is connected to the host via a USB cable. GDB interfaces the
|
97 |
|
|
on-board debugger through the Actel flashpro driver. Detailed example of a debugging
|
98 |
|
|
session is described later in this chapter.
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
HAL and Device Drivers
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
HAL
|
114 |
|
|
Actel HAL and Device Drivers
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
Clocking
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
The internal clock network of the Smarfusion devices includes a large amount of possible
|
122 |
|
|
configuration combination. The network has 3 different input clocks (CLKA, CLKB and CLKC),
|
123 |
|
|
each of them can be connected to a different clock source such as the main oscillator, the
|
124 |
|
|
RC oscillator, the FPGA fabric or the dedicated single-ended or differential IO. The clock
|
125 |
|
|
network has an internal PLL and 3 global output clocks (CLKGA, CLKGB and CLKGC). The cortex-M3,
|
126 |
|
|
digital and analog peripherals clocks are derived either from CLKGA or CLKGC through the
|
127 |
|
|
NGMUX.
|
128 |
|
|
Due to the large amount of configuration parameters, it is recommended to use the Actel MSS
|
129 |
|
|
configuration tool to setup the clock network and let the system boot handle the configuration.
|
130 |
|
|
However, the eCos HAL includes all the required options to setup the clock network. Note that
|
131 |
|
|
only a limited subset of combinations have been tested.
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
SPI bus
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
The Actel AF2xxx microcontroller family has 2 SPI buses available. Each SPI bus has
|
142 |
|
|
a certain number of slave select line (called SPI_x_SSx) that are directly driven by
|
143 |
|
|
the SPI controller.
|
144 |
|
|
The first SPI bus has 4 slave select lines available (SPI_0_SS0 to SPI_0_SS3) while the
|
145 |
|
|
second bus has 8 of them (SPI_1_SS0 to SPI_1_SS7). In addition, the eCos SPI driver allows
|
146 |
|
|
using the GPIO of the microcontroller as slave select lines which is in some cases required.
|
147 |
|
|
In the rest of this chapter, the former case is called SPI controlled slave select while
|
148 |
|
|
the later is called GPIO controlled slave select
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
NOTE: The SPI_x_SSx microcontroller dedicated pins can be used as GPIO, thus, it is possible
|
153 |
|
|
to use SPI_0_SS0 as slave select either in SPI or GPIO controlled mode. This is true for all
|
154 |
|
|
SPI_x_SSx pins.
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
New SPI devices are instantiated using the following macro:
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
#include
|
162 |
|
|
#include
|
163 |
|
|
|
164 |
|
|
#define CYG_DEVS_SPI_CORTEXM_A2FXXX_DEVICE( \
|
165 |
|
|
_name_, _bus_, _csnum_, _csgpio_, _proto_, _clpol_, \
|
166 |
|
|
_clpha_, _brate_, _csup_dly_, _csdw_dly_, _trbt_dly_)
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
_name_ is the name of the SPI device. This will be used to
|
170 |
|
|
reference a data structure of type cyg_spi_device
|
171 |
|
|
which can be passed to the SPI driver API without
|
172 |
|
|
needing a cast.
|
173 |
|
|
_bus_ is the bus number to which this device is attached
|
174 |
|
|
(1 or 2).
|
175 |
|
|
_csgpio_ when set to false:
|
176 |
|
|
- the device slave select line is controlled by the
|
177 |
|
|
SPI controller.
|
178 |
|
|
when set to true:
|
179 |
|
|
- the device slave select line is a GPIO of the
|
180 |
|
|
processor controlled by the SPI driver.
|
181 |
|
|
_csnum_ when _csgpio_ is set to false :
|
182 |
|
|
- is the slave select line used for this device,
|
183 |
|
|
numbered from 0.
|
184 |
|
|
when _csgpio_ is set to true :
|
185 |
|
|
- is the GPIO number used to drive the device slave
|
186 |
|
|
select line.
|
187 |
|
|
_proto_ is the SPI bus protocol:
|
188 |
|
|
|
189 |
|
|
valid in this mode)
|
190 |
|
|
1 -> National Semiconductor MICROWIRE Mode
|
191 |
|
|
2 -> Texas Instruments (TI) Synchronous Serial Mode
|
192 |
|
|
_clpol_ is the SPI bus clock polarity used by the device
|
193 |
|
|
(valid only for Motorola SPI Protocol).
|
194 |
|
|
_clpha_ is the SPI bus clock phase used by the device
|
195 |
|
|
(valid only for Motorola SPI Protocol).
|
196 |
|
|
_brate_ is the SPI bus clock baud rate used by the device,
|
197 |
|
|
measured in Hz.
|
198 |
|
|
_csup_dly_ is the minimum delay between slave select assert and
|
199 |
|
|
transfer start, measured in microseconds.
|
200 |
|
|
_csdw_dly_ is the minimum delay between transfer end and slave
|
201 |
|
|
select deassert, measured in microseconds.
|
202 |
|
|
_trbt_dly_ is the minimum delay between consecutive transfers.
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
NOTE: _csup_dly_ and _csdw_dly_ are only valid when GPIOs are configured to drive the
|
207 |
|
|
slave select line. When the SPI controller drives the slave select line itself, the user
|
208 |
|
|
has no control over the exact timing.
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
The Actel Smartfusion board features a SPI serial flash (AT25DF641) attached
|
213 |
|
|
to the first SPI bus. The SPI flash is connected to the SPI_0_SS0 line, however, to suit
|
214 |
|
|
eCos SPI transaction, the line is configured as a general purpose IO and controlled by the
|
215 |
|
|
SPI driver.
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
The following section describes how the SPI serial flash is declared. The code is located
|
220 |
|
|
in devs/fash/cortexm/a2fxxx/a2f200_eval/flash_a2f200_eval.c. The required includes are:
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
#include
|
225 |
|
|
#include
|
226 |
|
|
#include
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
The device is defined to be connected on SPI bus 1, using GPIO 19 for slave select.
|
231 |
|
|
The Motorola protocol (mode 0) is selected with a bus clock speed of 25MHz.
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
CYG_DEVS_SPI_CORTEXM_A2FXXX_DEVICE (
|
236 |
|
|
at25dfxxx_spi_device, 1, 19, true, A2FXXX_SPI_MOTOROLA, 0, 0, 25000000, 1, 1, 1
|
237 |
|
|
);
|
238 |
|
|
|
239 |
|
|
_bus_ = 1
|
240 |
|
|
_csgpio_ = true -> use GPIO
|
241 |
|
|
_csgpio_ = 19 -> GPIO19 also SPI_0_SS0
|
242 |
|
|
_proto_ = Motorola Protocol
|
243 |
|
|
_clpol_ = 0
|
244 |
|
|
_clpha_ = 0
|
245 |
|
|
_brate_ = 25MHz
|
246 |
|
|
_csup_dly = 1us
|
247 |
|
|
_csdw_dly_ = 1us
|
248 |
|
|
_trbt_dly_ = 1us
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
From the default CDL, SPI bus 1 uses the DMA channel 0 for outbound and channel 1 for inbound
|
253 |
|
|
transfer. SPI bus 2 uses DMA channel 2 and 3 respectively. The DMA channel number are selected
|
254 |
|
|
with:
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
CYGNUM_DEVS_SPI_CORTEXM_A2FXXX_BUS1_TX_DMA
|
259 |
|
|
CYGNUM_DEVS_SPI_CORTEXM_A2FXXX_BUS1_RX_DMA
|
260 |
|
|
and
|
261 |
|
|
CYGNUM_DEVS_SPI_CORTEXM_A2FXXX_BUS2_TX_DMA
|
262 |
|
|
CYGNUM_DEVS_SPI_CORTEXM_A2FXXX_BUS2_RX_DMA
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
I2C bus
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
The Actel microcontroller family has 2 I2C buses available and the Smartfusion evaluation kit
|
273 |
|
|
feature an OLED display connected to the first I2C bus with address 0x3C.
|
274 |
|
|
The I2C driver is tested using the OLED display, however, the OLED driver is not part of the
|
275 |
|
|
eCos HAL. A new I2C bus is instantiated using the following macro:
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
#define CYG_A2FXXX_I2C_BUS( \
|
280 |
|
|
_name_, \
|
281 |
|
|
_init_fn_, \
|
282 |
|
|
_base_, \
|
283 |
|
|
_base_bb_, \
|
284 |
|
|
_periph_, \
|
285 |
|
|
_isr_vec_, \
|
286 |
|
|
_isr_pri_) \
|
287 |
|
|
|
288 |
|
|
_name_ is the name of the SPI device.
|
289 |
|
|
_init_fn_ is the I2C initialization function to be called by the C constructor.
|
290 |
|
|
_base_ is the base address of the I2C peripheral.
|
291 |
|
|
_base_bb_ is the Bit-Band base address of the I2C peripheral.
|
292 |
|
|
_periph_ is the peripheral bit identifier for reset/release operation.
|
293 |
|
|
_isr_vec_ is the peripheral interrupt vector number.
|
294 |
|
|
_isr_pri_ is the interrupt priority.
|
295 |
|
|
|
296 |
|
|
|
297 |
|
|
|
298 |
|
|
The following section describes how the I2C bus 0 is declared. The code is located in
|
299 |
|
|
hal/cortexm/a2fxxx/a2f200_eval/current/src/platform_i2c.c. The required includes are:
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
#include
|
304 |
|
|
#include
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
The first part declares the I2C bus 0 and the second part attached a I2C device with address
|
309 |
|
|
0x3C to the bus.
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
CYG_A2FXXX_I2C_BUS(hal_a2fxxx_i2c0_bus,
|
314 |
|
|
a2fxxx_i2c0_init,
|
315 |
|
|
CYGHWR_HAL_A2FXXX_I2C0,
|
316 |
|
|
CYGHWR_HAL_A2FXXX_I2C0_BB,
|
317 |
|
|
CYGHWR_HAL_A2FXXX_SC_CLR_SOFTRST_CR_I2C0,
|
318 |
|
|
CYGNUM_HAL_INTERRUPT_I2C0_0,
|
319 |
|
|
0x60);
|
320 |
|
|
|
321 |
|
|
_name_ = hal_a2fxxx_i2c0_bus
|
322 |
|
|
_init_fn_ = a2fxxx_i2c0_init
|
323 |
|
|
_base_ = CYGHWR_HAL_A2FXXX_I2C0 // Base address
|
324 |
|
|
_base_bb_ = CYGHWR_HAL_A2FXXX_I2C0_BB // for bit-band access
|
325 |
|
|
_periph_ = CYGHWR_HAL_A2FXXX_SC_CLR_SOFTRST_CR_I2C0
|
326 |
|
|
_isr_vec_ = CYGNUM_HAL_INTERRUPT_I2C0_0
|
327 |
|
|
_isr_pri_ = 0x60
|
328 |
|
|
|
329 |
|
|
CYG_I2C_DEVICE(i2c_a2fxxx_oled,
|
330 |
|
|
&hal_a2fxxx_i2c0_bus,
|
331 |
|
|
0x3c,
|
332 |
|
|
0,
|
333 |
|
|
CYG_I2C_DEFAULT_DELAY);
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
Ethernet Controller
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
The Ethernet MAC layer of the Actel device is compliant with the RMII 10/100Mbps specification.
|
344 |
|
|
The development kit interface the DP83848 PHY from National Semiconductor.
|
345 |
|
|
|
346 |
|
|
|
347 |
|
|
NOTE: To use the Ethernet interface of the evaluation kit, the FPGA fabric must be programmed.
|
348 |
|
|
The Ethernet PHY input clock (50MHz) is connected to an IO only accessible from the fabric. It
|
349 |
|
|
is therefore required to route the MAC_CLK from the clock network to the IO (T6).
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
Some of the driver configuration parameters accessible from the CDL file are:
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
|
356 |
|
|
|
357 |
|
|
CYGSEM_DEVS_ETH_CORTEXM_A2FXXX_CHATTER
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
Selecting this option will cause the Ethernet driver to print status
|
361 |
|
|
messages as various Ethernet operations are undertaken. This is option
|
362 |
|
|
is designed to help debugging the Ethernet driver.
|
363 |
|
|
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
CYGSEM_DEVS_ETH_CORTEXM_A2FXXX_PROMISCUOUS
|
369 |
|
|
|
370 |
|
|
|
371 |
|
|
Selecting this option will set the Ethernet MAC in promiscuous mode, all Ethernet
|
372 |
|
|
packets will be delivered to the application layer whether or not destinated to the
|
373 |
|
|
device.
|
374 |
|
|
|
375 |
|
|
|
376 |
|
|
|
377 |
|
|
|
378 |
|
|
|
379 |
|
|
CYGNUM_DEVS_ETH_CORTEXM_A2FXXX_BUFSIZE_TX
|
380 |
|
|
|
381 |
|
|
|
382 |
|
|
This option specifies the size of the internal transmit buffers used
|
383 |
|
|
for the Ethernet device.
|
384 |
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
CYGNUM_DEVS_ETH_CORTEXM_A2FXXX_BUFSIZE_RX
|
390 |
|
|
|
391 |
|
|
|
392 |
|
|
This option specifies the size of the internal receive buffers used
|
393 |
|
|
for the Ethernet device.
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
CYGNUM_DEVS_ETH_CORTEXM_A2FXXX_TxNUM
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
This option specifies the number of output buffer packets
|
403 |
|
|
to be used for the Ethernet device.
|
404 |
|
|
|
405 |
|
|
|
406 |
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
CYGNUM_DEVS_ETH_CORTEXM_A2FXXX_RxNUM
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
This option specifies the number of input buffer packets
|
413 |
|
|
to be used for the Ethernet device.
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
|
417 |
|
|
|
418 |
|
|
|
419 |
|
|
CYGSEM_DEVS_ETH_CORTEXM_A2FXXX_STATS
|
420 |
|
|
|
421 |
|
|
|
422 |
|
|
Selecting this option will cause the Ethernet driver to accumulate statistics
|
423 |
|
|
provided from the MAC layer.
|
424 |
|
|
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
Serial
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
The Actel A2Fxxx uses the 16x5x generic serial device driver. The driver is instantiaced through
|
437 |
|
|
the CYGPKG_IO_SERIAL_CORTEXM_A2FXXX serial package.
|
438 |
|
|
|
439 |
|
|
|
440 |
|
|
|
441 |
|
|
|
442 |
|
|
|
443 |
|
|
|
444 |
|
|
DMA
|
445 |
|
|
|
446 |
|
|
|
447 |
|
|
The eCos HAL offers some basics routines to configure and use the 8 DMA channels
|
448 |
|
|
available in the Smartfusion chips. It must be noted that all channels are sharing
|
449 |
|
|
the same interrupt. The current implementation limits the transfer size to byte
|
450 |
|
|
tranfer ( field TRANSFER_SIZE from the CHANNEL_x_CONTROL register ).
|
451 |
|
|
Currently only the SPI driver makes use of the DMA interface.
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
|
455 |
|
|
DMA channels are registered / released with a2fxxx_dma_ch_attach and
|
456 |
|
|
a2fxxx_dma_ch_detach respectively:
|
457 |
|
|
|
458 |
|
|
|
459 |
|
|
|
460 |
|
|
cyg_uint32
|
461 |
|
|
a2fxxx_dma_ch_attach(cyg_uint8 ch, cyg_ISR_t *isr, cyg_DSR_t *dsr, cyg_addrword_t data)
|
462 |
|
|
|
463 |
|
|
ch specify the DMA channel numbered from 0.
|
464 |
|
|
isr specify the interrupt ISR to call for this channel.
|
465 |
|
|
dsr specify the interrupt DSR to call for this channel.
|
466 |
|
|
data data argument passed to the ISR and DSR routine.
|
467 |
|
|
|
468 |
|
|
|
469 |
|
|
|
470 |
|
|
void
|
471 |
|
|
a2fxxx_dma_ch_detach (cyg_uint8 ch)
|
472 |
|
|
|
473 |
|
|
ch specify the DMA channel number from 0 to 7
|
474 |
|
|
|
475 |
|
|
|
476 |
|
|
|
477 |
|
|
|
478 |
|
|
DMA channels are configured with a2fxxx_dma_ch_setup :
|
479 |
|
|
|
480 |
|
|
|
481 |
|
|
|
482 |
|
|
cyg_uint32
|
483 |
|
|
a2fxxx_dma_ch_setup(cyg_uint8 ch, cyg_uint8 type, cyg_bool outbound,
|
484 |
|
|
cyg_uint8 src_incr, cyg_uint8 dst_incr, cyg_bool pri, cyg_uint8 wr_adj)
|
485 |
|
|
|
486 |
|
|
ch is the DMA channel numbered from 0.
|
487 |
|
|
type is the transfer type to be performed. For valid
|
488 |
|
|
values, check CYGHWR_HAL_A2FXXX_DMA_XFER(_x) in var_io.h.
|
489 |
|
|
outbound set to true for transfer out of memory, false for transfer
|
490 |
|
|
to memory
|
491 |
|
|
src_incr is the memory address increment step for the source. Valid
|
492 |
|
|
values are 0, 1, 2 and 4 byte(s). 0 can be used for DMA
|
493 |
|
|
transfer from peripheral FIFO for instance.
|
494 |
|
|
dst_incr is the memory address increment step for the destination.
|
495 |
|
|
Valid values are 0, 1, 2 and 4 byte(s). 0 can be used for
|
496 |
|
|
DMA transfer to peripheral FIFO for instance.
|
497 |
|
|
pri is the DMA channel priority (true = high , false = low)
|
498 |
|
|
wr_adj indicates the number of FCLK periods which the PDMA must wait
|
499 |
|
|
after completion of a read or write access to a peripheral
|
500 |
|
|
before evaluating the out-of-band status signals from that
|
501 |
|
|
peripheral for another transfer.
|
502 |
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
|
|
DMA transfer are initiated using a2fxxx_dma_xfer :
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
cyg_uint32
|
510 |
|
|
a2fxxx_dma_xfer (cyg_uint8 ch, cyg_bool polled, cyg_uint32 len, cyg_uint8 *src,
|
511 |
|
|
cyg_uint8 *dst)
|
512 |
|
|
|
513 |
|
|
ch is the DMA channel numbered from 0.
|
514 |
|
|
polled set to true to use the DMA channel in polling mode ( no
|
515 |
|
|
end of tranfer interrupt are raised ).
|
516 |
|
|
len select the length of the transfer ( in number of byte
|
517 |
|
|
transfered ).
|
518 |
|
|
src is the start address from which data is to be read during
|
519 |
|
|
the next DMA transfer cycle.
|
520 |
|
|
dst is the start address from which data is to be written during
|
521 |
|
|
the next DMA transfer cycle.
|
522 |
|
|
|
523 |
|
|
|
524 |
|
|
|
525 |
|
|
DMA interrupts are cleared with a2fxxx_dma_clear_interrupt and
|
526 |
|
|
status of the transaction is retreived with a2fxxx_dma_get_comp_flag :
|
527 |
|
|
|
528 |
|
|
|
529 |
|
|
|
530 |
|
|
void
|
531 |
|
|
a2fxxx_dma_clear_interrupt (cyg_uint8 ch)
|
532 |
|
|
|
533 |
|
|
cyg_uint8
|
534 |
|
|
a2fxxx_dma_get_comp_flag (cyg_uint8 ch)
|
535 |
|
|
|
536 |
|
|
ch is the DMA channel numbered from 0.
|
537 |
|
|
|
538 |
|
|
|
539 |
|
|
|
540 |
|
|
|
541 |
|
|
|
542 |
|
|
|
543 |
|
|
|
544 |
|
|
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
Configuration
|
550 |
|
|
|
551 |
|
|
|
552 |
|
|
Configuration
|
553 |
|
|
Configure, compile and debug the application
|
554 |
|
|
|
555 |
|
|
|
556 |
|
|
|
557 |
|
|
Overview
|
558 |
|
|
|
559 |
|
|
For compilation of the application, the official eCos ARM toolchain is required
|
560 |
|
|
(gcc version 4.3.2).
|
561 |
|
|
For debugging, it is needed to install the FlashPro utility from Actel as well
|
562 |
|
|
as SoftConsole. SoftConsole is an Eclipse based IDE from Microsemi that installs
|
563 |
|
|
along with the CodeSourcery ARM toolchain. Both are freely available and require
|
564 |
|
|
a Windows OS based host workstation.
|
565 |
|
|
To use some peripherals such as the Ethernet controller, the FPGA fabric must be
|
566 |
|
|
configured to route the Ethernet PHY clock from the MAC_CLK. It is recommended to
|
567 |
|
|
restore the factory image provided from Actel as a starting point in case the user
|
568 |
|
|
has already experimented with the fabric.
|
569 |
|
|
|
570 |
|
|
|
571 |
|
|
|
572 |
|
|
|
573 |
|
|
|
574 |
|
|
Building the application
|
575 |
|
|
|
576 |
|
|
|
577 |
|
|
The steps needed to build the HAL library for the Smartfusion evaluation board are:
|
578 |
|
|
|
579 |
|
|
|
580 |
|
|
$ mkdir a2f200_eval
|
581 |
|
|
$ cd a2f200_eval
|
582 |
|
|
$ ecosconfig new smartfusion kernel
|
583 |
|
|
$ ecosconfig resolve
|
584 |
|
|
$ ecosconfig tree
|
585 |
|
|
$ make
|
586 |
|
|
|
587 |
|
|
|
588 |
|
|
At the end of the build the
|
589 |
|
|
class="directory">install/lib subdirectory should contain the library and linker script and the
|
590 |
|
|
class="directory">install/include subdirectory the necessary includes to compile the application.
|
591 |
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
|
|
The differents startup type available for this platforme are:
|
595 |
|
|
|
596 |
|
|
|
597 |
|
|
|
598 |
|
|
|
599 |
|
|
600 |
|
|
|
|
601 |
|
|
Configuration (HAL_PLF_STARTUP_TYPE)
|
602 |
|
|
Description
|
603 |
|
|
|
604 |
|
|
|
|
605 |
|
|
606 |
|
|
|
|
607 |
|
|
ROM
|
608 |
|
|
Application running from the board's internal flash, LMA = 0x60000000 and VMA = 0x60000000
|
609 |
|
|
|
610 |
|
|
|
|
611 |
|
|
SRAM
|
612 |
|
|
Application running from the board's internal RAM, LMA = 0x20000000 and VMA = 0x20000000
|
613 |
|
|
|
614 |
|
|
|
|
615 |
|
|
ROM_SOFTCONSOLE
|
616 |
|
|
Application running from the board's internal flash, LMA = 0x60000000 and VMA = 0x00000000
|
617 |
|
|
|
618 |
|
|
|
|
619 |
|
|
|
620 |
|
|
|
621 |
|
|
|
622 |
|
|
|
623 |
|
|
|
624 |
|
|
|
625 |
|
|
|
626 |
|
|
System Boot
|
627 |
|
|
|
628 |
|
|
|
629 |
|
|
The Smartfusion devices boot process is not entirely controlled by the user. The
|
630 |
|
|
Embedded Non-volatile Memory contains spare pages that are reserved to store
|
631 |
|
|
specific data such as the factory boot code, the manufacturing parameters, the
|
632 |
|
|
system boot code or other data such as the Analog block or MSS configuration.
|
633 |
|
|
|
634 |
|
|
|
635 |
|
|
|
636 |
|
|
As described in the device user manual, the device first boots from factory boot
|
637 |
|
|
code before jumping to the system boot and eventually giving the hand to the user
|
638 |
|
|
code, in this case, the eCos ROM application.
|
639 |
|
|
|
640 |
|
|
|
641 |
|
|
|
642 |
|
|
The Actel MSS configuration tool can be used to alter the system boot and the
|
643 |
|
|
configuration pages. The ENVM spare pages can then be re-programmed using the
|
644 |
|
|
Actel FlashPro utility. The FlashPro utility can also be used to program the
|
645 |
|
|
FPGA fabric if required.
|
646 |
|
|
|
647 |
|
|
|
648 |
|
|
|
649 |
|
|
|
650 |
|
|
651 |
|
|
|
|
652 |
|
|
Spare page content
|
653 |
|
|
Address
|
654 |
|
|
|
655 |
|
|
|
|
656 |
|
|
657 |
|
|
|
|
658 |
|
|
Manufacturing parameters
|
659 |
|
|
0x60080000
|
660 |
|
|
|
661 |
|
|
|
|
662 |
|
|
Factory boot
|
663 |
|
|
0x60080400
|
664 |
|
|
|
665 |
|
|
|
|
666 |
|
|
System Boot
|
667 |
|
|
0x60080800
|
668 |
|
|
|
669 |
|
|
|
|
670 |
|
|
Analog block configuration
|
671 |
|
|
0x60081600
|
672 |
|
|
|
673 |
|
|
|
|
674 |
|
|
MSS configuration
|
675 |
|
|
0x60081E80
|
676 |
|
|
|
677 |
|
|
|
|
678 |
|
|
|
679 |
|
|
|
680 |
|
|
|
681 |
|
|
|
682 |
|
|
|
683 |
|
|
|
684 |
|
|
|
685 |
|
|
Debugging from console
|
686 |
|
|
|
687 |
|
|
|
688 |
|
|
Loading of the application to internal FLASH or RAM of the target is done either
|
689 |
|
|
using the SoftConsole IDE supplied from Actel or GDB from command line. The later
|
690 |
|
|
case is described in this paragraph.
|
691 |
|
|
|
692 |
|
|
|
693 |
|
|
|
694 |
|
|
To debug ROM based application, while configuring eCos, select the ROM_SOFTCONSOLE
|
695 |
|
|
startup type. The ROM_SOFTCONSOLE startup type is equivalent to a ROM startup but
|
696 |
|
|
while the application is loaded at address 0x60000000 (FLASH), it runs and is debugged
|
697 |
|
|
from address 0x00000000. This is done by setting the load address (LMA) to 0x60000000
|
698 |
|
|
and the virtual address (VMA) to 0x00000000 in the eCos memory layout file. In this
|
699 |
|
|
example, the timers test application from the eCos Smartfusion HAL is compiled:
|
700 |
|
|
|
701 |
|
|
|
702 |
|
|
|
703 |
|
|
$ mkdir a2f200_eval
|
704 |
|
|
$ cd a2f200_eval
|
705 |
|
|
$ ecosconfig new smartfusion kernel
|
706 |
|
|
-> Select ROM_SOFTCONSOLE statup type
|
707 |
|
|
$ ecosconfig resolve
|
708 |
|
|
$ ecosconfig tree
|
709 |
|
|
$ make
|
710 |
|
|
$ make -s tests IGNORE_LINK_ERRORS=y
|
711 |
|
|
|
712 |
|
|
|
713 |
|
|
|
714 |
|
|
Once the application is compiled, from a Windows command interpreter, start the
|
715 |
|
|
actel-keepalive utility:
|
716 |
|
|
|
717 |
|
|
|
718 |
|
|
|
719 |
|
|
c:> start actel-keepalive actel-keepalive
|
720 |
|
|
|
721 |
|
|
|
722 |
|
|
|
723 |
|
|
The GDB initialisation sequence located in a2fxxx/a2f200_eval/current/host/softconsole_flash_init.txt
|
724 |
|
|
is an example of initialisation sequence to use for debugging application located in
|
725 |
|
|
ROM. For RAM based application, the initialisation sequence from
|
726 |
|
|
a2fxxx/a2f200_eval/current/host/softconsole_sram_init.txt shall be used.
|
727 |
|
|
Make sure to replace the path to the debugger toolchain and the eCos repository first. The GDB
|
728 |
|
|
initialisation sequence without in-line comments is:
|
729 |
|
|
|
730 |
|
|
|
731 |
|
|
|
732 |
|
|
set arm fallback-mode thumb
|
733 |
|
|
target remote | "C:/Program Files (x86)/Microsemi/SoftConsole v3.3/Sourcery-G++/b-
|
734 |
|
|
in/arm-none-eabi-sprite" flashpro:?cpu=Cortex-M3 "C:/wrk/ecos/packages/hal/cortex-
|
735 |
|
|
m/a2fxxx/a2f200_eval/current/host"
|
736 |
|
|
set mem inaccessible-by-default off
|
737 |
|
|
set *0x40006010 = 0x4C6E55FA
|
738 |
|
|
set *0xE0042000 = 0
|
739 |
|
|
set *0xE0042008 = 1
|
740 |
|
|
set *0xE0042040 = 0x00207FFD
|
741 |
|
|
set *0xE004203C = 0x00000001
|
742 |
|
|
set *0xE0042030 = *0xE0042030 & 0xFFFFFFF7
|
743 |
|
|
set *0xE000ED08 = 0x00000000
|
744 |
|
|
load
|
745 |
|
|
set $sp = *0x60080000
|
746 |
|
|
set $pc = *0x60080004 - 1
|
747 |
|
|
|
748 |
|
|
|
749 |
|
|
|
750 |
|
|
Start the GDB session to debug the timers test example:
|
751 |
|
|
|
752 |
|
|
|
753 |
|
|
|
754 |
|
|
C:\root\a2f200_eval>arm-none-eabi-gdb install\tests\hal\cortexm\a2fxxx\var\curren-
|
755 |
|
|
t\tests\timers
|
756 |
|
|
GNU gdb (Sourcery G++ Lite Sourcery G++ Lite 2010q1-188 + Actel 1.2) 7.0.50.20100-
|
757 |
|
|
218-cvs
|
758 |
|
|
Copyright (C) 2010 Free Software Foundation, Inc.
|
759 |
|
|
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
760 |
|
|
This is free software: you are free to change and redistribute it.
|
761 |
|
|
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
|
762 |
|
|
and "show warranty" for details.
|
763 |
|
|
This GDB was configured as "--host=i686-mingw32 --target=arm-none-eabi".
|
764 |
|
|
For bug reporting instructions, please see:
|
765 |
|
|
<https://support.codesourcery.com/GNUToolchain/>...
|
766 |
|
|
Reading symbols from c:\root\a2f200_eval\install\tests\hal\cortexm\a2fxxx\var\curren-
|
767 |
|
|
t\tests\timers...done.
|
768 |
|
|
(gdb)
|
769 |
|
|
|
770 |
|
|
|
771 |
|
|
|
772 |
|
|
A typical log from the GDB initialisation sequence is shown here:
|
773 |
|
|
|
774 |
|
|
|
775 |
|
|
|
776 |
|
|
Remote debugging using | "C:/Program Files (x86)/Microsemi/SoftConsole v3.3/Sourc-
|
777 |
|
|
ery-G++/bin/arm-none-eabi-sprite" flashpro:?cpu=Cortex-M3 "C:/wrk/ecos/packages/h-
|
778 |
|
|
al/cortexm/a2fxxx/a2f200_eval/current/host"
|
779 |
|
|
arm-none-eabi-sprite: Using memory map C:/wrk/ecos/packages/hal/cortexm/a2fxxx/a2f-
|
780 |
|
|
200_eval/current/host/memory-map.xml
|
781 |
|
|
arm-none-eabi-sprite: Target reset
|
782 |
|
|
arm-none-eabi-sprite: Transferring memory map (may cause a delay)
|
783 |
|
|
0x6008051c in ?? ()
|
784 |
|
|
Loading section .rom_vectors, size 0x8 lma 0x60000000
|
785 |
|
|
Loading section .ARM.exidx, size 0x10 lma 0x60000008
|
786 |
|
|
Loading section .text, size 0x3340 lma 0x60000018
|
787 |
|
|
Loading section .rodata, size 0x4dc lma 0x60003358
|
788 |
|
|
Loading section .data, size 0x318 lma 0x6000383c
|
789 |
|
|
arm-none-eabi-sprite: Using host routines for flash programming
|
790 |
|
|
arm-none-eabi-sprite: Start of flash programming
|
791 |
|
|
arm-none-eabi-sprite: Comparing flash memory contents of actel-smartfusion-envm @-
|
792 |
|
|
0x60000000
|
793 |
|
|
arm-none-eabi-sprite: Program 0x60000000 sector [0x0,+0x80) unchanged
|
794 |
|
|
arm-none-eabi-sprite: Program 0x60000000 sector [0x80,+0x80) unchanged
|
795 |
|
|
arm-none-eabi-sprite: Program 0x60000000 sector [0x100,+0x80) unchanged
|
796 |
|
|
....
|
797 |
|
|
arm-none-eabi-sprite: Program 0x60000000 sector [0x3b00,+0x80) unchanged
|
798 |
|
|
arm-none-eabi-sprite: End of programming
|
799 |
|
|
Start address 0x18, load size 15180
|
800 |
|
|
Transfer rate: 8 KB/sec, 62 bytes/write.
|
801 |
|
|
|
802 |
|
|
|
803 |
|
|
|
804 |
|
|
|
805 |
|
|
|
806 |
|
|
|
807 |
|
|
|
808 |
|
|
|
809 |
|
|
|
810 |
|
|
|
811 |
|
|
|
812 |
|
|
|
813 |
|
|
|
814 |
|
|
|