Skip to content
Merged
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
76 changes: 70 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1037,27 +1037,37 @@ jobs:
- name: Configure (ARM cross, NET=LWIP)
run: cmake --preset freertos-cross-lwip

- name: Cross-build FreeRTOS+lwIP link-probe ELF
- name: Cross-build FreeRTOS+lwIP BDD target ELF
run: cmake --build --preset freertos-cross-lwip --target SolidSyslogBddTargetLwip

- name: Assert no PlusTcp / Plus-TCP symbols linked
run: |
elf=build/freertos-cross-lwip/Bdd/Targets/FreeRtosLwip/SolidSyslogBddTargetLwip.elf
arm-none-eabi-nm "$elf" > /tmp/lwip-probe-symbols.txt
if grep -E -i 'PlusTcp|FreeRTOS_socket|FreeRTOS_sendto|FreeRTOS_recv|FreeRTOS_IPInit' /tmp/lwip-probe-symbols.txt; then
echo "::error::PlusTcp / FreeRTOS-Plus-TCP symbol linked into the lwIP probe ELF"
arm-none-eabi-nm "$elf" > /tmp/lwip-symbols.txt
if grep -E -i 'PlusTcp|FreeRTOS_socket|FreeRTOS_sendto|FreeRTOS_recv|FreeRTOS_IPInit' /tmp/lwip-symbols.txt; then
echo "::error::PlusTcp / FreeRTOS-Plus-TCP symbol linked into the lwIP BDD target ELF"
exit 1
fi
echo "OK: no PlusTcp / FreeRTOS-Plus-TCP symbols in the lwIP probe ELF"
echo "OK: no PlusTcp / FreeRTOS-Plus-TCP symbols in the lwIP BDD target ELF"

- name: Upload FreeRTOS+lwIP link-probe ELF
- name: Upload FreeRTOS+lwIP BDD target ELF
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: solid-syslog-bdd-target-freertos-lwip
path: build/freertos-cross-lwip/Bdd/Targets/FreeRtosLwip/SolidSyslogBddTargetLwip.elf
retention-days: 1
compression-level: 0

# BDD-side mirror of build-time tunables (configure_file). The lwIP bdd
# lane consumes this so environment.py's runtime tag gates track the lwIP
# target's SOLIDSYSLOG_MAX_MESSAGE_SIZE (512, same as +TCP).
- name: Upload BDD Python tunables (FreeRTOS+lwIP)
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: bdd-tunables-freertos-lwip
path: Bdd/features/steps/solidsyslog_tunables.py
retention-days: 1

bdd-freertos-qemu-plustcp:
needs: build-freertos-target-plustcp
runs-on: ubuntu-latest
Expand Down Expand Up @@ -1110,6 +1120,60 @@ jobs:
if: failure()
run: docker compose -f ci/docker-compose.bdd.yml logs --no-color

# Advisory (S28.09): not in summary.needs, so a failure does not block
# merges while the lwIP netif beds in. S28.11 promotes it to required.
bdd-freertos-qemu-lwip:
needs: build-freertos-target-lwip
runs-on: ubuntu-latest
permissions:
contents: read
checks: write

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: solid-syslog-bdd-target-freertos-lwip
path: build/freertos-cross-lwip/Bdd/Targets/FreeRtosLwip/

- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: bdd-tunables-freertos-lwip
path: Bdd/features/steps/

- name: Make ELF readable
run: chmod +r build/freertos-cross-lwip/Bdd/Targets/FreeRtosLwip/SolidSyslogBddTargetLwip.elf

- name: Prepare BDD output directory
run: mkdir -p Bdd/junit && chmod 777 Bdd/junit

- name: Run BDD tests
run: >
docker compose -f ci/docker-compose.bdd.yml
up --abort-on-container-exit --exit-code-from behave-freertos-lwip
behave-freertos-lwip syslog-ng-freertos-lwip

