The HAL Port

Name

HAL Port -- Implementation Details

Overview

This documentation explains how the eCos HAL specification has been mapped onto the SAM4E-EK board hardware, and should be read in conjunction with that specification. The SAM4E-EK platform HAL package complements the Cortex-M architectural HAL and the SAM variant HAL. It provides functionality which is specific to the target board.

Startup

Following a hard or soft reset the HAL will initialize or reinitialize many of the on-chip peripherals. There is an exception for RAM startup applications which depend on a ROM monitor for certain services.

For ROM and JTAG startup, the HAL will perform additional initialization, programming the various internal registers including the PLL, peripheral clocks and pin multiplexing. The details of the early hardware startup may be found in the src/sam4e_ek_misc.c in both hal_system_init() and hal_platform_init().

Memory Map

The platform HAL package provides the memory layout information needed to generate the linker script. The key memory areas are as follows:

Internal SRAM

This is located at address 0x20000000 of the memory space, and is 128KiB in size. The eCos VSR table occupies the bottom 256 bytes, with the virtual vector table starting at 0x20000100 and extending to 0x20000200. The top CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE bytes are reserved for the interrupt stack. The remainder of internal RAM is available for use by applications.

Internal FLASH

This is located at address 0x004000000 of the memory space and will be mapped to 0x00000000 at reset. This region is 1024KiB in size. ROM applications are by default configured to run from this memory.

On-Chip Peripherals

These are accessible at locations 0x40000000 and 0xE0000000 upwards. Descriptions of the contents can be found in the SAM4E User Manual.

Linker Scripts

The platform linker scripts define the following symbols:

hal_vsr_table

This defines the location of the VSR table. This is set to 0x20000000 for all startup types, and space for 64 entries is reserved.

hal_virtual_vector_table

This defines the location of the virtual vector table used to communicate between a ROM monitor and an eCos application. This is allocated right after the VSR table, at 0x20000100.

hal_interrupt_stack

This defines the location of the interrupt stack. For all startup types this is allocated to the top of internal SRAM, 0x20020000.

hal_startup_stack

This defines the location of the startup stack. For all startup types it is initially allocated at the half-way point of the interrupt stack.

Diagnostic LEDs

Three LEDs are fitted on the board for diagnostic purposes: D2 (blue), D3 (amber) and D4 (green).

The platform HAL header file at <cyg/hal/plf_io.h> defines the following convenience function to allow the LEDs to be set:

       extern void hal_sam_led(int val);
     
The lowest 3 bits of the argument val correspond to each of the 3 LEDs (with D2 as the least significant bit).

The variant HAL signals progress through clock initialization on the LEDs, leaving them all illuminated if initialization is successful. Following this, the LEDs are available for application use.

Real-time characterization

The tm_basic kernel test gives statistics gathered about the real-time characterization and performance of the kernel. The sample output is shown here for information. The test was built for JTAG startup.

             Startup, main thrd : stack used   352 size  1536
             Startup : Idlethread stack used    84 size  1280

eCos Kernel Timings
Notes: all times are in microseconds (.000001) unless otherwise stated

Reading the hardware clock takes 0 'ticks' overhead
... this value will be factored out of all other measurements
Clock interrupt took    9.00 microseconds (9 raw clock ticks)

