root/branches/libffado-2.0/src/bebob/bebob_dl_mgr.cpp

Revision 1278, 21.9 kB (checked in by ppalmers, 16 years ago)

display more wait progress indicators, fix up help message

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "bebob_dl_mgr.h"
25 #include "bebob_dl_codes.h"
26 #include "bebob_dl_bcd.h"
27
28 #include "libieee1394/configrom.h"
29 #include "libieee1394/ieee1394service.h"
30
31 #include "libutil/cmd_serialize.h"
32 #include "libutil/Time.h"
33
34 #include "libutil/ByteSwap.h"
35
36 #include <cstdio>
37 #include <cstring>
38
39 namespace BeBoB {
40     enum {
41         AddrRegInfo    = 0xffffc8020000ULL,
42         AddrRegReq     = 0xffffc8021000ULL,
43         AddrRegReqBuf  = 0xffffc8021040ULL,
44         AddrRegResp    = 0xffffc8029000ULL,
45         AddrRegRespBuf = 0xffffc8029040ULL,
46     };
47
48     enum {
49         RegInfoManufactorIdOffset =      0x00,
50         RegInfoProtocolVersionOffset =   0x08,
51         RegInfoBootloaderVersionOffset = 0x0c,
52         RegInfoGUID =                    0x10,
53         RegInfoHardwareModelId =         0x18,
54         RegInfoHardwareRevision =        0x1c,
55         RegInfoSoftwareDate =            0x20,
56         RegInfoSoftwareTime =            0x28,
57         RegInfoSoftwareId =              0x30,
58         RegInfoSoftwareVersion =         0x34,
59         RegInfoBaseAddress =             0x38,
60         RegInfoMaxImageLen =             0x3c,
61         RegInfoBootloaderDate =          0x40,
62         RegInfoBootloaderTime =          0x48,
63         RegInfoDebuggerDate =            0x50,
64         RegInfoDebuggerTime =            0x58,
65         RegInfoDebuggerId =              0x60,
66         RegInfoDebuggerVersion =         0x64
67     };
68
69     enum {
70         MaxRetries = 10,
71     };
72
73     IMPL_DEBUG_MODULE( BootloaderManager, BootloaderManager, DEBUG_LEVEL_NORMAL );
74 }
75
76 BeBoB::BootloaderManager::BootloaderManager(Ieee1394Service& ieee1349service,
77                                             fb_nodeid_t nodeId )
78     : m_ieee1394service( &ieee1349service )
79     , m_protocolVersion( eBPV_Unknown )
80     , m_isAppRunning( false )
81     , m_forceEnabled( false )
82     , m_bStartBootloader( true )
83 {
84     memset( &m_cachedInfoRegs, 0, sizeof( m_cachedInfoRegs ) );
85
86     m_configRom = new ConfigRom( *m_ieee1394service, nodeId );
87     // XXX throw exception if initialize fails!
88     m_configRom->initialize();
89     if ( !cacheInfoRegisters() ) {
90         debugError( "BootloaderManager: could not cache info registers\n" );
91     }
92
93     switch(  m_cachedInfoRegs.m_protocolVersion ) {
94     case 1:
95         m_protocolVersion = eBPV_V1;
96         break;
97     case 3:
98         m_protocolVersion = eBPV_V3;
99         break;
100     default:
101         // exception?
102         break;
103     }
104
105     pthread_mutex_init( &m_mutex, 0 );
106     pthread_cond_init( &m_cond, 0 );
107
108     m_functor = new MemberFunctor0< BeBoB::BootloaderManager*,
109                 void (BeBoB::BootloaderManager::*)() >
110                 ( this, &BeBoB::BootloaderManager::busresetHandler, false );
111     m_ieee1394service->addBusResetHandler( m_functor );
112 }
113
114 BeBoB::BootloaderManager::~BootloaderManager()
115 {
116     m_ieee1394service->remBusResetHandler( m_functor );
117     delete( m_functor );
118
119     delete m_configRom;
120
121     pthread_cond_destroy( &m_cond );
122     pthread_mutex_destroy( &m_mutex );
123 }
124
125 bool
126 BeBoB::BootloaderManager::cacheInfoRegisters()
127 {
128     if ( !m_configRom->updatedNodeId() ) {
129         debugError( "cacheInfoRegisters: did not find device anymore\n" );
130         return false;
131     }
132
133     if ( !m_ieee1394service->read(
134              0xffc0 | m_configRom->getNodeId(),
135              AddrRegInfo,
136              sizeof( m_cachedInfoRegs )/4,
137              reinterpret_cast<fb_quadlet_t*>( &m_cachedInfoRegs ) ) )
138     {
139         return false;
140     }
141
142     if ( m_cachedInfoRegs.m_bootloaderVersion != 0x0 ) {
143         m_isAppRunning = false;
144     } else {
145         m_isAppRunning = true;
146     }
147
148     m_cachedInfoRegs.m_guid = ( m_cachedInfoRegs.m_guid >> 32 )
149                               | ( m_cachedInfoRegs.m_guid << 32 );
150
151     return true;
152 }
153
154 bool
155 BeBoB::BootloaderManager::cacheInfoRegisters( int retries )
156 {
157     for ( int i = 0; i < retries; ++i ) {
158         if ( cacheInfoRegisters() ) {
159             return true;
160         }
161         sleep( 1 );
162         printf(".");
163         fflush(stdout);
164     }
165
166     return false;
167 }
168
169 void
170 BeBoB::BootloaderManager::printInfoRegisters()
171 {
172     using namespace std;
173
174     if ( !cacheInfoRegisters() ) {
175         debugError( "Could not read info registers\n" );
176         return;
177     }
178
179     printf( "Info Registers\n" );
180     printf( "\tManufactors Id:\t\t%s\n",
181             makeString( m_cachedInfoRegs.m_manId ).c_str() );
182     printf( "\tProtocol Version:\t0x%08x\n",
183             m_cachedInfoRegs.m_protocolVersion );
184     printf( "\tBootloader Version:\t0x%08x\n",
185             m_cachedInfoRegs.m_bootloaderVersion );
186     printf( "\tGUID:\t\t\t0x%08x%08x\n",
187             ( unsigned int )( m_cachedInfoRegs.m_guid >> 32 ),
188             ( unsigned int )( m_cachedInfoRegs.m_guid & 0xffffffff ) );
189     printf( "\tHardware Model ID:\t0x%08x\n",
190             m_cachedInfoRegs.m_hardwareModelId );
191     printf( "\tHardware Revision:\t0x%08x\n",
192             m_cachedInfoRegs.m_hardwareRevision );
193     if (  m_cachedInfoRegs.m_softwareDate
194           && m_cachedInfoRegs.m_softwareTime )
195     {
196         printf( "\tSoftware Date:\t\t%s, %s\n",
197                 makeDate( m_cachedInfoRegs.m_softwareDate ).c_str(),
198                 makeTime( m_cachedInfoRegs.m_softwareTime ).c_str() );
199     }
200     printf( "\tSoftware Id:\t\t0x%08x\n", m_cachedInfoRegs.m_softwareId );
201     printf( "\tSoftware Version:\t0x%08x\n",
202             m_cachedInfoRegs.m_softwareVersion );
203     printf( "\tBase Address:\t\t0x%08x\n", m_cachedInfoRegs.m_baseAddress );
204     printf( "\tMax. Image Len:\t\t0x%08x\n", m_cachedInfoRegs.m_maxImageLen );
205     if ( m_cachedInfoRegs.m_bootloaderDate
206          && m_cachedInfoRegs.m_bootloaderTime )
207     {
208         printf( "\tBootloader Date:\t%s, %s\n",
209                 makeDate( m_cachedInfoRegs.m_bootloaderDate ).c_str(),
210                 makeTime( m_cachedInfoRegs.m_bootloaderTime ).c_str() );
211     }
212     if ( m_cachedInfoRegs.m_debuggerDate
213          && m_cachedInfoRegs.m_debuggerTime )
214     {
215         printf( "\tDebugger Date:\t\t%s, %s\n",
216                 makeDate( m_cachedInfoRegs.m_debuggerDate ).c_str(),
217                 makeTime( m_cachedInfoRegs.m_debuggerTime ).c_str() );
218     }
219     printf( "\tDebugger Id:\t\t0x%08x\n", m_cachedInfoRegs.m_debuggerId );
220     printf( "\tDebugger Version:\t0x%08x\n",
221             m_cachedInfoRegs.m_debuggerVersion );
222 }
223
224 bool
225 BeBoB::BootloaderManager::downloadFirmware( std::string filename )
226 {
227     using namespace std;
228
229     printf( "parse BCD file\n" );
230     std::auto_ptr<BCD> bcd = std::auto_ptr<BCD>( new BCD( filename ) );
231     if ( !bcd.get() ) {
232         debugError( "downloadFirmware: Could not open or parse BCD '%s'\n",
233                     filename.c_str() );
234         return false;
235     }
236     if ( !bcd->parse() ) {
237         debugError( "downloadFirmware: BCD parsing failed\n" );
238         return false;
239     }
240
241     printf( "check firmware device compatibility... " );
242     if ( !m_forceEnabled ) {
243         if ( !checkDeviceCompatibility( *bcd ) ) {
244             printf( "failed.\n" );
245             return false;
246         }
247         printf( "ok\n" );
248     } else {
249         printf( "forced\n" );
250     }
251
252     if ( m_bStartBootloader ) {
253         printf( "prepare for download (start bootloader)\n" );
254         if ( !startBootloaderCmd() ) {
255             debugError( "downloadFirmware: Could not start bootloader\n" );
256             return false;
257         }
258     }
259
260     printf( "start downloading protocol for application image\n" );
261     if ( !downloadObject( *bcd, eOT_Application ) ) {
262         debugError( "downloadFirmware: Firmware download failed\n" );
263         return false;
264     }
265
266     printf( "start downloading protocol for CnE\n" );
267     if ( !downloadObject( *bcd, eOT_CnE ) ) {
268         debugError( "downloadFirmware: CnE download failed\n" );
269         return false;
270     }
271
272     printf( "setting CnE to factory default settings\n" );
273     if ( !initializeConfigToFactorySettingCmd() ) {
274         debugError( "downloadFirmware: Could not reinitalize CnE\n" );
275         return false;
276     }
277
278     printf( "start application\n" );
279     if ( !startApplicationCmd() ) {
280         debugError( "downloadFirmware: Could not restart application\n" );
281         return false;
282     }
283
284     return true;
285 }
286
287 bool
288 BeBoB::BootloaderManager::downloadCnE( std::string filename )
289 {
290     using namespace std;
291
292     printf( "parse BCD file\n" );
293     std::auto_ptr<BCD> bcd = std::auto_ptr<BCD>( new BCD( filename ) );
294     if ( !bcd.get() ) {
295         debugError( "downloadCnE: Could not open or parse BCD '%s'\n",
296                     filename.c_str() );
297         return false;
298     }
299     if ( !bcd->parse() ) {
300         debugError( "downloadCnE: BCD parsing failed\n" );
301         return false;
302     }
303
304     printf( "check firmware device compatibility... " );
305     if ( !m_forceEnabled ) {
306         if ( !checkDeviceCompatibility( *bcd ) ) {
307             printf( "failed.\n" );
308             return false;
309         }
310         printf( "ok\n" );
311     } else {
312         printf( "forced\n" );
313     }
314
315     if ( m_bStartBootloader ) {
316         printf( "prepare for download (start bootloader)\n" );
317         if ( !startBootloaderCmd() ) {
318             debugError( "downloadCnE: Could not start bootloader\n" );
319             return false;
320         }
321     }
322
323     printf( "start downloading protocol for CnE\n" );
324     if ( !downloadObject( *bcd, eOT_CnE ) ) {
325         debugError( "downloadCnE: CnE download failed\n" );
326         return false;
327     }
328
329     printf( "setting CnE to factory default settings\n" );
330     if ( !initializeConfigToFactorySettingCmd() ) {
331         debugError( "downloadFirmware: Could not reinitalize CnE\n" );
332         return false;
333     }
334
335     printf( "start application\n" );
336     if ( !startApplicationCmd() ) {
337         debugError( "downloadCnE: Could not restart application\n" );
338         return false;
339     }
340
341     return true;
342 }
343
344
345 bool
346 BeBoB::BootloaderManager::downloadObject( BCD& bcd, EObjectType eObject )
347 {
348     using namespace std;
349
350     CommandCodesDownloadStart::EObject eCCDSObject;
351     fb_quadlet_t baseAddress;
352     fb_quadlet_t imageLength;
353     fb_quadlet_t crc;
354     fb_quadlet_t offset;
355
356     switch ( eObject ) {
357     case eOT_Application:
358         eCCDSObject = CommandCodesDownloadStart::eO_Application;
359         baseAddress = bcd.getImageBaseAddress();
360         imageLength = bcd.getImageLength();
361         crc = bcd.getImageCRC();
362         offset = bcd.getImageOffset();
363         break;
364     case eOT_CnE:
365         eCCDSObject = CommandCodesDownloadStart::eO_Config;
366         baseAddress = 0;
367         imageLength = bcd.getCnELength();
368         crc = bcd.getCnECRC();
369         offset = bcd.getCnEOffset();
370         break;
371     default:
372         return false;
373     }
374
375     CommandCodesDownloadStart ccDStart ( m_protocolVersion, eCCDSObject );
376     ccDStart.setDate( bcd.getSoftwareDate() );
377     ccDStart.setTime( bcd.getSoftwareTime() );
378     ccDStart.setId( bcd.getSoftwareId() );
379     ccDStart.setVersion( bcd.getSoftwareVersion() );
380     ccDStart.setBaseAddress( baseAddress );
381     ccDStart.setLength( imageLength );
382     ccDStart.setCRC( crc );
383
384     if ( !writeRequest( ccDStart ) ) {
385         debugError( "downloadObject: start command write request failed\n" );
386         return false;
387     }
388
389     // bootloader erases the flash, have to wait until is ready
390     // to answer our next request
391     printf( "wait until flash erasing has terminated\n" );
392     int cnt = 30;
393     while(cnt--) {
394         sleep( 1 );
395         printf(".");
396         fflush(stdout);
397     }
398     printf("\n");
399
400     if ( !readResponse( ccDStart ) ) {
401         debugError( "downloadObject: (start) command read request failed\n" );
402         return false;
403     }
404
405     if ( ccDStart.getMaxBlockSize() < 0 ) {
406         debugError( "downloadObject: (start) command reported error %d\n",
407                     ccDStart.getMaxBlockSize() );
408         return false;
409     }
410
411     unsigned int maxBlockSize = m_configRom->getAsyMaxPayload();
412     unsigned int i = 0;
413     fb_quadlet_t address = 0;
414     bool result = true;
415     int totalBytes = imageLength;
416     int downloadedBytes = 0;
417     while ( imageLength > 0 ) {
418         unsigned int blockSize = imageLength > maxBlockSize ?
419                         maxBlockSize  : imageLength;
420
421         fb_byte_t block[blockSize];
422         if ( !bcd.read( offset, block, blockSize ) ) {
423             result = false;
424             break;
425         }
426
427         if ( !get1394Serivce()->write(
428                  0xffc0 | getConfigRom()->getNodeId(),
429                  AddrRegReqBuf,
430                  ( blockSize + 3 ) / 4,
431                  reinterpret_cast<fb_quadlet_t*>( block ) ) )
432         {
433             debugError( "downloadObject: Could not write to node %d\n",
434                         getConfigRom()->getNodeId() );
435             return false;
436         }
437
438         CommandCodesDownloadBlock ccBlock( m_protocolVersion );
439         ccBlock.setSeqNumber( i );
440         ccBlock.setAddress( baseAddress + address );
441         ccBlock.setNumberBytes( blockSize );
442
443         if ( !writeRequest( ccBlock ) ) {
444             debugError( "downloadObject: (block) write request failed\n" );
445             result = false;
446             break;
447         }
448         SleepRelativeUsec( 100 );
449
450         if ( !readResponse( ccBlock ) ) {
451             debugError( "downloadObject: (block) read request failed\n" );
452             result = false;
453             break;
454         }
455
456         if ( i != ccBlock.getRespSeqNumber() ) {
457             debugError( "downloadObject: (block) wrong sequence number "
458                         "reported. %d expected, %d reported\n",
459                         i, ccBlock.getRespSeqNumber() );
460             result = false;
461             break;
462         }
463         if ( ccBlock.getRespErrorCode() != 0 ) {
464             debugError( "downloadObject: (block) failed download with "
465                         "error code 0x%08x\n", ccBlock.getRespErrorCode() );
466             result = false;
467             break;
468         }
469
470         downloadedBytes += blockSize;
471         if ( ( i % 100 ) == 0 ) {
472            printf( "%10d/%d bytes downloaded\r",
473                    downloadedBytes, totalBytes );
474            fflush(stdout);
475         }
476
477         imageLength -= blockSize;
478         address += blockSize;
479         offset += blockSize;
480         i++;
481     }
482     printf( "%10d/%d bytes downloaded\n",
483             downloadedBytes, totalBytes );
484
485     if ( !result ) {
486         debugError( "downloadObject: seqNumber = %d, "
487                     "address = 0%08x, offset = 0x%08x, "
488                     "restImageLength = 0x%08x\n",
489                     i, address, offset, imageLength );
490     }
491
492     CommandCodesDownloadEnd ccEnd( m_protocolVersion );
493     if ( !writeRequest( ccEnd ) ) {
494         debugError( "downloadObject: (end) command write failed\n" );
495     }
496
497     printf( "wait for transaction completion\n" );
498     cnt = 10;
499     while(cnt--) {
500         sleep( 1 );
501         printf(".");
502         fflush(stdout);
503     }
504     printf("\n");
505
506     if ( !readResponse( ccEnd ) ) {
507         debugError( "downloadObject: (end) command read failed\n" );
508     }
509
510     if ( result ) {
511         if ( ccEnd.getRespIsValid() ) {
512             if ( ccEnd.getRespCrc32() == crc ) {
513                 debugOutput( DebugModule::eDL_Normal,
514                              "downloadObject: CRC match\n" );
515             } else {
516                 debugError( "downloadObject: CRC mismatch. 0x%08x expected, "
517                             "0x%08x reported",
518                             crc, ccEnd.getRespCrc32() );
519                 result = false;
520             }
521         } else {
522             debugError( "downloadObject: (end) object is not valid\n" );
523             result = false;
524         }
525     }
526     printf( "download protocol successfuly completed\n" );
527     return result;
528 }
529
530 bool
531 BeBoB::BootloaderManager::programGUID( fb_octlet_t guid )
532 {
533     if ( m_bStartBootloader ) {
534         if ( !startBootloaderCmd() ) {
535             debugError( "programGUID: Could not start bootloader\n" );
536             return false;
537         }
538     }
539
540     if ( !programGUIDCmd( guid ) ) {
541         debugError( "programGUID: Could not program guid\n" );
542         return false;
543     }
544
545     if ( !startApplicationCmd() ) {
546         debugError( "Could not restart application\n");
547         return false;
548     }
549
550     return true;
551 }
552
553 void
554 BeBoB::BootloaderManager::busresetHandler()
555 {
556     pthread_cond_signal( &m_cond );
557 }
558
559 void
560 BeBoB::BootloaderManager::waitForBusReset()
561 {
562     struct timespec timeout;
563     int retcode;
564     clock_gettime(CLOCK_REALTIME, &timeout);
565     do {
566         printf(".");
567         fflush(stdout);
568         timeout.tv_sec = timeout.tv_sec + 1;
569         retcode = pthread_cond_timedwait( &m_cond, &m_mutex, &timeout );
570     } while (retcode == ETIMEDOUT);
571 }
572
573 bool
574 BeBoB::BootloaderManager::writeRequest( CommandCodes& cmd )
575 {
576     unsigned char buf[ ( ( cmd.getMaxSize()+3 )/4 ) * 4 ];
577     memset( buf, 0, sizeof( buf ) );
578
579     Util::Cmd::BufferSerialize se( buf,  sizeof( buf ) );
580     if ( !cmd.serialize( se ) ) {
581         debugError( "writeRequest: Could not serialize command code %d\n",
582                     cmd.getCommandCode() );
583         return false;
584     }
585
586     if ( !get1394Serivce()->write(
587              0xffc0 | getConfigRom()->getNodeId(),
588              AddrRegReq,
589              sizeof( buf )/4,
590              reinterpret_cast<fb_quadlet_t*>( buf ) ) )
591     {
592         debugError( "writeRequest: Could not ARM write to node %d\n",
593                     getConfigRom()->getNodeId() );
594         return false;
595     }
596
597     return true;
598 }
599
600 bool
601 BeBoB::BootloaderManager::readResponse( CommandCodes& writeRequestCmd )
602 {
603     const size_t buf_length = 0x40;
604     unsigned char raw[buf_length];
605     if ( !get1394Serivce()->read(
606              0xffc0 | getConfigRom()->getNodeId(),
607              AddrRegResp,
608              writeRequestCmd.getRespSizeInQuadlets(),
609              reinterpret_cast<fb_quadlet_t*>( raw ) ) )
610     {
611         return false;
612     }
613
614     Util::Cmd::BufferDeserialize de( raw, buf_length );
615     if ( !writeRequestCmd.deserialize( de ) ) {
616         debugError( "readResponse: deserialize failed\n" );
617         return false;
618     }
619
620     bool result =
621         writeRequestCmd.getProtocolVersion()
622         == writeRequestCmd.getRespProtocolVersion();
623     result &=
624         writeRequestCmd.getCommandId()
625         == writeRequestCmd.getRespCommandId();
626     result &=
627         writeRequestCmd.getCommandCode()
628         == writeRequestCmd.getRespCommandCode();
629     #ifdef DEBUG
630        if ( !result ) {
631            debugError( "readResponse: protocol version: %d expected, "
632                        " %d reported\n",
633                        writeRequestCmd.getProtocolVersion(),
634                        writeRequestCmd.getRespProtocolVersion() );
635            debugError( "readResponse: command id: %d expected, "
636                        " %d reported\n",
637                        writeRequestCmd.getCommandId(),
638                        writeRequestCmd.getRespCommandId() );
639            debugError( "readResponse: command code: %d expected, "
640                        " %d reported\n",
641                        writeRequestCmd.getCommandCode(),
642                        writeRequestCmd.getRespCommandCode() );
643        }
644     #endif
645     return result;
646 }
647
648 bool
649 BeBoB::BootloaderManager::startBootloaderCmd()
650 {
651     CommandCodesReset cmd( m_protocolVersion,
652                            CommandCodesReset::eSM_Bootloader ) ;
653     if ( !writeRequest( cmd ) ) {
654         debugError( "startBootloaderCmd: writeRequest failed\n" );
655         return false;
656     }
657
658     waitForBusReset();
659     if ( !cacheInfoRegisters( MaxRetries ) ) {
660         debugError( "startBootloaderCmd: Could not read info registers\n" );
661         return false;
662     }
663
664     // wait for bootloader finish startup sequence
665     // there is no way to find out when it has finished
666     sleep( 10 );
667     int cnt = 10;
668     while(cnt--) {
669         sleep( 1 );
670         printf(".");
671         fflush(stdout);
672     }
673     printf("\n");
674
675     return true;
676 }
677
678 bool
679 BeBoB::BootloaderManager::startApplicationCmd()
680 {
681     CommandCodesGo cmd( m_protocolVersion,
682                            CommandCodesGo::eSM_Application ) ;
683     if ( !writeRequest( cmd ) ) {
684         debugError( "startApplicationCmd: writeRequest failed\n" );
685         return false;
686     }
687
688     return true;
689 }
690
691 bool
692 BeBoB::BootloaderManager::programGUIDCmd( fb_octlet_t guid )
693 {
694     CommandCodesProgramGUID cmd( m_protocolVersion, guid );
695     if ( !writeRequest( cmd ) ) {
696         debugError( "programGUIDCmd: writeRequest failed\n" );
697         return false;
698     }
699
700     sleep( 1 );
701
702     return true;
703 }
704
705 bool
706 BeBoB::BootloaderManager::initializePersParamCmd()
707 {
708     CommandCodesInitializePersParam cmd( m_protocolVersion );
709     if ( !writeRequest( cmd ) ) {
710         debugError( "initializePersParamCmd: writeRequest failed\n" );
711         return false;
712     }
713
714     sleep( 1 );
715
716     return true;
717 }
718
719 bool
720 BeBoB::BootloaderManager::initializeConfigToFactorySettingCmd()
721 {
722     CommandCodesInitializeConfigToFactorySetting cmd( m_protocolVersion );
723     if ( !writeRequest( cmd ) ) {
724         debugError( "initializeConfigToFactorySettingCmd: writeRequest failed\n" );
725         return false;
726     }
727
728     sleep( 5 );
729     int cnt = 5;
730     while(cnt--) {
731         sleep( 1 );
732         printf(".");
733         fflush(stdout);
734     }
735     printf("\n");
736
737     return true;
738 }
739
740 bool
741 BeBoB::BootloaderManager::checkDeviceCompatibility( BCD& bcd )
742 {
743     fb_quadlet_t vendorOUI = (  m_cachedInfoRegs.m_guid >> 40 );
744
745
746     if ( ( vendorOUI == bcd.getVendorOUI() )
747          && ( m_cachedInfoRegs.m_softwareId == bcd.getSoftwareId() ) )
748     {
749         return true;
750     }
751
752     printf( "vendorOUI = 0x%08x\n", vendorOUI );
753     printf( "BCD vendorOUI = 0x%08x\n", bcd.getVendorOUI() );
754     printf( "software ID = 0x%08x\n", m_cachedInfoRegs.m_softwareId );
755     printf( "BCD software ID = 0x%08x\n", bcd.getSoftwareId() );
756
757     return false;
758 }
Note: See TracBrowser for help on using the browser.