Changeset f383c6df in rtems


Ignore:
Timestamp:
Feb 17, 2011, 1:25:10 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
ddb29e37
Parents:
2888a65
Message:

2011-02-17 Till Straumann <strauman@…>

PR 1738/bsps

  • README, startup/bspstart.c, startup/linkcmds: Add support for dynamic clock speed determination. This algorithm is described in the README file. The output of the RTEMS Timing Tests was moved to TIMES to signicantly shrink the README.
  • TIMES: New file.
Location:
c/src/lib/libbsp/m68k/uC5282
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/m68k/uC5282/ChangeLog

    r2888a65 rf383c6df  
     12011-02-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR 1738/bsps
     4        * README, startup/bspstart.c, startup/linkcmds: Add support for dynamic
     5        clock speed determination. This algorithm is described in the README
     6        file. The output of the RTEMS Timing Tests was moved to TIMES to
     7        signicantly shrink the README.
     8        * TIMES: New file.
     9
    1102011-02-11      Ralf Corsépius <ralf.corsepius@rtems.org>
    211
  • c/src/lib/libbsp/m68k/uC5282/README

    r2888a65 rf383c6df  
    2626This seems OK to me, but others may find it lame.....
    2727
    28 I/O pin restrictions make simultaneous operation
    29 of I2C, CAN and UART2 impossible.  The BSP configures UART2 to
    30 use the CAN pins and leaves the I2C pins available for use.
     28I/O pin restrictions make simultaneous operation of I2C, CAN and UART2
     29impossible.  The BSP configures UART2 to use the CAN pins and leaves
     30the I2C pins available for use.
    3131 
    3232BSP NAME:           uC5282
     
    1001006) Type 'goram<CR>' to start the downloaded program, or type 'program<CR>'
    101101to burn the code onto the uCDIMM flash.
     102
     103Clock Speed Determination Algorithm
     104===================================
     105Till Straumann submitted a patch to provide more dynamic clock speed
     106selection.
     107
     108Currently, the uC5282 BSP requires relinking the application with a
     109special linker flag in order to make it work with 80MHz boards (breaking
     110run-time compatibility with 64MHz variants).
     111
     112The change aims adds support for run-time guessing/setting of
     113the system-clock frequency:
     114
     1151) If uCbootloader environment variable SYS_CLOCK_SPEED is set to a
     116non-zero number then the BSP assumes this number to specify the clock
     117frequency in Hz.
     118
     1192) If 1) yields no non-zero frequency then the linker-provided symbol
     120_CPUClockSpeed is assumed to specify the clock frequency (in Hz). This
     121is the traditional behavior but the default value of _CPUClockSpeed
     122was changed from 64000000 to 0 (in order to let step 3) do it's work
     123by default).
     124
     1253) If neither 1) nor 2) yield a non-zero frequency then assume a PLL
     126reference frequency (in Hz) as defined by the linker-provided symbol
     127'_PLLRefClockSpeed' (which defaults to 8000000) and compute the system
     128clock frequency from the divisor/multiplier settings in the SYNCR
     129register.
     130
     131We have both, 64MHz and 80MHz variants and both use a PLL reference of
     1328MHz so that run-time heuristics + detection 3) work fine.
    102133
    103134EPICS Bootstrap Information
     
    208239============================================================================
    209240
    210 TIMING TESTS  2005-01-28
    211 ========================
    212 
    213 *** TIME TEST 1 ***
    214 rtems_semaphore_create 19
    215 rtems_semaphore_delete 21
    216 rtems_semaphore_obtain: available 4
    217 rtems_semaphore_obtain: not available -- NO_WAIT 5
    218 rtems_semaphore_release: no waiting tasks 12
    219 *** END OF TEST 1 ***
    220 
    221 *** TIME TEST 2 ***
    222 rtems_semaphore_obtain: not available -- caller blocks 34
    223 *** END OF TEST 2 ***
    224 
    225 *** TIME TEST 3 ***
    226 rtems_semaphore_release: task readied -- preempts caller 27
    227 *** END OF TEST 3 ***
    228 
    229 *** TIME TEST 4 ***
    230 rtems_task_restart: blocked task -- preempts caller 54
    231 rtems_task_restart: ready task -- preempts caller 52
    232 rtems_semaphore_release: task readied -- returns to caller 18
    233 rtems_task_create 87
    234 rtems_task_start 24
    235 rtems_task_restart: suspended task -- returns to caller 27
    236 rtems_task_delete: suspended task 66
    237 rtems_task_restart: ready task -- returns to caller 28
    238 rtems_task_restart: blocked task -- returns to caller 38
    239 rtems_task_delete: blocked task 69
    240 *** END OF TEST 4 ***
    241 
    242 *** TIME TEST 5 ***
    243 rtems_task_suspend: calling task 23
    244 rtems_task_resume: task readied -- preempts caller 22
    245 *** END OF TEST 5 ***
    246 
    247 *** TIME TEST 6 ***
    248 rtems_task_restart: calling task 30
    249 rtems_task_suspend: returns to caller 9
    250 rtems_task_resume: task readied -- returns to caller 12
    251 rtems_task_delete: ready task 69
    252 *** END OF TEST 6 ***
    253 
    254 *** TIME TEST 7 ***
    255 rtems_task_restart: suspended task -- preempts caller 44
    256 *** END OF TEST 7 ***
    257 
    258 *** TIME TEST 8 ***
    259 rtems_task_set_priority: obtain current priority 6
    260 rtems_task_set_priority: returns to caller 17
    261 rtems_task_mode: obtain current mode 3
    262 rtems_task_mode: no reschedule 3
    263 rtems_task_mode: reschedule -- returns to caller 8
    264 rtems_task_mode: reschedule -- preempts caller 22
    265 rtems_task_set_note 6
    266 rtems_task_get_note 6
    267 rtems_clock_set 22
    268 rtems_clock_get 1
    269 *** END OF TEST 8 ***
    270 
    271 *** TIME TEST 9 ***
    272 rtems_message_queue_create 55
    273 rtems_message_queue_send: no waiting tasks 20
    274 rtems_message_queue_urgent: no waiting tasks 21
    275 rtems_message_queue_receive: available 20
    276 rtems_message_queue_flush: no messages flushed 8
    277 rtems_message_queue_flush: messages flushed 12
    278 rtems_message_queue_delete 29
    279 *** END OF TEST 9 ***
    280 
    281 *** TIME TEST 10 ***
    282 rtems_message_queue_receive: not available -- NO_WAIT 10
    283 rtems_message_queue_receive: not available -- caller blocks 38
    284 *** END OF TEST 10 ***
    285 
    286 *** TIME TEST 11 ***
    287 rtems_message_queue_send: task readied -- preempts caller 37
    288 *** END OF TEST 11 ***
    289 
    290 *** TIME TEST 12 ***
    291 rtems_message_queue_send: task readied -- returns to caller 23
    292 *** END OF TEST 12 ***
    293 
    294 *** TIME TEST 13 ***
    295 rtems_message_queue_urgent: task readied -- preempts caller 35
    296 *** END OF TEST 13 ***
    297 
    298 *** TIME TEST 14 ***
    299 rtems_message_queue_urgent: task readied -- returns to caller 24
    300 *** END OF TEST 14 ***
    301 
    302 *** TIME TEST 15 ***
    303 rtems_event_receive: obtain current events 0
    304 rtems_event_receive: not available -- NO_WAIT 5
    305 rtems_event_receive: not available -- caller blocks 28
    306 rtems_event_send: no task readied 5
    307 rtems_event_receive: available 9
    308 rtems_event_send: task readied -- returns to caller 16
    309 *** END OF TEST 15 ***
    310 
    311 *** TIME TEST 16 ***
    312 rtems_event_send: task readied -- preempts caller 27
    313 *** END OF TEST 16 ***
    314 
    315 *** TIME TEST 17 ***
    316 rtems_task_set_priority: preempts caller 39
    317 *** END OF TEST 17 ***
    318 
    319 *** TIME TEST 18 ***
    320 rtems_task_delete: calling task 83
    321 *** END OF TEST 18 ***
    322 
    323 *** TIME TEST 19 ***
    324 rtems_signal_catch 5
    325 rtems_signal_send: returns to caller 12
    326 rtems_signal_send: signal to self 20
    327 exit ASR overhead: returns to calling task 15
    328 exit ASR overhead: returns to preempting task 18
    329 *** END OF TEST 19 ***
    330 
    331 *** TIME TEST 20 ***
    332 rtems_partition_create 20
    333 rtems_region_create 40
    334 rtems_partition_get_buffer: available 11
    335 rtems_partition_get_buffer: not available 7
    336 rtems_partition_return_buffer 12
    337 rtems_partition_delete 11
    338 rtems_region_get_segment: available 28
    339 rtems_region_get_segment: not available -- NO_WAIT 29
    340 rtems_region_return_segment: no waiting tasks 29
    341 rtems_region_get_segment: not available -- caller blocks 55
    342 rtems_region_return_segment: task readied -- preempts caller 72
    343 rtems_region_return_segment: task readied -- returns to caller 58
    344 rtems_region_delete 25
    345 rtems_io_initialize 1
    346 rtems_io_open 1
    347 rtems_io_close 1
    348 rtems_io_read 1
    349 rtems_io_write 1
    350 rtems_io_control 1
    351 *** END OF TEST 20 ***
    352 
    353 *** TIME TEST 21 ***
    354 rtems_task_ident 60
    355 rtems_message_queue_ident 60
    356 rtems_semaphore_ident 69
    357 rtems_partition_ident 59
    358 rtems_region_ident 60
    359 rtems_port_ident 59
    360 rtems_timer_ident 61
    361 rtems_rate_monotonic_ident 60
    362 *** END OF TEST 21 ***
    363 
    364 *** TIME TEST 22 ***
    365 rtems_message_queue_broadcast: task readied -- returns to caller 32
    366 rtems_message_queue_broadcast: no waiting tasks 14
    367 rtems_message_queue_broadcast: task readied -- preempts caller 39
    368 *** END OF TEST 22 ***
    369 
    370 *** TIME TEST 23 ***
    371 rtems_timer_create 8
    372 rtems_timer_fire_after: inactive 12
    373 rtems_timer_fire_after: active 12
    374 rtems_timer_cancel: active 9
    375 rtems_timer_cancel: inactive 8
    376 rtems_timer_reset: inactive 14
    377 rtems_timer_reset: active 15
    378 rtems_timer_fire_when: inactive 21
    379 rtems_timer_fire_when: active 21
    380 rtems_timer_delete: active 12
    381 rtems_timer_delete: inactive 11
    382 rtems_task_wake_when 35
    383 *** END OF TEST 23 ***
    384 
    385 *** TIME TEST 24 ***
    386 rtems_task_wake_after: yield -- returns to caller 3
    387 rtems_task_wake_after: yields -- preempts caller 18
    388 *** END OF TEST 24 ***
    389 
    390 *** TIME TEST 25 ***
    391 rtems_clock_tick 7
    392 *** END OF TEST 25 ***
    393 
    394 *** TIME TEST 26 ***
    395 _ISR_Disable 1
    396 _ISR_Flash 0
    397 _ISR_Enable 0
    398 _Thread_Disable_dispatch 1
    399 _Thread_Enable_dispatch 3
    400 _Thread_Set_state 7
    401 _Thread_Disptach (NO FP) 16
    402 context switch: no floating point contexts 12
    403 context switch: self 2
    404 context switch: to another task 1
    405 fp context switch: restore 1st FP task 14
    406 fp context switch: save idle, restore initialized 3
    407 fp context switch: save idle, restore idle 13
    408 fp context switch: save initialized, restore initialized 2
    409 _Thread_Resume 7
    410 _Thread_Unblock 6
    411 _Thread_Ready 5
    412 _Thread_Get 1
    413 _Semaphore_Get 1
    414 _Thread_Get: invalid id 0
    415 *** END OF TEST 26 ***
    416 
    417 *** TIME TEST 27 ***
    418 interrupt entry overhead: returns to interrupted task 3
    419 interrupt exit overhead: returns to interrupted task 3
    420 interrupt entry overhead: returns to nested interrupt 2
    421 interrupt exit overhead: returns to nested interrupt 2
    422 interrupt entry overhead: returns to preempting task 4
    423 interrupt exit overhead: returns to preempting task 20
    424 *** END OF TEST 27 ***
    425 
    426 *** TIME TEST 28 ***
    427 rtems_port_create 12
    428 rtems_port_external_to_internal 5
    429 rtems_port_internal_to_external 6
    430 rtems_port_delete 12
    431 *** END OF TEST 28 ***
    432 
    433 *** TIME TEST 29 ***
    434 rtems_rate_monotonic_create 13
    435 rtems_rate_monotonic_period: initiate period -- returns to caller 20
    436 rtems_rate_monotonic_period: obtain status 10
    437 rtems_rate_monotonic_cancel 13
    438 rtems_rate_monotonic_delete: inactive 17
    439 rtems_rate_monotonic_delete: active 16
    440 rtems_rate_monotonic_period: conclude periods -- caller blocks 24
    441 *** END OF TEST 29 ***
    442 
    443 *** TIME CHECKER ***
    444 Units may not be in microseconds for this test!!!
    445 0 100000
    446 Total time = 0
    447 Average time = 0
    448 NULL timer stopped at 0
    449 LOOP (1000) timer stopped at 188
    450 LOOP (10000) timer stopped at 1875
    451 LOOP (50000) timer stopped at 9375
    452 LOOP (100000) timer stopped at 18750
    453 *** END OF TIME CHECKER ***
    454 
    455 *** TIME TEST OVERHEAD ***
    456 rtems_initialize_executive 0
    457 rtems_shutdown_executive 0
    458 rtems_task_create 0
    459 rtems_task_ident 0
    460 rtems_task_start 0
    461 rtems_task_restart 0
    462 rtems_task_delete 0
    463 rtems_task_suspend 0
    464 rtems_task_resume 0
    465 rtems_task_set_priority 0
    466 rtems_task_mode 0
    467 rtems_task_get_note 0
    468 rtems_task_set_note 0
    469 rtems_task_wake_when 1
    470 rtems_task_wake_after 0
    471 rtems_interrupt_catch 0
    472 rtems_clock_get 1
    473 rtems_clock_set 1
    474 rtems_clock_tick 0
    475 rtems_timer_create 0
    476 rtems_timer_delete 0
    477 rtems_timer_ident 0
    478 rtems_timer_fire_after 1
    479 rtems_timer_fire_when 1
    480 rtems_timer_reset 0
    481 rtems_timer_cancel 0
    482 rtems_semaphore_create 0
    483 rtems_semaphore_delete 0
    484 rtems_semaphore_ident 0
    485 rtems_semaphore_obtain 0
    486 rtems_semaphore_release 0
    487 rtems_message_queue_create 0
    488 rtems_message_queue_ident 0
    489 rtems_message_queue_delete 0
    490 rtems_message_queue_send 0
    491 rtems_message_queue_urgent 0
    492 rtems_message_queue_broadcast 0
    493 rtems_message_queue_receive 0
    494 rtems_message_queue_flush 0
    495 rtems_event_send 0
    496 rtems_event_receive 0
    497 rtems_signal_catch 0
    498 rtems_signal_send 0
    499 rtems_partition_create 0
    500 rtems_partition_ident 0
    501 rtems_partition_delete 0
    502 rtems_partition_get_buffer 0
    503 rtems_partition_return_buffer 0
    504 rtems_region_create 0
    505 rtems_region_ident 0
    506 rtems_region_delete 0
    507 rtems_region_get_segment 0
    508 rtems_region_return_segment 0
    509 rtems_port_create 0
    510 rtems_port_ident 0
    511 rtems_port_delete 0
    512 rtems_port_external_to_internal 0
    513 rtems_port_internal_to_external 0
    514 rtems_io_initialize 0
    515 rtems_io_open 0
    516 rtems_io_close 0
    517 rtems_io_read 0
    518 rtems_io_write 0
    519 rtems_io_control 0
    520 rtems_fatal_error_occurred 0
    521 rtems_rate_monotonic_create 0
    522 rtems_rate_monotonic_ident 0
    523 rtems_rate_monotonic_delete 0
    524 rtems_rate_monotonic_cancel 0
    525 rtems_rate_monotonic_period 0
    526 rtems_multiprocessing_announce 0
    527 *** END OF TIME OVERHEAD ***
  • c/src/lib/libbsp/m68k/uC5282/startup/bspstart.c

    r2888a65 rf383c6df  
    2323#include <errno.h>
    2424#include <stdio.h>
     25#include <mcf5282/mcf5282.h>
    2526
    2627/*
     
    3536extern char RamSize[];
    3637extern char RamBase[];
    37 
     38extern char _CPUClockSpeed[];
     39extern char _PLLRefClockSpeed[];
     40
     41uint32_t BSP_sys_clk_speed = (uint32_t)_CPUClockSpeed;
     42uint32_t BSP_pll_ref_clock = (uint32_t)_PLLRefClockSpeed;
    3843/*
    3944 * CPU-space access
     
    237242void bsp_start( void )
    238243{
    239   int i;
     244  int   i;
     245  const char *clk_speed_str;
     246  uint32_t clk_speed, mfd, rfd;
    240247
    241248  /*
     
    300307  MCF5282_CS2_CSCR = MCF5282_CS_CSCR_PS_16;
    301308  MCF5282_GPIO_PJPAR |= 0x06;
    302 }
    303 
    304 extern char _CPUClockSpeed[];
     309
     310  /*
     311   * Hopefully, the UART clock is still correctly set up
     312   * so they can see the printk() output...
     313   */
     314  clk_speed = 0;
     315  printk("Trying to figure out the system clock\n");
     316  printk("Checking ENV variable SYS_CLOCK_SPEED:\n");
     317  if ( (clk_speed_str = bsp_getbenv("SYS_CLOCK_SPEED")) ) {
     318    printk("Found: %s\n", clk_speed_str);
     319        for ( clk_speed = 0, i=0;
     320              clk_speed_str[i] >= '0' && clk_speed_str[i] <= '9';
     321              i++ ) {
     322                clk_speed = 10*clk_speed + clk_speed_str[i] - '0';
     323        }
     324        if ( 0 != clk_speed_str[i] ) {
     325                printk("Not a decimal number; I'm not using this setting\n");
     326                clk_speed = 0;
     327        }
     328  } else {
     329    printk("Not set.\n");
     330  }
     331
     332  if ( 0 == clk_speed )
     333        clk_speed = BSP_sys_clk_speed;
     334
     335  if ( 0 == clk_speed ) {
     336        printk("Using some heuristics to determine clock speed...\n");
     337        printk("Assuming %uHz PLL ref. clock\n", BSP_pll_ref_clock);
     338        if ( 0xf8 != MCF5282_CLOCK_SYNSR ) {
     339          printk("FATAL ERROR: Unexpected SYNSR contents, can't proceed\n");
     340          bsp_sysReset(0);
     341        }
     342        mfd = MCF5282_CLOCK_SYNCR;
     343        rfd = (mfd >>  8) & 7;
     344        mfd = (mfd >> 12) & 7;
     345        /* Check against 'known' cases */
     346        if ( 0 != rfd || (2 != mfd && 3 != mfd) ) {
     347          printk("WARNING: Pll divisor/multiplier has unknown value; \n");
     348          printk("         either your board is not 64MHz or 80Mhz or\n");
     349          printk("         it uses a PLL reference other than 8MHz.\n");
     350          printk("         I'll proceed anyways but you might have to\n");
     351          printk("         reset the board and set uCbootloader ENV\n");
     352          printk("         variable \"SYS_CLOCK_SPEED\".\n");
     353        }
     354        mfd = 2 * (mfd + 2);
     355        /* sysclk = pll_ref * 2 * (MFD + 2) / 2^(rfd) */
     356        printk("PLL multiplier: %u, output divisor: %u\n", mfd, rfd);
     357        clk_speed = (BSP_pll_ref_clock * mfd) >> rfd;
     358  }
     359
     360  if ( 0 == clk_speed ) {
     361        printk("FATAL ERROR: Unable to determine system clock speed\n");
     362        bsp_sysReset(0);
     363  } else {
     364        BSP_sys_clk_speed = clk_speed;
     365        printk("System clock speed: %uHz\n", bsp_get_CPU_clock_speed());
     366  }
     367}
    305368
    306369uint32_t bsp_get_CPU_clock_speed(void)
    307370{
    308   return( (uint32_t)_CPUClockSpeed);
     371  return( BSP_sys_clk_speed );
    309372}
    310373
  • c/src/lib/libbsp/m68k/uC5282/startup/linkcmds

    r2888a65 rf383c6df  
    3131/*
    3232 * System clock speed
    33  */
    34 _CPUClockSpeed = DEFINED(_CPUClockSpeed) ? _CPUClockSpeed : 64000000 ;
     33 *
     34 * If autodetection of the system clock pased on the PLL ref. clock
     35 * (AFAIK 8MHz for both 64MHz and 80MHz boards) doesn't work then
     36 * you can:
     37 *   - define (nonzero) system clock speed from app- linkflags (or here)
     38 *   - use a uCbootloader env. var: SYS_CLOCK_SPEED to define it.
     39 * You can also redefine the PLL reference clock speed from linkflags
     40 * or here...
     41 */
     42_CPUClockSpeed    = DEFINED(_CPUClockSpeed)    ? _CPUClockSpeed : 0 ;
     43_PLLRefClockSpeed = DEFINED(_PLLRefClockSpeed) ? _PLLRefClockSpeed : 8000000;
    3544
    3645/*
Note: See TracChangeset for help on using the changeset viewer.