- name: BDD Test Report (FreeRTOS+lwIP)
uses: dorny/test-reporter@v3
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if: success() || failure()
with:
name: Test Results (BDD FreeRTOS+lwIP)
path: Bdd/junit/TESTS-*.xml
reporter: java-junit

- name: Upload JUnit XML
if: success() || failure()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: junit-bdd-freertos-qemu-lwip
path: Bdd/junit/TESTS-*.xml
retention-days: 1

- name: Compose logs on failure
if: failure()
run: docker compose -f ci/docker-compose.bdd.yml logs --no-color

summary:
if: always() && github.event_name == 'pull_request'
needs: [build-linux-gcc, build-linux-tunable-override, build-linux-clang, sanitize-linux-gcc, coverage-linux-gcc, analyze-tidy, analyze-tidy-freertos-plustcp, analyze-cppcheck, analyze-format, analyze-iwyu, analyze-iwyu-freertos-plustcp, bdd-linux-syslog-ng, build-windows-msvc, bdd-windows-otel, integration-linux-openssl, integration-linux-mbedtls, integration-windows-openssl, build-freertos-host-tdd-plustcp, build-freertos-target-plustcp, bdd-freertos-qemu-plustcp]
Expand Down
84 changes: 61 additions & 23 deletions Bdd/Targets/FreeRtosLwip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# FreeRTOS + lwIP (Raw API) link-probe ELF for QEMU mps2-an385 (Cortex-M3).
# FreeRTOS + lwIP (Raw API, NO_SYS=0) BDD target ELF for QEMU mps2-an385
# (Cortex-M3).
#
# S28.07: cross-build the Platform/LwipRaw adapter tree for a FreeRTOS/ARM
# target, selected via SOLIDSYSLOG_FREERTOS_NET=LWIP, proving it links against
# lwIP core with zero dependency on Platform/PlusTcp / FreeRTOS-Plus-TCP. No
# LAN9118 netif driver and no QEMU run — those land with S28.09, which reuses
# this directory's lwipopts.h / FreeRTOSConfig.h / arch/cc.h and grows main.c
# into the real netif + tcpip integration.
# S28.09: grew the S28.07 link-probe into a runnable BDD target — a real
# LAN9118 lwIP netif (netif/EthernetIf.c over the vendored Arm smsc9220
# driver), tcpip_init + a static IP, and the SolidSyslog UDP pipeline reaching
# the syslog-ng oracle on QEMU. Selected via SOLIDSYSLOG_FREERTOS_NET=LWIP,
# with zero dependency on Platform/PlusTcp / FreeRTOS-Plus-TCP.
#
# Source layout mirrors Bdd/Targets/FreeRtos/CMakeLists.txt: upstream
# FreeRTOS-Kernel + lwIP-core sources compile into a separate OBJECT library
# FreeRTOS-Kernel + lwIP-core + lwIP-api + the contrib FreeRTOS sys_arch + the
# vendored LAN9118 driver compile into a separate OBJECT library
# (`solid_syslog_freertos_lwip_upstream`) under a relaxed warning set; our own
# code (main.c, the reused Cortex-M3 startup, and the Platform/LwipRaw adapter
# code (main.c, the reused Cortex-M3 startup, netif/EthernetIf.c, the
# Platform/LwipRaw + Platform/FreeRtos adapters, and the shared BddTarget
# sources) stays in the executable under the strict project warning bar.

set(FREERTOS_KERNEL_PATH "$ENV{FREERTOS_KERNEL_PATH}")
Expand All @@ -27,32 +29,48 @@ if(NOT LWIP_DIR)
"which sets this to /opt/lwip.")
endif()

# lwIP ships its source lists as *_SRCS variables via Filelists.cmake (it is
# explicitly NOT an add_subdirectory target). We consume the minimal IPv4 core
# set — no api/ (NO_SYS=1, no sequential/socket API), no ipv6, no netif driver.
# lwIP ships its source lists as *_SRCS variables via Filelists.cmake. For
# NO_SYS=0 we consume the IPv4 core set plus the api/ set (tcpip.c, api_lib,
# api_msg, …) — the tcpip thread, timeouts, and tcpip_callback marshal hop
# live there. No ipv6.
include(${LWIP_DIR}/src/Filelists.cmake)

