Ejemplo n.º 1
0
static INT32 BurnFlash()
{
    INT32 er;

    osal_interrupt_disable();
    do
    {
#ifndef _BUILD_OTA_E_

        er = BackupDatabase();
        if(SUCCESS != er)
            break;

        // burn ota.bin
        //change_flash_protect(C_OTACODE_OFFSET, C_OTACODE_OFFSET+C_OTACODE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.ota_bin_addr, m_ota_info.user_db_start_sector , m_ota_info.ota_bin_sectors);
        if(SUCCESS != er)
            break;

        // burn firmware.bin
        //change_flash_protect(C_MAINCODE_OFFSET, C_MAINCODE_OFFSET+C_MAINCODE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.ota_upg_addr, 1, m_ota_info.ota_upg_sectors);
        if(SUCCESS != er)
            break;

        //change_flash_protect(C_DATABASE_OFFSET, C_DATABASE_OFFSET+C_DATABASE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.backup_db_addr, m_ota_info.user_db_start_sector, m_ota_info.user_db_sectors);
        if(SUCCESS != er)
            break;
#else
        er = BurnBlock((UINT8*)m_ota_info.ota_upg_addr, 1, m_ota_info.ota_upg_sectors);
        if(SUCCESS != er)
            break;

        //UpdateMessage("Restore database...");
        er = BurnBlock((UINT8*)NULL, m_ota_info.user_db_start_sector, m_ota_info.user_db_sectors);
        if(SUCCESS != er)
            break;
#endif
    } while(0);
    osal_interrupt_enable();
    return er;
}
Ejemplo n.º 2
0
    void OnSaveDatabase() override
    {
        BackupDatabase();

        Anope::string db_name = Anope::DataDir + "/" + Config->GetModule(this)->Get<Anope::string>("database", "anope.db");

        if (Anope::IsFile(db_name))
            rename(db_name.c_str(), (db_name + ".tmp").c_str());

        std::fstream f(db_name.c_str(), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary);

        if (!f.is_open())
        {
            Log(this) << "Unable to open " << db_name << " for writing";
        }
        else
        {
            for (std::pair<Serialize::ID, Serialize::Object *> p : Serialize::objects)
            {
                Serialize::Object *object = p.second;
                Serialize::TypeBase *s_type = object->GetSerializableType();

                f << "OBJECT " << s_type->GetName() << "\n";
                f << "ID " << object->id << "\n";
                for (Serialize::FieldBase *field : s_type->GetFields())
                    if (field->HasFieldS(object)) // for ext
                        f << "DATA " << field->serialize_name << " " << field->SerializeToString(object) << "\n";
                f << "END\n";
            }
        }

        if (!f.is_open() || !f.good())
        {
            f.close();
            rename((db_name + ".tmp").c_str(), db_name.c_str());
        }
        else
        {
            f.close();
            unlink((db_name + ".tmp").c_str());
        }
    }
Ejemplo n.º 3
0
static INT32 BurnFlash()
{
    INT32 er;

	osal_interrupt_disable();
    do
    {
#ifndef _BUILD_OTA_E_
#if 1

if (burning_flag == 1)
{
        er = BackupDatabase();
        if(SUCCESS != er)
            break;

		// burn ota.bin
        //change_flash_protect(C_OTACODE_OFFSET, C_OTACODE_OFFSET+C_OTACODE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.ota_bin_addr, m_ota_info.user_db_start_sector , m_ota_info.ota_bin_sectors);
        if(SUCCESS != er)
            break;

		// burn firmware.bin
        //change_flash_protect(C_MAINCODE_OFFSET, C_MAINCODE_OFFSET+C_MAINCODE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.ota_upg_addr, 1, m_ota_info.ota_upg_sectors);
        if(SUCCESS != er)
            break;

        //change_flash_protect(C_DATABASE_OFFSET, C_DATABASE_OFFSET+C_DATABASE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.backup_db_addr, m_ota_info.user_db_start_sector, m_ota_info.user_db_sectors);
        if(SUCCESS != er)
            break;

}
else  if (burning_flag == 2)
{
			// burn key.bin
	        er = BurnBlock((UINT8*)m_ota_info.ota_fw_addr , m_ota_info.ota_fw_size/*now ,ota_fw_size is key block num*/ , 1);
	        if(SUCCESS != er)
	            break;
}
else  if (burning_2 ==2)
 	{
		// burn db.bin

        er = BurnBlock((UINT8*)m_ota_info.ota_fw_addr + 0x80, m_ota_info.user_db_start_sector, m_ota_info.user_db_sectors);

	     //  er = BurnBlock((UINT8*)m_ota_info.ota_fw_addr , 47 , 17);
	        if(SUCCESS != er)
	            break;
	 }
else  if (burning_flag == 3)
 	{
			// burn key.bin
	        er = BurnBlock((UINT8*)m_ota_info.ota_fw_addr , m_ota_info.ota_fw_size/*now ,ota_fw_size is key block num*/ , 1);
	        if(SUCCESS != er)
	            break;

			// burn db.bin
	        er = BurnBlock((UINT8*)m_ota_info.ota_fw_addr+0x10080/*key have 64k bt and 64 bit user db head*/ , m_ota_info.user_db_start_sector , m_ota_info.ota_upg_sectors2);
      //  er = BurnBlock((UINT8*)m_ota_info.backup_db_addr, m_ota_info.user_db_start_sector, m_ota_info.user_db_sectors);

	        if(SUCCESS != er)
	            break;
	 }

#else
        er = BackupDatabase();
        if(SUCCESS != er)
            break;

		// burn ota.bin
        //change_flash_protect(C_OTACODE_OFFSET, C_OTACODE_OFFSET+C_OTACODE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.ota_bin_addr, m_ota_info.user_db_start_sector , m_ota_info.ota_bin_sectors);
        if(SUCCESS != er)
            break;

		// burn firmware.bin
        //change_flash_protect(C_MAINCODE_OFFSET, C_MAINCODE_OFFSET+C_MAINCODE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.ota_upg_addr, 1, m_ota_info.ota_upg_sectors);
        if(SUCCESS != er)
            break;

        //change_flash_protect(C_DATABASE_OFFSET, C_DATABASE_OFFSET+C_DATABASE_SIZE);
        er = BurnBlock((UINT8*)m_ota_info.backup_db_addr, m_ota_info.user_db_start_sector, m_ota_info.user_db_sectors);
        if(SUCCESS != er)
            break;
#endif
#else
        er = BurnBlock((UINT8*)m_ota_info.ota_upg_addr, 1, m_ota_info.ota_upg_sectors);
        if(SUCCESS != er)
            break;

        //UpdateMessage("Restore database...");
		er = BurnBlock((UINT8*)NULL, m_ota_info.user_db_start_sector, m_ota_info.user_db_sectors);
		if(SUCCESS != er)
		    break;
#endif
    }while(0);
	osal_interrupt_enable();
    return er;
}
Ejemplo n.º 4
0
int main(void) 
{
  int choice;
  int ret;

  ret = eXdbmInit();
  if(ret==-1) {
    ErrorMessage();
    return(EXIT_FAILURE);
  }

  choice=-1;

  while(choice!=12) {
    choice = MainMenu();
    switch(choice) {
    case 1 : 
      OpenDatabase();
      break;

    case 2 :
      NewDatabase();
      break;

    case 3 : 
      CloseDatabase();
      break;

    case 4 :
      UpdateDatabase();
      break;

    case 5 : 
      BackupDatabase();
      break;

    case 6 :
      ReloadDatabase();
      break;

    case 7 :
      PrintDatabase();
      break;

    case 8 :
      PrintValues();
      break;

    case 9 :
      AddEntry();
      break;

    case 10:
      ChangeEntry();
      break;

    case 11 :
      DeleteEntry();
      break;
      
    }
  }

  printf("\n\nBye bye ...\n");

  return(1);
}