This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Memory allocation error with bootloader

I have a big problem with LPC2387 and http-upload demo project when it's loaded by bootloader.
After one ten of minute that the application it's running with one ftp connection and one http connection that try to download the same a big file; the application hangs with this error:

MEM ERR: Alloc, No memory Used 5300 bytes, 12 blocks

This error occur also with only continuously ping without any communication with the socket but the error occur after some hour.

If the ethernet cable is disconnected the application run well without problem.

I think that the remap of the vector interrupts by the application it's correct. I have used the define REMAP RAM_MODE RAM_INTVEC and the interrupt like serial, timer, ethernet and so on it's ok.

In the startup file of application I have forced the cpu to go to the supervisor mode to properly setting of stack and heap of the application with this piece of code:

SWI_RAM_ADDR EQU 0x40000028 LDR R8, =SWI_RAM_ADDR LDR R7, [R8] LDR R9, =Stack_Set_Addr STR R9, [R8] SWI 11
Stack_Set_Addr DCD Stack_Setup
Stack_Setup STR R7, [R8]

This is my setting of bootloader and project application:

-> Bootloader:
Secondary SD Bootloader from nxp:
No RTX
IROM1 address 0x0000, size 0x10000
IRAM1 address 0x4000000, size 0x1000
Heap Size: 0x400
Stack Size (user Mode): 0x400

-> Application: Http_upload demo project without RTX

IROM1 address 0x10000, size 0x70000
IRAM1 address 0x4000040, 0xFFC0 //Save first 64 byte for remap interrupt
IRAM2 address 0x7FD0000, size 0x4000
Ass Define: REMAP RAM_MODE RAM_INTVEC

I already tried:

1) Change Memory pool in Net_config.c (increase or decrease) -> problem no solved
2) Increase Heap Size of Bootloader or/and application -> no solution
3) Increase Stack Size in User Mode in bootloader and/or application -> no solution
4) Build the application without bootloader but with Remapping of interrupts vector -> no solution

I'm afraid that the promblem it's the use of DMA or Memory allocation when the interrupt are mapped in the RAM.

Someone have any solution for me?

Thank's

Parents
  • I don't know much about this.
    But maybe

    IRAM1 address 0x4000040, 0xFFC0 //Save first 64 byte for remap interrupt
    


    64 Bytes is not enough for ISP/IAP.

    UM10211
    Chapter 29: LPC23XX Flash memory programming firmware

    3.2.8 RAM used by ISP command handler
    ISP commands use on-chip RAM from 0x4000 0120 to 0x4000 01FF. The user could use
    this area, but the contents may be lost upon reset. Flash programming commands use the
    top 32 bytes of on-chip RAM. The stack is located at RAM top - 32. The maximum stack
    usage is 256 bytes and it grows downwards.

    Maybe see this:
    http://www.keil.com/forum/20257/

Reply
  • I don't know much about this.
    But maybe

    IRAM1 address 0x4000040, 0xFFC0 //Save first 64 byte for remap interrupt
    


    64 Bytes is not enough for ISP/IAP.

    UM10211
    Chapter 29: LPC23XX Flash memory programming firmware

    3.2.8 RAM used by ISP command handler
    ISP commands use on-chip RAM from 0x4000 0120 to 0x4000 01FF. The user could use
    this area, but the contents may be lost upon reset. Flash programming commands use the
    top 32 bytes of on-chip RAM. The stack is located at RAM top - 32. The maximum stack
    usage is 256 bytes and it grows downwards.

    Maybe see this:
    http://www.keil.com/forum/20257/

Children
  • Hello John,

    I have read the 3.2.8 chapter of UM10211.
    The RAM that it's needed from bootloader for ISP section it's allocated first that application is run. After that, the BL load the application program and the BL don't run anyway and this RAM it's free.

    The first 64 byte in RAM are reserved from application because the same application remap the interrupt vector to RAM from 0x4000000 to 0x400003F.

    In any case I have try to change the IRAM1 to 0x4001000 in the applicaton but the problem it's the same.

    To eliminate any question today; I have try to build the original project http_upload without any modification (only change Target from LPC2378 to LPC2387)...no bootlaoder and I have tried to download a big file (1.4GB) from SD card and I have seen that the board hangs after 400/500MB....
    The Memory Error occour also with original project by keil....

    Seems to be a problem of memory leak when the TCP IP stack handle a long TCP IP Connection.
    In fact if I try to download many times smaller file (like 100MB) the board run without hangs...

    Can be a problem of my revision of LPC2387?

  • Can your program locally create a huge file? Or might there be an issue somewhere when the file system code have to support a very long cluster chain in the FAT system? The FAT system allocates blocks to files by creating a linked list of clusters, and if the program doesn't have the full FAT in memory, or keep track of the position for the last entry all the time, there will be a longer and longer search to walk that chain to find where to add a new entry when the file grows.