set(LWIP_CONTRIB_FREERTOS_DIR "${LWIP_DIR}/contrib/ports/freertos")

set(FREERTOS_PORT_DIR "${FREERTOS_KERNEL_PATH}/portable/GCC/ARM_CM3")
set(FREERTOS_COMMON_DIR "${CMAKE_SOURCE_DIR}/Bdd/Targets/FreeRtos/Common")
set(FREERTOS_TCP_TARGET_DIR "${CMAKE_SOURCE_DIR}/Bdd/Targets/FreeRtos")
set(FREERTOS_COMMON_DIR "${FREERTOS_TCP_TARGET_DIR}/Common")

# --- Upstream OBJECT library --------------------------------------------------
#
# FreeRTOS kernel (minimal: scheduler + heap) + lwIP IPv4 core, compiled with
# the relaxed warning set those upstream sources require. The executable
# consumes the objects via $<TARGET_OBJECTS:...> so the relaxations don't leak.
# FreeRTOS kernel + lwIP IPv4 core + lwIP api (tcpip thread) + the contrib
# FreeRTOS sys_arch + the vendored Arm LAN9118 driver, compiled with the
# relaxed warning set those upstream / third-party sources require. The
# executable consumes the objects via $<TARGET_OBJECTS:...> so the relaxations
# don't leak into project code.

add_library(solid_syslog_freertos_lwip_upstream OBJECT
${FREERTOS_KERNEL_PATH}/tasks.c
${FREERTOS_KERNEL_PATH}/queue.c
${FREERTOS_KERNEL_PATH}/list.c
${FREERTOS_KERNEL_PATH}/timers.c
${FREERTOS_KERNEL_PATH}/event_groups.c
${FREERTOS_PORT_DIR}/port.c
${FREERTOS_KERNEL_PATH}/portable/MemMang/heap_4.c
${lwipcore_SRCS}
${lwipcore4_SRCS}
${lwipapi_SRCS}
# etharp (in core4) emits ARP frames via ethernet_output/ethbroadcast/
# ethzero from netif/ethernet.c — pull that one netif source in (but not
# bridgeif/slipif from lwipnetif_SRCS, which this probe has no use for).
# bridgeif/slipif from lwipnetif_SRCS, which this target has no use for).
${LWIP_DIR}/src/netif/ethernet.c
# lwIP FreeRTOS OS-abstraction port (sys_mutex/sem/mbox/thread) — required
# for NO_SYS=0.
${LWIP_CONTRIB_FREERTOS_DIR}/sys_arch.c
# Vendored Arm LAN9118 (SMSC9220) low-level driver (Apache-2.0). The lwIP
# netif wrapper over it (netif/EthernetIf.c) stays in the executable under
# the strict bar; this third-party source sits under the relaxations.
${CMAKE_CURRENT_SOURCE_DIR}/netif/smsc9220/smsc9220_eth_drv.c
)

