Skip to content

Develop/nn#2

Merged
00lllooolll00 merged 9 commits into
masterfrom
develop/nn
Jan 29, 2026
Merged

Develop/nn#2
00lllooolll00 merged 9 commits into
masterfrom
develop/nn

Conversation

@00lllooolll00

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 29, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an “export/auto-init” mechanism and adds initial HAL scaffolding (tick/uart/spi/gpio), along with some cleanup/simplification of toolchain CMake files.

Changes:

  • Add EK_EXPORT_ENABLE and implement EK_EXPORT(...) + ek_export_init() to run registered init functions at startup.
  • Add new HAL modules (tick, uart, spi, gpio) and wire startup tick/log + export init in ek_main().
  • Simplify toolchain CMake files and remove legacy toolchain/linker-script files.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
ek_conf.h Adds EK_EXPORT_ENABLE feature toggle (currently enabled by default).
cmake/starm-clang.cmake Toolchain config cleanup; sets default linker script path.
cmake/gcc-arm-none-eabi.cmake Toolchain config cleanup; sets default linker script path.
cmake/arm-compile6.cmake Removed legacy toolchain file.
L5_App/src/ek_app.c Calls ek_export_init() and switches log tick to HAL ticker.
L2_Core/utils/src/ek_export.c Implements exported init-function iteration using linker symbols.
L2_Core/utils/inc/ek_export.h Defines EK_EXPORT(...) macro and integration notes.
L2_Core/hal/src/ek_hal_uart.c Adds UART HAL driver stub + list registration.
L2_Core/hal/src/ek_hal_tick.c Adds default ticker implementation (currently placeholder).
L2_Core/hal/src/ek_hal_spi.c Adds SPI HAL driver stub and exports init function.
L2_Core/hal/src/ek_hal_gpio.c Adds GPIO HAL driver stub and exports init function.
L2_Core/hal/inc/ek_hal_uart.h Refactors UART HAL public interface.
L2_Core/hal/inc/ek_hal_tick.h Adds tick HAL public interface.
L2_Core/hal/inc/ek_hal_spi.h Adds SPI HAL public interface.
L2_Core/hal/inc/ek_hal_gpio.h Adds GPIO HAL public interface.
L2_Core/hal/inc/ek_hal_base.h Removed unused base HAL abstraction.
L1_MCU/STM32F429ZIT6_STARM/stm32f4xx_flash.ld Removed legacy linker script file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +26 to +35
const _ek_export_init_fn_t __init_##fn##prio __attribute__((used, section(".ek_export_fn." _EK_STR(prio)))) = fn

#else

# define EK_EXPORT(fn, prio)

#endif /* EK_EXPORT_ENABLE */

void ek_export_init(void);

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When EK_EXPORT_ENABLE is 0, this header does not declare ek_export_init(). Any call sites will fail to compile/link. Provide a no-op declaration/definition for ek_export_init() in the disabled branch, or require callers to guard calls with #if (EK_EXPORT_ENABLE == 1).

Suggested change
const _ek_export_init_fn_t __init_##fn##prio __attribute__((used, section(".ek_export_fn." _EK_STR(prio)))) = fn
#else
# define EK_EXPORT(fn, prio)
#endif /* EK_EXPORT_ENABLE */
void ek_export_init(void);
const _ek_export_init_fn_t __init_##fn##prio __attribute__((used, section(".ek_export_fn." _EK_STR(prio)))) = fn
void ek_export_init(void);
#else
# define EK_EXPORT(fn, prio)
static inline void ek_export_init(void)
{
}
#endif /* EK_EXPORT_ENABLE */

Copilot uses AI. Check for mistakes.
* KEEP(*(SORT(.ek_export_fn*)))
* . = ALIGN(4);
* _ek_export_fn_end = .;
* } > flash

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example linker script uses > flash, but the STM32 linker scripts in this repo use an uppercase FLASH memory region name. As written, the example is likely to be copy-pasted and fail; consider using >FLASH (or explicitly note that it must match the target linker script’s region name).

Suggested change
* } > flash
* } > FLASH /* FLASH 必须与目标链接脚本中的内存区域名称一致 */

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +16

