How to find Free RAM in MQX 3.8?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to find Free RAM in MQX 3.8?

ソリューションへジャンプ
2,556件の閲覧回数
mariappanramasa
Contributor I

Hi all,

I am new to MQX RTOS infact RTOS itself.

Can anyone please tell me if there is any way to find free RAM space in MQX?

Something similar to "free" in linux.

Thanks in advance

タグ(2)
0 件の賞賛
返信
1 解決策
1,514件の閲覧回数
BryGuyH
Contributor IV

_mem_get_free

_mem_get_free_from

If you get an error add these files to the lwmem section of the PSP project

(Use this recommendation at your own risk since I don't know why Freescale hasn't included these in the PSP projects. I have not see any adverse affects myself.)

lwm_gfre.c

lwm_gfri.c

lwm_gfrf.c

These files are located in the \mqx\source\lwmem folder. For example the default install on my machine is:

C:\Program Files\Freescale\Freescale MQX 3.8\mqx\source\lwmem

In my application I have a shell command that dumps a bunch of system information. In it I've used the functions like this:

        printf("Static RAM Usage:   %d Bytes\r\n", (uint32_t)_mqx_get_initialization()->START_OF_KERNEL_MEMORY - 0x1FFF0000);

        printf("  Peak RAM Usage:   %d Bytes(%d%%)\r\n", (uint32_t)_mem_get_highwater() - 0x1FFF0000, ((uint32_t)_mem_get_highwater() - 0x1FFF0000)/0x51E);

        printf("Current RAM Free:   %d Bytes(%d%%)\r\n", _mem_get_free(), _mem_get_free()/0x51E);

The magic numbers used above (0x1FFF0000 and 0x51E) are the base memory address (0x1FFF0000) and ram size (0x51E) for the Kinetis K20/K60 chips. Change them to match your system. Mine looks like this when running:

Static RAM Usage:   23712 Bytes

  Peak RAM Usage:   98500 Bytes(75%)

Current RAM Free:   35468 Bytes(27%)

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
1,515件の閲覧回数
BryGuyH
Contributor IV

_mem_get_free

_mem_get_free_from

If you get an error add these files to the lwmem section of the PSP project

(Use this recommendation at your own risk since I don't know why Freescale hasn't included these in the PSP projects. I have not see any adverse affects myself.)

lwm_gfre.c

lwm_gfri.c

lwm_gfrf.c

These files are located in the \mqx\source\lwmem folder. For example the default install on my machine is:

C:\Program Files\Freescale\Freescale MQX 3.8\mqx\source\lwmem

In my application I have a shell command that dumps a bunch of system information. In it I've used the functions like this:

        printf("Static RAM Usage:   %d Bytes\r\n", (uint32_t)_mqx_get_initialization()->START_OF_KERNEL_MEMORY - 0x1FFF0000);

        printf("  Peak RAM Usage:   %d Bytes(%d%%)\r\n", (uint32_t)_mem_get_highwater() - 0x1FFF0000, ((uint32_t)_mem_get_highwater() - 0x1FFF0000)/0x51E);

        printf("Current RAM Free:   %d Bytes(%d%%)\r\n", _mem_get_free(), _mem_get_free()/0x51E);

The magic numbers used above (0x1FFF0000 and 0x51E) are the base memory address (0x1FFF0000) and ram size (0x51E) for the Kinetis K20/K60 chips. Change them to match your system. Mine looks like this when running:

Static RAM Usage:   23712 Bytes

  Peak RAM Usage:   98500 Bytes(75%)

Current RAM Free:   35468 Bytes(27%)

0 件の賞賛
返信
1,514件の閲覧回数
c0170
Senior Contributor III

Thanks bryan,

I totally missed _mem_get_free functions.:smileysilly:

Regards,

MartinK

1,514件の閲覧回数
c0170
Senior Contributor III

Hello mariappanramasamy,

There's _tad_stack_usage() function in tad file which you can find in MQX/source/tad. Or another option is TAD (Task Aware Debugging) which shows stack usage in IDE.

For more information about TAD (5th chapter) : http://cache.freescale.com/files/32bit/doc/app_note/AN3905.pdf

There are more documents where TAD is described for different IDE's. These are located in MQX/doc folder.

Regards,

MartinK