Skip to content

Commit

Permalink
WIP CMakeLists for utils, platform, rtos
Browse files Browse the repository at this point in the history
Main work by @nicka101.

Also, by @shymega:

- Add another `target_link_libraries` to util_sha256
    This links to CMSIS and HAL libs.
- Fixup Dockerfile for GCC ARM download, and tidy
- Had to run `dos2unix` on some files.
- Remove `*.cmake` from .gitignore
  This allows us to keep future CMake modules, for example, Corrosion.
- Update devcontainer.json name
- Move `.devcontainer/devcontainer.json` to root of repo

Signed-off-by: Dom Rodriguez <[email protected]>
  • Loading branch information
nicka101 authored and shymega committed Jul 24, 2024
1 parent e649274 commit 61505fb
Show file tree
Hide file tree
Showing 39 changed files with 355 additions and 63 deletions.
16 changes: 10 additions & 6 deletions .devcontainer/devcontainer.json → .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{
"name": "Open PineBuds Pro - VS Code Development Environment",
"name": "OpenPineBuds - Dev Environment",
"build": {
"dockerfile": "../Dockerfile",
"context": ".."
},
"extensions": [
"ms-vscode.cmake-tools",
"ms-vscode.cpptools"
],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cmake-tools",
"ms-vscode.cpptools"
]
}
},
"runArgs": [
"--privileged"
],
"userEnvProbe": "loginInteractiveShell",
"remoteUser": "root"
}
}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
!.gitattributes
!.mailmap
!.github
!.devcontainer
!.devcontainer.json

# Backup files
*~
Expand Down Expand Up @@ -102,3 +102,8 @@ Release/
# *.ini
log.txt
log.txt

#CMake
/build/
CMakeCache.txt
/CMakeFiles/
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required (VERSION 3.12)
project (OpenPineBuds C CXX)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
project (OpenPineBuds C CXX ASM)

option (OPB_BLUE_CONN_LIGHT "Enable the blue connection light" OFF) # Use BLE to control this.

Expand Down
105 changes: 52 additions & 53 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
FROM debian:bullseye-slim AS base

FROM base AS rust_build

LABEL org.opencontainers.image.authors = "Ben V. Brown <[email protected]>, Dom Rodriguez <[email protected]>"

WORKDIR /usr/src
ENV PATH="/root/.cargo/bin:$PATH"

RUN apt-get update \
&& apt-get install -y \
bc \
build-essential \
curl \
git \
libudev-dev \
pkg-config \
&& curl https://sh.rustup.rs -sSf | bash -s -- -y \
&& git clone https://github.com/Ralim/bestool.git \
&& cd /usr/src/bestool/bestool/ \
&& cargo build --release

FROM base as dev_env

WORKDIR /usr/src

RUN apt-get update \
&& apt-get install -y \
bash \
bc \
bzip2 \
curl \
ffmpeg \
clang-format \
git \
make \
tar \
xxd \
&& git config --global --add safe.directory /src \
&& mkdir -pv /src \
&& curl \
https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-$(arch)-linux.tar.bz2 | tar -xj -C /src/

RUN apt-get update \
&& apt-get install -y \
minicom \
sudo

ENV PATH="${PATH}:/src/gcc-arm-none-eabi-9-2019-q4-major/bin"
COPY --from=rust_build /usr/src/bestool/bestool/target/release/bestool /usr/local/bin/bestool
COPY . /usr/src

ENTRYPOINT ["/bin/bash"]
FROM debian:bullseye-slim AS base

FROM base AS rust_build

LABEL org.opencontainers.image.authors = "Ben V. Brown <[email protected]>, Dom Rodriguez <[email protected]>"

WORKDIR /usr/src
ENV PATH="/root/.cargo/bin:$PATH"

RUN apt-get update \
&& apt-get install -y \
bc \
build-essential \
curl \
git \
libudev-dev \
pkg-config \
&& curl https://sh.rustup.rs -sSf | bash -s -- -y \
&& git clone https://github.com/Ralim/bestool.git \
&& cd /usr/src/bestool/bestool/ \
&& cargo build --release

FROM base as dev_env

WORKDIR /usr/src

RUN apt-get update \
&& apt-get install -y \
bash \
bc \
bzip2 \
clang-format \
cmake \
curl \
ffmpeg \
git \
make \
minicom \
sudo \
tar \
xxd \
&& git config --global --add safe.directory /usr/src \
&& mkdir -pv /usr/local/toolchains \
&& curl \
https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-$(arch)-linux.tar.bz2 \
| tar -xj -C /usr/local/toolchains

ENV PATH="${PATH}:/usr/local/toolchains/gcc-arm-none-eabi-9-2019-q4-major/bin"
COPY --from=rust_build /usr/src/bestool/bestool/target/release/bestool /usr/local/bin/bestool
COPY . /usr/src

