Skip to content

Adds library source back and adds SD card library #58

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

Merged
merged 11 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ TEENSY_LIB = teensy4

# Used external libraries
LIBRARY_DIR = libraries
# this is where you add your new library to, add it's path with a '-I' attached to the front
LIBRARY_INCLUDE = -Ilibraries/Adafruit_BusIO -Ilibraries/Adafruit_ICM20X -Ilibraries/Adafruit_LIS3MDL -Ilibraries/Adafruit_LSM6DS -Ilibraries/Adafruit_Sensor -Ilibraries/FlexCAN_T4 -Ilibraries/FreqMeasureMulti -Ilibraries/SPI -Ilibraries/unity -Ilibraries/Wire -Ilibraries/VL53L4CD
LIBRARY_SOURCE_C = $(shell find $(LIBRARY_DIR) -name "*.c")
LIBRARY_SOURCE_CPP = $(shell find $(LIBRARY_DIR) -name "*.cpp")

LIBRARY_INCLUDE = -Ilibraries/Adafruit_BusIO -Ilibraries/Adafruit_ICM20X -Ilibraries/Adafruit_LIS3MDL -Ilibraries/Adafruit_LSM6DS -Ilibraries/Adafruit_Sensor -Ilibraries/FlexCAN_T4 -Ilibraries/FreqMeasureMulti -Ilibraries/SPI -Ilibraries/unity -Ilibraries/Wire -Ilibraries/VL53L4CD -Ilibraries/SD -Ilibraries/SdFat -Ilibraries/SdFat/src

# name of the output lib file
LIBRARY_LIB_NAME = liblibs.a
# lib file name stripped of initial 'lib' and '.a'
Expand All @@ -28,8 +31,7 @@ PROJECT_INCLUDE = src
PROJECT_NAME = firmware

# Teensy41 compiler flags
TEENSY4_FLAGS = -DF_CPU=600000000 -DUSB_RAWHID -DLAYOUT_US_ENGLISH -D__IMXRT1062__ -DTEENSYDUINO=157 -DARDUINO_TEENSY41

TEENSY4_FLAGS = -DF_CPU=600000000 -DUSB_RAWHID -DLAYOUT_US_ENGLISH -D__IMXRT1062__ -DTEENSYDUINO=157 -DARDUINO_TEENSY41 -DARDUINO=200
# CPU flags to tailor the code for the Teensy processor
CPU_FLAGS = -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb

Expand Down Expand Up @@ -63,7 +65,7 @@ COMPILER_C := $(ARDUINO_PATH)/packages/teensy/tools/teensy-compile/5.4.1/arm/bin
OBJCOPY := $(ARDUINO_PATH)/packages/teensy/tools/teensy-compile/5.4.1/arm/bin/arm-none-eabi-objcopy

# targets are phony to force it to rebuild every time
.PHONY: build upload monitor kill clean_objs clean_bin clean
.PHONY: build upload monitor kill restart clean clean_objs clean_bin rebuild_libs lib_all lib_teensy lib_libs clean_libs
.DEFAULT_GOAL = build

# builds source, links with libraries, and constructs the .hex to be uploaded
Expand Down Expand Up @@ -111,3 +113,31 @@ clean_bin:
# overall clean target
clean: clean_objs clean_bin

rebuild_libs: clean_libs lib_all

lib_all: lib_teensy lib_libs

lib_teensy:
@echo [Building Teensy Core CPP]
@$(COMPILER_CPP) $(COMPILE_FLAGS) $(CPP_FLAGS) -c $(TEENSY_DIR)/*.cpp $(TEENSY_INCLUDE)
@echo [Building Teensy Core C]
@$(COMPILER_C) $(COMPILE_FLAGS) -c $(TEENSY_DIR)/*.c $(TEENSY_INCLUDE)
@echo [Assembling Static Library]
@ar rcs $(TEENSY_LIB_NAME) *.o
@echo [$(TEENSY_LIB_NAME) Created in $(PROJECT_DIR)]
@rm *.o -f
@echo [Cleaning Up]

lib_libs:
@echo [Building Libraries C]
@$(COMPILER_C) $(COMPILE_FLAGS) -c $(LIBRARY_SOURCE_C) $(LIBRARY_INCLUDE) $(TEENSY_INCLUDE)
@echo [Building Libraries CPP]
@$(COMPILER_CPP) $(COMPILE_FLAGS) $(CPP_FLAGS) -c $(LIBRARY_SOURCE_CPP) $(LIBRARY_INCLUDE) $(TEENSY_INCLUDE)
@echo [Assembling Static Library]
@ar rcs $(LIBRARY_LIB_NAME) *.o
@echo [$(LIBRARY_LIB_NAME) Created in $(PROJECT_DIR)]
@rm *.o -f
@echo [Cleaning Up]

clean_libs:
@rm *.a -f
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can find our documentation guidelines at [docs/README](docs/README.md), and
## Installation
To begin, clone the repository:
```bash
git clone https://gitlab.com/cu-robotics/firmware.git
git clone https://github.com/cu-robotics/firmware.git
```

Then, install dependencies:
Expand All @@ -20,11 +20,7 @@ git config --local core.hooksPath .githooks
```

If the files `liblibs.a` and `libsteensy4.a` do not exist in the core directory, follow these steps.
* Checkout the branch `lib-source`
* Run `make`
* Store the resulting library files `liblibs.a` and `libteensy4.a` to some tempory location outside of the repository
* Return to your old branch (or `main`)
* Copy those library files into the core directory
* Run `make lib_all`

## Usage

Expand Down Expand Up @@ -54,3 +50,6 @@ This repo follows the CU Robotics code standard:
- `patch` branches are named `patch-[patchname]` and contain bugfixes and/or minor adjustments. Unit and integration testing is a soft requirement.
- All software is required to pass formatting and build tests before being merged into a `production` branch.
- Other branch-based style questions are answered in the [style guide](docs/README.md).

## Licensing
This repository uses the MIT License, which covers the code and tools written for our robot firmware. See separate copyright/licensing information for the external libraries used in the repo (in the libaries/ and teensy4/ directories).
Loading
Loading