You can use standard library available with atmel for reading size and vendore code.
check the following link :
Sent: Wednesday, 16 January 2013 5:05 PM
Subject: [AT91SAM] how to read Flash / SDRAM size and vendor name
I have just joined the grioup.
I'm working on AT91SAM9G45 device and using IAR workbench. I would like to read
Flash / SDRAM "SIZE and VENDOR NAME". Is there any API or any registers to read
where I can get above information ?
Thanks in advance.