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

Update Tinyusb Build System Integration #1

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

Jake-Carter
Copy link

Description

  • The primary change is to re-use the core "driver" Makefile/project.mk combo that exists in our example projects. This lets us clean up the implementations of the "header" makefile (tinyusb.mk) and the makefile responsible for actually building the library. There's a lot less boilerplate/legacy mess for the library integrator, and we can avoid copying over a lot of the legacy mess that usually gets passed on to new libraries.

    • Things that should be exposed universally to tinyusb projects should go in "tinyusb.mk". It is include-ed at the top-level, so the top-level project build sees anything here. This includes things like IPATH, LIBS += , and the recursive rule for building the library.
    • Things that are specific to building the library file should go in "project.mk". The project implementation is essentially "here are the source files, build them as a library with this filename".
  • I added a default configuration directory to store a default tusb_config.h file. Projects can use a local one by overriding TINYUSB_CONFIG_DIR.

  • Added tusb_config.h as a dependency to the library so that it's automatically rebuilt if the config changes

  • The library will build inside the tinyusb library folder by default (build/MAX32650/tinyusb.a), or a tinyusb sub-folder if BUILD_DIR is set inside a project.

  • Added make clean.tinyusb, which also gets caught by make libclean and make distclean

- Swap out Makefile for latest project "driver" Makefile.  The only
  difference here is that TARGET is floating.
- Simplify tinyusb.mk
- Add build-specific configuration to project.mk, and simplify
  IPATH/VPATH requirements
- Add clean.tinyusb
- Build library inside the tinyusb library by default
- Add default configuration directory
@BrentK-ADI
Copy link
Owner

Thanks @Jake-Carter . I tried building the example projects I included and looks like a couple things are off with the updates. Rather than creating the tinyusb.a library, the library name is the project name. And similarly, the project's ELF file is trying to be placed in the TUSB build folder. I can hunt this down next week if you don't have the time, but figured you just may know it off the top of your head. Let me know.

Loaded project.mk
****************************************************************************
* Analog Devices MSDK
* v2023_10-172-gd3f8669fd6
* - User Guide: https://analogdevicesinc.github.io/msdk/USERGUIDE/
* - Get Support: https://www.analog.com/support/technical-support.html
* - Report Issues: https://github.com/analogdevicesinc/msdk/issues
* - Contributing: https://analogdevicesinc.github.io/msdk/CONTRIBUTING/
****************************************************************************
make -C C:/Workspace/MSDK_Development/brentk-adi-fork/Libraries/tinyusb lib BUILD_DIR=C:/Workspace/MSDK_Development/brentk-adi-fork/Libraries/tinyusb/build/MAX32650
Loaded /c/Workspace/MSDK_Development/brentk-adi-fork/Libraries/tinyusb/project.mk
- AR C:/Workspace/MSDK_Development/brentk-adi-fork/Libraries/tinyusb/build/MAX32650/cdc_msc.a
- LD C:/Workspace/MSDK_Development/brentk-adi-fork/Libraries/tinyusb/build/MAX32650/cdc_msc.elf
arm-none-eabi-gcc.exe: error: C:/Workspace/MSDK_Development/brentk-adi-fork/Libraries/tinyusb/build/MAX32650/tinyusb.a: No such file or directory
make: *** [C:/Workspace/MSDK_Development/brentk-adi-fork/Libraries/CMSIS/Device/Maxim/GCC/gcc.mk:594: C:/Workspace/MSDK_Development/brentk-adi-fork/Libraries/tinyusb/build/MAX32650/cdc_msc.elf] Error 1

 *  The terminal process "C:\windows\System32\cmd.exe /d /c make -r -j 8 --output-sync=target --no-print-directory TARGET=MAX32650 BOARD=EvKit_V1 MAXIM_PATH=C:/Workspace/MSDK_Development/brentk-adi-fork MAKE=make PROJECT=cdc_msc" terminated with exit code: 2. 

@Jake-Carter
Copy link
Author

@BrentK-ADI whoops - sorry, was only testing on the command-line. Just needed an override on the PROJECT variable. Should work now.

@BrentK-ADI
Copy link
Owner

@Jake-Carter , The one lingering thing is tinyusb.mk is stomping on BUILD_DIR causing all build files to end up in tinyusb, not just the library. I'm going to merge in this PR as is, and just edit that line on my next commit for example and documentation updates.

Thanks for supporting this integration!

@BrentK-ADI BrentK-ADI merged commit ab4d5e5 into BrentK-ADI:tinyusb_support Aug 12, 2024
1 of 2 checks passed
@Jake-Carter
Copy link
Author

@BrentK-ADI thanks, you're right. Didn't intend for that. Was trying to build in a target-specific sub-dir when you build from a project and from inside the library folder. There's some complications with where the BUILD_DIR default is set that makes this harder than it should be for the recursive calls...

Just reverted it. It'll build in the target-specific folder from a project, which is the important thing for when other micros are supported.

analogdevicesinc@dd93762

BrentK-ADI pushed a commit that referenced this pull request Aug 23, 2024
* Update tinyusb build system integration

- Swap out Makefile for latest project "driver" Makefile.  The only
  difference here is that TARGET is floating.
- Simplify tinyusb.mk
- Add build-specific configuration to project.mk, and simplify
  IPATH/VPATH requirements
- Add clean.tinyusb
- Build library inside the tinyusb library by default
- Add default configuration directory

* Use override on PROJECT
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

Successfully merging this pull request may close these issues.

2 participants