chettrick / discobsd

2.11BSD-based UNIX-like OS for STM32 and PIC32 Microcontrollers
http://www.DiscoBSD.org
BSD 3-Clause "New" or "Revised" License
171 stars 15 forks source link

FreeBSD require gcc-arm-embedded on STM32 (instead of arm-none-eabi-gcc) #10

Closed lhondareyte closed 11 months ago

lhondareyte commented 1 year ago

FreeBSD ports provide two ARM compilers:

The second one is for embedded devices like STM2 familly. His path is /usr/local/gcc-arm-embedded/bin

chettrick commented 12 months ago

I've set up a new FreeBSD 13.2 box to test using the gcc-arm-embedded port, but I haven't worked through all the issues yet. This should get in, at least to bring along FreeBSD as a host development OS in the future.

Please also add the same change for the compiler prefix for ARM_GCC_PREFIX in /sys/stm32/gcc-config.mk to this pull request.

Thanks again for your interest and help.

chettrick commented 11 months ago

I've been able to build base and kernel for stm32 with both compilers on FreeBSD 13.2.

Selecting which compiler to use on FreeBSD should be a personal choice, as I would prefer to not to use non-portable make features to determine which package is installed, especially when FreeBSD is not yet officially supported as a host development environment.

I am going to leave arm-none-eabi-gcc as the default on FreeBSD for now, and close this PR.

lhondareyte commented 11 months ago

I should have specified that the generated code does not work on the target. Only the compiler devel/gcc-arm-embedded works. (https://forums.freebsd.org/threads/arm-none-eabi-gcc-does-not-see-standard-libraries.80772/#post-516053) I had the same problem while compiling NuttX: compile is OK but fail to run on target.

chettrick commented 11 months ago

Thanks for the feedback @lhondareyte. I looked deeper into this (previously I only compiled it) and figured out the issue. The arm-none-eabi-gcc FreeBSD package does not enable multilibs and especially not the Cortex M/R profile that uses only Thumb-2 ARMv7e-m instructions supported by stm32f4 devices. The gcc-arm-embedded package does enable this, and makes proper stm32 kernels and base executables. I have tested a full base build and kernel build for the stm32f412g-disco board.

chettrick commented 11 months ago

@lhondareyte, I will merge this pull request as soon as you add the same change for the compiler prefix for ARM_GCC_PREFIX in /sys/stm32/gcc-config.mk. Then it's all good. Thanks again!

chettrick commented 11 months ago

Just for completeness of information, I worked through this compiler multilib profile issue with the devel/arm-none-eabi-gcc-linaro port on OpenBSD last September on commit b5e2d75707cd3938f9efbe7e8a9f3d3c2fccb218.

I wonder if anyone would like to put in the effort and see if a compiled port of devel/arm-none-eabi-gcc on FreeBSD with multilib enabled, similar to what I did in the above commit, would produce usable results. I may work on it if it is desired and needed.

Regards

chettrick commented 11 months ago

@lhondareyte, I will merge this pull request as soon as you add the same change for the compiler prefix for ARM_GCC_PREFIX in /sys/stm32/gcc-config.mk. Then it's all good. Thanks again!

I merged this PR, and also made a separate commit for the above specified change to /sys/stm32/gcc-config.mk.

FreeBSD should now be able to successfully compile stm32 kernels and the base system with the devel/gcc-arm-embedded package (albeit, with a few warnings raised due to the new GCC compiler version). Raise a new issue if that is not the case.

Regards.