kermitas wrote:1) why we need to do "align data" ?
I'm not entirely sure on the reasoning for this, but if you have debug enabled then the asserts in the memory pool code will halt the system. Maybe Giovanni can explain better?
2) is this second argument a size of each block in the pool? if yes then what maximum count of blocks can hold this pool?
yes it is the size of the memory objects in the pool. I think the upper limit is probably your mcu memory..
3) if third (last) argument is NULL then this list cannot grow - am I right? if yes then how to write grovable memory pool?
It can still grow by adding more with chPoolFree, but there is no function called whenever data is allocated. I think you only need this if you're doing some advanced allocation, e.g using several memory pools from one block of data
4) if BasicMessage contains integer and pointer then I can't see any place where we pass this number and some pointer into a new "instance"

, where to do that?
I'm not sure I understand this question; are you asking how to put data into the structure? you can of course expand BasicMessage to be as long as you want.
5) if I want to send to mailbox a task that will be executed only once (for example: in the start of system write "hello") then should it be BasicMessage allocated staticaly or by memory poll/malloc?
I'd avoid the use of malloc unless you really need it. In the case of using memory pools in the example I provided, the memory is statically allocated as at the beginning it defines an array of objects of length N.
6)hmmm I am starting to thinking that I am completly doesn't undesrstand memory pools

, here is what I want to do:
- thread receive messages from it's Mailbox
- messages in Mailbox are BasicMessage
- it task (task code is in "int code" in BasicMessage) to execute by the thread is to execute many times then I think it should be alocated statically
- if task to execute by the thread is one-time task then I think it should by allocated dynamically -> for this purpose I thought I should use memory pools but maybe it should be malloc() and after execution free()?
You can achieve this easily using memory pools. Your server thread uses chPoolAlloc to get a new BasicMessage pointer, and checks it isn't NULL. It adds in the data and posts it to your mailbox. Your client thread waits on that mailbox, receives a mail and gets out the pointer by casting the message to BasicMessage*. Once it is done with the data the
client thread calls chPoolFree, not the server. This is an important part of the mechanism!
That's the basic structure used in the C++ class I posted, you should be able to get the relevant parts from it.
OMG! You are those guy from this example

! I study it every day! I also considered to write in C++ style (my brain is object oriented after many years in Java and Scala) but then Giovanni wrote that C++ wrappers are old and small subset of ChibiOS so I leave this idea

. What is your experience? Did you have to write all wrappers by yourself? Why did you wrote in C++ when everybodoy will tell you that in embeddes systems you have to use pure C??

It is true that the C++ wrappers for Chibios represent a small subset, but you can still call all the C functions, so you don't lose any functionality, but gain the ability to use object oriented classes which may be of benefit in your application! You should note that it is not easy (or probably recommended) to use some features of C++ on an embedded system, e.g new and delete.
What is your board? My is STM32F4Discovery, great, powerful, fast and cheap.
My board is a custom PCB with some inertial sensors and an RF modem (RFM22B).
And the most important question. Can whole of your code be publictly viewable (like on Github? Bitbucket? ect) ??
Not yet, it is mostly specific to a research project I'm working on and is not ready for release, sorry!