OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sh/] [sh4_202_md/] [current/] [doc/] [sh4_202_md.sgml] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
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
37
 
38
SuperH SH4-202 MicroDev Board Support
39
 
40
41
 
42
43
  
44
    Overview
45
  
46
  
47
    eCos Support for the SuperH SH4-202 MicroDev Board
48
    Overview
49
  
50
 
51
  Description
52
    
53
The SuperH SH4-202 MicroDev board (henceforth just "MicroDev") has
54
an SH4-202 processor, 64MB of external SDRAM, 32MB of external flash
55
memory, an SMSC LAN91C111 ethernet controller and connectors plus
56
required support chips for all the on-chip peripherals.
57
    
58
    
59
For typical eCos development, a RedBoot image is programmed into the
60
flash memory, and the board will boot this image from reset. RedBoot
61
provides gdb stub functionality so it is then possible to download and
62
debug stand-alone and eCos applications via the gdb debugger. This can
63
happen over either a serial line or over ethernet.
64
    
65
  
66
 
67
  Supported Hardware
68
    
69
The flash memory consists of 128 blocks of 256k bytes each.
70
In a typical setup, the first
71
flash block is used for the ROM RedBoot image
72
and the second is used to store a version of RedBoot that can run out of
73
RAM. The topmost two blocks are used to manage the flash and hold RedBoot fconfig
74
values. The remaining 124 blocks between 0xA0080000 and 0xA1F7FFFF can be
75
used by application code.
76
    
77
    
78
The board is fitted with a PLCC socket suitable for an EEPROM (or PROM) such as
79
the 1Mbit ST M29WO10B. This is enabled by toggling two DIP switches, after which
80
the EEPROM is mapped into the same address as the flash memory. Therefore,
81
the flash is not accessible if booting from the EEPROM.
82
    
83
    
84
There is a serial driver CYGPKG_DEVS_SERIAL_SH_SCIF
85
which supports the on-chip serial device. This device
86
can be used by RedBoot for communication with the host. If this device
87
is needed by the application, either directly or via the serial
88
driver, then it cannot also be used for RedBoot communication. Another
89
communication channel such as ethernet should be used instead. The
90
serial driver package is loaded automatically when configuring for the
91
MicroDev target.
92
    
93
    
94
There is an ethernet driver CYGPKG_DEVS_ETH_SH_MICRODEV
95
for the on-chip ethernet device. This driver is also loaded
96
automatically when configuring for the MicroDev target.
97
    
98
    
99
eCos manages the on-chip interrupt controller. Timer 0 is used to
100
implement the eCos system clock, and timer 1 is used to implement a
101
microsecond delay function. Timer 2 is unused and
102
left for the application. Other on-chip devices (FEMI, EMI, INTC, TMU,
103
CAC, UBC) are initialized only as far as is necessary for eCos to
104
run. Other devices (eg RTC, DMAC, etc) are not touched.
105
    
106
  
107
 
108
  Tools
109
    
110
The MicroDev port is intended to work with GNU tools configured for an
111
sh-elf target. The original port was done using sh-elf-gcc version
112
3.2.1, sh-elf-gdb version 5.3, and binutils version 2.13.1.
113
    
114
126
  
127
 
128
129
 
130
131
132
 
133
134
  
135
    Setup
136
  
137
  
138
    Setup
139
    Preparing the MicroDev board for eCos Development
140
  
141
 
142
  Overview
143
    
144
In a typical development environment, the MicroDev board boots from
145
flash into the RedBoot ROM monitor. eCos applications are configured
146
for RAM startup and then downloaded and run on the board via the
147
debugger sh-elf-gdb. Preparing the board therefore usually involves
148
programming a suitable RedBoot image into flash memory. Alternatively
149
RedBoot may be programmed into a PLCC EEPROM and inserted into socket U21,
150
although in that case, the flash memory is not accessible.
151
    
152
    
153
The following RedBoot configurations are supported:
154
    
155
    
156
      
157
        
158
          
159
            Configuration
160
            Description
161
            Use
162
            File
163
          
164
        
165
        
166
          
167
            ROM
168
            RedBoot running from the board's flash
169
            redboot_ROM.ecm