ENTRYPOINT ["/bin/bash"]
11 changes: 10 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
add_subdirectory (apps)
set(CHIP best2300p)
set(CHIP_BEST2300P 1)
set(CHIP_ID_LITERAL best2300p)

add_compile_definitions(CHIP=${CHIP} CHIP_BEST2300P=${CHIP_BEST2300P} CHIP_ID_LITERAL=${CHIP_ID_LITERAL})

add_subdirectory(apps)
add_subdirectory(utils)
add_subdirectory(platform)
add_subdirectory(rtos)

include_directories (include)
1 change: 1 addition & 0 deletions src/apps/apptester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (apps_apptester STATIC ${sources} ${headers})
target_link_libraries(apps_apptester apps_common)
1 change: 1 addition & 0 deletions src/apps/audioplayers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (apps_audioplayers STATIC ${sources} ${headers})
target_link_libraries(apps_audioplayers util_list)
3 changes: 2 additions & 1 deletion src/apps/audioplayers/a2dp_decoder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (apps_audiplayers_a2dpdecoder STATIC ${sources} ${headers})
add_library (apps_audioplayers_a2dpdecoder STATIC ${sources} ${headers})
target_link_libraries(apps_audioplayers_a2dpdecoder util_list)
1 change: 1 addition & 0 deletions src/apps/battery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ file (GLOB headers "*.h")
file (GLOB sources "*.cpp")

