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

Revision 2707, 22.3 kB (checked in by jwoithe, 3 years ago)

Fix compilation of bebob_dl_mgr.cpp.

The bebob_dl_mgr.cpp file requires the include of "ffadodevice.h" in order
to pick up the definition of ffado_smartptr. Thanks to Jano Svitok for
reporting the problem and the solution.

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