170
            redboot_ROM.bin
171
          
172
          
173
            EEPROM
174
            RedBoot running from the board's socketed EEPROM
175
            redboot_EEPROM.ecm
176
            redboot_EEPROM.bin
177
          
178
          
179
            RAM
180
            Used for upgrading ROM version
181
            redboot_RAM.ecm
182
            redboot_RAM.bin
183
          
184
        
185
      
186
    
187
    
188
For serial communications, all versions run with 8 bits, no parity, and
189
1 stop bit at 38400 baud. This baud rate can be changed via the
190
configuration option
191
CYGNUM_HAL_SH_SH4_SCIF_BAUD_RATE and rebuilding
192
RedBoot. RedBoot also supports ethernet communication and flash
193
management.
194
    
195
  
196
 
197
  Initial Installation
198
   Flash Installation
199
    
200
This process assumes that the board is connected to a SuperH Micro
201
Probe. The Micro Probe should be set up as described in Appendix A of
202
the "SH4 Development Tools User Guide". You should also have access to
203
the SuperH development tools since it is necessary to use the version
204
of GDB that comes with those tools to access the Micro Probe,
205
sh-elf-gdb will not work.
206
    
207
    
208
Programming the RedBoot ROM monitor into flash memory requires an
209
application that can manage flash blocks. RedBoot itself has this
210
capability. Rather than have a separate application that is used only
211
for flash management during the initial installation, a special
212
RAM-resident version of RedBoot is loaded into memory and run. This
213
version can then be used to load the normal flash-resident version of
214
RedBoot and program it into the flash.
215
    
216
    
217
The first step is to connect an RS232 null modem cable between the MicroDev
218
serial port and the host PC. Next start a terminal emulation application such as
219
HyperTerminal or minicom on the host PC and set the serial
220
communication parameters to 38400 baud, 8 data bits, no parity, 1 stop
221
bit (8N1) and no flow control (handshaking).
222
    
223
    
224
Now run the sh4gdb command, giving it the name of
225
the RAM redboot ELF file, connect to the Micro Probe, load the
226
executable and run it. The entire session should look like this:
227
    
228
    
229
$ sh4gdb redboot_RAM.elf
230
GNU gdb 5.2.1
231
Copyright 2002 Free Software Foundation, Inc.
232
GDB is free software, covered by the GNU General Public License, and you are
233
welcome to change it and/or distribute copies of it under certain conditions.
234
Type "show copying" to see the conditions.
235
There is absolutely no warranty for GDB.  Type "show warranty" for details.
236
This GDB was configured as "--host=i686-pc-linux-gnu --target=sh-superh-elf"...
237
(gdb) sh4si superh
238
The target is assumed to be little endian
239
The target architecture is assumed to be sh4
240
0xa0000000 in ?? ()
241
(gdb) load
242
Loading section .vectors, size 0x9e0 lma 0x88010000
243
Loading section .text, size 0x1ab20 lma 0x880109e0
244
Loading section .rodata, size 0x3e6c lma 0x8802b500
245
Loading section .data, size 0xf30 lma 0x8802f370
246
Start address 0x88010000, load size 131740
247
Transfer rate: 351306 bits/sec, 433 bytes/write.
248
(gdb) cont
249
Continuing.
250
    
251
    
252
The required redboot_RAM.elf file is normally
253
supplied with the eCos release in the 
254
class="directory">loaders directory. If it needs to be
255
rebuilt then instructions for this are supplied 
256
linkend="sh4-microdev-setup-rebuild">below.
257
    
258
    
259
If this sequence fails in any way then check the setup and connections
260
of the Micro Probe. It if is successful then you should see the
261
following printed out on the serial line:
262
    
263
    
264
+FLASH configuration checksum error or invalid key
265
... waiting for BOOTP information
266
Ethernet eth0: MAC address 00:08:ee:00:0b:37
267
Can't get BOOTP info for device!
268
 
269
RedBoot(tm) bootstrap and debug environment [RAM]
270
Non-certified release, version UNKNOWN - built 14:28:55, Sep  8 2003
271
 
272
Copyright (C) 2000, 2001, 2002, Free Software Foundation, Inc.
273
 
