Skip to content

Commit a2a17b2

Browse files
committed
Hacked for Zephyr
1 parent bfa55e5 commit a2a17b2

File tree

10 files changed

+87
-4
lines changed

10 files changed

+87
-4
lines changed

.codespell-ignore-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
comIn
2+
Ines

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
####
55

66
cmake_minimum_required(VERSION 3.24.2)
7+
add_compile_definitions(_POSIX_C_SOURCE=200809L)
78

89
# Set BOARD_ROOT to find custom boards
910
# The structure is BOARD_ROOT/boards/vendor/board
@@ -33,6 +34,12 @@ fprime_setup_included_code()
3334

3435
# This includes project-wide objects
3536
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FprimeZephyrReference")
36-
37+
if (FPRIME_USE_POSIX)
38+
set_target_properties(Drv_Ip PROPERTIES EXCLUDE_FROM_ALL TRUE)
39+
set_target_properties(Drv_TcpServer PROPERTIES EXCLUDE_FROM_ALL TRUE)
40+
set_target_properties(Drv_TcpClient PROPERTIES EXCLUDE_FROM_ALL TRUE)
41+
set_target_properties(Drv_Udp PROPERTIES EXCLUDE_FROM_ALL TRUE)
42+
target_compile_definitions(Os_File_Posix_Implementation PRIVATE SYNTHETIC_FALLOCATE)
43+
endif()
3744
set_target_properties(Svc_FatalHandler PROPERTIES EXCLUDE_FROM_ALL TRUE)
3845
set_target_properties(fprime-zephyr_Drv_ZephyrSpiDriver PROPERTIES EXCLUDE_FROM_ALL TRUE)

FprimeZephyrReference/ReferenceDeployment/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@ if (FPRIME_PLATFORM STREQUAL "Zephyr")
2020
"${CMAKE_CURRENT_LIST_DIR}/Main.cpp"
2121
DEPENDS
2222
${FPRIME_CURRENT_MODULE}_Top
23+
CHOOSES_IMPLEMENTATIONS
24+
# Can remain stubs for now
25+
Os_File_Posix
2326
)
2427
endif()

FprimeZephyrReference/ReferenceDeployment/Main.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <zephyr/kernel.h>
1111
#include <zephyr/sys/printk.h>
12+
#include <Os/File.hpp>
1213

1314
const struct device* serial = DEVICE_DT_GET(DT_NODELABEL(cdc_acm_uart0));
1415
const struct device* lora = DEVICE_DT_GET(DT_NODELABEL(lora0));
@@ -19,7 +20,25 @@ int main(int argc, char* argv[]) {
1920
// This sleep is necessary to allow the USB CDC ACM interface to initialize before
2021
// the application starts writing to it.
2122
k_sleep(K_MSEC(3000));
22-
23+
Os::File file;
24+
U8 message[] = "Hello Ines\n";
25+
U8 message1[sizeof(message) + 1] = {0};
26+
Os::File::Status status;
27+
FwSizeType size;
28+
// = file.open("/tmp1", Os::File::Mode::OPEN_CREATE);
29+
// Os::File::Status status = file.open("/tmp1", Os::File::Mode::OPEN_CREATE);
30+
// FwSizeType size = static_cast<FwSignedSizeType>(sizeof(message));
31+
// printk("Status: %d - open\n", static_cast<int>(status));
32+
// status = file.write(message, size);
33+
// printk("Status: %d - write %" PRI_FwSizeType "\n", static_cast<int>(status), size);
34+
// file.close();
35+
status = file.open("/tmp1", Os::File::Mode::OPEN_READ);
36+
printk("Status: %d - open (R)\n", static_cast<int>(status));
37+
size = static_cast<FwSignedSizeType>(sizeof(message));
38+
status = file.read(message1, size);
39+
printk("Status: %d - read %" PRI_FwSizeType "\n", static_cast<int>(status), size);
40+
message1[sizeof(message)] = 0;
41+
printk("Message: %s\n", message1);
2342
Os::init();
2443
// Object for communicating state to the topology
2544
ReferenceDeployment::TopologyState inputs;

boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5-pinctrl.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#include <zephyr/dt-bindings/pinctrl/rpi-pico-rp2350a-pinctrl.h>
22

33
&pinctrl {
4+
spi0_default: spi0_default {
5+
group1 {
6+
pinmux = <SPI0_SCK_P18>, <SPI0_TX_P19>;
7+
};
8+
9+
group2 {
10+
pinmux = <SPI0_RX_P16>;
11+
input-enable;
12+
};
13+
};
414
spi1_default: spi1_default {
515
group1 {
616
pinmux = <SPI1_SCK_P10>, <SPI1_TX_P11>;

boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
zephyr,code-partition = &code_partition;
1515
};
1616

17+
fstab {
18+
compatible = "zephyr,fstab";
19+
ffs1: ffs1 {
20+
compatible = "zephyr,fstab,fatfs";
21+
automount;
22+
disk-access;
23+
mount-point = "/";
24+
};
25+
};
26+
27+
1728
aliases {
1829
watchdog0 = &wdt0;
1930
};
@@ -89,6 +100,24 @@ zephyr_udc0: &usbd {
89100
status = "okay";
90101
};
91102

103+
&spi0 {
104+
status = "okay";
105+
cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
106+
pinctrl-0 = <&spi0_default>;
107+
pinctrl-names = "default";
108+
sdhc0: sdhc@0 {
109+
compatible = "zephyr,sdhc-spi-slot";
110+
reg = <0>;
111+
status = "okay";
112+
mmc {
113+
compatible = "zephyr,sdmmc-disk";
114+
disk-name = "SD";
115+
status = "okay";
116+
};
117+
spi-max-frequency = <24000000>;
118+
};
119+
};
120+
92121
&spi1 {
93122
status = "okay";
94123
cs-gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;

lib/fprime

lib/fprime-zephyr

prj.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,14 @@ CONFIG_LOG=n
5454
CONFIG_LOG_DEFAULT_LEVEL=3
5555

5656
CONFIG_CBPRINTF_FP_SUPPORT=y
57+
58+
59+
CONFIG_POSIX_AEP_CHOICE_PSE52=y
60+
CONFIG_POSIX_FILE_SYSTEM=y
61+
CONFIG_FILE_SYSTEM=y
62+
CONFIG_SDHC=y
63+
CONFIG_DISK_ACCESS=y
64+
CONFIG_FAT_FILESYSTEM_ELM=y
65+
CONFIG_FS_FATFS_EXFAT=y
66+
CONFIG_FS_FATFS_MOUNT_MKFS=y
67+
CONFIG_FS_FATFS_FSTAB_AUTOMOUNT=y

settings.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ default_cmake_options: FPRIME_ENABLE_FRAMEWORK_UTS=OFF
88
FPRIME_ENABLE_AUTOCODER_UTS=OFF
99
BOARD_ROOT=.
1010
BOARD=proves_flight_control_board_v5d/rp2350a/m33
11+
FPRIME_USE_POSIX=ON
12+
FPRIME_CMAKE_QUIET=ON
13+
FPRIME_INSTALL_STATIC_LIBRARIES=OFF

0 commit comments

Comments
 (0)