-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a more Modern CMake approach #6
base: master
Are you sure you want to change the base?
Conversation
faee242
to
f164e31
Compare
Split off the Atmel Start specific instructions from toolchain.cmake into a separate CMakeLists.txt and defined the Atmel Start code as a separate static library with all the include paths and compile/link options set as PUBLIC options.
I am not sure what's wrong with CMake files, but the linker doesn't link the libatstart.a file correctly which results in bad elf file... Did it work for you? |
I'm still waiting for my prototypes to arrive, unfortunately. Do you know what is wrong with the ELF file? |
here is a comparison of the master branch, and your pull request version. Looks like somehow main function is missing or etc https://gist.github.com/aurimasniekis/35da388137d9cde7fbca8c613852802c |
One clue I found is that there is a startup c file with reset handler in lib so I moved it out and now at least the MCU starts, but I am getting stuck in DummyHandler for some reason... |
Okay, I have figured out the issue. The first one is that add_executable(example ${ATMEL_START_DIR}/samd21a/gcc/gcc/startup_samd21.c main.c)
target_link_options(example PUBLIC -Wl,--section-start=.text=0 -mthumb -mcpu=cortex-m0plus -D__SAMD21G18A__) |
I am not sure if there is a nice way to specify that |
I don't have a computer near me now, but I think that perhaps certain symbols in that startup should perhaps be made weak. That way you can override them if you don't want the implementation provided be the SDK. I might have some time tomorrow to have a look at it. |
This is my current solution including fix of 0 value clocks generated because of how Atmel Start generates YAML file aurimasniekis@6025d08 |
I also just noticed that moving ASF into lib causes a lot of other issues, like STDIO redirect doesn't find replacements and etc things. |
I replaced the library approach with simple adding target sources to target it now works with all the things which weren't working before. aurimasniekis@2a8bdab |
Finally got around to assembling my prototypes so I could continue with this. |
First of all, thanks for this project. It's my first time starting an ATSAMD project from scratch. (I typically use NXP MCUs and to be honest, their SDK/tooling is a lot more "developer friendly" than what Microchip seems to be offering. However this did help to simplify some things.)
One thing I did notice, is that the CMake files generated are rather "old school" CMake, rather than Modern CMake (see this gist and this online "course" for a bit of background).
I've split off the Atmel Start specific instructions from
toolchain.cmake
into a separate CMakeLists.txt and defined the Atmel Start code as a separate static library with all the include paths and compile/link options set as PUBLIC options.Rather than setting global options/variables, everything Atmel specific should be more or less linked to the
atstart
target defined in the generatedCMakeLists.txt
I've never developer with Go before, so I still need to figure out how I can install my changes on my system in order to test them. That's why I marked the PR as a Draft.