AJA NTV2 SDK  18.1.0.2262
NTV2 SDK 18.1.0.2262
ntv2konaflashprogram.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef NTV2KONAFLASHPROGRAM_H
9 #define NTV2KONAFLASHPROGRAM_H
10 
11 #include "ntv2card.h"
12 #include <fstream>
13 #include <vector>
14 #include <string>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <fcntl.h>
18 #include <iostream>
19 #include "ntv2debug.h"
20 #include "ntv2spiinterface.h"
21 #include "ntv2bitfile.h"
22 
23 #define MAXMCSINFOSIZE 256
24 #define MAXMCSLICENSESIZE 256
25 #define MCS_STEPS 6
26 
27 struct MacAddr
28 {
29  uint8_t mac[6];
30  std::string AsString(void) const;
31 };
32 
33 
35 {
36  public:
38 
40  virtual ~CNTV2FlashProgress() {}
41  virtual bool UpdatePercentage (const size_t inPercentage) {(void) inPercentage; return true;}
42 }; // CNTV2PercentUpdater
43 
44 
46 {
47 public:
49  virtual ~CNTV2KonaFlashProgram();
50  static std::string FlashBlockIDToString (const FlashBlockID inID, const bool inShortDisplay = false); // New in SDK 16.0
51 
52 public:
53  virtual bool SetBoard (uint32_t index = 0);
54  virtual inline CNTV2Card & device(void) const {return _card;}
55  bool ReadHeader (FlashBlockID flashBlock);
56  bool SetBitFile (const std::string & inBitfileName, std::ostream & outMsgs, const FlashBlockID blockNumber = AUTO_FLASHBLOCK); // New in SDK 16.0
57  std::string Program (bool fullVerify = false);
58  bool ProgramCustom (const std::string & sCustomFileName, const uint32_t addr, std::ostream & outMsgs);
59  bool ProgramKonaxMB (const std::string & sCustomFileName, const uint32_t addr, std::ostream & outMsgs);
60  bool EraseBlock (FlashBlockID blockNumber);
61  bool EraseChip (UWord chip = 0);
62  bool CreateSRecord (bool bChangeEndian);
63  bool CreateEDIDIntelRecord ();
64  void SetQuietMode ();
65  bool VerifyFlash (FlashBlockID flashBlockNumber, bool fullVerify = false);
66  bool ReadFlash (NTV2Buffer & outBuffer, const FlashBlockID flashID, CNTV2FlashProgress & inFlashProgress = CNTV2FlashProgress::nullUpdater); // New in SDK 16.0
67  bool SetBankSelect (BankSelect bankNumber);
68  bool SetFlashBlockIDBank(FlashBlockID blockID);
69  bool ROMHasBankSelect();
70  uint32_t ReadBankSelect ();
71  bool IsInstalledFWRunning (bool & outIsRunning, std::ostream & outErrorMsgs);
72  bool WriteCommand(_FLASH_COMMAND inCommand);
73 
74  std::string GetDesignName (void) const {return _parser.DesignName();}
75  std::string GetPartName (void) const {return _parser.PartName();}
76  std::string GetDate (void) const {return _parser.Date();}
77  std::string GetTime (void) const {return _parser.Time();}
78  const NTV2BitfileHeaderParser & Parser (void) const {return _parser;}
79  uint32_t GetNumBytes(void) const {return _numBytes;}
80  bool CreateBankRecord(BankSelect bankID);
81 
82  bool ProgramMACAddresses(MacAddr * mac1, MacAddr * mac2);
83  bool ReadMACAddresses(MacAddr & mac1, MacAddr & mac2);
84  bool ProgramLicenseInfo(const std::string & licenseString);
85  bool ReadLicenseInfo(std::string & licenseString);
86  void DisplayData(const uint32_t address, const uint32_t len);
87  bool ProgramInfoFromString(std::string infoString);
88  bool FullProgram(std::vector<uint8_t> & dataBuffer);
89 
90  bool WaitForFlashNOTBusy();
91  bool ProgramFlashValue(uint32_t address, uint32_t value);
92  bool FastProgramFlash256(uint32_t address, uint32_t* buffer);
93  bool EraseSector(uint32_t sectorAddress);
94  bool CheckFlashErasedWithBlockID(FlashBlockID flashBlockNumber);
95  uint32_t ReadDeviceID();
96  bool SetDeviceProperties();
97  void DetermineFlashTypeAndBlockNumberFromFileName(const std::string & bitFileName);
98 
99  uint32_t GetSectorAddressForSector(FlashBlockID flashBlockNumber,uint32_t sectorNumber)
100  {
101  return GetBaseAddressForProgramming(flashBlockNumber)+(sectorNumber*_sectorSize);
102  }
103 
104  uint32_t GetBaseAddressForProgramming(FlashBlockID flashBlockNumber)
105  {
106  switch ( flashBlockNumber )
107  {
108  default:
109  case MAIN_FLASHBLOCK: return _mainOffset;
110  case FAILSAFE_FLASHBLOCK: return _failSafeOffset;
111  case SOC1_FLASHBLOCK: return _soc1Offset;
112  case SOC2_FLASHBLOCK: return _soc2Offset;
113  case MAC_FLASHBLOCK: return _macOffset;
114  case MCS_INFO_BLOCK: return _mcsInfoOffset;
115  case LICENSE_BLOCK: return _licenseOffset;
116  }
117 
118  }
119 
120  uint32_t GetNumberOfSectors(FlashBlockID flashBlockNumber)
121  {
122  switch ( flashBlockNumber )
123  {
124  default:
125  case MAIN_FLASHBLOCK: return _numSectorsMain;
126  case FAILSAFE_FLASHBLOCK: return _numSectorsFailSafe;
127  case SOC1_FLASHBLOCK: return _numSectorsSOC1;
128  case SOC2_FLASHBLOCK: return _numSectorsSOC2;
129  case MAC_FLASHBLOCK: return 1;
130  case MCS_INFO_BLOCK: return 1;
131  case LICENSE_BLOCK: return 1;
132  }
133  }
134  bool SetWarmBootFirmwareReload(bool enable);
135 #if 0 // IoIP/KonaIP10g purge
136  bool ReadInfoString();
137  bool SetMCSFile (const std::string & sMCSFileName);
138  bool ProgramFromMCS(bool verify);
139  bool ProgramSOC(bool verify = true);
140  bool SetMBReset();
141  const std::string & GetMCSInfo (void) const {return _mcsInfo;}
142  void ParsePartitionFromFileLines(uint32_t address, uint16_t & partitionOffset);
143  bool ProgramMACAddresses(MacAddr * mac1, MacAddr * mac2);
144  bool ReadMACAddresses(MacAddr & mac1, MacAddr & mac2);
145  bool ProgramLicenseInfo(const std::string & licenseString);
146  bool ReadLicenseInfo(std::string & licenseString);
147  bool ProgramInfoFromString(std::string infoString);
148  int32_t NextMcsStep() {return ++_mcsStep;}
149  bool VerifySOCPartition(FlashBlockID flashID, uint32_t FlashBlockOffset);
150  bool CheckAndFixMACs();
151  bool MakeMACsFromSerial( const char *sSerialNumber, MacAddr *pMac1, MacAddr *pMac2 );
152 #endif // IoIP/KonaIP10g purge
153 protected:
156  uint8_t * _customFileBuffer;
157  uint32_t _bitFileSize;
159  std::string _bitFileName;
160  std::string _mcsInfo;
161  uint32_t _spiDeviceID;
162  uint32_t _flashSize;
163  uint32_t _bankSize;
164  uint32_t _sectorSize;
165  uint32_t _mainOffset;
166  uint32_t _failSafeOffset;
167  uint32_t _macOffset;
168  uint32_t _mcsInfoOffset;
169  uint32_t _licenseOffset;
170  uint32_t _soc1Offset;
171  uint32_t _soc2Offset;
172  uint32_t _numSectorsMain;
173  uint32_t _numSectorsSOC1;
174  uint32_t _numSectorsSOC2;
176  uint32_t _numBytes;
178  uint32_t _deviceID;
179  bool _bQuiet;
180 #if 0
181  int32_t _mcsStep;
182  CNTV2MCSfile _mcsFile;
183 #endif
184  std::vector<uint8_t> _partitionBuffer;
188 }; // CNTV2KonaFlashProgram
189 
190 #endif // NTV2KONAFLASHPROGRAM_H
uint32_t GetBaseAddressForProgramming(FlashBlockID flashBlockNumber)
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
virtual CNTV2Card & device(void) const
BankSelect
Definition: ntv2enums.h:4289
_FLASH_COMMAND
Definition: ntv2enums.h:4301
std::string GetDate(void) const
Declares the CNTV2SpiFlash and CNTV2AxiSpiFlash classes.
Knows how to extract information from a bitfile header.
Definition: ntv2bitfile.h:26
FlashBlockID
Definition: ntv2enums.h:4277
std::string GetPartName(void) const
uint32_t GetSectorAddressForSector(FlashBlockID flashBlockNumber, uint32_t sectorNumber)
uint32_t GetNumBytes(void) const
std::string GetDesignName(void) const
std::string AsString(void) const
Describes a user-space buffer on the host computer. I have an address and a length, plus some optional attributes (allocated by SDK?, page-aligned? etc.).
NTV2BitfileHeaderParser _parser
#define AJAExport
Definition: export.h:33
uint32_t GetNumberOfSectors(FlashBlockID flashBlockNumber)
const NTV2BitfileHeaderParser & Parser(void) const
Declares the CNTV2Bitfile class.
uint16_t UWord
Definition: ajatypes.h:234
std::vector< uint8_t > _partitionBuffer
uint8_t mac[6]
std::string GetTime(void) const
Declares the CNTV2Card class.
virtual bool UpdatePercentage(const size_t inPercentage)
static CNTV2FlashProgress & nullUpdater