Home/Support/Support Forum/Writing the program to the FLASH
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Writing the program to the FLASH

0 votes
I am attempting to write a program update to the FLASH from my program. I have it successfully downloaded into a 1MB array, then when I attempt to copy it to FLASH using NAFlashWrite() it says that it worked, but when I reboot I just get the 9-1-1 error.

1. I am using NAAppOffsetInFlash to determine the start sector (7).
2. I am using NAFlashGetSectorSizes() to determine how much to write. (10 sectors)
3. I use NAFlashErase() before writing.
4. NAFlashWrite() is really slow (5 seconds a sector) - is this an indication of a problem?

Anyone who has done this before have any ideas?

asked Nov 6, 2004 in NET+OS by egawtry Veteran of the Digi Community (349 points)
recategorized Dec 19, 2013 by tuxembb

Please log in or register to answer this question.

3 Answers

0 votes
For those interested, I got it to work. It turns out that the __attribute__ ((packed)) doesn't work very well.

answered Nov 10, 2004 by egawtry Veteran of the Digi Community (349 points)
0 votes
Erik (All interested),

Per the ARM - Architecture Reference Manual (pg. A2-26, 2001, Issue E) can be UNPREDICTABLE and should therefore be avoided.

*** From the aforementioned document:

The architecturally defined behavior of a load/store instruction which generates an unaligned access is one of the following:

- It ignores the low-order address bits that make the access unaligned. This means it effectively uses teh formula (address AND 0xFFFFFFFE) for a halfword access, and uses the formula (address AND 0xFFFFFFFC) for a word access.
- It ignores the low-order address bits that make the access unaligned for the memory access itself, but then uses those low-order bits to control a rotation of the loaded data. (This behavior applies only to the LDR and SWP instructions).

Which of these three options applies to a load/store instruction depends on which instruction it is, and is documented on the instruction pages.

*** End

Essentially, avoid packing structures like the plague. The common reason for packing that I have come across is when implementing a protocol. In such a case it would be best to leave the structure unpacked and manually create the outgoing buffer in its packed form (the reverse would be necessary for incoming buffers).

answered Nov 10, 2004 by Cameron Seasoned Professional (221 points)
0 votes
That is exactly what I did. ;-)
answered Nov 11, 2004 by egawtry Veteran of the Digi Community (349 points)