Reply by timojaask May 14, 20092009-05-14
--- In l..., gaoyuan wrote:
>
> Which NXP chip use? I used NXP 2119 2129 2292 which has 16k ram
> and the buffer should be in 0x40000000 - 0x40000000 + 16k
>

I actually use LPC2388 (mentioned in first post), which has 64k + 16k USB + 16k Eth SRAM.
But the problem is solved now (see my other reply).
Thank you for your input! :)

An Engineer's Guide to the LPC2100 Series

Reply by timojaask May 13, 20092009-05-13
Thanks Mike and gaoyuan for your replies!
I've found out that initialized variables to to .data and uninitialized variables go to .bss.
Since my array was uninitialized it was always put into .bss section which comes after .data.

So I tried UINT32 flash_buffer[ 128 ] = {0x55555555} which initializes the array with some data and put this .c file to the top of the Makefile list, and that did the trick. Now the array is located at the top of the RAM and IAP write works fine.

Thank you again for your input.
- Timo

Reply by gaoyuan May 13, 20092009-05-13
timojaask 写道:
> Buffer actually was a global variable already. The word boundary problem was solved by declaring it as UINT32 (instead of UINT8).
>
> Now the problem is with IAP Write complaining about source (buffer) not being mapped in the memory map (SRC_ADDR_NOT_MAPPED), which unfortunately doesn't say much to me.
>
> The buffer is declared as a global variable and according to map file is located
> at 0x4000a6cc. My RAM region starts at 0x40000000 and is 60k long.
>
> My friend thinks that IAP function requires variable to be located in the first 32k of RAM (right now compiler puts it at 0x4000a6cc, which is beyond 32k ). But neither of us have any idea how to force the variable to be located within 32k (between 0x40000000 and 0x40008000).
>
> Any ideas how to overcome this?
>
> --- In l..., gaoyuan wrote:
>> Declare the variable buffer as global variable,
>> it will lose if it is declared in function, at
>> this time it is in stack area.
>> Compiler will put it boundary normally.
>Which NXP chip use? I used NXP 2119 2129 2292 which has 16k ram
and the buffer should be in 0x40000000 - 0x40000000 + 16k
Reply by timojaask May 13, 20092009-05-13
Buffer actually was a global variable already. The word boundary problem was solved by declaring it as UINT32 (instead of UINT8).

Now the problem is with IAP Write complaining about source (buffer) not being mapped in the memory map (SRC_ADDR_NOT_MAPPED), which unfortunately doesn't say much to me.

The buffer is declared as a global variable and according to map file is located
at 0x4000a6cc. My RAM region starts at 0x40000000 and is 60k long.

My friend thinks that IAP function requires variable to be located in the first 32k of RAM (right now compiler puts it at 0x4000a6cc, which is beyond 32k ). But neither of us have any idea how to force the variable to be located within 32k (between 0x40000000 and 0x40008000).

Any ideas how to overcome this?

--- In l..., gaoyuan wrote:
> >
> Declare the variable buffer as global variable,
> it will lose if it is declared in function, at
> this time it is in stack area.
> Compiler will put it boundary normally.
>

Reply by timojaask May 13, 20092009-05-13
Thanks, I now declared it as UINT32 and it indeed was put on word boundary. The second problem still persists though:
SRC_ADDR_NOT_MAPPED:
Source address is not mapped in the memory map.
Count value is taken in to consideration where
applicable.

The buffer is declared as a global variable and according to map file is located at 0x4000a6cc. I don't quite understand how is it not mapped when it resides inside of the RAM region ( starts at 0x40000000 and is 60k long).
--- In l..., Mike Harrison wrote:
> It wants the buffer to be at word boundaries because it writes words at a time.
> Make your buffer an array of words. If you need to access it as bytes, make it a union so it can be
> accessed as bytes by your app, and words by IAP.
> If nothing else, declaring it as word should force the linker to place it on a word boundary.
>

