forte+freertos+lwip on stm32 flash problem [message #1827389] |
Thu, 14 May 2020 03:24 |
joy woo Messages: 198 Registered: May 2019 |
Senior Member |
|
|
I did as
https://www.eclipse.org/4diac/en_help.php?helppage=html/installation/freeRTOSLwIP.html
the libforte-static.a library is 2570kb
if i check the iec61131 moduble, then the file will be very large,
then i complied the library with freertos and lwip,
the bin file will be over 512k, it runs out off the 512k flash.
Any experience?
The second problem is when i debug
static void forte_thread(void *arg)
{
forteGlobalInitialize();
TForteInstance forteInstance = 0;
int resultForte = forteStartInstanceGeneric(0, 0, &forteInstance);
if(FORTE_OK == resultForte){
forteJoinInstance(forteInstance);
}else{
printf("Error %d: Couldn't start forte\n", resultForte);
}
forteGlobalDeinitialize();
vTaskDelete(NULL);
}
int resultForte = forteStartInstanceGeneric(0, 0, &forteInstance);
this line is hang up, why?
[Updated on: Thu, 14 May 2020 07:54] Report message to a moderator
|
|
|
Re: forte+freertos+lwip on stm32 flash problem [message #1827429 is a reply to message #1827389] |
Thu, 14 May 2020 10:47 |
|
Hi,
first of all I assume you built everything with debug disabled? Debug symbols consume quite some memory.
I made good experiences with -Os (optimize for size) or -O2. The latter often produces smaller binaries for arm then -Os.
Furthermore I had a quick look on the default compiler settings of our default freeRTOS setup and it is missing quite some options that can help you on embedded systems.
I would experiment at least with the following compiler settings: -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions
and the following linker options for the final linking stage linking your binary: -W,--gc-sections -fno-threadsafe-statics
The functions and data sections allow the linker with the gc-sections to remove not used elements. No-rtti and no-exceptions should greatly reduce the binary size as well.
No-Threadsafe-statics should reduce ram usage. If you take an older forte (1.8.4 or so) you will find there also CMakefiles for Lego Mindstorms nxt (in the ecos folder). There I did the most heavy tuning. Producing a Map file can help here to find out what is all part of your binary image.
Maybe some arm specific options like -mno-thumb-interwork could also bring some size reduction. But here I would refer to your tool-chain.
For your second problem I would a assume a stack size or heapsize problem. How much ram do you have? Can you step into and find out where it breaks inside.
I hope this helps you to move forward.
|
|
|
Re: forte+freertos+lwip on stm32 flash problem [message #1828053 is a reply to message #1827429] |
Sat, 30 May 2020 15:47 |
joy woo Messages: 198 Registered: May 2019 |
Senior Member |
|
|
Thank you for your so nice advice,
yes, now i have the problem of RAM, my device is stm32F407ZET6,
it's with 512k flash and 128k ram,the Eth is W5500,
in definition:
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.priority = (osPriority_t) osPriorityHigh,
.stack_size = 128 * 4
};
/* Definitions for Task02 */
osThreadId_t Task02Handle;
const osThreadAttr_t Task02_attributes = {
.name = "Task02",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 128 * 50
};
in main()
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
void StartDefaultTask(void *argument)
{
lwipInit();
Task02Handle = osThreadNew(forte_thread, NULL, &Task02_attributes);
vTaskDelete(NULL);
}
the forte version is 1.11 the freertos is 10.2.1 ,the lwip is 2.1.2,
the libforte-static.a is ready on windows with trueStudio, tool-chain is
arm-atollic-eabi.
it seems not enough ram according to the suspending thread stack
even I change
osThreadId_t Task02Handle;
const osThreadAttr_t Task02_attributes = {
.name = "Task02",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 128 * 50
};
to 128*80 it didn't work
-
Attachment: snap1.jpg
(Size: 30.18KB, Downloaded 70 times)
[Updated on: Sat, 30 May 2020 15:51] Report message to a moderator
|
|
|
|
|
Re: forte+freertos+lwip on stm32 flash problem [message #1828125 is a reply to message #1828122] |
Tue, 02 June 2020 07:45 |
|
In the advanced cmake options you can adjust the size of the string dict. There is also an option to make stringdict a statically allocated array which would then not be resized and therefore not be allocated on the heap.
but 15k of heap will definitely not be enough. I think you need to deeper analyze what is needing your ram for what puproses and tune that.
|
|
|
|
|
|
|
Re: forte+freertos+lwip on stm32 flash problem [message #1828487 is a reply to message #1828480] |
Wed, 10 June 2020 14:52 |
|
In my experience on low memory devices composite FBs need a lot of memory and for beginning you should definitly avoid them. If you need a lightweight encapsulation means you can use subapps (typed and untyped). I had 4diac FORTE running on an arm7 with 64k of ram using eCos. I currently don't know how much RAM freertos and lwIP is using. A good starting point is looking at the map file which your linker can produce.
|
|
|
|
Re: forte+freertos+lwip on stm32 flash problem [message #1828509 is a reply to message #1828499] |
Thu, 11 June 2020 07:40 |
joy woo Messages: 198 Registered: May 2019 |
Senior Member |
|
|
CIEC_ANY *CTypeLib::createDataTypeInstance(CStringDictionary::TStringId pa_nDTNameId, TForteByte *pa_acDataBuf) {
CIEC_ANY *poNewDT = 0;
CTypeEntry *poToCreate = findType(pa_nDTNameId, m_poDTLibStart);
if (0 != poToCreate) {
poNewDT = (static_cast<CDataTypeEntry *>(poToCreate))->createDataTypeInstance(pa_acDataBuf);
if (0 == poNewDT) // we could not create the requested object
m_eLastErrorMSG = e_OVERFLOW;
} else
m_eLastErrorMSG = e_UNSUPPORTED_TYPE;
return poNewDT;
}
e_UNSUPPORTED_TYPE;
can't findType, still researching
[Updated on: Thu, 11 June 2020 07:41] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04584 seconds