274
RAM: 0x88000000-0x8c000000, 0x8812cca0-0x8bfb1000 available
275
FLASH: 0xa0000000 - 0xa2000000, 128 blocks of 0x00040000 bytes each.
276
RedBoot>
277
    
278
    
279
If the ethernet cable is not plugged in there may be a fairly long
280
wait after the "... waiting for BOOTP information" message.
281
At this stage the RedBoot flash management initialization has not yet
282
happened so the warning about the configuration checksum error is
283
expected. To perform this initialization use the
284
fis init -f command:
285
    
286
    
287
RedBoot> fis init -f
288
About to initialize [format] FLASH image system - continue (y/n)? y
289
*** Initialize FLASH Image System
290
... Unlock from 0xa1fc0000-0xa2000000: .
291
... Erase from 0xa1fc0000-0xa2000000: .
292
... Program from 0x8bfbf000-0x8bfff000 at 0xa1fc0000: .
293
... Lock from 0xa1fc0000-0xa2000000: .
294
RedBoot>
295
    
296
    
297
At the end, the block of flash at
298
location 0xA1FC0000 holds information about the various flash blocks,
299
allowing other flash management operations to be performed. The next
300
step is to set up RedBoot's non-volatile configuration values:
301
    
302
    
303
RedBoot> fconfig -i
304
Initialize non-volatile configuration - continue (y/n)? y
305
Run script at boot: false
306
Use BOOTP for network configuration: true
307
Console baud rate: 38400
308
DNS server IP address:
309
Set eth0 network hardware address [MAC]: false
310
GDB connection port: 9000
311
Force console for special debug messages: false
312
Network debug at boot time: false
313
Update RedBoot non-volatile configuration - continue (y/n)? y
314
... Unlock from 0xa1f80000-0xa1f81000: .
315
... Erase from 0xa1f80000-0xa1f81000: .
316
... Program from 0x8bfb2000-0x8bfb3000 at 0xa1f80000: .
317
... Lock from 0xa1f80000-0xa1f81000: .
318
RedBoot>
319
    
320
    
321
For most of these configuration variables, the default value is
322
correct. If there is no suitable BOOTP service running on the local
323
network then BOOTP should be disabled and, instead, RedBoot will prompt
324
for a fixed IP address, netmask, and addresses for the local gateway
325
and DNS server.
326
    
327
    
328
It is now possible to load the flash-resident version of RedBoot.
329
Because of the way that flash chips work, it is better to first load it
330
into RAM and then program it into flash.
331
    
332
    
333
RedBoot> load -r -m xmodem -b %{freememlo}
334
    
335
    
336
The file redboot_ROM.bin should now be uploaded
337
using the terminal emulator. The file is a raw binary and should be
338
transferred using the X-modem protocol.
339
    
340
    
341
Raw file loaded 0x8812d000-0x8814e32f, assumed entry at 0x8812d000
342
xyzModem - CRC mode, 1064(SOH)/0(STX)/0(CAN) packets, 2 retries
343
RedBoot>
344
    
345
    
346
Once RedBoot has been loaded into RAM it can be programmed into flash:
347
    
348
    
349
RedBoot> fis create RedBoot -b %{freememlo}
350
An image named 'RedBoot' exists - continue (y/n)? y
351
... Erase from 0xa0000000-0xa0040000: .
352
... Program from 0x8812d000-0x8816d000 at 0xa0000000: .
353
... Unlock from 0xa1fc0000-0xa2000000: .
354
... Erase from 0xa1fc0000-0xa2000000: .
355
... Program from 0x8bfbf000-0x8bfff000 at 0xa1fc0000: .
356
... Lock from 0xa1fc0000-0xa2000000: .
357
RedBoot>
358
    
359
    
360
The flash-resident version of RedBoot has now been programmed at location
361
0xA0000000, and the flash info block at 0xA1FC0000 has been updated.
362
The initial setup is now complete. Power off the Micro Probe and reset
363
the MicroDev board using S6. You should see the following:
364
 
365
    
366
    
367
+... waiting for BOOTP information
368
Ethernet eth0: MAC address 00:08:ee:00:0b:37
369
Can't get BOOTP info for device!
370
 
