Changeset 276 for branches/libfreebob-downloader/src/bebob/bebob_dl_mgr.cpp
- Timestamp:
- 06/27/06 14:46:41 (18 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libfreebob-downloader/src/bebob/bebob_dl_mgr.cpp
r271 r276 76 76 memset( &m_cachedInfoRegs, 0, sizeof( m_cachedInfoRegs ) ); 77 77 78 m_configRom = new ConfigRom( m_ieee1394service, nodeId );78 m_configRom = new ConfigRom( *m_ieee1394service, nodeId ); 79 79 // XXX throw exception if initialize fails! 80 80 m_configRom->initialize(); … … 214 214 using namespace std; 215 215 216 printf( "parse BCD file\n" ); 216 217 std::auto_ptr<BCD> bcd = std::auto_ptr<BCD>( new BCD( filename ) ); 217 218 if ( !bcd.get() ) { … … 220 221 return false; 221 222 } 222 223 223 if ( !bcd->parse() ) { 224 224 debugError( "downloadFirmware: BCD parsing failed\n" ); … … 226 226 } 227 227 228 printf( "prepare for download (start bootloader)\n" ); 228 229 if ( !startBootloaderCmd() ) { 229 230 debugError( "downloadFirmware: Could not start bootloader\n" ); 230 231 return false; 231 232 } 232 waitForBusReset(); 233 if ( !cacheInfoRegisters( MaxRetries ) ) { 234 debugError( "downloadFirmware: Could not read info registers\n" ); 235 return false; 236 } 237 238 // wait for bootloader finish startup sequence 239 // there is no way to find out when it has finished 240 sleep( 10 ); 241 233 234 printf( "start downloading protocol for application image\n" ); 242 235 if ( !downloadObject( *bcd, eOT_Application ) ) { 243 236 debugError( "downloadFirmware: Firmware download failed\n" ); … … 245 238 } 246 239 240 printf( "start downloading protocol for CnE\n" ); 247 241 if ( !downloadObject( *bcd, eOT_CnE ) ) { 248 242 debugError( "downloadFirmware: CnE download failed\n" ); … … 250 244 } 251 245 252 sleep( 5 ); 253 254 // Let's try to start the image in any case... 246 printf( "setting CnE to factory default settings\n" ); 247 if ( !initializeConfigToFactorySettingCmd() ) { 248 debugError( "downloadFirmware: Could not reinitalize CnE\n" ); 249 return false; 250 } 251 252 printf( "start application\n" ); 255 253 if ( !startApplicationCmd() ) { 256 254 debugError( "downloadFirmware: Could not restart application\n" ); … … 266 264 using namespace std; 267 265 266 printf( "parse BCD file\n" ); 268 267 std::auto_ptr<BCD> bcd = std::auto_ptr<BCD>( new BCD( filename ) ); 269 268 if ( !bcd.get() ) { … … 272 271 return false; 273 272 } 274 275 273 if ( !bcd->parse() ) { 276 274 debugError( "downloadCnE: BCD parsing failed\n" ); … … 278 276 } 279 277 278 printf( "prepare for download (start bootloader)\n" ); 280 279 if ( !startBootloaderCmd() ) { 281 280 debugError( "downloadCnE: Could not start bootloader\n" ); 282 281 return false; 283 282 } 284 waitForBusReset(); 285 if ( !cacheInfoRegisters( MaxRetries ) ) { 286 debugError( "downloadCnE: Could not read info registers\n" ); 287 return false; 288 } 289 290 // wait for bootloader finish startup sequence 291 // there is no way to find out when it has finished 292 sleep( 10 ); 293 294 get1394Serivce()->setVerbose( true ); 295 283 284 printf( "start downloading protocol for CnE\n" ); 296 285 if ( !downloadObject( *bcd, eOT_CnE ) ) { 297 286 debugError( "downloadCnE: CnE download failed\n" ); … … 299 288 } 300 289 290 printf( "setting CnE to factory default settings\n" ); 301 291 if ( !initializeConfigToFactorySettingCmd() ) { 302 debugError( "downloadCnE: Setting default config " 303 "settings failed\n" ); 304 return false; 305 } 306 307 sleep( 5 ); 308 309 // Let's try to start the image in any case... 292 debugError( "downloadFirmware: Could not reinitalize CnE\n" ); 293 return false; 294 } 295 296 printf( "start application\n" ); 310 297 if ( !startApplicationCmd() ) { 311 298 debugError( "downloadCnE: Could not restart application\n" ); … … 363 350 // bootloader erases the flash, have to wait until is ready 364 351 // to answer our next request 352 printf( "wait unitl flash ereasing has terminated\n" ); 365 353 sleep( 20 ); 366 354 … … 380 368 fb_quadlet_t address = 0; 381 369 bool result = true; 382 int nrBlocks = ( imageLength + maxBlockSize - 1 ) / maxBlockSize; 370 int totalBytes = imageLength; 371 int downloadedBytes = 0; 383 372 while ( imageLength > 0 ) { 384 373 unsigned int blockSize = imageLength > maxBlockSize ? … … 412 401 break; 413 402 } 414 usleep( 100 0);403 usleep( 100 ); 415 404 416 405 if ( !readResponse( ccBlock ) ) { … … 434 423 } 435 424 436 if ( ( i % 1000 ) == 0 ) { 437 printf( "[%04d/%04d] packets downloaded\n", i, nrBlocks ); 425 downloadedBytes += blockSize; 426 if ( ( i % 100 ) == 0 ) { 427 printf( "%10d/%d bytes downloaded\n", 428 downloadedBytes, totalBytes ); 438 429 } 439 430 … … 443 434 i++; 444 435 } 436 printf( "%10d/%d bytes downloaded\n", 437 downloadedBytes, totalBytes ); 445 438 446 439 if ( !result ) { … … 456 449 } 457 450 451 printf( "wait for transaction completion\n" ); 458 452 sleep( 10 ); 459 453 … … 478 472 } 479 473 } 474 printf( "download protocol successfuly completed\n" ); 480 475 return result; 481 476 } … … 488 483 return false; 489 484 } 490 491 waitForBusReset();492 if ( !cacheInfoRegisters( MaxRetries ) ) {493 debugError( "programGUID: Could not read info registers\n" );494 return false;495 }496 497 // wait for bootloader finish startup sequence498 // there is no way to find out when it has finished499 sleep( 10 );500 485 501 486 if ( !programGUIDCmd( guid ) ) { … … 609 594 } 610 595 596 waitForBusReset(); 597 if ( !cacheInfoRegisters( MaxRetries ) ) { 598 debugError( "startBootloaderCmd: Could not read info registers\n" ); 599 return false; 600 } 601 602 // wait for bootloader finish startup sequence 603 // there is no way to find out when it has finished 604 sleep( 10 ); 605 611 606 return true; 612 607 } … … 615 610 BeBoB::BootloaderManager::startApplicationCmd() 616 611 { 617 CommandCodes Resetcmd( m_protocolVersion,618 CommandCodes Reset::eSM_Application ) ;612 CommandCodesGo cmd( m_protocolVersion, 613 CommandCodesGo::eSM_Application ) ; 619 614 if ( !writeRequest( cmd ) ) { 620 615 debugError( "startApplicationCmd: writeRequest failed\n" ); … … 634 629 } 635 630 631 sleep( 1 ); 632 636 633 return true; 637 634 } … … 646 643 } 647 644 645 sleep( 1 ); 646 648 647 return true; 649 648 } … … 658 657 } 659 658 660 return true; 661 } 659 sleep( 5 ); 660 661 return true; 662 }