add_library (apps_battery STATIC ${sources} ${headers})
target_link_libraries(apps_battery apps_main)
8 changes: 8 additions & 0 deletions src/apps/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (apps_common STATIC ${sources} ${headers})
target_link_libraries(apps_common platform_hal platform_drivers_ana)
target_include_directories(apps_common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(apps_common PRIVATE
${CMAKE_SOURCE_DIR}/services/ibrt_ui/inc/
${CMAKE_SOURCE_DIR}/services/ibrt_core/inc/
${CMAKE_SOURCE_DIR}/services/bt_app/
${CMAKE_SOURCE_DIR}/services/app_ai/inc/
)
1 change: 1 addition & 0 deletions src/apps/key/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ file (GLOB headers "*.h")
file (GLOB sources "*.cpp")

add_library (apps_key STATIC ${sources} ${headers})
target_link_libraries(apps_key platform_hal)
1 change: 1 addition & 0 deletions src/apps/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (apps_main STATIC ${sources} ${headers})
target_link_libraries(apps_main platform_hal)
4 changes: 4 additions & 0 deletions src/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_subdirectory(cmsis)
add_subdirectory(drivers)
add_subdirectory(hal)
#add_subdirectory(main)
16 changes: 16 additions & 0 deletions src/platform/cmsis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
file (GLOB headers "inc/*.h" "inc/ca/*.h" "*.h")
file (GLOB sources "ca/*.c" "ca/*.S" "*.c*")

add_compile_definitions(USAGE_FAULT=1 BUS_FAULT=1 MEM_FAULT=1)

if(DSP_LIB)
add_subdirectory(DSP_Lib)
endif(DSP_LIB)

add_library (platform_cmsis STATIC ${sources} ${headers})
set_property(TARGET platform_cmsis APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")
target_link_libraries(platform_cmsis platform_drivers_ana platform_drivers_codec platform_drivers_norflash)
target_include_directories(platform_cmsis PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/inc/ca/
${CMAKE_CURRENT_SOURCE_DIR}/inc/
)
5 changes: 5 additions & 0 deletions src/platform/drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_subdirectory(ana)
add_subdirectory(bt)
add_subdirectory(btpcm)
add_subdirectory(codec)
add_subdirectory(norflash)
6 changes: 6 additions & 0 deletions src/platform/drivers/ana/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file (GLOB headers "*.h" "${CHIP}/*.h")
file (GLOB sources "*.c*" "${CHIP}/*.c")

add_library (platform_drivers_ana STATIC ${sources} ${headers})
target_link_libraries(platform_drivers_ana platform_hal)
target_include_directories(platform_drivers_ana PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${CHIP})
9 changes: 9 additions & 0 deletions src/platform/drivers/bt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
file (GLOB headers "*.h" "${CHIP}/*.h")
file (GLOB sources "*.c*" "${CHIP}/*.c")

add_library (platform_drivers_bt STATIC ${sources} ${headers})
target_link_libraries(platform_drivers_bt apps_common platform_drivers_ana utils_cqueue util_heap)
target_include_directories(platform_drivers_bt PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${CHIP})
target_include_directories(platform_drivers_bt PRIVATE
${CMAKE_SOURCE_DIR}/services/nvrecord
)
6 changes: 6 additions & 0 deletions src/platform/drivers/btpcm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (platform_drivers_btpcm STATIC ${sources} ${headers})
target_include_directories(platform_drivers_btpcm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(platform_drivers_btpcm rtos)
6 changes: 6 additions & 0 deletions src/platform/drivers/codec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file (GLOB headers "*.h" "${CHIP}/*.h")
file (GLOB sources "*.c*" "${CHIP}/*.c")

add_library (platform_drivers_codec STATIC ${sources} ${headers})
target_link_libraries(platform_drivers_codec platform_drivers_ana)
target_include_directories(platform_drivers_codec PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${CHIP})
10 changes: 10 additions & 0 deletions src/platform/drivers/norflash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (platform_drivers_norflash STATIC ${sources} ${headers})
target_link_libraries(platform_drivers_norflash util_boot_struct)
target_include_directories(platform_drivers_norflash PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(platform_drivers_norflash PRIVATE
${CMAKE_SOURCE_DIR}/services/nvrecord
${CMAKE_SOURCE_DIR}/tests/programmer/inc
)
10 changes: 10 additions & 0 deletions src/platform/hal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (platform_hal STATIC ${sources} ${headers})
target_link_libraries(platform_hal platform_drivers_ana platform_cmsis util_crash_catcher platform_drivers_norflash util_boot_struct)
target_include_directories(platform_hal PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(platform_hal PRIVATE
${CMAKE_SOURCE_DIR}/platform/drivers/spi_norflash/
${CMAKE_SOURCE_DIR}/tests/programmer/inc/
)
26 changes: 26 additions & 0 deletions src/rtos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

set(KERNEL "rtx")

if(KERNEL STREQUAL "rtx5") #RTX5
file (GLOB headers "rtx5/*.h" "rtx_config/*.h")
file (GLOB sources "rtx5/*.c*" "rtx_config/*.c*")
else() #RTX
file (GLOB headers "rtx/TARGET_CORTEX_M/*.h")
file (GLOB sources "rtx/TARGET_CORTEX_M/*.c*" "rtx/TARGET_CORTEX_M/TARGET_M4/TOOLCHAIN_GCC/*.S")
endif()

add_library (rtos STATIC ${sources} ${headers})
target_link_libraries(rtos platform_cmsis platform_hal util_hwtimer_list)

if(KERNEL STREQUAL "rtx5") #RTX5
target_include_directories(rtos PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/rtx5/
${CMAKE_CURRENT_SOURCE_DIR}/rtx5/rtx_config/
)
else() #RTX
set_property(TARGET rtos APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")
target_include_directories(rtos PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/rtx/TARGET_CORTEX_M/
)
endif()

19 changes: 19 additions & 0 deletions src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_subdirectory(boot_struct)
#add_subdirectory(build_info)
add_subdirectory(cqueue)
add_subdirectory(crash_catcher)
add_subdirectory(crc16)
add_subdirectory(crc32)
add_subdirectory(encrypt)
add_subdirectory(heap)
add_subdirectory(hexdump)
add_subdirectory(hwtimer_list)
add_subdirectory(intersyshci)
add_subdirectory(kfifo)
#add_subdirectory(libc)
add_subdirectory(list)
add_subdirectory(lockcqueue)
add_subdirectory(retention_ram)
#add_subdirectory(rom_utils)
#add_subdirectory(sha256)
add_subdirectory(xyzmodem)
6 changes: 6 additions & 0 deletions src/utils/boot_struct/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (util_boot_struct STATIC ${sources} ${headers})
target_link_libraries(util_boot_struct platform_hal)
target_include_directories(util_boot_struct PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
6 changes: 6 additions & 0 deletions src/utils/cqueue/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file (GLOB headers "*.h")
file (GLOB sources "*.c*")

add_library (util_cqueue STATIC ${sources} ${headers})
target_link_libraries(util_cqueue platform_cmsis)
target_include_directories(util_cqueue PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
12 changes: 12 additions & 0 deletions src/utils/crash_catcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
file (GLOB headers "*.h" "include/*.h")
file (GLOB sources "*.c*")

set_property(SOURCE CrashCatcher_armv7m.S APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")
add_library (util_crash_catcher STATIC ${sources} ${headers} CrashCatcher_armv7m.S)
target_link_libraries(util_crash_catcher platform_cmsis utils_xyzmodem)
target_include_directories(util_crash_catcher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
target_include_directories(util_crash_catcher PRIVATE
${CMAKE_SOURCE_DIR}/utils/libc/inc
${CMAKE_SOURCE_DIR}/services/nv_section/log_section/
${CMAKE_SOURCE_DIR}/rtos/rtx/TARGET_CORTEX_M/
)
2 changes: 2 additions & 0 deletions src/utils/crc16/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_library(util_crc16 STATIC "crc16.c" "crc16.h")
target_include_directories(util_crc16 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
Loading

0 comments on commit 61505fb

Please sign in to comment.