2020-05-01 12:40 AM
I've been attempting to get TouchGFX running with MbedOS. I've got the program compiling but I'm getting some consistent link errors. Any suggestions on this?
Using ARMC6 (6.13) I get the following:
```
[Warning] @0,0: L3912W: Option 'legacyalign' is deprecated.
[Error] @0,0: L6218E: Undefined symbol touchgfx::HAL::instance (referred from BUILD/DISCO_F746NG/ARMC6/Middlewares/ST/touchgfx/framework/source/touchgfx/containers/CacheableContainer.o).
[Error] @0,0: L6218E: Undefined symbol touchgfx::Bitmap::dynamicBitmapGetAddress(unsigned short) (referred from BUILD/DISCO_F746NG/ARMC6/Middlewares/ST/touchgfx/framework/source/touchgfx/containers/CacheableContainer.o).
...
...
Finished: 0 information, 1 warning and 164 error messages.
```
All 164 errors are consistent undefined symbols coming from touchgfx files.
Correct me if I'm wrong, but this seems to be down to static members of a class not being defined in a .cpp that they are used in (Defining these members seems to fix the error)
(Like this: https://stackoverflow.com/questions/185844/how-to-initialize-private-static-members-in-c)
Is there any way other than correcting this in the 164 occurrences? (I'd rather not do this every time the touchgfx libraries are updated)
I've also tried using GCC ARM (9-2019-q4-major) as I thought it may be more compatible and I get the following:
```
[ERROR] c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lchgfx_core
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lchgfx_core_release
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lchgfx_core
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lchgfx_core_release
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lchgfx_core
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lchgfx_core_release
collect2.exe: error: ld returned 1 exit status
```
Any ideas?
Thanks!
2020-05-01 06:14 AM
No luck so far.
The Makefile is unchanged from how it was generated by the TouchGFX designer. And I haven't really changed the file structure, just added the MBedOS files and removed the files that I don't need (EWARM, MDK-ARM etc) and cause errors (simulator files, SDL2 etc). So from what I can tell the linker path should be correct.
But I may not be understanding how these files are used to compile. Should the GCC compiler be automatically invoking the Makefile in some way? (like I said I have little knowledge in how this process works!)
2020-05-01 08:51 AM
After a bit of reading and playing, I realise now that the question I asked doesn't make much sense!
It was a problem with the library files, but not with finding the ones that I required:
I'm compiling through Mbed Studio (IDE) which seems to scan all of the files to build the include paths and find library files automatically. It looks like the IDE was picking up on the .lib files which it could not read, and this was causing the error above.
After removing the unused library files it is now reading the .a files, which are causing the following errors:
```
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: error: ./Middlewares/ST/touchgfx/lib/core/cortex_m7/gcc\libtouchgfx-float-abi-hard.a(AbstractPartition.o) uses VFP register arguments, BUILD/DISCO_F746NG/GCC_ARM/tGFX_Mbed_GCC.elf does not
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file ./Middlewares/ST/touchgfx/lib/core/cortex_m7/gcc\libtouchgfx-float-abi-hard.a(AbstractPartition.o)
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: error: ./Middlewares/ST/touchgfx/lib/core/cortex_m7/gcc\libtouchgfx-float-abi-hard.a(HAL.o) uses VFP register arguments, BUILD/DISCO_F746NG/GCC_ARM/tGFX_Mbed_GCC.elf does not
c:/program files (x86)/gnu tools arm embedded/9 2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: failed to merge target specific data of file ./Middlewares/ST/touchgfx/lib/core/cortex_m7/gcc\libtouchgfx-float-abi-hard.a(HAL.o)
```
From reading through your support documentation, I guess this is something to do with Linker options being used?
So now I'm looking for where these linker options are configured in the IDE/CubeOS to add the suggested options!
(Cortex-M7: -Wl,-static -nostartfiles -mthumb -mno-thumb-interwork -fno-exceptions -fno-rtti -Wl,--gc-sections -mcpu=cortex-m7 -Wno-psabi)
2020-05-02 06:28 AM
Success, I now have TouchGFX running on it's own thread with MbedOS, in Mbed Studio! :beaming_face_with_smiling_eyes:
I didn't end up changing any linker options as above (but I did find them in the Mbed Build profiles .json files). Instead I just deleted the "libtouchgfx-float-abi-hard.a" file and it all compiled successfully (I hope there's nothing too important in this library file! :grinning_face_with_sweat:).
Then it was just a case of fiddling with the MX peripheral initialisations and IRQs to get them working nicely, before setting up a thread for the touchGFX process.
Thanks for the help guys!
2020-05-03 01:22 PM
Great work, George! :) Glad you were able to solve it (and understand it) while i was having a "relaxing" weekend.
/Martin