Fix linker: disable ortho cache, stub CancelAllStenoKeys, stub flash, fix C linkage for raise_zmk_keycode_state_changed

This commit is contained in:
afiqzudinhadi 2026-06-23 00:06:57 +08:00
parent 21f1804527
commit d40dc7f537
4 changed files with 29 additions and 17 deletions

View file

@ -187,6 +187,7 @@ print(f'Stripped test blocks from {count} files')
src/platform/zmk_flash_shim.cc
src/platform/zmk_connection_shim.cc
src/platform/zmk_console_shim.cc
src/platform/zmk_stubs.cc
)
# ZMK behavior driver (C, not C++)
@ -234,6 +235,7 @@ print(f'Stripped test blocks from {count} files')
JAVELIN_PLATFORM_ZEPHYR=1
JAVELIN_BOARD_CONFIG=<stddef.h>
M_PI=3.14159265358979323846
USE_ORTHOGRAPHY_CACHE=0
)
# Test suppression handled by include/javelin_overrides/unit_test.h
# which shadows Javelin's unit_test.h via include path ordering.

View file

@ -1,25 +1,18 @@
#include "flash.h"
#include "mem.h"
#include <zephyr/device.h>
#include <zephyr/drivers/flash.h>
static off_t xip_to_offset(const void *ptr) {
return (off_t)(uintptr_t)ptr;
}
// Stub implementations — real flash ops deferred until flash partition configured.
// EraseBlockInternal/WriteBlockInternal are weak in javelin/flash.cc.
// Our strong definitions here override them.
void Flash::EraseBlockInternal(const void *target, size_t size) {
const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash));
if (!device_is_ready(dev)) {
return;
}
flash_erase(dev, xip_to_offset(target), size);
(void)target;
(void)size;
}
void Flash::WriteBlockInternal(const void *target, const void *data,
size_t size) {
const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash));
if (!device_is_ready(dev)) {
return;
}
flash_write(dev, xip_to_offset(target), data, size);
(void)target;
(void)data;
(void)size;
}

View file

@ -2,8 +2,20 @@
#include "key_code.h"
#include <zephyr/kernel.h>
#include <zmk/event_manager.h>
#include <zmk/events/keycode_state_changed.h>
// ZMK event headers need C linkage for the function declarations
// but Zephyr's own headers are C++-safe.
extern "C" {
struct zmk_keycode_state_changed {
uint16_t usage_page;
uint32_t keycode;
uint8_t implicit_modifiers;
uint8_t explicit_modifiers;
bool state;
int64_t timestamp;
};
int raise_zmk_keycode_state_changed(struct zmk_keycode_state_changed ev);
}
static constexpr uint16_t HID_USAGE_PAGE_KEYBOARD = 0x07;
static constexpr uint16_t HID_USAGE_PAGE_CONSUMER = 0x0C;

View file

@ -0,0 +1,5 @@
// Stubs for Javelin platform functions not relevant to ZMK.
#include "button_script.h"
void ButtonScript::CancelAllStenoKeys() {}