Testing parameters:
   Clock samples:            32
   Threads:                   6
   Thread switches:         128
   Mutexes:                  32
   Mailboxes:                32
   Semaphores:               32
   Scheduler operations:    128
   Counters:                 32
   Flags:                    32
   Alarms:                   32
   Stack Size:             1088


                                 Confidence
     Ave     Min     Max     Var  Ave  Min  Function
  ======  ======  ======  ====== ========== ========
    7.50    7.00    8.00    0.50  100%  50% Create thread
    1.67    1.00    2.00    0.44   66%  33% Yield thread [all suspended]
    1.67    1.00    2.00    0.44   66%  33% Suspend [suspended] thread
    2.00    2.00    2.00    0.00  100% 100% Resume thread
    2.67    2.00    3.00    0.44   66%  33% Set priority
    0.33    0.00    1.00    0.44   66%  66% Get priority
    4.83    4.00    5.00    0.28   83%  16% Kill [suspended] thread
    2.00    2.00    2.00    0.00  100% 100% Yield [no other] thread
    2.33    2.00    3.00    0.44   66%  66% Resume [suspended low prio] thread
    2.00    2.00    2.00    0.00  100% 100% Resume [runnable low prio] thread
    2.33    2.00    3.00    0.44   66%  66% Suspend [runnable] thread
    1.17    1.00    2.00    0.28   83%  83% Yield [only low prio] thread
    2.00    2.00    2.00    0.00  100% 100% Suspend [runnable->not runnable]
    5.00    5.00    5.00    0.00  100% 100% Kill [runnable] thread
    4.00    4.00    4.00    0.00  100% 100% Destroy [dead] thread
    7.67    7.00    8.00    0.44   66%  33% Destroy [runnable] thread
    8.50    8.00    9.00    0.50  100%  50% Resume [high priority] thread
    2.87    2.00    5.00    0.26   84%  14% Thread switch

    0.34    0.00    1.00    0.45   65%  65% Scheduler lock
    1.35    1.00    2.00    0.46   64%  64% Scheduler unlock [0 threads]
    1.48    1.00    2.00    0.50   51%  51% Scheduler unlock [1 suspended]
    1.42    1.00    2.00    0.49   57%  57% Scheduler unlock [many suspended]
    1.18    1.00    2.00    0.29   82%  82% Scheduler unlock [many low prio]

    0.41    0.00    1.00    0.48   59%  59% Init mutex
    1.94    1.00    2.00    0.12   93%   6% Lock [unlocked] mutex
    2.28    2.00    3.00    0.40   71%  71% Unlock [locked] mutex
    1.81    1.00    2.00    0.31   81%  18% Trylock [unlocked] mutex
    1.00    1.00    1.00    0.00  100% 100% Trylock [locked] mutex
    0.56    0.00    1.00    0.49   56%  43% Destroy mutex
    9.13    9.00   10.00    0.22   87%  87% Unlock/Lock mutex

    0.72    0.00    1.00    0.40   71%  28% Create mbox
    0.31    0.00    1.00    0.43   68%  68% Peek [empty] mbox
    2.16    2.00    3.00    0.26   84%  84% Put [first] mbox
    0.28    0.00    1.00    0.40   71%  71% Peek [1 msg] mbox
    2.06    2.00    3.00    0.12   93%  93% Put [second] mbox
    0.31    0.00    1.00    0.43   68%  68% Peek [2 msgs] mbox
    2.03    2.00    3.00    0.06   96%  96% Get [first] mbox
    2.03    2.00    3.00    0.06   96%  96% Get [second] mbox
    1.75    1.00    2.00    0.38   75%  25% Tryput [first] mbox
    1.69    1.00    2.00    0.43   68%  31% Peek item [non-empty] mbox
    1.84    1.00    2.00    0.26   84%  15% Tryget [non-empty] mbox
    2.00    2.00    2.00    0.00  100% 100% Peek item [empty] mbox
    2.00    2.00    2.00    0.00  100% 100% Tryget [empty] mbox
    0.38    0.00    1.00    0.47   62%  62% Waiting to get mbox
    0.38    0.00    1.00    0.47   62%  62% Waiting to put mbox
    0.81    0.00    1.00    0.31   81%  18% Delete mbox
    6.19    6.00    7.00    0.30   81%  81% Put/Get mbox

    0.47    0.00    1.00    0.50   53%  53% Init semaphore
    1.50    1.00    2.00    0.50  100%  50% Post [0] semaphore
    1.78    1.00    2.00    0.34   78%  21% Wait [1] semaphore
    1.53    1.00    2.00    0.50   53%  46% Trywait [0] semaphore
    1.59    1.00    2.00    0.48   59%  40% Trywait [1] semaphore
    0.56    0.00    1.00    0.49   56%  43% Peek semaphore
    0.56    0.00    1.00    0.49   56%  43% Destroy semaphore
    5.41    5.00    6.00    0.48   59%  59% Post/Wait semaphore

    0.81    0.00    1.00    0.31   81%  18% Create counter
    0.56    0.00    1.00    0.49   56%  43% Get counter value
    0.34    0.00    1.00    0.45   65%  65% Set counter value
    2.00    2.00    2.00    0.00  100% 100% Tick counter
    0.47    0.00    1.00    0.50   53%  53% Delete counter

    0.41    0.00    1.00    0.48   59%  59% Init flag
    1.84    1.00    2.00    0.26   84%  15% Destroy flag
    1.63    1.00    2.00    0.47   62%  37% Mask bits in flag
    1.81    1.00    2.00    0.31   81%  18% Set bits in flag [no waiters]
    2.59    2.00    3.00    0.48   59%  40% Wait for flag [AND]
    2.50    2.00    3.00    0.50  100%  50% Wait for flag [OR]
    2.59    2.00    3.00    0.48   59%  40% Wait for flag [AND/CLR]
    2.50    2.00    3.00    0.50  100%  50% Wait for flag [OR/CLR]
    0.31    0.00    1.00    0.43   68%  68% Peek on flag

    1.19    1.00    2.00    0.30   81%  81% Create alarm
    2.56    2.00    3.00    0.49   56%  43% Initialize alarm
    1.56    1.00    2.00    0.49   56%  43% Disable alarm
    3.00    3.00    3.00    0.00  100% 100% Enable alarm
    1.81    1.00    2.00    0.31   81%  18% Delete alarm
    2.22    2.00    3.00    0.34   78%  78% Tick counter [1 alarm]
   11.59   11.00   12.00    0.48   59%  40% Tick counter [many alarms]
    3.94    3.00    4.00    0.12   93%   6% Tick & fire counter [1 alarm]
   65.00   65.00   65.00    0.00  100% 100% Tick & fire counters [>1 together]
   13.31   13.00   14.00    0.43   68%  68% Tick & fire counters [>1 separately]
    8.00    8.00    8.00    0.00  100% 100% Alarm latency [0 threads]
    7.34    7.00    8.00    0.45   65%  65% Alarm latency [2 threads]
    7.57    7.00    8.00    0.49   57%  42% Alarm latency [many threads]
   12.02   12.00   14.00    0.03   99%  99% Alarm -> thread resume latency

    0.00    0.00    0.00    0.00            Clock/interrupt latency

    3.68    3.00    4.00    0.00            Clock DSR latency

     190     180     212                    Worker thread stack used (stack size 1088)
            All done, main thrd : stack used   804 size  1536
            All done : Idlethread stack used   172 size  1280

Timing complete - 29810 ms total

PASS:<Basic timing OK>
EXIT:<done>
    
2017-02-09
Documentation license for this page: eCosPro License