chThdCreateFromHeap migration issue

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

omcdr
Posts: 89
Joined: Wed Aug 17, 2016 3:25 pm
Has thanked: 7 times
Been thanked: 7 times

Re: chThdCreateFromHeap migration issue

Post by omcdr »

My code looks like now:

Code: Select all

#pragma data_alignment = 4
static uint8_t data[MEMORY_POOL_SIZE];
static memory_pool_t mp1;

chPoolObjectInit(&mp1, sizeof(data), NULL);
chPoolFree(&mp1, &data[0]);
cmd_console.threadp = chThdCreateFromMemoryPool(&mp1, "cmd", NORMALPRIO + 5, cmd_console_thd, (void *) &cmd_console);
chThdWait(cmd_console.threadp);

I still got chSysHalt.

With commented out line in chThdCreateSuspendedI:

Code: Select all

  chDbgCheck(MEM_IS_ALIGNED(tdp->wbase, PORT_WORKING_AREA_ALIGN) &&
             MEM_IS_ALIGNED(tdp->wend, PORT_STACK_ALIGN) &&
             (tdp->wend > tdp->wbase) &&
             (((size_t)tdp->wend - (size_t)tdp->wbase) >= THD_WORKING_AREA_SIZE(0)));

and my thread is working correctly.

Should I check every condition in this check separately?

I don't run test suite on my boards.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chThdCreateFromHeap migration issue

Post by Giovanni »

Yes, you should understand which condition fails, you problem is then clear.

Giovanni
omcdr
Posts: 89
Joined: Wed Aug 17, 2016 3:25 pm
Has thanked: 7 times
Been thanked: 7 times

Re: chThdCreateFromHeap migration issue

Post by omcdr »

I have found problem, should be:

Code: Select all

#pragma data_alignment = 32
static uint8_t data[MEMORY_POOL_SIZE];


Do you have plans for integrate #pragma data_alignment into code for IAR compiler version ?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chThdCreateFromHeap migration issue

Post by Giovanni »

Hi,

Alignment support is provided by the macros used to declare thread working areas. You need to declare your buffer using those.

Giovanni
Post Reply