Environment details: binutils: 2.18 arm-elf-gcc: 4.2.2 newlib: 1.16.0 Device: AT91SAM7X256 Compiler: IAR and GCC (for ARM) Problem statement: -- I am trying to port a code written for an AVR 8 bit controller compiled for both IAR and GCC (for AVR). This code had an function which basically writes and reads from FLASH using the keywords provided by IAR and GCC for FLASH operations. /*********************************USEFUL CODE***************************************/ #if defined(_ICCAVR_) #define FLASH_DECLARE(x) __flash x #define FLASH_STRING(x) ((__flash const char *)(x)) #define FLASH_STRING_T char const __flash * #endif #if defined(_GNUC_) #define FLASH_DECLARE(x) x __attribute__((_progmem_)) #define FLASH_STRING(x) PSTR(x) #define FLASH_STRING_T PGM_P #endif void assert_test(bool expression, FLASH_STRING_T message, int8_t *file, uint16_t line) { /* This function prints the provided assert message on serial using UART */ } #define ASSERT(expr) assert_test(expr, FLASH_STRING( #expr ), (int8_t*)__FILE__, _LINE_) void main(void) { ASSERT("Some string" == 0); } /*********************************USEFUL CODE***************************************/ -- I am porting the above mentioned code for AT91SAM7X256 for IAR and GCC both. Question: Does GCC/IAR provide any way by which i can read and write the FLASH at run time.
Vinit Bidkar wrote: >... > Question: Does GCC/IAR provide any way by which i can read and write the > FLASH at run time. There is no special handling needed for "flash read" since there is only one address-space in the used controller so there is no need for something like LPM of the AVR. Just make sure the "variables"/constants in flash are defined with const. Location can be verified with map- and symbol-files. Writing to flash similar to the self-programming-support on AVR can be done with the EFC (see manual/datasheet). For an example-implementation see the "basic-internalflash" project in Atmel's softpack for the AT91SAM7X-EK.
Hi, I m not an expert of Atmel, But i did it on a ARM9 STR912 from ST, To do it, you need to load in RAM, and execute from the RAM the piece of code which will update the sector. Doing it from flash will crash your software (verified on STR912, at least) Regards. Damien.
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.