CTRDG_Read

# CTRDG_WriteAndVerifyAgbFlash

## C Specification

      #include <nitro/ctrdg.h>

      u32 CTRDG_WriteAndVerifyAgbFlash(u16 sec_num, u8* src, u32 verifysize)

      Corresponding AGB function: u32 ProgramFlashSectorEx2(u16 secNo,u8 *src,u32 verifySize)

## Arguments

sec_num | The destination flash sector number.
src | Writes the source address.
verifysize | The verify size in bytes.

## Return Values

Returns 0 if the process ends normally. Returns non-zero if the process fails, and returns the error address on the device side when there is a verification error.

## Description

This function internally uses `CTRDG_WriteAgbFlashSector` to write data and then `CTRDG_VerifyAgbFlash` to verify data for the number of bytes given by `verifysize`. If there is an error, the function retries up to the number of times specified by `CTRDB_AGB_FLASH_RETRY_MAX` (defined in `AgbFlash.h`). Note: When checking error codes, this function returns an error code using 16 out of 32 bits when there is a write error, but returns a 32-bit error address on the device side when there is a verification error.

The access cycle setting does not need to be set beforehand because it is created inside the function. In addition, the `OS_InitTick` function must be called before this function because clock ticks are used by this function to measure timeouts.

Note: All interrupts are disabled inside this function and the cartridge bus is locked for a set period. In particular, when this function is called, do not use DMA that starts automatically during direct sound and V/H blank synchronization, display synchronization, cartridge request, etc.

Note that the AGB backup device cannot be accessed normally with version IS-NITRO-DEBUGGER 1.66 or earlier.

## See Also

`CTRDG_WriteAgbFlashSector, CTRDG_VerifyAgbFlash, CTRDG_WriteAndVerifyAgbFlash, CTRDG_WriteAndVerifyAgbFlashAsync
`

## Revision History

05/25/2006 Added a description that the AGB backup device cannot be accessed normally with version IS-NITRO-DEBUGGER 1.66 or earlier.
04/07/2006 Initial version.

CONFIDENTIAL