Reply by gaoyuan May 13, 20092009-05-13
timojaask 写道:
> Hi! Maybe someone with experience on IAP could give me some guidelines?
>
> I'm having quite a hard time with writing to flash (IAP) in my program.
> I am using LPC2388 and my application needs to download lots of stuff from UART and write that into into flash. I am using GNU tools.
>
> My application is receiving 512bytes at a time from UART and saves that into a uint8 buffer[512]. Once buffer is full, it should pause the receiving, write data to flash and then get back to receiving the next 512 bytes. This repeating many times in a loop until all the data is received and stored into flash.
>
> The problem I am having is with calling IAP write function. So I do Prepare - OK, Erase - OK, Prepare - OK, Write - write gives errors.
>
> First I got the following error:
> SRC_ASRC_ADDR_ERROR, which according to manual means "Source address is not on word boundary." So in my case it probably means that buffer[] is located in the wrong address. I have no idea why does it want that, and I have no idea how to fix that, but I tried to make a temporary workaround just to see if it's really the problem (hehe, I think I will get flamed for this) - in the Map file I looked up the address where buffer[] was located. It was a RAM address ending with 9, which I guess isn't "on a word boundary". So I went ahead and added 3 more bytes to the buffer length and passed &buffer[3] to IAP function as the source pointer (9+3 = C, which I think is a word boundary).
>
> The first error went away! But I got a new error: SRC_ADDR_NOT_MAPPED, which according to manual means "Source address is not mapped in the memory map. Count value is taken in to consideration where applicable." Not mapped in the memory map? I haven't yet figured what should I actually do to fix that.
>
> I can see that I am going into the wrong way with my "solution". There got to be some clever way of aligning buffer[] to word boundary. But honestly, I don't even know where should I look for solution.
>
> Any ideas?
>
> Thanks,
> Timo
Declare the variable buffer as global variable,
it will lose if it is declared in function, at
this time it is in stack area.
Compiler will put it boundary normally.
Reply by Mike Harrison May 12, 20092009-05-12
On Tue, 12 May 2009 17:01:00 -0000, you wrote:

>Hi! Maybe someone with experience on IAP could give me some guidelines?
>
>I'm having quite a hard time with writing to flash (IAP) in my program.
>I am using LPC2388 and my application needs to download lots of stuff from UART and write that into into flash. I am using GNU tools.
>
>My application is receiving 512bytes at a time from UART and saves that into a uint8 buffer[512]. Once buffer is full, it should pause the receiving, write data to flash and then get back to receiving the next 512 bytes. This repeating many times in a loop until all the data is received and stored into flash.
>
>The problem I am having is with calling IAP write function. So I do Prepare - OK, Erase - OK, Prepare - OK, Write - write gives errors.
>
>First I got the following error:
>SRC_ASRC_ADDR_ERROR, which according to manual means "Source address is not on word boundary." So in my case it probably means that buffer[] is located in the wrong address. I have no idea why does it want that, and I have no idea how to fix that, but I tried to make a temporary workaround just to see if it's really the problem (hehe, I think I will get flamed for this) - in the Map file I looked up the address where buffer[] was located. It was a RAM address ending with 9, which I guess isn't "on a word boundary". So I went ahead and added 3 more bytes to the buffer length and passed &buffer[3] to IAP function as the source pointer (9+3 = C, which I think is a word boundary).
>
>The first error went away! But I got a new error: SRC_ADDR_NOT_MAPPED, which according to manual means "Source address is not mapped in the memory map. Count value is taken in to consideration where applicable." Not mapped in the memory map? I haven't yet figured what should I actually do to fix that.
>
>I can see that I am going into the wrong way with my "solution". There got to be some clever way of aligning buffer[] to word boundary. But honestly, I don't even know where should I look for solution.
It wants the buffer to be at word boundaries because it writes words at a time.
Make your buffer an array of words. If you need to access it as bytes, make it a union so it can be
accessed as bytes by your app, and words by IAP.
If nothing else, declaring it as word should force the linker to place it on a word boundary.

Reply by timojaask May 12, 20092009-05-12
Hi! Maybe someone with experience on IAP could give me some guidelines?

I'm having quite a hard time with writing to flash (IAP) in my program.
I am using LPC2388 and my application needs to download lots of stuff from UART and write that into into flash. I am using GNU tools.

My application is receiving 512bytes at a time from UART and saves that into a uint8 buffer[512]. Once buffer is full, it should pause the receiving, write data to flash and then get back to receiving the next 512 bytes. This repeating many times in a loop until all the data is received and stored into flash.

The problem I am having is with calling IAP write function. So I do Prepare - OK, Erase - OK, Prepare - OK, Write - write gives errors.

First I got the following error:
SRC_ASRC_ADDR_ERROR, which according to manual means "Source address is not on word boundary." So in my case it probably means that buffer[] is located in the wrong address. I have no idea why does it want that, and I have no idea how to fix that, but I tried to make a temporary workaround just to see if it's really the problem (hehe, I think I will get flamed for this) - in the Map file I looked up the address where buffer[] was located. It was a RAM address ending with 9, which I guess isn't "on a word boundary". So I went ahead and added 3 more bytes to the buffer length and passed &buffer[3] to IAP function as the source pointer (9+3 = C, which I think is a word boundary).

The first error went away! But I got a new error: SRC_ADDR_NOT_MAPPED, which according to manual means "Source address is not mapped in the memory map. Count value is taken in to consideration where applicable." Not mapped in the memory map? I haven't yet figured what should I actually do to fix that.

I can see that I am going into the wrong way with my "solution". There got to be some clever way of aligning buffer[] to word boundary. But honestly, I don't even know where should I look for solution.

Any ideas?

Thanks,
Timo