cancel
Showing results for 
Search instead for 
Did you mean: 

It is an error that "main" is not defined in "bl main" command.

yum
Associate II

I attach examples and unselected examples of the "Do not generate the main" option of the Application Structure in the Project Manger of STM32CubeMX.

In both cases, when TrueStudio is compiled, an error occurs in startup_stm32f769xx.s in the "startup" folder.

The error is "undefined reference to 'main'".

It is an error that "main" is not defined in "bl main" command.

I want to know how to fix this error.

1 ACCEPTED SOLUTION

Accepted Solutions
Mon2
Senior III

@yum​ , TrueStudio at this time is not well integrated into this toolchain and you will see similar error codes.

Can you switch to IAR or SW4STM32 compilers?

Review this webpage:

https://touchgfx.zendesk.com/hc/en-us/articles/360020208091-Configuring-STM32F769I-DISCO

View solution in original post

14 REPLIES 14
AvaTar
Lead

> I attach examples and unselected examples of the "Do not generate the main" option of the Application Structure in the Project Manger of STM32CubeMX.

I don't know Cube well, but that surely means you want/need to provide your own main() function, instead of a Cube-generated one.

A function named main() is defined as the entry point of the application, and startup code across all platform assumes this name.

You can chenge the startup code, and replace "main" with a different label. If your application contains the same label/function.

yum
Associate II

Thank you for answer.

I changed "main.cpp" to "new_main.cpp".

However, an error occurs even if the "bl main" of the strartup code is set to "bl new_main".

> I changed "main.cpp" to "new_main.cpp".

The name of the source file itself does not matter to the linker.

A function of the name "main" is required.

C++ is a different matter - the linker uses name mangling to differ between overloaded functions. The full declaration (parameters, return value) matters as well. Not sure how TrueStudio handles this.

Mon2
Senior III

@yum​ , TrueStudio at this time is not well integrated into this toolchain and you will see similar error codes.

Can you switch to IAR or SW4STM32 compilers?

Review this webpage:

https://touchgfx.zendesk.com/hc/en-us/articles/360020208091-Configuring-STM32F769I-DISCO

yum
Associate II

Thank you for answer.

The IAR compiler does not have a purchase plan.

TureStudio is free so I tried to use it.

I will try SW4STM32 if possible.

Unfortunately, I hope I can use it in TureStudio.

yum
Associate II

Thank you very much.

I compiled the project with SW4STM32 as you suggested.

I downloaded the zip file from your article on "STM32F429i_DISC1 Tutorials with IAR and SW4STM32 Compilers (with TouchGFX & STM32CubeMX)".

Compiled without errors

I will step it up by creating a project in CubMX myself.

I will try to refer to your file at this time.

I once again say thank you very much.

zul-a
Associate II

Hi @yum​ and @Mon2​ 

I am having same problem. Please see attached. I am trying to generate a project via Cube MX for Attolic True studio with Touch Gfx interface. I am using STM32F746G-DISCO board. Any ideas where things are going wrong?

Thanks for the help.

Regards

Zain

Mon2
Senior III

Hi @zul-a​ , I am in Hong Kong at this time and do not have full remote access to my lab setup so here are some quick comments:

1) The tool integration is broken so you are facing the observed issues

2) Review the following possible work arounds (in no particular order of preference):

Plan A:

Review the following webpage:

https://community.st.com/s/question/0D70X0000076dLS/guides-for-using-touchgfx-410-with-cubemx-50-known-limitations?s1oid=00Db0000000YtG6&s1nid=0DB0X000000DYbd&emkind=chatterCommentNotification&s1uid=0050X000007vr0X&emtm=1550748757318&fromEmail=1&s1ext=0

and note specifically that you must select V2.0 template from the TouchGFX toolchain.

For this method, you are launching the Touchgfx toolchain FIRST -> select v2.0 template for this target kit -> create your GUI -> compile and test with the simulator -> reflash your target kit and verify it works correctly.

Then proceed to locate the file folder built from this toolchain and launch the CubeMX tool. Suspecting that any code wizard use inside CubeMX will currently break the generated code so you must review the following to fix the broken code:

For use with IAR & STM32F746 Discovery Kit:

https://touchgfx.zendesk.com/hc/en-us/articles/360019884752-Configuring-STM32F746G-DISCO

PS: Do try to run with IAR (if you have it as-is before fixing the code using the above link).

From our experience of investing about a month into these tools with daily long hours, IAR is the most stable compiler to use for integrating these tools till all is fixed by ST in the future.

Plan B: Review the notes from @BBenn​  on how to use the same kit with Atollic on the same landing page.

Plan C: Review the document from @Clark Sann​ on how to get this kit working using the SW4STM32 compiler:

https://community.st.com/s/question/0D50X0000AAHSjZSQX/how-to-get-a-working-touchgfx-project-working-with-stm32f746gdisco-board-and-sw4stm32

As noted a few times, the forum search engine requires some improvement to locate some of these gems of articles.

Hope this helps.

PS: For future readers, please post your update on using this kit and resolution.

zul-a
Associate II

@Mon2​  Thanks a lot for your quick and very detailed response. Would definitely give this a go.

@Amel NASRI​ Any idea by when can we expect to have Cube MX generate bug free code for Atollic TS and Touch Gfx.

Thanks

Zain