Name
HAL Port — Implementation Details
Overview
This documentation explains how the eCos HAL specification has been
mapped onto the Freescale TWR-K60N512 and TWR-K60D100M hardware, and
should be read in conjunction with that
specification. The CYGPKG_HAL_CORTEXM_KINETIS_TWR_K60N512
platform HAL package complements the Cortex-M architectural HAL and
the Kinetis variant HAL. It provides functionality which is specific
to the target boards.
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, and for the platform JTAG startup where the host debugger configuration is responsible for initialising the DDRMC world for the external SDRAM used to hold the application being loaded.
For ROM startup, the HAL will perform additional initialization,
programming the various internal registers including the PLL,
peripheral clocks and GPIO pins. The details of the early hardware
startup may be found in
the src/twr_k60n512_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 locations are as follows:
- Internal RAM
-
This is located at address 0x1FFF0000 of the memory space, and is
128KiB in size. The eCos VSR table occupies the bottom 512-bytes. The
virtual vector table starts at 0x1FFF0200 and extends to
0x20000300. For ROM, and JTAG startups, 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 0x00000000 of the memory space. This region is 1MiB in size. ROM applications are by default configured to run from this memory.
- On-Chip Peripherals
- These are accessible from locations 0x40000000 and 0xE0000000 upwards. Descriptions of the contents can be found in the Kinetis 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 0x1FFF0000 for all startup types, and space for 128 entries allocated, though the K60 sub-family in use may use less entries.
- hal_virtual_vector_table
- This defines the location of the virtual vector table used to communicate between an ROM monitor and an eCos application. This is allocated right after the VSR table, at 0x20000200.
- hal_interrupt_stack
- This defines the location of the interrupt stack. For all startup types this is allocated to the top of internal SRAM, 0x20010000.
- 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
Four LEDs are fitted on the board for diagnostic purposes:
Platform HAL manifest | Colour | Board Label |
---|---|---|
CYGHWR_IO_KINETIS_PIN_LED1
| Orange |
E1
|
CYGHWR_IO_KINETIS_PIN_LED2
| Yellow |
E2
|
CYGHWR_IO_KINETIS_PIN_LED3
| Green |
E3
|
CYGHWR_IO_KINETIS_PIN_LED4
| Blue |
E4
|
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_twr_k60n512_led(char c);
The lowest 4-bits of the argument c
correspond to
each of the 4 LEDs (with LED1 as the least significant bit).
The platform HAL will automatically light all of the LEDs when the platform initialisation is complete, however the LEDs are free 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 the variant ROM startup with optimization flag -O3.
Example 291.1. twr_k60n512 Real-time characterization
INFO:<code from 0x00000410 -> 0x000181dc, CRC 0356> Startup, main thrd : stack used 112 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 8.00 microseconds (8 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.17 7.00 8.00 0.28 83% 83% Create thread 1.33 1.00 2.00 0.44 66% 66% Yield thread [all suspended] 1.83 1.00 2.00 0.28 83% 16% Suspend [suspended] thread 2.00 2.00 2.00 0.00 100% 100% Resume thread 3.33 3.00 4.00 0.44 66% 66% Set priority 0.33 0.00 1.00 0.44 66% 66% Get priority 5.50 5.00 6.00 0.50 100% 50% Kill [suspended] thread 1.33 1.00 2.00 0.44 66% 66% Yield [no other] thread 3.00 3.00 3.00 0.00 100% 100% Resume [suspended low prio] thread 2.00 2.00 2.00 0.00 100% 100% Resume [runnable low prio] thread 2.67 2.00 3.00 0.44 66% 33% Suspend [runnable] thread 2.00 2.00 2.00 0.00 100% 100% Yield [only low prio] thread 1.50 1.00 2.00 0.50 100% 50% Suspend [runnable->not runnable] 5.33 5.00 6.00 0.44 66% 66% Kill [runnable] thread 4.33 4.00 5.00 0.44 66% 66% Destroy [dead] thread 8.33 8.00 9.00 0.44 66% 66% Destroy [runnable] thread 10.83 10.00 12.00 0.56 50% 33% Resume [high priority] thread 3.54 3.00 5.00 0.51 52% 46% Thread switch 0.47 0.00 1.00 0.50 53% 53% Scheduler lock 1.30 1.00 2.00 0.42 70% 70% Scheduler unlock [0 threads] 1.34 1.00 2.00 0.45 66% 66% Scheduler unlock [1 suspended] 1.28 1.00 2.00 0.40 71% 71% Scheduler unlock [many suspended] 1.30 1.00 2.00 0.42 70% 70% Scheduler unlock [many low prio] 0.50 0.00 1.00 0.50 100% 50% Init mutex 2.34 2.00 3.00 0.45 65% 65% Lock [unlocked] mutex 2.44 2.00 3.00 0.49 56% 56% Unlock [locked] mutex 1.88 1.00 2.00 0.22 87% 12% Trylock [unlocked] mutex 1.69 1.00 2.00 0.43 68% 31% Trylock [locked] mutex 0.44 0.00 1.00 0.49 56% 56% Destroy mutex 12.00 12.00 12.00 0.00 100% 100% Unlock/Lock mutex 0.56 0.00 1.00 0.49 56% 43% Create mbox 0.28 0.00 1.00 0.40 71% 71% Peek [empty] mbox 2.53 2.00 3.00 0.50 53% 46% Put [first] mbox 0.28 0.00 1.00 0.40 71% 71% Peek [1 msg] mbox 2.69 2.00 3.00 0.43 68% 31% Put [second] mbox 0.22 0.00 1.00 0.34 78% 78% Peek [2 msgs] mbox 2.31 2.00 3.00 0.43 68% 68% Get [first] mbox 2.28 2.00 3.00 0.40 71% 71% Get [second] mbox 1.88 1.00 2.00 0.22 87% 12% Tryput [first] mbox 1.72 1.00 2.00 0.40 71% 28% Peek item [non-empty] mbox 1.69 1.00 2.00 0.43 68% 31% Tryget [non-empty] mbox 1.53 1.00 2.00 0.50 53% 46% Peek item [empty] mbox 1.94 1.00 2.00 0.12 93% 6% Tryget [empty] mbox 0.31 0.00 1.00 0.43 68% 68% Waiting to get mbox 0.31 0.00 1.00 0.43 68% 68% Waiting to put mbox 0.44 0.00 1.00 0.49 56% 56% Delete mbox 8.00 8.00 8.00 0.00 100% 100% Put/Get mbox 0.28 0.00 1.00 0.40 71% 71% Init semaphore 1.63 1.00 2.00 0.47 62% 37% Post [0] semaphore 2.00 2.00 2.00 0.00 100% 100% Wait [1] semaphore 1.69 1.00 2.00 0.43 68% 31% Trywait [0] semaphore 2.00 2.00 2.00 0.00 100% 100% Trywait [1] semaphore 0.44 0.00 1.00 0.49 56% 56% Peek semaphore 0.38 0.00 1.00 0.47 62% 62% Destroy semaphore 7.00 7.00 7.00 0.00 100% 100% Post/Wait semaphore 0.72 0.00 1.00 0.40 71% 28% Create counter 0.50 0.00 1.00 0.50 100% 50% Get counter value 0.31 0.00 1.00 0.43 68% 68% Set counter value 2.50 2.00 3.00 0.50 100% 50% Tick counter 0.34 0.00 1.00 0.45 65% 65% Delete counter 0.31 0.00 1.00 0.43 68% 68% Init flag 2.00 2.00 2.00 0.00 100% 100% Destroy flag 1.25 1.00 2.00 0.38 75% 75% Mask bits in flag 2.00 2.00 2.00 0.00 100% 100% Set bits in flag [no waiters] 3.00 3.00 3.00 0.00 100% 100% Wait for flag [AND] 2.72 2.00 3.00 0.40 71% 28% Wait for flag [OR] 2.88 2.00 3.00 0.22 87% 12% Wait for flag [AND/CLR] 2.47 2.00 3.00 0.50 53% 53% Wait for flag [OR/CLR] 0.38 0.00 1.00 0.47 62% 62% Peek on flag 0.94 0.00 1.00 0.12 93% 6% Create alarm 2.91 2.00 3.00 0.17 90% 9% Initialize alarm 1.72 1.00 2.00 0.40 71% 28% Disable alarm 2.78 2.00 3.00 0.34 78% 21% Enable alarm 1.91 1.00 2.00 0.17 90% 9% Delete alarm 2.66 2.00 3.00 0.45 65% 34% Tick counter [1 alarm] 9.50 9.00 10.00 0.50 100% 50% Tick counter [many alarms] 4.22 4.00 5.00 0.34 78% 78% Tick & fire counter [1 alarm] 39.09 39.00 40.00 0.17 90% 90% Tick & fire counters [>1 together] 11.00 11.00 11.00 0.00 100% 100% Tick & fire counters [>1 separately] 7.00 7.00 7.00 0.00 100% 100% Alarm latency [0 threads] 5.83 5.00 7.00 0.31 79% 18% Alarm latency [2 threads] 6.01 5.00 7.00 0.64 36% 31% Alarm latency [many threads] 12.02 12.00 14.00 0.03 99% 99% Alarm -> thread resume latency 236 236 236 Worker thread stack used (stack size 1088) All done, main thrd : stack used 760 size 1536 All done : Idlethread stack used 188 size 1280 Timing complete - 27870 ms total PASS:<Basic timing OK> EXIT:<done>
2024-12-10 | eCosPro Non-Commercial Public License |