root/trunk/libffado/src/bebob/bebob_dl_mgr.cpp

Revision 554, 21.1 kB (checked in by ppalmers, 15 years ago)

Merge echoaudio branch into trunk.

This adds support for the Echo Audiofire devices to FFADO. Possibly also other devices working with the Apple Class Driver will work with this code. It is not fully complete yet, but the main rework is
done.

First of all the IAvDevice class/interface is renamed to FFADODevice, in order to separate the AV/C code from the FFADO API code. A device supported by FFADO implements a FFADODevice.

The BeBoB device has been split up into three groups:
- libavc/* : all code and commands that are specified by AV/C specs. Note that a lot of the code that used to be in BeBoB::AvDevice? now resides in AVC::Unit
- genericavc/* : a FFADODevice that uses AV/C descriptors & commands for discovery and config
- bebob/* : the bebob FFADODevice that inherits from GenericAVC::AvDevice? but that uses BridgeCo? commands for discovery

Everything has been moved as high as possible in the class hierarchy. If necessary, a subclass that uses device specific commands is introduced (e.g. BeBoB::Plug inherits from AVC::Plug and uses the
BridgeCo? extended plug info command to discover it's properties).

There are some other fixes along the way that have been done too.

Line 
1 /*
2  * Copyright (C) 2005-2007 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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
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 "libavc/util/avc_serialize.h"
32
33 #include <netinet/in.h>
34
35 #include <cstdio>
36
37 using namespace AVC;
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     }
163
164     return false;
165 }
166
167 void
168 BeBoB::BootloaderManager::printInfoRegisters()
169 {
170     using namespace std;
171
172     if ( !cacheInfoRegisters() ) {
173         debugError( "Could not read info registers\n" );
174         return;
175     }
176
177     printf( "Info Registers\n" );
178     printf( "\tManufactors Id:\t\t%s\n",
179             makeString( m_cachedInfoRegs.m_manId ).c_str() );
180     printf( "\tProtocol Version:\t0x%08x\n",
181             m_cachedInfoRegs.m_protocolVersion );
182     printf( "\tBootloader Version:\t0x%08x\n",
183             m_cachedInfoRegs.m_bootloaderVersion );
184     printf( "\tGUID:\t\t\t0x%08x%08x\n",
185             ( unsigned int )( m_cachedInfoRegs.m_guid >> 32 ),
186             ( unsigned int )( m_cachedInfoRegs.m_guid & 0xffffffff ) );
187     printf( "\tHardware Model ID:\t0x%08x\n",
188             m_cachedInfoRegs.m_hardwareModelId );
189     printf( "\tHardware Revision:\t0x%08x\n",
190             m_cachedInfoRegs.m_hardwareRevision );
191     if (  m_cachedInfoRegs.m_softwareDate
192           && m_cachedInfoRegs.m_softwareTime )
193     {
194         printf( "\tSoftware Date:\t\t%s, %s\n",
195                 makeDate( m_cachedInfoRegs.m_softwareDate ).c_str(),
196                 makeTime( m_cachedInfoRegs.m_softwareTime ).c_str() );
197     }
198     printf( "\tSoftware Id:\t\t0x%08x\n", m_cachedInfoRegs.m_softwareId );
199     printf( "\tSoftware Version:\t0x%08x\n",
200             m_cachedInfoRegs.m_softwareVersion );
201     printf( "\tBase Address:\t\t0x%08x\n", m_cachedInfoRegs.m_baseAddress );
202     printf( "\tMax. Image Len:\t\t0x%08x\n", m_cachedInfoRegs.m_maxImageLen );
203     if ( m_cachedInfoRegs.m_bootloaderDate
204          && m_cachedInfoRegs.m_bootloaderTime )
205     {
206         printf( "\tBootloader Date:\t%s, %s\n",
207                 makeDate( m_cachedInfoRegs.m_bootloaderDate ).c_str(),
208                 makeTime( m_cachedInfoRegs.m_bootloaderTime ).c_str() );
209     }
210     if ( m_cachedInfoRegs.m_debuggerDate
211          && m_cachedInfoRegs.m_debuggerTime )
212     {
213         printf( "\tDebugger Date:\t\t%s, %s\n",
214                 makeDate( m_cachedInfoRegs.m_debuggerDate ).c_str(),
215                 makeTime( m_cachedInfoRegs.m_debuggerTime ).c_str() );
216     }
217     printf( "\tDebugger Id:\t\t0x%08x\n", m_cachedInfoRegs.m_debuggerId );
218     printf( "\tDebugger Version:\t0x%08x\n",
219             m_cachedInfoRegs.m_debuggerVersion );
220 }
221
222 bool
223 BeBoB::BootloaderManager::downloadFirmware( std::string filename )
224 {
225     using namespace std;
226
227     printf( "parse BCD file\n" );
228     std::auto_ptr<BCD> bcd = std::auto_ptr<BCD>( new BCD( filename ) );
229     if ( !bcd.get() ) {
230         debugError( "downloadFirmware: Could not open or parse BCD '%s'\n",
231                     filename.c_str() );
232         return false;
233     }
234     if ( !bcd->parse() ) {
235         debugError( "downloadFirmware: BCD parsing failed\n" );
236         return false;
237     }
238
239     printf( "check firmware device compatibility... " );
240     if ( !m_forceEnabled ) {
241         if ( !checkDeviceCompatibility( *bcd ) ) {
242             printf( "failed.\n" );
243             return false;
244         }
245         printf( "ok\n" );
246     } else {
247         printf( "forced\n" );
248     }
249
250     if ( m_bStartBootloader ) {
251         printf( "prepare for download (start bootloader)\n" );
252         if ( !startBootloaderCmd() ) {
253             debugError( "downloadFirmware: Could not start bootloader\n" );
254             return false;
255         }
256     }
257
258     printf( "start downloading protocol for application image\n" );
259     if ( !downloadObject( *bcd, eOT_Application ) ) {
260         debugError( "downloadFirmware: Firmware download failed\n" );
261         return false;
262     }
263
264     printf( "start downloading protocol for CnE\n" );
265     if ( !downloadObject( *bcd, eOT_CnE ) ) {
266         debugError( "downloadFirmware: CnE download failed\n" );
267         return false;
268     }
269
270     printf( "setting CnE to factory default settings\n" );
271     if ( !initializeConfigToFactorySettingCmd() ) {
272         debugError( "downloadFirmware: Could not reinitalize CnE\n" );
273         return false;
274     }
275
276     printf( "start application\n" );
277     if ( !startApplicationCmd() ) {
278         debugError( "downloadFirmware: Could not restart application\n" );
279         return false;
280     }
281
282     return true;
283 }
284
285 bool
286 BeBoB::BootloaderManager::downloadCnE( std::string filename )
287 {
288     using namespace std;
289
290     printf( "parse BCD file\n" );
291     std::auto_ptr<BCD> bcd = std::auto_ptr<BCD>( new BCD( filename ) );
292     if ( !bcd.get() ) {
293         debugError( "downloadCnE: Could not open or parse BCD '%s'\n",
294                     filename.c_str() );
295         return false;
296     }
297     if ( !bcd->parse() ) {
298         debugError( "downloadCnE: BCD parsing failed\n" );
299         return false;
300     }
301
302     printf( "check firmware device compatibility... " );
303     if ( !m_forceEnabled ) {
304         if ( !checkDeviceCompatibility( *bcd ) ) {
305             printf( "failed.\n" );
306             return false;
307         }
308         printf( "ok\n" );
309     } else {
310         printf( "forced\n" );
311     }
312
313     if ( m_bStartBootloader ) {
314         printf( "prepare for download (start bootloader)\n" );
315         if ( !startBootloaderCmd() ) {
316             debugError( "downloadCnE: Could not start bootloader\n" );
317             return false;
318         }
319     }
320
321     printf( "start downloading protocol for CnE\n" );
322     if ( !downloadObject( *bcd, eOT_CnE ) ) {
323         debugError( "downloadCnE: CnE download failed\n" );
324         return false;
325     }
326
327     printf( "setting CnE to factory default settings\n" );
328     if ( !initializeConfigToFactorySettingCmd() ) {
329         debugError( "downloadFirmware: Could not reinitalize CnE\n" );
330         return false;
331     }
332
333     printf( "start application\n" );
334     if ( !startApplicationCmd() ) {
335         debugError( "downloadCnE: Could not restart application\n" );
336         return false;
337     }
338
339     return true;
340 }
341
342
343 bool
344 BeBoB::BootloaderManager::downloadObject( BCD& bcd, EObjectType eObject )
345 {
346     using namespace std;
347
348     CommandCodesDownloadStart::EObject eCCDSObject;
349     fb_quadlet_t baseAddress;
350     fb_quadlet_t imageLength;
351     fb_quadlet_t crc;
352     fb_quadlet_t offset;
353
354     switch ( eObject ) {
355     case eOT_Application:
356         eCCDSObject = CommandCodesDownloadStart::eO_Application;
357         baseAddress = bcd.getImageBaseAddress();
358         imageLength = bcd.getImageLength();
359         crc = bcd.getImageCRC();
360         offset = bcd.getImageOffset();
361         break;
362     case eOT_CnE:
363         eCCDSObject = CommandCodesDownloadStart::eO_Config;
364         baseAddress = 0;
365         imageLength = bcd.getCnELength();
366         crc = bcd.getCnECRC();
367         offset = bcd.getCnEOffset();
368         break;
369     default:
370         return false;
371     }
372
373     CommandCodesDownloadStart ccDStart ( m_protocolVersion, eCCDSObject );
374     ccDStart.setDate( bcd.getSoftwareDate() );
375     ccDStart.setTime( bcd.getSoftwareTime() );
376     ccDStart.setId( bcd.getSoftwareId() );
377     ccDStart.setVersion( bcd.getSoftwareVersion() );
378     ccDStart.setBaseAddress( baseAddress );
379     ccDStart.setLength( imageLength );
380     ccDStart.setCRC( crc );
381
382     if ( !writeRequest( ccDStart ) ) {
383         debugError( "downloadObject: start command write request failed\n" );
384         return false;
385     }
386
387     // bootloader erases the flash, have to wait until is ready
388     // to answer our next request
389     printf( "wait until flash ereasing has terminated\n" );
390     sleep( 30 );
391
392     if ( !readResponse( ccDStart ) ) {
393         debugError( "downloadObject: (start) command read request failed\n" );
394         return false;
395     }
396
397     if ( ccDStart.getMaxBlockSize() < 0 ) {
398         debugError( "downloadObject: (start) command reported error %d\n",
399                     ccDStart.getMaxBlockSize() );
400         return false;
401     }
402
403     unsigned int maxBlockSize = m_configRom->getAsyMaxPayload();
404     unsigned int i = 0;
405     fb_quadlet_t address = 0;
406     bool result = true;
407     int totalBytes = imageLength;
408     int downloadedBytes = 0;
409     while ( imageLength > 0 ) {
410         unsigned int blockSize = imageLength > maxBlockSize ?
411                         maxBlockSize  : imageLength;
412
413         fb_byte_t block[blockSize];
414         if ( !bcd.read( offset, block, blockSize ) ) {
415             result = false;
416             break;
417         }
418
419         if ( !get1394Serivce()->write(
420                  0xffc0 | getConfigRom()->getNodeId(),
421                  AddrRegReqBuf,
422                  ( blockSize + 3 ) / 4,
423                  reinterpret_cast<fb_quadlet_t*>( block ) ) )
424         {
425             debugError( "downloadObject: Could not write to node %d\n",
426                         getConfigRom()->getNodeId() );
427             return false;
428         }
429
430         CommandCodesDownloadBlock ccBlock( m_protocolVersion );
431         ccBlock.setSeqNumber( i );
432         ccBlock.setAddress( baseAddress + address );
433         ccBlock.setNumberBytes( blockSize );
434
435         if ( !writeRequest( ccBlock ) ) {
436             debugError( "downloadObject: (block) write request failed" );
437             result = false;
438             break;
439         }
440         usleep( 100 );
441
442         if ( !readResponse( ccBlock ) ) {
443             debugError( "downloadObject: (block) read request failed\n" );
444             result = false;
445             break;
446         }
447
448         if ( i != ccBlock.getRespSeqNumber() ) {
449             debugError( "downloadObject: (block) wrong sequence number "
450                         "reported. %d expected, %d reported\n",
451                         i, ccBlock.getRespSeqNumber() );
452             result = false;
453             break;
454         }
455         if ( ccBlock.getRespErrorCode() != 0 ) {
456             debugError( "downloadObject: (block) failed download with "
457                         "error code 0x%08x\n", ccBlock.getRespErrorCode() );
458             result = false;
459             break;
460         }
461
462         downloadedBytes += blockSize;
463         if ( ( i % 100 ) == 0 ) {
464            printf( "%10d/%d bytes downloaded\n",
465                    downloadedBytes, totalBytes );
466         }
467
468         imageLength -= blockSize;
469         address += blockSize;
470         offset += blockSize;
471         i++;
472     }
473     printf( "%10d/%d bytes downloaded\n",
474             downloadedBytes, totalBytes );
475
476     if ( !result ) {
477         debugError( "downloadObject: seqNumber = %d, "
478                     "address = 0%08x, offset = 0x%08x, "
479                     "restImageLength = 0x%08x\n",
480                     i, address, offset, imageLength );
481     }
482
483     CommandCodesDownloadEnd ccEnd( m_protocolVersion );
484     if ( !writeRequest( ccEnd ) ) {
485         debugError( "downloadObject: (end) command write failed\n" );
486     }
487
488     printf( "wait for transaction completion\n" );
489     sleep( 10 );
490
491     if ( !readResponse( ccEnd ) ) {
492         debugError( "downloadObject: (end) command read failed\n" );
493     }
494
495     if ( result ) {
496         if ( ccEnd.getRespIsValid() ) {
497             if ( ccEnd.getRespCrc32() == crc ) {
498                 debugOutput( DebugModule::eDL_Normal,
499                              "downloadObject: CRC match\n" );
500             } else {
501                 debugError( "downloadObject: CRC mismatch. 0x%08x expected, "
502                             "0x%08x reported",
503                             crc, ccEnd.getRespCrc32() );
504                 result = false;
505             }
506         } else {
507             debugError( "downloadObject: (end) object is not valid\n" );
508             result = false;
509         }
510     }
511     printf( "download protocol successfuly completed\n" );
512     return result;
513 }
514
515 bool
516 BeBoB::BootloaderManager::programGUID( fb_octlet_t guid )
517 {
518     if ( m_bStartBootloader ) {
519         if ( !startBootloaderCmd() ) {
520             debugError( "programGUID: Could not start bootloader\n" );
521             return false;
522         }
523     }
524
525     if ( !programGUIDCmd( guid ) ) {
526         debugError( "programGUID: Could not program guid\n" );
527         return false;
528     }
529
530     if ( !startApplicationCmd() ) {
531         debugError( "Could not restart application\n");
532         return false;
533     }
534
535     return true;
536 }
537
538 void
539 BeBoB::BootloaderManager::busresetHandler()
540 {
541     pthread_cond_signal( &m_cond );
542 }
543
544 void
545 BeBoB::BootloaderManager::waitForBusReset()
546 {
547     pthread_cond_wait( &m_cond, &m_mutex );
548 }
549
550 bool
551 BeBoB::BootloaderManager::writeRequest( CommandCodes& cmd )
552 {
553     unsigned char buf[ ( ( cmd.getMaxSize()+3 )/4 ) * 4 ];
554     memset( buf, 0, sizeof( buf ) );
555
556     BufferSerialize se( buf,  sizeof( buf ) );
557     if ( !cmd.serialize( se ) ) {
558         debugError( "writeRequest: Could not serialize command code %d\n",
559                     cmd.getCommandCode() );
560         return false;
561     }
562
563     if ( !get1394Serivce()->write(
564              0xffc0 | getConfigRom()->getNodeId(),
565              AddrRegReq,
566              sizeof( buf )/4,
567              reinterpret_cast<fb_quadlet_t*>( buf ) ) )
568     {
569         debugError( "writeRequest: Could not ARM write to node %d\n",
570                     getConfigRom()->getNodeId() );
571         return false;
572     }
573
574     return true;
575 }
576
577 bool
578 BeBoB::BootloaderManager::readResponse( CommandCodes& writeRequestCmd )
579 {
580     const size_t buf_length = 0x40;
581     unsigned char raw[buf_length];
582     if ( !get1394Serivce()->read(
583              0xffc0 | getConfigRom()->getNodeId(),
584              AddrRegResp,
585              writeRequestCmd.getRespSizeInQuadlets(),
586              reinterpret_cast<fb_quadlet_t*>( raw ) ) )
587     {
588         return false;
589     }
590
591     BufferDeserialize de( raw, buf_length );
592     if ( !writeRequestCmd.deserialize( de ) ) {
593         debugError( "readResponse: deserialize failed\n" );
594         return false;
595     }
596
597     bool result =
598         writeRequestCmd.getProtocolVersion()
599         == writeRequestCmd.getRespProtocolVersion();
600     result &=
601         writeRequestCmd.getCommandId()
602         == writeRequestCmd.getRespCommandId();
603     result &=
604         writeRequestCmd.getCommandCode()
605         == writeRequestCmd.getRespCommandCode();
606     #ifdef DEBUG
607        if ( !result ) {
608            debugError( "readResponse: protocol version: %d expected, "
609                        " %d reported\n",
610                        writeRequestCmd.getProtocolVersion(),
611                        writeRequestCmd.getRespProtocolVersion() );
612            debugError( "readResponse: command id: %d expected, "
613                        " %d reported\n",
614                        writeRequestCmd.getCommandId(),
615                        writeRequestCmd.getRespCommandId() );
616            debugError( "readResponse: command code: %d expected, "
617                        " %d reported\n",
618                        writeRequestCmd.getCommandCode(),
619                        writeRequestCmd.getRespCommandCode() );
620        }
621     #endif
622     return result;
623 }
624
625 bool
626 BeBoB::BootloaderManager::startBootloaderCmd()
627 {
628     CommandCodesReset cmd( m_protocolVersion,
629                            CommandCodesReset::eSM_Bootloader ) ;
630     if ( !writeRequest( cmd ) ) {
631         debugError( "startBootloaderCmd: writeRequest failed\n" );
632         return false;
633     }
634
635     waitForBusReset();
636     if ( !cacheInfoRegisters( MaxRetries ) ) {
637         debugError( "startBootloaderCmd: Could not read info registers\n" );
638         return false;
639     }
640
641     // wait for bootloader finish startup sequence
642     // there is no way to find out when it has finished
643     sleep( 10 );
644
645     return true;
646 }
647
648 bool
649 BeBoB::BootloaderManager::startApplicationCmd()
650 {
651     CommandCodesGo cmd( m_protocolVersion,
652                            CommandCodesGo::eSM_Application ) ;
653     if ( !writeRequest( cmd ) ) {
654         debugError( "startApplicationCmd: writeRequest failed\n" );
655         return false;
656     }
657
658     return true;
659 }
660
661 bool
662 BeBoB::BootloaderManager::programGUIDCmd( fb_octlet_t guid )
663 {
664     CommandCodesProgramGUID cmd( m_protocolVersion, guid );
665     if ( !writeRequest( cmd ) ) {
666         debugError( "programGUIDCmd: writeRequest failed\n" );
667         return false;
668     }
669
670     sleep( 1 );
671
672     return true;
673 }
674
675 bool
676 BeBoB::BootloaderManager::initializePersParamCmd()
677 {
678     CommandCodesInitializePersParam cmd( m_protocolVersion );
679     if ( !writeRequest( cmd ) ) {
680         debugError( "initializePersParamCmd: writeRequest failed\n" );
681         return false;
682     }
683
684     sleep( 1 );
685
686     return true;
687 }
688
689 bool
690 BeBoB::BootloaderManager::initializeConfigToFactorySettingCmd()
691 {
692     CommandCodesInitializeConfigToFactorySetting cmd( m_protocolVersion );
693     if ( !writeRequest( cmd ) ) {
694         debugError( "initializeConfigToFactorySettingCmd: writeRequest failed\n" );
695         return false;
696     }
697
698     sleep( 5 );
699
700     return true;
701 }
702
703 bool
704 BeBoB::BootloaderManager::checkDeviceCompatibility( BCD& bcd )
705 {
706     fb_quadlet_t vendorOUI = (  m_cachedInfoRegs.m_guid >> 40 );
707
708
709     if ( ( vendorOUI == bcd.getVendorOUI() )
710          && ( m_cachedInfoRegs.m_softwareId == bcd.getSoftwareId() ) )
711     {
712         return true;
713     }
714
715     printf( "vendorOUI = 0x%08x\n", vendorOUI );
716     printf( "BCD vendorOUI = 0x%08x\n", bcd.getVendorOUI() );
717     printf( "software ID = 0x%08x\n", m_cachedInfoRegs.m_softwareId );
718     printf( "BCD software ID = 0x%08x\n", bcd.getSoftwareId() );
719
720     return false;
721 }
Note: See TracBrowser for help on using the browser.