371
RedBoot(tm) bootstrap and debug environment [ROM]
372
Non-certified release, version UNKNOWN - built 14:22:57, Sep  8 2003
373
 
374
Copyright (C) 2000, 2001, 2002, Free Software Foundation, Inc.
375
 
376
RAM: 0x88000000-0x8c000000, 0x8800db98-0x8bfb1000 available
377
FLASH: 0xa0000000 - 0xa2000000, 128 blocks of 0x00040000 bytes each.
378
RedBoot>
379
    
380
    
381
When RedBoot issues its prompt, it is also ready to accept connections
382
from sh-elf-gdb, allowing applications to be downloaded and
383
debugged.
384
    
385
    
386
Occasionally it may prove necessary to update the installed RedBoot
387
image. This can be done simply by repeating the above process, using
388
the Micro Probe. Alternatively, the existing
389
RedBoot install can be used to load the RAM-resident version. You can
390
even install the RAM resident RedBoot in the "RedBoot[backup]" flash
391
region. See the RedBoot documentation for instruction on how to do this.
392
    
393
    
394
    EEPROM Installation
395
      
396
The board has a 32-pin PLCC socket suitable for an EEPROM, silk screened U21.
397
To use RedBoot running from EEPROM, you must first program the file
398
redboot_EEPROM.bin (normally supplied with the eCos release
399
in the loaders directory) into the
400
EEPROM using an appropriate programmer. No byte swapping is required. If RedBoot
401
needs to be rebuilt, then instructions for this are supplied 
402
linkend="sh4-microdev-setup-rebuild">below, and the import file
403
redboot_EEPROM.ecm should be used.
404
      
405
      
406
To configure the board to boot from the EEPROM instead of flash, you must
407
power off the board and change the following DIP switch settings, which may
408
both be found on DIP switch 2 (silk screened S2): switch 2 (silk
409
screened FEMI SIZ1) should be set to ON, which will change the access
410
width for FEMI area 0 from 32-bit to 8-bit; switch 6 (silk screened
411
FPGA SW3) should be set to OFF to configure the FPGA to map memory
412
accesses for FEMI area 0 to point at the EEPROM instead of flash. In
413
this mode, it is no longer possible to access flash memory as the EEPROM
414
is mapped into the same area in the address space.
415
      
416
      
417
Note that it is usually preferable to boot from flash instead of EEPROM as
418
flash is accessed 32-bits at a time, whereas the EEPROM is accessed 8-bits
419
at a time, which therefore affects performance as this requires 4 times as
420
many read cycles.
421
      
422
    
423
  
424
 
425
  Rebuilding RedBoot
426
    
427
Should it prove necessary to rebuild a RedBoot binary, this is done
428
most conveniently at the command line. The steps needed to rebuild the
429
RAM version of RedBoot are:
430
    
431
    
432
$ mkdir redboot_ram
433
$ cd redboot_ram
434
$ ecosconfig new sh4_202_md redboot
435
$ ecosconfig import $ECOS_REPOSITORY/hal/sh/sh4_202_md/v2_0_2/misc/redboot_RAM.ecm
436
$ ecosconfig resolve
437
$ ecosconfig tree
438
$ make
439
    
440
    
441
At the end of the build the 
442
class="directory">install/bin subdirectory should contain
443
the file redboot.bin.
444
    
445
    
446
Rebuilding the ROM versions involves basically the same
447
process. The ROM version uses the file
448
redboot_ROM.ecm and generates a file
449
redboot.bin. Make sure you don't mix up the
450
different redboot.bin files; rename them to something more memorable
451
such as redboot_RAM.bin and
452
redboot_ROM.bin.
453
    
454
  
455
 
456
457
 
458
459
460
 
461
462
  
463
    Configuration
464
  
465
  
466
    Configuration
467
    Platform-specific Configuration Options
468
  
469
 
470
  Overview
471
    
472
The MicroDev platform HAL package is loaded automatically when eCos is
473
configured for an sh4_202_md target. It should
474
never be necessary to load this package explicitly. Unloading the
475
package should only happen as a side effect of switching target
476
hardware.
477
    
478
  
479
 
480
  Startup
481
    
