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

Revision 1763, 22.2 kB (checked in by ppalmers, 11 years ago)

Merged revisions 1536,1541,1544-1546,1549,1554-1562,1571,1579-1581,1618,1632,1634-1635,1661,1677-1679,1703-1704,1715,1720-1723,1743-1745,1755 via svnmerge from
svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0

Also fix remaining format string warnings.

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