Skip to content

Commit cacca0f

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/Sabo-WIP
2 parents 9c253ce + a6affae commit cacca0f

File tree

16 files changed

+712
-20
lines changed

16 files changed

+712
-20
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ jobs:
4242
mkdir artifacts
4343
cp ./out/openmower-yardforce.bin ./artifacts
4444
cp ./out/openmower-yardforce.elf ./artifacts
45+
cp ./out/openmower-yardforce-v4.bin ./artifacts
46+
cp ./out/openmower-yardforce-v4.elf ./artifacts
4547
cp ./out/openmower-worx.bin ./artifacts
4648
cp ./out/openmower-worx.elf ./artifacts
4749
cp ./out/openmower-lyfco-e1600.bin ./artifacts
4850
cp ./out/openmower-lyfco-e1600.elf ./artifacts
4951
cp ./out/openmower-sabo.bin ./artifacts
5052
cp ./out/openmower-sabo.elf ./artifacts
53+
cp ./out/ram-info.html ./artifacts
54+
cp ./out/flash-info.html ./artifacts
5155
- name: Upload Artifacts
5256
uses: actions/upload-artifact@v4
5357
with:
@@ -64,9 +68,9 @@ jobs:
6468
name: openmower
6569
path: artifacts
6670
- name: Compress release directory into a versioned ZIP file
67-
run: zip -r "xcore-boot-${{ github.ref_name }}.zip" artifacts/*
71+
run: cd artifacts && zip -r "../fw-openmower-v2-${{ github.ref_name }}.zip" .
6872
- uses: "marvinpinto/action-automatic-releases@latest"
6973
with:
7074
repo_token: "${{ secrets.GITHUB_TOKEN }}"
7175
prerelease: false
72-
files: "xcore-boot-${{ github.ref_name }}.zip"
76+
files: "fw-openmower-v2-${{ github.ref_name }}.zip"

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
8181
src/drivers/motor/vesc/buffer.cpp
8282
src/drivers/motor/vesc/crc.cpp
8383
src/drivers/motor/vesc/VescDriver.cpp
84+
# YFR4-ESC driver
85+
src/drivers/motor/yfr4esc/YFR4escDriver.cpp
8486
# PWM motor driver
8587
src/drivers/motor/pwm/pwm_motor_driver.cpp
8688
# GPS driver
@@ -155,3 +157,16 @@ add_custom_target(upload
155157
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
156158
DEPENDS ${CMAKE_PROJECT_NAME}
157159
)
160+
161+
# Check if elf-size-analyze is available
162+
find_program(ELF_SIZE_ANALYZE_EXECUTABLE elf-size-analyze)
163+
164+
if(ELF_SIZE_ANALYZE_EXECUTABLE)
165+
add_custom_command(
166+
TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
167+
COMMAND ${ELF_SIZE_ANALYZE_EXECUTABLE} -R -t arm-none-eabi- ${CMAKE_PROJECT_NAME}.elf
168+
COMMENT "Running elf-size-analyze on target binary..."
169+
)
170+
else()
171+
message(WARNING "elf-size-analyze not found! Skipping size analysis.")
172+
endif()

Dockerfile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,40 @@ RUN apt-get update && apt-get install -y \
99
make \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
# Install ccache (TODO: REMOVE as soon as we have universal firmware)
13+
RUN apt-get update && apt-get install -y ccache \
14+
&& rm -rf /var/lib/apt/lists/* \
15+
&& /usr/sbin/update-ccache-symlinks
16+
ENV PATH="/usr/lib/ccache:$PATH"
17+
18+
RUN pip install elf-size-analyze
19+
1220
COPY . /project
1321

1422
WORKDIR /project
1523
RUN mkdir build
1624
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=YardForce -BYardForce && cd YardForce && make -j$(nproc)
25+
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=YardForce_V4 -BYardForce_V4 && cd YardForce_V4 && make -j$(nproc)
1726
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=Worx -BWorx && cd Worx && make -j$(nproc)
1827
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=Lyfco_E1600 -BLyfco_E1600 && cd Lyfco_E1600 && make -j$(nproc)
1928
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=Sabo -BSabo && cd Sabo && make -j$(nproc)
2029
RUN cd build && cmake .. --preset=Release -DROBOT_PLATFORM=xBot -BxBot && cd xBot && make -j$(nproc)
21-
30+
# Use Sabo build for RAM and ROM analysis for now - it has the most libraries
31+
RUN elf-size-analyze -H -R -t arm-none-eabi- ./build/Sabo/openmower.elf -W > build/ram-info.html
32+
RUN elf-size-analyze -H -F -t arm-none-eabi- ./build/Sabo/openmower.elf -W > build/flash-info.html
33+
RUN ccache -s > build/ccache.txt
2234

2335
FROM scratch
36+
COPY --from=builder /project/build/ccache.txt /ccache.txt
37+
COPY --from=builder /project/build/ram-info.html /ram-info.html
38+
COPY --from=builder /project/build/flash-info.html /flash-info.html
39+
2440
COPY --from=builder /project/build/YardForce/openmower.bin /openmower-yardforce.bin
2541
COPY --from=builder /project/build/YardForce/openmower.elf /openmower-yardforce.elf
2642

43+
COPY --from=builder /project/build/YardForce_V4/openmower.bin /openmower-yardforce-v4.bin
44+
COPY --from=builder /project/build/YardForce_V4/openmower.elf /openmower-yardforce-v4.elf
45+
2746
COPY --from=builder /project/build/Worx/openmower.bin /openmower-worx.bin
2847
COPY --from=builder /project/build/Worx/openmower.elf /openmower-worx.elf
2948

ext/ChibiOS_21.11.3/os/hal/ports/STM32/LLD/USARTv3/hal_uart_lld.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,10 @@ void uart_lld_serve_interrupt(UARTDriver *uartp) {
12171217
isr = u->ISR;
12181218
u->ICR = isr;
12191219

1220+
if (isr & USART_ISR_CMF) {
1221+
_uart_rx_char_match_isr_code(uartp);
1222+
}
1223+
12201224
if (isr & (USART_ISR_LBDF | USART_ISR_ORE | USART_ISR_NE |
12211225
USART_ISR_FE | USART_ISR_PE)) {
12221226
_uart_rx_error_isr_code(uartp, translate_errors(isr));

ext/ChibiOS_21.11.3/os/hal/ports/STM32/LLD/USARTv3/hal_uart_lld.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,10 @@ typedef struct hal_uart_config {
894894
* flags in CR registers and supported hardware features.
895895
*/
896896
uartcb_t timeout_cb;
897+
/**
898+
* @brief Character Received callback.
899+
*/
900+
uartcb_t rx_cm_cb;
897901
/**
898902
* @brief Receiver timeout value in terms of number of bit duration.
899903
* @details Set it to 0 when you want to handle idle interrupt instead of

robots/CMakeLists.txt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,8 @@ else()
66
message("Selected Robot Platform: ${ROBOT_PLATFORM}")
77
endif ()
88

9-
string(TOLOWER "${ROBOT_PLATFORM}" ROBOT_PLATFORM_LOWER)
9+
# find the platform sources and add them
10+
file(GLOB_RECURSE PLATFORM_SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*")
1011

11-
# Common Robot sources
12-
file(GLOB ROBOT_COMMON_SOURCES
13-
"${CMAKE_CURRENT_LIST_DIR}/src/robot.cpp"
14-
)
15-
16-
# Robot specific sources
17-
file(GLOB ROBOT_PLATFORM_SOURCES
18-
"${CMAKE_CURRENT_LIST_DIR}/src/${ROBOT_PLATFORM_LOWER}_*.cpp"
19-
)
20-
21-
# Zusammenführen und nach oben geben
22-
set(PLATFORM_SOURCES
23-
${ROBOT_COMMON_SOURCES}
24-
${ROBOT_PLATFORM_SOURCES}
25-
)
12+
# Expose a preprocessor guard like ROBOT_PLATFORM_YardForce_V4=1 for #ifdef use
13+
add_compile_definitions(ROBOT_PLATFORM_${ROBOT_PLATFORM}=1)

robots/include/robot.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define ROBOT_HPP
33

44
#include <drivers/motor/vesc/VescDriver.h>
5+
#include <drivers/motor/yfr4esc/YFR4escDriver.h>
56
#include <hal.h>
67

78
#include <debug/debug_tcp_interface.hpp>
@@ -48,7 +49,14 @@ class MowerRobot : public Robot {
4849

4950
xbot::driver::motor::VescDriver left_motor_driver_{};
5051
xbot::driver::motor::VescDriver right_motor_driver_{};
51-
xbot::driver::motor::VescDriver mower_motor_driver_{};
52+
53+
// Select mower motor ESC by platform: YFR4 on YardForce_V4, VESC otherwise
54+
#if defined(ROBOT_PLATFORM_YardForce_V4)
55+
using MowerEscDriver = xbot::driver::motor::YFR4escDriver;
56+
#else
57+
using MowerEscDriver = xbot::driver::motor::VescDriver;
58+
#endif
59+
MowerEscDriver mower_motor_driver_{};
5260

5361
DebugTCPInterface left_esc_driver_interface_{65102, &left_motor_driver_};
5462
DebugTCPInterface mower_esc_driver_interface_{65103, &mower_motor_driver_};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef YARDFORCE_V4_ROBOT_HPP
2+
#define YARDFORCE_V4_ROBOT_HPP
3+
4+
#include <drivers/charger/bq_2576/bq_2576.hpp>
5+
6+
#include "robot.hpp"
7+
8+
class YardForce_V4Robot : public MowerRobot {
9+
public:
10+
void InitPlatform() override;
11+
bool IsHardwareSupported() override;
12+
13+
UARTDriver* GPS_GetUartPort() override {
14+
#ifndef STM32_UART_USE_USART6
15+
#error STM32_SERIAL_USE_UART6 must be enabled for the YardForce build to work
16+
#endif
17+
return &UARTD6;
18+
}
19+
20+
float Power_GetDefaultBatteryFullVoltage() override {
21+
return 7.0f * 4.2f;
22+
}
23+
24+
float Power_GetDefaultBatteryEmptyVoltage() override {
25+
return 7.0f * 3.3f;
26+
}
27+
28+
float Power_GetDefaultChargeCurrent() override {
29+
return 0.5;
30+
}
31+
32+
float Power_GetAbsoluteMinVoltage() override {
33+
// 3.3V min, 7s pack
34+
return 7.0f * 3.0;
35+
}
36+
37+
private:
38+
BQ2576 charger_{};
39+
};
40+
41+
#endif // YARDFORCE_V4_ROBOT_HPP

robots/src/robot.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "../include/worx_robot.hpp"
88
#include "../include/xbot_robot.hpp"
99
#include "../include/yardforce_robot.hpp"
10+
#include "../include/yardforce_v4_robot.hpp"
1011

1112
#define EXPAND(x) x
1213
#define ROBOT_CLASS_NAME(platform) platform##Robot

robots/src/yardforce_v4_robot.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "../include/yardforce_v4_robot.hpp"
2+
3+
#include <services.hpp>
4+
5+
void YardForce_V4Robot::InitPlatform() {
6+
// Initialize default motors (VESC for left/right + mower)
7+
InitMotors();
8+
charger_.setI2C(&I2CD1);
9+
power_service.SetDriver(&charger_);
10+
}
11+
12+
bool YardForce_V4Robot::IsHardwareSupported() {
13+
// Accept YardForce 1.x.x boards
14+
if (strncmp("hw-openmower-yardforce", carrier_board_info.board_id, sizeof(carrier_board_info.board_id)) == 0 &&
15+
carrier_board_info.version_major == 1) {
16+
return true;
17+
}
18+
19+
// Accept early testing boards
20+
if (strncmp("hw-xbot-devkit", carrier_board_info.board_id, sizeof(carrier_board_info.board_id)) == 0) {
21+
return true;
22+
}
23+
24+
return false;
25+
}

0 commit comments

Comments
 (0)