Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
cmake make \
gdb-multiarch && \
ln -s /usr/bin/nm /usr/bin/nm-multiarch && \
ln -s /usr/bin/objdump /usr/bin/objdump-multiarch
ln -s /usr/bin/objdump /usr/bin/objdump-multiarch && \
echo 'source /usr/share/bash-completion/completions/git' >> /home/dev/.bashrc

USER $USERNAME
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"vscode": {
"extensions": [
"ms-vscode.cpptools-extension-pack",
"marus25.cortex-debug",
"marus25.cortex-debug"
]
}
}
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ jobs:
mkdir artifacts
cp ./out/openmower-yardforce.bin ./artifacts
cp ./out/openmower-yardforce.elf ./artifacts
cp ./out/openmower-yardforce-v4.bin ./artifacts
cp ./out/openmower-yardforce-v4.elf ./artifacts
cp ./out/openmower-worx.bin ./artifacts
cp ./out/openmower-worx.elf ./artifacts
cp ./out/openmower-lyfco-e1600.bin ./artifacts
cp ./out/openmower-lyfco-e1600.elf ./artifacts
cp ./out/openmower-sabo.bin ./artifacts
cp ./out/openmower-sabo.elf ./artifacts
cp ./out/ram-info.html ./artifacts
cp ./out/flash-info.html ./artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -64,9 +68,9 @@ jobs:
name: openmower
path: artifacts
- name: Compress release directory into a versioned ZIP file
run: zip -r "xcore-boot-${{ github.ref_name }}.zip" artifacts/*
run: cd artifacts && zip -r "../fw-openmower-v2-${{ github.ref_name }}.zip" .
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: "xcore-boot-${{ github.ref_name }}.zip"
files: "fw-openmower-v2-${{ github.ref_name }}.zip"
31 changes: 30 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES

target_compile_options(${CMAKE_PROJECT_NAME} PUBLIC -Wall -Wextra -Werror)


# Add lib subdirectory
add_subdirectory(ext)
target_compile_definitions(ulog PUBLIC ULOG_ENABLED)
Expand All @@ -47,6 +46,12 @@ target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined library search paths
)

# Add LVGL assets
file(GLOB LVGL_ASSETS_SRC
"src/drivers/ui/lvgl/assets/*.c"
"src/drivers/ui/lvgl/assets/Orbitron/*.c"
)

# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
boards/XCORE/board_utils.cpp
Expand Down Expand Up @@ -77,6 +82,8 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
src/drivers/motor/vesc/buffer.cpp
src/drivers/motor/vesc/crc.cpp
src/drivers/motor/vesc/VescDriver.cpp
# YFR4-ESC driver
src/drivers/motor/yfr4esc/YFR4escDriver.cpp
# PWM motor driver
src/drivers/motor/pwm/pwm_motor_driver.cpp
# GPS driver
Expand All @@ -88,13 +95,21 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
src/drivers/input/input_driver.cpp
src/drivers/input/gpio_input_driver.cpp
src/drivers/input/worx_input_driver.cpp
src/drivers/input/yardforce_input_driver.cpp
$<$<CONFIG:Debug>:src/drivers/input/simulated_input_driver.cpp>
# YardForce Cover UI Driver
src/drivers/ui/YardForceCoverUI/yardforce_cover_ui_driver.cpp
# Sabo driver
src/drivers/ui/SaboCoverUI/sabo_cover_ui_cabo_driver_base.cpp
src/drivers/ui/SaboCoverUI/sabo_cover_ui_controller.cpp
src/drivers/ui/SaboCoverUI/sabo_cover_ui_display_driver_uc1698.cpp
# Raw driver debug interface
src/debug/debug_tcp_interface.cpp
src/debug/debug_udp_interface.cpp
src/debug/debuggable_driver.cpp
robots/src/robot.cpp
${PLATFORM_SOURCES}
${LVGL_ASSETS_SRC}
)

# Add include paths
Expand All @@ -121,6 +136,7 @@ target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
etl::etl
LittleFS
lwjson
lvgl
)

target_add_service(${CMAKE_PROJECT_NAME} ImuService ${CMAKE_CURRENT_SOURCE_DIR}/services/imu_service.json)
Expand All @@ -146,3 +162,16 @@ add_custom_target(upload
COMMAND docker run --rm --network=host -v ${CMAKE_BINARY_DIR}:/workdir ghcr.io/xtech/fw-xcore-boot:latest -i tap0 upload /workdir/${CMAKE_PROJECT_NAME}.bin
DEPENDS ${CMAKE_PROJECT_NAME}
)

# Check if elf-size-analyze is available
find_program(ELF_SIZE_ANALYZE_EXECUTABLE elf-size-analyze)

if(ELF_SIZE_ANALYZE_EXECUTABLE)
add_custom_command(
TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${ELF_SIZE_ANALYZE_EXECUTABLE} -R -t arm-none-eabi- ${CMAKE_PROJECT_NAME}.elf
COMMENT "Running elf-size-analyze on target binary..."
)
else()
message(WARNING "elf-size-analyze not found! Skipping size analysis.")
endif()
21 changes: 20 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,40 @@ RUN apt-get update && apt-get install -y \
make \
&& rm -rf /var/lib/apt/lists/*

# Install ccache (TODO: REMOVE as soon as we have universal firmware)
RUN apt-get update && apt-get install -y ccache \
&& rm -rf /var/lib/apt/lists/* \
&& /usr/sbin/update-ccache-symlinks
ENV PATH="/usr/lib/ccache:$PATH"

RUN pip install elf-size-analyze

COPY . /project

WORKDIR /project
RUN mkdir build
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=YardForce -BYardForce && cd YardForce && make -j$(nproc)
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=YardForce_V4 -BYardForce_V4 && cd YardForce_V4 && make -j$(nproc)
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=Worx -BWorx && cd Worx && make -j$(nproc)
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=Lyfco_E1600 -BLyfco_E1600 && cd Lyfco_E1600 && make -j$(nproc)
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=Sabo -BSabo && cd Sabo && make -j$(nproc)
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=xBot -BxBot && cd xBot && make -j$(nproc)

# Use Sabo build for RAM and ROM analysis for now - it has the most libraries
RUN elf-size-analyze -H -R -t arm-none-eabi- ./build/Sabo/openmower.elf -W > build/ram-info.html
RUN elf-size-analyze -H -F -t arm-none-eabi- ./build/Sabo/openmower.elf -W > build/flash-info.html
RUN ccache -s > build/ccache.txt

FROM scratch
COPY --from=builder /project/build/ccache.txt /ccache.txt
COPY --from=builder /project/build/ram-info.html /ram-info.html
COPY --from=builder /project/build/flash-info.html /flash-info.html

COPY --from=builder /project/build/YardForce/openmower.bin /openmower-yardforce.bin
COPY --from=builder /project/build/YardForce/openmower.elf /openmower-yardforce.elf

COPY --from=builder /project/build/YardForce_V4/openmower.bin /openmower-yardforce-v4.bin
COPY --from=builder /project/build/YardForce_V4/openmower.elf /openmower-yardforce-v4.elf

COPY --from=builder /project/build/Worx/openmower.bin /openmower-worx.bin
COPY --from=builder /project/build/Worx/openmower.elf /openmower-worx.elf

Expand Down
29 changes: 4 additions & 25 deletions boards/XCORE/board_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "board_utils.hpp"

#include <etl/crc16_genibus.h>
#include <crc_lookup_map.hpp>

#pragma pack(push, 1)
struct LineParams {
Expand All @@ -10,10 +10,6 @@ struct LineParams {
};
#pragma pack(pop)

constexpr uint16_t crc16(const char* str) {
return etl::crc16_genibus(str, str + strlen(str)).value();
}

constexpr uint32_t ports[] = {GPIOA_BASE, GPIOB_BASE, GPIOC_BASE, GPIOD_BASE,
GPIOE_BASE, GPIOF_BASE, GPIOG_BASE, GPIOH_BASE};

Expand Down Expand Up @@ -123,28 +119,11 @@ constexpr LineParams lines[] = {
{crc16("OSC_OUT"), port_idx('H'), 1},
};

static_assert(
[] {
constexpr size_t count = sizeof(lines) / sizeof(LineParams);
for (size_t i = 0; i < count; i++) {
for (size_t j = i + 1; j < count; j++) {
if (lines[i].crc == lines[j].crc) {
return false;
}
}
}
return true;
}(),
"CRC16 values are not unique");
static_assert(HasUniqueCrcs(lines), "CRC16 values are not unique");

ioline_t GetIoLineByName(const char* name) {
uint16_t crc = crc16(name);
for (const auto& line : lines) {
if (line.crc == crc) {
return PAL_LINE(ports[line.port], line.pad);
}
}
return PAL_NOLINE;
auto* line = LookupByName(name, lines);
return line != nullptr ? PAL_LINE(ports[line->port], line->pad) : PAL_NOLINE;
}

UARTDriver* GetUARTDriverByIndex(uint8_t index) {
Expand Down
5 changes: 5 additions & 0 deletions ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ target_compile_definitions(xbot-service PUBLIC XBOT_ENABLE_STATIC_STACK)
add_subdirectory(LSM6DS3TR-C-PID)
add_subdirectory(etl)

set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CONFIG_LV_BUILD_EXAMPLES OFF)
set(CONFIG_LV_BUILD_DEMOS OFF)
set(CONFIG_LV_USE_THORVG_INTERNAL OFF)
add_subdirectory(lvgl)

# Add LittleFS
add_library(LittleFS littlefs/lfs.c littlefs/lfs_util.c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,10 @@ void uart_lld_serve_interrupt(UARTDriver *uartp) {
isr = u->ISR;
u->ICR = isr;

if (isr & USART_ISR_CMF) {
_uart_rx_char_match_isr_code(uartp);
}

if (isr & (USART_ISR_LBDF | USART_ISR_ORE | USART_ISR_NE |
USART_ISR_FE | USART_ISR_PE)) {
_uart_rx_error_isr_code(uartp, translate_errors(isr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,10 @@ typedef struct hal_uart_config {
* flags in CR registers and supported hardware features.
*/
uartcb_t timeout_cb;
/**
* @brief Character Received callback.
*/
uartcb_t rx_cm_cb;
/**
* @brief Receiver timeout value in terms of number of bit duration.
* @details Set it to 0 when you want to handle idle interrupt instead of
Expand Down
9 changes: 9 additions & 0 deletions ext/lvgl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Include(FetchContent)

FetchContent_Declare(
lvgl
GIT_REPOSITORY https://github.com/lvgl/lvgl
GIT_TAG v9.3.0
)

FetchContent_MakeAvailable(lvgl)
2 changes: 1 addition & 1 deletion ext/xbot_framework
Loading
Loading