target_compile_options(solid_syslog_freertos_lwip_upstream PRIVATE
Expand All @@ -61,10 +79,10 @@ target_compile_options(solid_syslog_freertos_lwip_upstream PRIVATE
-ffunction-sections
-fdata-sections
-fno-common
# FreeRTOS-Kernel + lwIP use non-prototype declarations, type-narrowing
# constructs, sign-conversion patterns, and shadowed locals that trip our
# strict host warnings. Scoped to this OBJECT library so the relaxations
# never reach project code.
# FreeRTOS-Kernel + lwIP + the Arm driver use non-prototype declarations,
# type-narrowing constructs, sign-conversion patterns, and shadowed locals
# that trip our strict host warnings. Scoped to this OBJECT library so the
# relaxations never reach project code.
-Wno-unused-parameter
-Wno-unused-but-set-variable
-Wno-implicit-fallthrough
Expand All @@ -77,9 +95,11 @@ target_compile_options(solid_syslog_freertos_lwip_upstream PRIVATE

target_include_directories(solid_syslog_freertos_lwip_upstream PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} # FreeRTOSConfig.h, lwipopts.h, arch/cc.h
${CMAKE_CURRENT_SOURCE_DIR}/netif/smsc9220 # smsc9220_eth_drv.h, smsc9220_emac_config.h
${FREERTOS_KERNEL_PATH}/include
${FREERTOS_PORT_DIR} # portmacro.h
${LWIP_DIR}/src/include
${LWIP_CONTRIB_FREERTOS_DIR}/include # arch/sys_arch.h
)

# --- Executable ---------------------------------------------------------------
Expand All @@ -89,7 +109,10 @@ target_include_directories(solid_syslog_freertos_lwip_upstream PRIVATE

add_executable(SolidSyslogBddTargetLwip
main.c
${FREERTOS_COMMON_DIR}/startup.c
${FREERTOS_TCP_TARGET_DIR}/Startup.c # Ethernet variant: IRQ 13 -> EthernetISR
${FREERTOS_COMMON_DIR}/CmsdkUart.c
${FREERTOS_COMMON_DIR}/Syscalls.c
netif/EthernetIf.c
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Source/SolidSyslogLwipRawAddress.c
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Source/SolidSyslogLwipRawAddressMessages.c
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Source/SolidSyslogLwipRawAddressStatic.c
Expand All @@ -103,6 +126,14 @@ add_executable(SolidSyslogBddTargetLwip
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Source/SolidSyslogLwipRawTcpStreamMessages.c
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Source/SolidSyslogLwipRawTcpStreamStatic.c
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Source/SolidSyslogLwipRawMarshal.c
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source/SolidSyslogFreeRtosMutex.c
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source/SolidSyslogFreeRtosMutexMessages.c
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source/SolidSyslogFreeRtosMutexStatic.c
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source/SolidSyslogFreeRtosSysUpTime.c
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common/BddTargetInteractive.c
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common/BddTargetIps.c
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common/BddTargetLanguage.c
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common/BddTargetSwitchConfig.c
$<TARGET_OBJECTS:solid_syslog_freertos_lwip_upstream>
)

Expand All @@ -118,13 +149,20 @@ target_compile_options(SolidSyslogBddTargetLwip PRIVATE

target_include_directories(SolidSyslogBddTargetLwip PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} # FreeRTOSConfig.h, lwipopts.h, arch/cc.h
${CMAKE_CURRENT_SOURCE_DIR}/netif # EthernetIf.h
${CMAKE_CURRENT_SOURCE_DIR}/netif/smsc9220 # smsc9220_eth_drv.h, smsc9220_emac_config.h
${FREERTOS_COMMON_DIR} # CmsdkUart.h
${CMAKE_SOURCE_DIR}/Core/Interface # SolidSyslog*.h
${CMAKE_SOURCE_DIR}/Core/Source # internal headers consumed by adapters
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Interface # SolidSyslogLwipRaw{Address,Resolver,Datagram,TcpStream}.h
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Interface # SolidSyslogLwipRaw{Address,Resolver,Datagram,TcpStream,Marshal}.h
${CMAKE_SOURCE_DIR}/Platform/LwipRaw/Source # SolidSyslogLwipRaw*Private.h
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Interface # SolidSyslogFreeRtos{Mutex,SysUpTime}.h
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source # SolidSyslogFreeRtosMutexPrivate.h
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common # BddTargetInteractive.h, BddTargetSwitchConfig.h, …
${FREERTOS_KERNEL_PATH}/include
${FREERTOS_PORT_DIR} # portmacro.h
${LWIP_DIR}/src/include
${LWIP_CONTRIB_FREERTOS_DIR}/include # arch/sys_arch.h (via lwip/sys.h)
)

target_link_libraries(SolidSyslogBddTargetLwip PRIVATE
Expand Down
64 changes: 42 additions & 22 deletions Bdd/Targets/FreeRtosLwip/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
@@ -1,55 +1,75 @@
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

/* FreeRTOS kernel configuration for the Cortex-M3 QEMU mps2-an385 lwIP
* link-probe (S28.07). Deliberately leaner than Bdd/Targets/FreeRtos/
* FreeRTOSConfig.h: this image only has to link the kernel alongside lwIP
* core + the Platform/LwipRaw adapters and start the scheduler with a single
* probe task that _Create/_Destroys each adapter. No timers, no static
* allocation, no IP-stack tasks, no hooks — so there is no hook boilerplate
* to carry. S28.09 introduces the real netif + tcpip integration on top of
* the fuller FreeRtos config. */
/* FreeRTOS kernel configuration for Cortex-M3 on QEMU mps2-an385 with lwIP
* (Raw API) under NO_SYS=0. lwIP runs its own "tcpip" thread (priority and
* stack sized in lwipopts.h via the contrib FreeRTOS sys_arch), the LAN9118
* netif RX task at configMAX_PRIORITIES - 2, and the SolidSyslog interactive /
* service tasks at tskIDLE_PRIORITY + 1.
*
* S28.09 grew this from the S28.07 link-probe config: the lwIP FreeRTOS
* sys_arch needs recursive mutexes (the LWIP_TCPIP_CORE_LOCKING mutex) and
* counting semaphores, and SolidSyslogFreeRtosMutex needs static allocation —
* so this now mirrors Bdd/Targets/FreeRtos/FreeRTOSConfig.h (the proven
* networking config for this machine) rather than the lean probe variant. The
* FreeRTOS software-timer service is left ON for parity even though lwIP runs
* its timeouts on the tcpip thread, not FreeRTOS timers. */

#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ((unsigned long) 25000000)
#define configTICK_RATE_HZ ((TickType_t) 100)
#define configMAX_PRIORITIES 5
#define configMAX_PRIORITIES 7
#define configMINIMAL_STACK_SIZE ((unsigned short) 128)
#define configTOTAL_HEAP_SIZE ((size_t) (32 * 1024))
#define configTOTAL_HEAP_SIZE ((size_t) (96 * 1024))
#define configMAX_TASK_NAME_LEN 16
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_TIMERS 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configSUPPORT_STATIC_ALLOCATION 0
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH 8
#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configUSE_MALLOC_FAILED_HOOK 1
/* Static allocation is required by SolidSyslogFreeRtosMutex
* (xSemaphoreCreateMutexStatic places the StaticSemaphore_t inside the
* caller-supplied storage). The idle / timer task static-memory hooks it
* pulls in are satisfied by configKERNEL_PROVIDED_STATIC_MEMORY = 1 — no
* boilerplate in main.c. Dynamic allocation stays on for the lwIP tcpip /
* RX tasks and the interactive / service tasks created via xTaskCreate. */
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configKERNEL_PROVIDED_STATIC_MEMORY 1

#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES 1

#define INCLUDE_vTaskPrioritySet 0
#define INCLUDE_uxTaskPriorityGet 0
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1

/* Cortex-M3 NVIC: top 3 priority bits implemented. */
#define configPRIO_BITS 3
#define configKERNEL_INTERRUPT_PRIORITY (7 << (8 - configPRIO_BITS))
#define configMAX_SYSCALL_INTERRUPT_PRIORITY (5 << (8 - configPRIO_BITS))
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 7
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5

/* Alias FreeRTOS port handlers to the standard CMSIS names so the vector
* table in Common/startup.c references SVC_Handler / PendSV_Handler /
* SysTick_Handler (and the FreeRTOS port supplies the bodies). */
* table in Startup.c references SVC_Handler / PendSV_Handler / SysTick_Handler
* (and the FreeRTOS port supplies the bodies). */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
Expand Down
Loading
Loading