static uint8_t uart1_rx_buffer[UART_RX_BUFFER_SIZE]; // 建议通过串口 + 空闲终端 + DMA将数据搬运到这个数组
static void uart1_uart_init(void);

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name uart1_uart_recieve_to_idle is misspelled (receive). This leaks into the .read binding and makes the API harder to search/maintain.

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +16
static void spi1_init(void);
static bool spi1_send(uint8_t *txdata, size_t size);
static bool spi1_recieve(uint8_t *rxdata, size_t size);
static bool spi1_write_recieve(uint8_t *txdata, uint8_t *rxdata, size_t size);

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several identifiers are misspelled (spi1_recieve, spi1_write_recieve). This makes the HAL API harder to search/maintain and can propagate into public interfaces if exposed later. Consider renaming to receive / write_receive.

Copilot uses AI. Check for mistakes.
Comment thread ek_conf.h
* - EK_STACK_ENABLE: 使能栈模块
* - EK_SHELL_ENABLE: 使能shell模块
* ======================================================================== */
#define EK_EXPORT_ENABLE (0)

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EK_EXPORT_ENABLE is enabled by default, but the new export mechanism requires linker-provided symbols (_ek_export_fn_start/_ek_export_fn_end). As-is, enabling this will break the default build unless all linker scripts are updated. Consider defaulting this to 0 until linker scripts are updated, or ensure the required section/symbols are present in all supported .ld files.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to 23
# 链接脚本路径 (可通过 -DLINKER_SCRIPT 覆盖)
set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/L1_MCU/STM32F429ZIT6/stm32f429xx_flash.ld"
CACHE FILEPATH "The path to the linker script")

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default LINKER_SCRIPT points to ${CMAKE_SOURCE_DIR}/L1_MCU/STM32F429ZIT6/stm32f429xx_flash.ld, but that path doesn’t exist in the repo. This will cause link failures when -T is applied. Update the default to an existing linker script (e.g. under L1_MCU/STM32F429ZIT6_GCC/) or require callers to pass -DLINKER_SCRIPT=... and fail fast if it’s unset/invalid.

Copilot uses AI. Check for mistakes.
Comment thread L2_Core/hal/src/ek_hal_gpio.c Outdated
Comment on lines +6 to +8
static void xxx_pin_set(vopd);
static void xxx_pin_reset(vopd);
static void xxx_pin_toggle(vopd);

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vopd is not a valid type and will not compile. These GPIO callbacks should likely be declared as void xxx_pin_set(void)/void xxx_pin_reset(void)/void xxx_pin_toggle(void) (or another concrete signature used by the HAL API).

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +8
extern _ek_export_init_fn_t _ek_export_fn_start;
extern _ek_export_init_fn_t _ek_export_fn_end;

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ek_export_fn_start/_ek_export_fn_end are linker-provided symbols, but there is no linker script in the repo defining them. With EK_EXPORT_ENABLE==1 and ek_export_init() referenced, this will fail to link. Add the required section/symbol definitions to the supported .ld files (or change to a mechanism that doesn’t require linker-script edits).

Suggested change
extern _ek_export_init_fn_t _ek_export_fn_start;
extern _ek_export_init_fn_t _ek_export_fn_end;
_ek_export_init_fn_t _ek_export_fn_start __attribute__((weak)) = 0;
_ek_export_init_fn_t _ek_export_fn_end __attribute__((weak)) = 0;

Copilot uses AI. Check for mistakes.
#if (EK_EXPORT_ENABLE == 1)

/*
* @note 使用这个模块请在对应的 .ld 中 SECTOINS 部分添加下列的部分:

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the linker-script integration note: SECTOINS should be SECTIONS.

Suggested change
* @note 使用这个模块请在对应的 .ld SECTOINS 部分添加下列的部分:
* @note 使用这个模块请在对应的 .ld SECTIONS 部分添加下列的部分:

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +19
ek_default_ticker.tick_to_wait = ek_default_ticker.get() + xticks;

while (ek_default_ticker.tick_to_wait >= ek_default_ticker.get());

Copilot AI Jan 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As implemented, default_delay() can spin forever because the default get() implementation returns a constant 0. Either implement get() with a real tick source, or make the default delay a safe no-op/assert until the ticker is configured.

Suggested change
ek_default_ticker.tick_to_wait = ek_default_ticker.get() + xticks;
while (ek_default_ticker.tick_to_wait >= ek_default_ticker.get());
/* If the ticker is still using the default stub, avoid spinning forever. */
if (ek_default_ticker.get == defualt_get_tick)
{
(void)xticks;
return;
}
ek_default_ticker.tick_to_wait = ek_default_ticker.get() + xticks;
while (ek_default_ticker.tick_to_wait >= ek_default_ticker.get())
{
/* busy wait until tick_to_wait is reached */
}

Copilot uses AI. Check for mistakes.
@00lllooolll00 00lllooolll00 merged commit e5c8447 into master Jan 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants