bool appIbPdsSave(void)
{
  uint32_t command[5];
  uint32_t result[4];
  uint32_t buffer[FLASH_PAGE_SIZE / sizeof(uint32_t)];

  memset((uint8_t *)buffer, 0xff, FLASH_PAGE_SIZE);
  memcpy((uint8_t *)buffer, (uint8_t *)&appIb, sizeof(appIb));

  command[0] = IAP_PREPARE_SECTOR;
  command[1] = PDS_FLASH_ADDR >> 12;
  command[2] = PDS_FLASH_ADDR >> 12;
  ATOMIC_SECTION_ENTER
    iap(command, result);
  ATOMIC_SECTION_LEAVE
  if (result[0])
    return false;

  command[0] = IAP_ERASE_SECTORS;
  command[1] = PDS_FLASH_ADDR >> 12;
  command[2] = PDS_FLASH_ADDR >> 12;
  ATOMIC_SECTION_ENTER
    iap(command, result);
  ATOMIC_SECTION_LEAVE
  if (result[0])
    return false;

  command[0] = IAP_PREPARE_SECTOR;
  command[1] = PDS_FLASH_ADDR >> 12;
  command[2] = PDS_FLASH_ADDR >> 12;
  ATOMIC_SECTION_ENTER
    iap(command, result);
  ATOMIC_SECTION_LEAVE
  if (result[0])
    return false;

  command[0] = IAP_COPY_RAM_TO_FLASH;
  command[1] = PDS_FLASH_ADDR;
  command[2] = (uint32_t)buffer;
  command[3] = FLASH_PAGE_SIZE;
  command[4] = F_CPU / 1000;
  ATOMIC_SECTION_ENTER
    iap(command, result);
  ATOMIC_SECTION_LEAVE
  if (result[0])
    return false;

  return true;
}
Exemple #2
0
int main()
{
	pFunction Jump_To_Application;
	uint32_t JumpAddress;

	SystemInit();		/* 配置系统时钟为72M */	
	NVIC_Configuration();

	watchdog_init();
	delay_init(72);	//72M
	w25x64_init();

	InitSerial();
	Signel_led_init();
	TIM_init();
	SerialPutString("BootLoader Runing...\n");
	SerialPutString("BootLoader for ");
	SerialPutString(SYSTEM_NAME);
	SerialPutString("\n");
	ymodem();

	iap();
	SerialPutString("Load App!\n");

	TIM_Cmd(TIM2,DISABLE);
	if (((*(__IO uint32_t*)APP_LOCATION) & 0x2FFE0000 ) == 0x20000000)
	{
		JumpAddress = *(__IO uint32_t*) (APP_LOCATION + 4);
		Jump_To_Application = (pFunction) JumpAddress;
		__set_MSP(*(__IO uint32_t*) APP_LOCATION);
		Jump_To_Application();
	}
	return 0;
}
Exemple #3
0
void iap_entry(unsigned param_tab[], unsigned result_tab[])
{
  void (*iap)(unsigned [], unsigned []);

  iap = (void (*)(unsigned [], unsigned []))IAP_ADDRESS;
  iap(param_tab,result_tab);
}
Exemple #4
0
void iapExecute(UInt32 *param_tab,UInt32 *result_tab)
{
    void (*iap)(unsigned [],unsigned []);

    iap = (void (*)(unsigned [],unsigned []))IAP_ADDRESS;
    iap(param_tab,result_tab);
}
/**
 * Function that opens and starts an RConnection.
 */	
TInt CPanConnections::StartIAP()
	{
	TInt rerr = KErrNone;
	// Create a set of connection preferences to override existing
	// set in CommDb when RConnection::Start is called.
	TCommDbConnPref connPref;
	PanProfileIAPs iap(EGeneralIAP);
		
	connPref.SetIapId(iap);
	connPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
	
	// load BT stack	
	rerr = Initialise();
	if(rerr == KErrNone)
		{
		// Open the connection
		rerr = iConnection.Open(iSockSvr);
		if(rerr == KErrNone)
			{
			// Start the connection
			// use the iStatus of active object, if it doesn't complete (we are listening)
			// then the active object deals with it, otherwise AO calls IapStarted function on this class
			// Something wrong with RConnection start
			iActiveMode = EIAPStart;	
			iConnection.Start(connPref, iStatus);
			SetActive();
			iIapLoading = ETrue;
			}
		}
	return rerr;
	}
void iap_entry(uint32_t param_tab[], uint32_t result_tab[])
{
    void (*iap)(uint32_t [], uint32_t []);

    iap = (void (*)(uint32_t [], uint32_t []))IAP_ADDRESS;
    iap(param_tab,result_tab);
}
Exemple #7
0
/**
 * Get the Device ID.
 * 
 * @return device ID
 */
uint32_t IAP::PartID()
{
    uint32_t result[2];
    uint32_t command = 54;
    
    iap (&command, result);
    
    return result[1];    
}
Exemple #8
0
/**
 * Get the "Mask ROM" boot loader version.  The boot loader really resides in flash memory that is write
 * protected at the factory.
 * 
 * @return boot loader version
 */
uint32_t IAP::BootCodeVersion()
{
    uint32_t result[2];
    uint32_t command = 55;
    
    iap (&command, result);
    
    return result[1];    
}
Exemple #9
0
/**
 * Prepare the flash memory for erase or write operations.
 * 
 * @param startSector starting sector number of operational block
 * @param endSector ending sector number (inclusive) of operational block
 * 
 * @return IAP Status code
 */
IAP::StatusCode IAP::PrepareSector (uint32_t startSector, uint32_t endSector)
{
    uint32_t command[5];
    uint32_t result[2];

    command[0] = 50;
    command[1] = startSector;
    command[2] = endSector;

    iap (command, result);
    
    return static_cast <StatusCode> (result[0]); 
}
// ---------------------------------------------------------
// CConnection::IsConnected()
// ---------------------------------------------------------
//
TBool CConnection::IsConnected( TUint32& aIap )
    {
    TBool connected( EFalse );
    if( iState == EConnected )
        {
        TBuf<KCommsDbSvrMaxColumnNameLength * 2 + 1> iapId;
        _LIT( KFormatIapId, "%S\\%S" );
        TPtrC iap( IAP );
        TPtrC id( COMMDB_ID );
        iapId.Format( KFormatIapId, &iap, &id );
        TInt err = iConn.GetIntSetting( iapId, aIap );
        connected = err ? EFalse : ETrue;
        }
    return connected;
    }
// -----------------------------------------------------------------------------
// CApplicationTriggeringConnDlg::RunL
// -----------------------------------------------------------------------------
//
void CApplicationTriggeringConnDlg::RunL()
    {
    if ( iStatus.Int() == KErrNone )
        {
        TUint32 iap( 0 );
        _LIT( KIAPId, "IAP\\Id" );
        iConnection.GetIntSetting( KIAPId, iap );

        PrintL( R_OUTPUT_CONNECTION_STARTED_WITH_IAP_ID, iap );
        }
    else
        {
        PrintL( R_OUTPUT_RUNL_STATUS_ERROR, iStatus.Int() );
        }
    }
void register_pluginx_js_extensions(JSContext* cx, JS::HandleObject global)
{
    JS::RootedObject ns(cx);
    pluginx::get_or_create_js_obj(cx, global, "plugin", &ns);

    JS::RootedObject iap(cx, jsb_cocos2d_plugin_ProtocolIAP_prototype);
    JS_DefineFunction(cx, iap, "setListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, iap, "getListener", js_pluginx_ProtocolIAP_getResultListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, iap, "payForProduct", js_pluginx_ProtocolIAP_payForProduct, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject ads(cx, jsb_cocos2d_plugin_ProtocolAds_prototype);
    JS_DefineFunction(cx, ads, "setListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, ads, "getListener", js_pluginx_ProtocolAds_getAdsListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject share(cx, jsb_cocos2d_plugin_ProtocolShare_prototype);
    JS_DefineFunction(cx, share, "setListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, share, "getListener", js_pluginx_ProtocolShare_getResultListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, share, "share", js_pluginx_ProtocolShare_share, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject social(cx, jsb_cocos2d_plugin_ProtocolSocial_prototype);
    JS_DefineFunction(cx, social, "setListener", js_pluginx_ProtocolSocial_setListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, social, "getListener", js_pluginx_ProtocolSocial_getListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, social, "submitScore", js_pluginx_ProtocolSocial_submitScore, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, social, "unlockAchievement", js_pluginx_ProtocolSocial_unlockAchievement, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject user(cx, jsb_cocos2d_plugin_ProtocolUser_prototype);
    JS_DefineFunction(cx, user, "setActionListener", js_pluginx_ProtocolUser_setActionListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, user, "getActionListener", js_pluginx_ProtocolUser_getActionListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, user, "login", js_pluginx_ProtocolUser_login, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, user, "logout", js_pluginx_ProtocolUser_logout, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject protocol(cx, jsb_cocos2d_plugin_PluginProtocol_prototype);
    JS_DefineFunction(cx, protocol, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, protocol, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, protocol, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, protocol, "callFloatFuncWithParam", js_pluginx_PluginProtocol_callFloatFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, protocol, "callBoolFuncWithParam", js_pluginx_PluginProtocol_callBoolFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject facebook(cx, jsb_cocos2d_plugin_FacebookAgent_prototype);
    JS_DefineFunction(cx, facebook, "login", js_pluginx_FacebookAgent_login, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, facebook, "_api", js_pluginx_FacebookAgent_api, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, facebook, "appRequest", js_pluginx_FacebookAgent_appRequest, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, facebook, "dialog", js_pluginx_FacebookAgent_dialog, 0, JSPROP_READONLY | JSPROP_PERMANENT);

    js_register_pluginx_protocols_PluginParam(cx, ns);
}
Exemple #13
0
void cpuid_get(void *id)
{
    uint32_t result[5];
    /* IAP command for UUID : 58 (UM10360 page 645) */
    uint32_t command = 58;
    /* Define pointer to function type */
    void (*iap)(uint32_t[], uint32_t[]);
    /* Set the function pointer */
    iap = (void (*)(uint32_t[], uint32_t[])) IAP_ADDRESS;
    /* Read UUID */
    iap(&command, result);

    if (result[0] == 0) {
        memcpy(id, &result[1], CPUID_LEN);
    }
    else {
        memset(id, 0xFF, CPUID_LEN);
    }
}
//*******************************************************************************
// Method      : CTestAppConsole::QueryNetworkSettings()
// Purpose     : 
// Parameters  : 
// Return Value: 
//*******************************************************************************
void CTestAppConsole::QueryNetworkSettings()
    {
    TBuf16<80> line;
    
    iConsole->Printf( _L("\nQUERYING NETWORK SETTINGS") );
    iConsole->Printf( _L("\nPress enter to use existing value") );
    
    TUint iap( KTestIapId );
    TInt inputErr( 0 );
    do 
        {
        iConsole->Printf( _L("\nINPUT IAPID: ") );
    	GetStringFromConsole( line );
    	if ( line.Length() != 0 )
    	    {
        	TLex lex( line );
        	inputErr = lex.Val( iap );    	    
    	    }
        } while ( inputErr );
    
    iNetsettings.iIapId = iap;
    }
Exemple #15
0
/**
 * Erase the flash memory starting at the desired address for a block of bytes.  NOTE: The address range is
 * translated to device sector numbers.  Therefore the operational range may be larger than specified.
 * 
 * @param destAddress starting address to erase
 * @param length number of bytes to erase
 * 
 * @return IAP Status code
 */
IAP::StatusCode IAP::Erase (uint32_t destAddress, uint32_t length)
{
    StatusCode statusCode;
    uint32_t irqState, command[5], result[2];
    
    // 
    command[0] = 52;
    command[1] = Sector(destAddress);
    command[2] = Sector(destAddress + length);
    command[3] = SystemControl::GetInstance()->GetPClock() / 1000;
    
    if ((statusCode = PrepareSector(command[1], command[2])) != CmdSuccess)
        return statusCode;    
    
    // We have to disable interrupts because flash memory will not be available to execute out of.
    irqState = disableIRQ();
    
    iap (command, result);
    
    restoreIRQ (irqState);
    
    return static_cast <StatusCode> (result[0]);
}
Exemple #16
0
/**
 * Write the flash memory starting at the desired address for a block of bytes.  NOTE: The length
 * must be 256, 512, 1024, or 4096 bytes.  The data pointer must be on a WORD boundary.
 * 
 * @param destAddress flash memory address
 * @param length number of bytes to write
 * @param data pointer to data block
 * 
 * @return IAP Status code
 */
IAP::StatusCode IAP::Write (uint32_t destAddress, uint32_t length, void *data)
{
    StatusCode statusCode;
    uint32_t irqState, command[5], result[2];
    
    if ((statusCode = PrepareSector(Sector(destAddress), Sector(destAddress + length))) != CmdSuccess)
        return statusCode;
    
    command[0] = 51;
    command[1] = destAddress;
    command[2] = reinterpret_cast <uint32_t> (data);
    command[3] = length;
    command[4] = SystemControl::GetInstance()->GetPClock() / 1000;
    
    // We have to disable interrupts because flash memory will not be available to execute out of.
    irqState = disableIRQ();
    
    iap (command, result);
    
    restoreIRQ (irqState);
    
    return static_cast <StatusCode> (result[0]);
}
Exemple #17
0
void
App::ArgvReceived(int32 argc, char **argv)
{
	printf("ArgvReceived\n");
	
	Message args; 
	(void) ParseArgs(argc, argv, args);
	HandleStandardDaemonArgs(args);

	const char * value;
	if (args.HasName("help")) {
		Log(MUSCLE_LOG_INFO, "Usage:  muscled [port=%u] [listen=ip:port] [displaylevel=lvl] [filelevel=lvl] [logfile=filename]\n", DEFAULT_MUSCLED_PORT); 
#ifdef MUSCLE_ENABLE_MEMORY_TRACKING
		Log(MUSCLE_LOG_INFO, "					 [maxmem=megs]\n");
#endif
		Log(MUSCLE_LOG_INFO, "					 [maxnodespersession=num] [remap=oldip=newip]\n");
		Log(MUSCLE_LOG_INFO, "					 [ban=ippattern] [require=ippattern]\n");
		Log(MUSCLE_LOG_INFO, "					 [privban=ippattern] [privunban=ippattern]\n");
		Log(MUSCLE_LOG_INFO, "					 [privkick=ippattern] [privall=ippattern]\n");
		Log(MUSCLE_LOG_INFO, "					 [maxsendrate=kBps] [maxreceiverate=kBps]\n");
		Log(MUSCLE_LOG_INFO, "					 [maxcombinedrate=kBps] [maxmessagesize=k]\n");
		Log(MUSCLE_LOG_INFO, "					 [maxsessions=num] [maxsessionsperhost=num]\n");
		Log(MUSCLE_LOG_INFO, "					 [localhost=ipaddress] [daemon]\n");
		Log(MUSCLE_LOG_INFO, " - port may be any number between 1 and 65536\n");
		Log(MUSCLE_LOG_INFO, " - listen is like port, except it includes a local interface IP as well.\n");
		Log(MUSCLE_LOG_INFO, " - lvl is: none, critical, errors, warnings, info, debug, or trace.\n");
#ifdef MUSCLE_ENABLE_MEMORY_TRACKING
		Log(MUSCLE_LOG_INFO, " - maxmem is the max megabytes of memory the server may use (default=unlimited)\n");
#endif
		Log(MUSCLE_LOG_INFO, " - You may also put one or more ban=<pattern> arguments in.\n");
		Log(MUSCLE_LOG_INFO, "	Each pattern specifies one or more IP addresses to\n");
		Log(MUSCLE_LOG_INFO, "	disallow connections from, e.g. ban=192.168.*.*\n");
		Log(MUSCLE_LOG_INFO, " - You may put one or more require=<pattern> arguments in.\n");
		Log(MUSCLE_LOG_INFO, "	If any of these are present, then only IP addresses that match\n");
		Log(MUSCLE_LOG_INFO, "	at least one of them will be allowed to connect.\n");
		Log(MUSCLE_LOG_INFO, " - To assign privileges, specify one of the following:\n");
		Log(MUSCLE_LOG_INFO, "	privban=<pattern>, privunban=<pattern>,\n");
		Log(MUSCLE_LOG_INFO, "	privkick=<pattern> or privall=<pattern>.\n");
		Log(MUSCLE_LOG_INFO, "	privall assigns all privileges to the matching IP addresses.\n");
		Log(MUSCLE_LOG_INFO, " - remap tells muscled to treat connections from a given IP address\n");
		Log(MUSCLE_LOG_INFO, "	as if they are coming from another (for stupid NAT tricks, etc)\n");
		Log(MUSCLE_LOG_INFO, " - If daemon is specified, muscled will run as a background process.\n");
	}

	{
		for (int32 i = 0; (args.FindString("port", i, &value) == B_NO_ERROR); i++) {
			int16 port = atoi(value);
			
			if (port >= 0)
				listenPorts.PutWithDefault(IPAddressAndPort(invalidIP, port));
		}

		for (int32 i = 0; (args.FindString("listen", i, &value) == B_NO_ERROR); i++) {
			IPAddressAndPort iap(value, DEFAULT_MUSCLED_PORT, false);
			
			if (iap.GetPort() > 0)
				listenPorts.PutWithDefault(iap);
			else
				LogTime(MUSCLE_LOG_ERROR, "Unable to parse IP/port string [%s]\n", value);
		}
	}

	{
		for (int32 i = 0; (args.FindString("remap", i, &value) == B_NO_ERROR); i++) {
			StringTokenizer tok(value, ",=");
			const char * from = tok();
			const char * to = tok();
			ip_address fromIP = from ? Inet_AtoN(from) : 0;
			
			if ((fromIP != invalidIP)&&(to)) {
				char ipbuf[64]; Inet_NtoA(fromIP, ipbuf);
				LogTime(MUSCLE_LOG_INFO, "Will treat connections coming from [%s] as if they were from [%s].\n", ipbuf, to);
				tempRemaps.Put(fromIP, to);
			} else
				LogTime(MUSCLE_LOG_ERROR, "Error parsing remap argument (it should look something like remap=192.168.0.1,132.239.50.8).\n");
		}
	}

#ifdef MUSCLE_ENABLE_MEMORY_TRACKING
	if (args.FindString("maxmem", &value) == B_NO_ERROR) {
		int megs = muscleMax(1, atoi(value));
		LogTime(MUSCLE_LOG_INFO, "Limiting memory usage to %i megabyte%s.\n", megs, (megs==1)?"":"s");
		maxBytes = megs*1024L*1024L;
	}
#endif

	if (args.FindString("maxmessagesize", &value) == B_NO_ERROR) {
		int k = muscleMax(1, atoi(value));
		LogTime(MUSCLE_LOG_INFO, "Limiting message sizes to %i kilobyte%s.\n", k, (k==1)?"":"s");
		maxMessageSize = k*1024L;
	}

	if (args.FindString("maxsendrate", &value) == B_NO_ERROR) {
		float k = (float) atof(value);
		maxSendRate = muscleMax((uint32)0, (uint32)(k * 1024.0f));
	}

	if (args.FindString("maxreceiverate", &value) == B_NO_ERROR) {
		float k = (float) atof(value);
		maxReceiveRate = muscleMax((uint32)0, (uint32)(k * 1024.0f));
	}

	if (args.FindString("maxcombinedrate", &value) == B_NO_ERROR) {
		float k = (float) atof(value);
		maxCombinedRate = muscleMax((uint32)0, (uint32)(k * 1024.0f));
	}

	if (args.FindString("maxnodespersession", &value) == B_NO_ERROR) {
		maxNodesPerSession = atoi(value);
		LogTime(MUSCLE_LOG_INFO, "Limiting nodes-per-session to "UINT32_FORMAT_SPEC".\n", maxNodesPerSession);
	}

	if (args.FindString("maxsessions", &value) == B_NO_ERROR) {
		maxSessions = atoi(value);
		LogTime(MUSCLE_LOG_INFO, "Limiting total session count to "UINT32_FORMAT_SPEC".\n", maxSessions);
	}

	if (args.FindString("maxsessionsperhost", &value) == B_NO_ERROR) {
		maxSessionsPerHost = atoi(value);
		LogTime(MUSCLE_LOG_INFO, "Limiting session count for any given host to "UINT32_FORMAT_SPEC".\n", maxSessionsPerHost);
	}
	
	if (args.FindString("privatekey", &value) == B_NO_ERROR) {
		fprivateKeyFilePath = new String(value);	
		//const String * fprivateKeyFilePath = args.GetStringPointer("privatekey");
		//LogTime(MUSCLE_LOG_INFO, "Limiting session count for any given host to "UINT32_FORMAT_SPEC".\n", fprivateKeyFilePath);
	}

	{
		for (int32 i = 0; (args.FindString("ban", i, &value) == B_NO_ERROR); i++) {
			LogTime(MUSCLE_LOG_INFO, "Banning all clients whose IP addresses match [%s].\n", value);	
			bans.AddTail(value);
		}
	}

	{
		for (int32 i = 0; (args.FindString("require", i, &value) == B_NO_ERROR); i++) {
			LogTime(MUSCLE_LOG_INFO, "Allowing only clients whose IP addresses match [%s].\n", value);	
			requires.AddTail(value);
		}
	}
	
	{
		const char * privNames[] = {"privkick", "privban", "privunban", "privall"};
		for (int p = 0; p <= PR_NUM_PRIVILEGES; p++) {  // if (p == PR_NUM_PRIVILEGES), that means all privileges
			for (int32 q=0; (args.FindString(privNames[p], q, &value) == B_NO_ERROR); q++) {
				LogTime(MUSCLE_LOG_INFO, "Clients whose IP addresses match [%s] get %s privileges.\n", value, privNames[p]+4);
				char tt[32]; 
				muscleSprintf(tt, "priv%i", p);
				tempPrivs.AddString(tt, value);
			}
		}
	}
}
Exemple #18
0
/******************************************************************************
 * Function:	compare
 *
 * Description:	This command is used to compare the memory contents at two locations. compare result may not
 *				be correct when source or destination address contains any of the first 64 bytes starting
 *				from address zero. First 64 bytes can be re-mapped to RAM.
 * 				Command Code: 56
 *				Param0(DST): Starting Flash or RAM address from where data bytes are to be
 *								address should be a word boundary.
 *				Param1(SRC): Starting Flash or RAM address from where data bytes are to be
 *								address should be a word boundary.
 *				Param2: Number of bytes to be compared. Count should be in multiple of 4.
 *
 * Parameters:	long tmp_adr_dst
 * 				long tmp_adr_src
 * 				long tmp_size
 *
 * Return: 		Code 	CMD_SUCCESS |
 *						COMPARE_ERROR |
 * 						COUNT_ERROR (Byte count is not multiple of 4) |
 *						ADDR_ERROR |
 *						ADDR_NOT_MAPPED
 * 				Result0: Offset of the first mismatch if the Status Code is COMPARE_ERROR.
 *****************************************************************************/
uint32_t compare(uint32_t tmp_adr_dst, uint32_t tmp_adr_src, uint32_t tmp_size)
{
    return iap(COMPARE, tmp_adr_dst, tmp_adr_src, tmp_size, 0);
}
Exemple #19
0
/******************************************************************************
 * Function:	erase_sectors
 *
 * Description:	This command is used to erase a sector or multiple sectors of on-chip Flash memory. The boot
 *				sector can not be erased by this command. To erase a single sector use the same "Start" and "End"
 *				sector numbers.
 * 				Command code: 52
 *				Param0: Start Sector Number
 *				Param1: End Sector Number: Should be greater than or equal to start sector number.
 *				Param2: System Clock Frequency (CCLK) in KHz.
 *
 * Parameters:	long tmp_sect1: 	Param0
 * 				long tmp_sect2:		Param1
 *
 * Return: 		Code 	CMD_SUCCESS |
 *						BUSY |
 *						SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION |
 *						INVALID_SECTOR
 *****************************************************************************/
uint32_t erase_sectors(uint32_t tmp_sect1, uint32_t tmp_sect2)
{
    return iap(ERASE_SECTOR, tmp_sect1, tmp_sect2, _XTAL, 0);
}
Exemple #20
0
/******************************************************************************
 * Function:	Prepare_Sector
 *
 * Description:	This command must be executed before executing "Copy RAM to Flash" or "Erase Sector(s)"
 *				command. Successful execution of the "Copy RAM to Flash" or "Erase Sector(s)" command causes
 *				relevant sectors to be protected again. The boot sector can not be prepared by this command. To
 *				prepare a single sector use the same "Start" and "End" sector numbers..
 * 				Command code: 50
 *				Param0: Start Sector Number
 *				Param1: End Sector Number: Should be greater than or equal to start sector number.
 *
 * Parameters:	long tmp_sect1: 	Param0
 * 				long tmp_sect2:		Param1
 *
 * Return: 		Code 	CMD_SUCCESS |
 *						BUSY |
 *						INVALID_SECTOR
 *****************************************************************************/
uint32_t prepare_sectors(uint32_t tmp_sect1, uint32_t tmp_sect2)
{
    return iap(PREPARE_SECTOR_FOR_WRITE_OPERATION, tmp_sect1, tmp_sect2, 0 , 0);
}
Exemple #21
0
/******************************************************************************
 * Function:	copy_ram_to_flash
 *
 * Description:	This command is used to programm the flash memory. the affected should be
 * 				prepared first by calling "Prepare Sector for Write Operation" command. the
 * 				affected sectors are automatically protected again once the copy command is
 * 				successfully executed. the boot sector cannot be written by this command.
 * 				Command: 51
 * 				Param0:	(DST) Destination Flash adress where data bytes are to be written.
 * 						This address should be a 512 byte boundary.
 * 				Param1: (SRC) Source RAM adress from which data byre are to be read.
 * 				Param2:	Number of bytes to be written. Should be 512 | 1024 | 4096 | 8192.
 * 				Param3: System Clock Frequency (CCLK) in KHz.
 *
 * Parameters:	long tmp_adr_dst:	Param0
 *  			long tmp_adr_src: 	Param1
 * 				long tmp_size:		Param2
 *
 * Return: 		Code 	CMD_SUCCESS |
 * 						SRC_ADDR_ERROR (Address not on word boundary) |
 *						DST_ADDR_ERROR (Address not on correct boundary) |
 *						SRC_ADDR_NOT_MAPPED |
 *						DST_ADDR_NOT_MAPPED |
 *						COUNT_ERROR (Byte count is not 512 | 1024 | 4096 | 8192) |
 * 						SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION |
 *						BUSY
 *****************************************************************************/
uint32_t copy_ram_to_flash(uint32_t tmp_adr_dst, uint32_t tmp_adr_src, uint32_t tmp_size)
{
    return iap(COPY_RAM_TO_FLASH, tmp_adr_dst, tmp_adr_src, tmp_size, _XTAL);
}
Exemple #22
0
/******************************************************************************
 * Function:	blank_check_sector
 *
 * Description:	This command is used to blank check a sector or multiple sectors
 * 				of on-chip Flash memory. To blank check a single sector use the
 * 				same "Start" and "End" sector numbers.
 * 				Command: 53
 * 				Param0:	Start Sector Number
 * 				Param1: End Sector Number (should be greater than equal to the start
 * 						sector number)
 *
 * Parameters:	long tmp_sect1:		Param0
 * 				long tmp_sect2:		Param1
 *
 * Return: 		Code 	CMD_SUCCESS |
 * 						BUSY |
 * 						SECTOR_NOT_BLANK |
 * 						INVALID_SECTOR
 * 				Result0: Offset of the first non blank word location if the status code is SECTOR_NOT_BLANK.
 * 				Result1: Contents of non blank wird location.
 *****************************************************************************/
uint32_t blank_check_sector(uint32_t tmp_sect1, uint32_t tmp_sect2)
{
    return iap(BLANK_CHECK_SECTOR, tmp_sect1, tmp_sect2, 0 , 0);
}
Exemple #23
0
void iap_entry(unsigned commands[],unsigned outputs[]) {
    void (*iap)(unsigned [],unsigned []);
    iap = (void (*)(unsigned [],unsigned []))IAP_LOCATION;
    iap(commands,outputs);
}