482
The MicroDev platform HAL package supports two separate startup types:
483
    
484
    
485
      
486
        RAM
487
        
488
This is the startup type which is normally used during application
489
development. The board has RedBoot programmed into flash at location
490
0xA0000000 and boots from that location.
491
sh-elf-gdb is then used to load a RAM
492
startup application into memory and debug it. It is assumed that the
493
hardware has already been initialized by RedBoot. By default the
494
application will use the eCos virtual vectors mechanism to obtain certain
495
services from RedBoot, including diagnostic output.
496
        
497
      
498
      
499
        ROM
500
        
501
This startup type can be used for finished applications which will
502
be programmed into flash at location 0xA0000000. The application will
503
be self-contained with no dependencies on services provided by other
504
software. eCos startup code will perform all necessary hardware
505
initialization.
506
        
507
      
508
    
509
 
510
  
511
 
512
  RedBoot and Virtual Vectors
513
    
514
If the application is intended to act as a ROM monitor, providing
515
services for other applications, then the configuration option
516
CYGSEM_HAL_ROM_MONITOR should be set. Typically
517
this option is set only when building RedBoot.
518
    
519
    
520
If the application is supposed to make use of services provided by a
521
ROM monitor, via the eCos virtual vector mechanism, then the
522
configuration option CYGSEM_HAL_USE_ROM_MONITOR
523
should be set. By default this option is enabled when building for a
524
RAM startup, disabled otherwise. It can be manually disabled for a RAM
525
startup, making the application self-contained, as a testing step
526
before switching to ROM startup.
527
    
528
    
529
If the application does not rely on a ROM monitor for diagnostic
530
services then the serial port will be claimed for HAL
531
diagnostics.
532
    
533
  
534
 
535
  Flash Driver
536
    
537
The MicroDev board contains 32Mb of Intel StrataFlash, specifically,
538
two E28F128 parts in parallel. The
539
CYGPKG_DEVS_FLASH_STRATA package contains all the
540
code necessary to support these parts and the
541
CYGPKG_DEVS_FLASH_SH_MICRODEV package contains
542
definitions that customize the driver to the MicroDev board.
543
    
544
    
545
Note that if booting from EEPROM instead of flash, the flash driver will
546
not be able to detect or use the flash parts.
547
    
548
  
549
 
550
  Ethernet Driver
551
    
552
The MicroDev board contains an SMSC LAN91C111 ethernet device.
553
The
554
CYGPKG_DEVS_ETH_SMSC_LAN91CXX package contains all the
555
code necessary to support this part and the
556
CYGPKG_DEVS_ETH_SH_MICRODEV package contains
557
definitions that customize the driver to the MicroDev board.
558
    
559
  
560
 
561
 
562
  System Clock
563
    
564
By default, the system clock interrupts once every 10ms, corresponding
565
to a 100Hz clock. This can be changed by the configuration option
566
CYGNUM_HAL_RTC_DENOMINATOR which corresponds to the
567
clock frequency. Other clock-related settings are recalculated
568
automatically if the denominator is changed.
569
    
570
  
571
 
572
  Compiler Flags
573
    
574
The platform HAL defines the default compiler and linker flags for all
575
packages, although it is possible to override these on a per-package
576
basis. Most of the flags used are the same as for other architectures
577
supported by eCos. There are two flags specific to this port:
578
    
579
    
580
      
581
        
582
        
583
The sh-elf-gcc compiler supports many
584
variants of the SH architecture, from the SH2 onwards.
585
A  option should be used to select the specific
586
variant in use, and with current tools  is the
587
correct option for the SH4-202.
588
        
589
      
590
609
    
610
  
611
 
612
613
 
614
615
616
 
617
618
  
619
    The HAL Port
620
  
621
  
622
    HAL Port
623
    Implementation Details
624
  
625
 
626
  Overview
627
    
628
This documentation explains how the eCos HAL specification has been
629
mapped onto the MicroDev hardware, and should be read in conjunction
630
with that specification. The MicroDev platform HAL package complements
631
the SH architectural HAL and the SH4 variant HAL. It provides
632
functionality which is specific to the target board.
633
    
634
  
635
 
636
  Startup
