Houston, I have a problem with main() function

Hi all,

As you know, I am trying to port RIOT to Cypress PsoC Ics and I am trying to create a PsoC Creator project for RIOT (I have also detailed PsoC Creator for RIOT in different mail thread; please see ‘Port RIOT to Different Environments (IDE)’ thread.)

PsoC Creator creates own files automatically for system initialization. I have used this files during RIOT porting. We cannot modify this files because for each build PsoC Creator IDE reverts auto generated files if they were changed before.

One of the files initializes PsoC device and calls main() function and I cannot modify this file.

And also main() function is called by RIOT in main thread (in kernel_init.c) statically but there is no modifiable area(file) to call kernel_init function before calling main function.

I have found two solution ;

1- Do not call main function statically in main thread.

Use ‘extern int ENTRY_POINT(void);’ instead of ‘extern int main(void);’ and call ENTRY_POINT(); in main thread.

2- Create a method that calls kernel_init first time at the start of main function as below (or something like this)

bool initialize_RIOT(void)

{

static bool riot_kernel_started = false;

if (riot_kernel_started)

{

return false;

}

else

{

kernel_started = true;

board_init();

kernel_init();

return true;

}

}

And use this function in main() function like this;

int main()

{

if (initialize_RIOT() == true)

{

return 0;

}

/* RIOT is active now and write application code */

}

I have used second one as a hack to not change RIOT core but I don’t prefer to use this option.

I would prefer first one if it is possible.

Do you have any suggestion to solve this issue?

Regards.

Murat.