summaryrefslogtreecommitdiff
path: root/firmware/src/dfu/flash.c
blob: 675552d6dced1c75b0979876ee89cbc5a19eacc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35


#define EFCS_CMD_WRITE_PAGE		0x01
#define EFCS_CMD_SET_LOCK_BIT		0x02
#define EFCS_CMD_WRITE_PAGE_LOCK	0x03
#define EFCS_CMD_CLEAR_LOCK		0x04
#define EFCS_CMD_ERASE_ALL		0x08
#define EFCS_CMD_SET_NVM_BIT		0x0b
#define EFCS_CMD_CLEAR_NVM_BIT		0x0d
#define EFCS_CMD_SET_SECURITY_BIT	0x0f


int unlock_page(u_int16_t page)
{
	AT91C_MC_FCMD_UNLOCK | AT91C_MC_CORRECT_KEY | 

}

int flash_sector(unsigned int sector, const u_int8_t *data, unsigned int len)
{
	volatile u_int32_t *p = (volatile u_int32_t *)0;
	u_int32_t *src32 = (u_int32_t *)data;
	int i;

	/* hand-code memcpy because we need to make sure only 32bit accesses
	 * are used */
	for (i = 0; i < len/4; i++)
		p[i] = src32[i];

	AT91F_MC_EFC_PerformCmd(pmc , AT91C_MC_FCMD_START_PROG|
				AT91C_MC_CORRECT_KEY | );
}



personal git repositories of Harald Welte. Your mileage may vary