637
    
638
Following a hard or soft reset the HAL will initialize or
639
reinitialize most of the on-chip peripherals. There is an exception
640
for RAM startup applications which depend on a ROM monitor for certain
641
services.
642
    
643
    
644
For ROM startup, the HAL will perform additional initialization,
645
setting up the external DRAM and programming the various internal
646
registers. The values used for most of these registers are assigned
647
fixed values from a table in the header 
648
class="headerfile">cyg/hal/platform.inc.
649
    
650
  
651
 
652
  Linker Scripts and Memory Maps
653
    
654
The platform HAL package provides the memory layout information needed
655
to generate the linker script. The key memory locations are as follows:
656
    
657
    
658
      
659
        off-chip Flash
660
        
661
This is located at address 0x00000000 of the physical memory space and is
662
therefore accessible in the P1 region at location 0x80000000. An
663
uncached shadow of this memory is available in the P2 region at 0xA0000000.
664
The contents of the flash are organized as described earlier.
665
        
666
      
667
      
668
        off-chip EEPROM
669
        
670
        
671
If selected by the DIP switches, this occupies the same addresses as the
672
off-chip flash, and the flash is no longer visible.
673
        
674
        
675
      
676
      
677
        external SDRAM
678
        
679
        
680
This is located at address 0x08000000 of the physical memory space and is
681
therefore accessable in the P1 region at location 0x88000000. An
682
uncached shadow of this memory is available in the P2 region at 0xA8000000. The
683
first 256 bytes are used for hardware exception vectors. The next 256
684
bytes are normally used for the eCos virtual vectors, allowing
685
RAM-based applications to use services provided by the ROM
686
monitor. For ROM startup, all remaining SDRAM is available. For RAM
687
startup, available SDRAM starts at location 0x80100000, with the bottom
688
1MB reserved for use by RedBoot.
689
        
690
        
691
      
692
      
693
        on-chip peripherals
694
        
695
These are accessible  via the P4 region at location 0xE0000000 onwards.
696
        
697
      
698
      
699
        off-chip peripherals
700
        
701
The ethernet device is located at 0xA7500000. The FPGA interrupt
702
controller is located at 0x06110000. These are the only
703
off-chip peripherals accessed by eCos. All others are left
704
untouched.
705
        
706
      
707
    
708
  
709
 
710
  Clock Support
711
    
712
The platform HAL provides configuration options for the eCos system
713
clock. This always uses the hardware timer 0, which should not be used
714
directly by application code. Timer 1 is used to implement a
715
microsecond resolution busy delay service. Timer 2 is not used by eCos
716
so application code is free to manipulate this as required. The
717
actual HAL macros for managing the clock are provided by the SH architecture
718
processor HAL.
719
    
720
    
721
There is a software model of the structure of the SH family clock
722
supply subsystem which performs the correct calculations to yield not
723
only the inputs for the CPU clock but also the peripheral clocks fed
724
to the serial device, memory controllers and other devices. The values
725
for the master crystal, the PLL multipliers and various dividers are
726
supplied by the platform HAL. Some care must be taken in defining
727
these since wrong values will cause the timers and the SCIF baud rate
728
to be miscalculated. If the OSCAR chip switches are changed from the
729
default then the value of CYGHWR_HAL_SH_OOC_XTAL
730
must be changed to match.
731
    
732
  
733
 
734
  Other Issues
735
    
736
The MicroDev platform HAL does not affect the implementation of other
737
parts of the eCos HAL specification. The
738
SH4 variant HAL, and the SH architectural HAL documentation
739
should be consulted for further details.
740
    
741
    
742
It should be noted that the floating point support in the SH HAL has a
743
caveat that, if the FPSCR register is changed, it may get reverted at a
744
later stage by certain operations performed by the GCC compiler. This
745
behaviour is intentional as the alternative would be to update the GCC
746
compiler's internal state about the FPSCR at every context switch which
747
would be expensive for a feature that is unlikely to be used frequently.
748
If the FPSCR is to be changed by the application, the developer
749
should call the function __set_fpscr(int), passing it
750
the new FPSCR value.
751
    
752
  
753
 
754
755
 
756
757
 
758

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.