Link an ARMCC (Keil MDK) precompiled lib to a GCC project - Page 1
Forum section: electronics / general

author: AloyseTech
author_rank: Regular Contributor
timestamp: March 22, 2020, 12:12:25 am
content: Hi,I'm considering porting the PhyplusInc PHY6202 (<0.5$ Cortex-M0 MCU with BLE) SDK to GCC.Some libraries sources are not available (mainly for the phy).Would it be possible to link a library compiled with Keil armcc to a GNU based project?Just to avoid diving deeper for nothing...

author: ataradov
author_rank: Super Contributor
timestamp: March 22, 2020, 07:21:42 am
content: What version of the compiler was used? ARMCC v5 is just Clang/LLVM, so it should be pretty easy to link its output.I'm not sure that earlier versions conform to ARM EABI standard. I have not looked at it that close.Also, how are the closed libraries distributed? Is it just a *.a or *.o files? Can you attach them as an example?

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: March 22, 2020, 08:45:23 am
content: Seems an interesting part!

author: AloyseTech
author_rank: Regular Contributor
timestamp: March 22, 2020, 10:32:58 am
content: Quote from: ataradov on March 22, 2020, 07:21:42 amA quick string analysis of the lib file gives the following clues :Code:Component: ARM Compiler 5.06 update 4 (build 422) Tool: armlink Component: ARM Compiler 5.06 update 4 (build 422) Tool: armasm Component: ARM Compiler 5.06 update 4 (build 422) Tool: ArmCC Quote from: ataradov on March 22, 2020, 07:21:42 amThe lib are .lib files. Also it might be possible that some code is pre-flashed in the ROM of the device... I'm still discovering this architecture.The SDK can be downloaded here :http://wiki.phyplusinc.com/doku.php?id=menu:phy62_series:phy6202direct link to the rar archive :http://wiki.phyplusinc.com/doc/SDK/PHY62XX_SDK_1.1.8.rarThe datasheet :http://wiki.phyplusinc.com/doc/DataSheet/PHY6202_BLE_SoC_Datasheet_v1.4.pdfIf some of you are interested, MakerFab has a 1$ development board :https://www.makerfabs.com/1-usd-ble-solution-core.html

author: Yansi
author_rank: Super Contributor
timestamp: March 22, 2020, 10:35:32 am
content: Linking ArmCC .lib file to GCC is not possible.

author: AloyseTech
author_rank: Regular Contributor
timestamp: March 22, 2020, 10:41:24 am
content: Quote from: Yansi on March 22, 2020, 10:35:32 amThanks Yansi for your reply. Would you mind sharing some details ?

author: Yansi
author_rank: Super Contributor
timestamp: March 22, 2020, 11:17:22 am
content: It is simply incompatible format, what else do you want to know?Or why do you think most major ARM vendors offer precompiled library extra for ARM, extra for IAR and then GCC?

author: AloyseTech
author_rank: Regular Contributor
timestamp: March 22, 2020, 11:35:14 am
content: I was (maybe wrongly) thinking that at the end anything is just assembly code with thumb instruction that should be compatible whatever the initial compiler.As for why major vendor distribute compiler specific library, I thought maybe it's to offer the easiest programming experience to the user. I've never used anything else than GCC and never dived into the compiler science. I might be totally wrong.

author: Yansi
author_rank: Super Contributor
timestamp: March 22, 2020, 11:45:25 am
content: Well, in the end, it is "just" a bunch of instructions. But the amount of incompatibility between the formats is simply not worth the hassle of trying to link it.I would also suspect, that large vendors, like ARM and IAR, would probably do their best to make the format as incompatible as possible, just to make the obligatory "vendor lock-in", that you would have to use just their piece of bloatware. And I hope such practices will go away in the near future.

author: greenpossum
author_rank: Frequent Contributor
timestamp: March 22, 2020, 01:59:23 pm
content: OP wouldn't it be better if you edited the SDK files to gcc syntax? Even if you succeed in using the Keil built libraries people would not be able to use them in GPL projects.

author: andersm
author_rank: Super Contributor
timestamp: March 22, 2020, 03:30:40 pm
content: I had a quick look, and normal arm-none-eabi GNU toolchain had no problems with the libraries (which are normal ar archives) or the object files within. Note to OP, wouldn't it have been quicker just to try?

author: AloyseTech
author_rank: Regular Contributor
timestamp: March 22, 2020, 04:22:11 pm
content: Quote from: greenpossum on March 22, 2020, 01:59:23 pmEditing the SDK files will maybe be necessary indeed. But if I'm not able to link the PHY/BLE precompiled lib I didn't want to go further.Quote from: andersm on March 22, 2020, 03:30:40 pmI wanted to know if someone already tried something similar and was able to tell me for sure it does not work befre trying to setup my environment for this device. How exactly did you try ?

author: SiliconWizard
author_rank: Super Contributor
timestamp: March 22, 2020, 04:46:00 pm
content: You may take a look there:https://answers.launchpad.net/gcc-arm-embedded/+question/188291And ask further questions, I think this would be the right place to ask.

author: greenpossum
author_rank: Frequent Contributor
timestamp: March 22, 2020, 05:32:46 pm
content: Quote from: AloyseTech on March 22, 2020, 04:22:11 pmI think in the long run, to have a truly free toolchain it will be necessary to reimplement the library with open source to replace the closed source. But maybe you're not the person to do this.Another problem with this chip is that it's near impossible to get outside China except through that Makerfabs board. Even LCSC knows nothing of it.

author: AloyseTech
author_rank: Regular Contributor
timestamp: March 22, 2020, 09:30:59 pm
content: This chip is still young. I was only thinking about bootstraping open source development on this target. Make some proof of concept.