Skip to content
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

avr-libc not present during recipe do_compile #2

Open
mdtusz opened this issue Mar 18, 2022 · 8 comments
Open

avr-libc not present during recipe do_compile #2

mdtusz opened this issue Mar 18, 2022 · 8 comments

Comments

@mdtusz
Copy link

mdtusz commented Mar 18, 2022

I'm trying to create a recipe for a non-avr target that includes an mcu binary, but am running into issues compiling the binary. avr-gcc is present and available in the compilation step, however there are issues with missing avr-libc components which I can't seem to find in the build-time sysroot. In the recipe, I have

DEPENDS += " \
  avr-libc \
  avg-gcc-native \
"

however I'm wondering if there is some additional yocto magic required, or if avr-libc is being added somewhere else (it isn't present in ${libdir} when inspecting during the do_compile step).

@schnitzeltony do you have any public recipes which do a similar thing that I could take a look at? The main issue seems to just be the presence of avr-libc in the sysroot while compiling.

@schnitzeltony
Copy link
Owner

From what I understand:
You want to compile avr sources with avr-gcc-native at build time - right?

@schnitzeltony do you have any public recipes which do a similar thing that I could take a look at? The main issue seems to just be the presence of avr-libc in the sysroot while compiling.

All code I have is in here. There are some very old avr-projects I did decades ago in https://github.com/schnitzeltony/old-avr-projects

Did that help?

@mdtusz
Copy link
Author

mdtusz commented Mar 21, 2022

You want to compile avr sources with avr-gcc-native at build time - right?

Yep! I'm trying to create the AVR binary (.hex file in my case) at build time so that it can be copied into the yocto system image (i.e. an image that runs on single-board-computer and needs to be able to flash an atmega board with the AVR firmware binary).

I'm not super well versed in yocto yet and suspect I may just be missing something from the recipe or am looking in the wrong places for the avr-libc headers during the do_compile build step. I had expected that by adding avr-libc to the recipe DEPENDS, it would be present during the build step, but this doesn't seem to be the case.

The repo linked seems to be AVR source rather than bitbake recipe examples that cross-compile during build time. No worries at all if you don't have anything available though or don't have a solution off the top of your head!

Feel free to close this issue too - just wanted to check before I dive in too deep.

@schnitzeltony
Copy link
Owner

When making the recipes for AVR toolchain I thought: Would be a nice feature to compile AVR sources during build time. Have prepared a bbclass for this here but that was never tested.
Now you come up with same idea.

So: Cannot promise a schedule - made this layer just for fun - but I would like to make this work (my old sources as test case) - just because it's cool

Feel free to close this issue too - just wanted to check before I dive in too deep.

Challenge - No reason to close this issue at all!

@schnitzeltony
Copy link
Owner

Update:

I pushed avr-toolchain.bbclass (haven't tested nothing - just guesswork).

Currently my free time is very limited. Maybe you want to give it a try by inheriting it and let me know - or send some PR...

@mdtusz
Copy link
Author

mdtusz commented Mar 23, 2022

I'll give it a look and test it out! I'm still new to yocto and figuring things out but I'll definitely open a PR if changes are needed and I can make it work!

@schnitzeltony
Copy link
Owner

Spent some cyles on this one an can now compile AVR sources during YOCTO build.
It is not not done yet:

  • hex/eep/elf are not installed - simple
  • assembler sub project fails but I hope this is not much of a challenge

You asked for a recipe: https://github.com/schnitzeltony/meta-microcontroller/blob/master/recipes-avr/avr-projects/old-avr-projects.bb

Ahh and: Had to do some adjustments on the project Makefiles (use += instead of = for flags). Makefiles were made manually and I wonder if other projects - with auto generated Makefiles - build either.
So: Are your AVR sources non-secret so I can use them for test?

@mdtusz
Copy link
Author

mdtusz commented Mar 29, 2022

Thank you so much for this! The new avr-toolchain class in the master branch seems to resolve the issues that I was facing and the header sources are now available - it would be awesome to get that merged into the named release branch.

For future readers, the key parts of the recipe files when trying to cross-build for AVR seem to be:

  • inherit avr-toolchain - this class sets up the correct env flags which most makefiles will pick up on and
  • DEPENDS += "avr-libc-native" - this likely is a requirement for most things building with avr-gcc

The key part that was causing issue for me was the missing avr-libc header files, but the avr-toolchain class now fixes this. Depending on how your Makefile is written, you may need to modify or patch it for these - specifically CFLAGS and LDFLAGS.

Again, thanks a ton @schnitzeltony!

@lgrosz
Copy link

lgrosz commented Mar 21, 2023

I was able to make similar changes off the zeus branch which worked great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants