Skip to content

FIRM-167 Hexray SoC - #1976

Open
KelmLelm wants to merge 18 commits into
masterfrom
hexray/bms/soc
Open

FIRM-167 Hexray SoC#1976
KelmLelm wants to merge 18 commits into
masterfrom
hexray/bms/soc

Conversation

@KelmLelm

@KelmLelm KelmLelm commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Changelist

  • Added SoC app layer and SoC storage IO layer.
  • Added SD card HW layer
  • Changed CMakeLists to include logfs in the build target
    NOTE: LUT for cells and function calls for segments need to be replaced when each are done. Lastly I still gotta fix test so they build 🥀
    Since the "C" version of the file system references the "C" functions for hw_sd_present(), had to call hw directly from add layer. Having the new C++ version should fix.

Testing Done

Resolved Tickets

FIRM-167
FIRM-367

@KelmLelm KelmLelm changed the title Hexray SoC FIRM-167 Hexray SoC Apr 26, 2026
@Lucien950 Lucien950 added the BMS Battery Management System label Apr 27, 2026

@Lucien950 Lucien950 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.

i don't think this is a full implementation, because i don't think the unhappy path is not well covered. please make sure that is implemented and tested

Comment thread firmware/hexray/BMS/CMakeLists.txt Outdated
Comment thread firmware/hexray/BMS/src/app/app_soc.hpp
Comment thread firmware/hexray/BMS/src/app/app_soc.hpp Outdated
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp Outdated
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp Outdated
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp Outdated
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp Outdated
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp Outdated
@KelmLelm
KelmLelm requested a review from Lucien950 May 7, 2026 12:53
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp Outdated
Comment thread firmware/hexray/BMS/src/app/app_soc.cpp Outdated
Comment thread firmware/hexray/BMS/CMakeLists.txt Outdated
Comment thread firmware/hexray/BMS/CMakeLists.txt
Comment thread firmware/hexray/BMS/src/app/app_socStorage.hpp Outdated
Comment on lines +50 to +58
std::expected<void, FileSystemError> requireStorageReady()
{
if (!soc_storage_ready)
{
return std::unexpected(soc_storage_status);
}

return {};
}

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.

for example here if the storage is not ready you don't need to know why it's not ready, just that it isn't
also this is highkey just a sanity check, and should not be part of your hot path
and also the error should probably be handled where it is thrown so the type of the error is not of interest to the consumer of this function

Comment on lines +103 to +107
if (auto result = recordStatus(io_fileSystem_init()); !result)
{
LOG_ERROR("SoC storage unavailable: failed to initialize file system");
return;
}

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.

i would decouple this functionality from soc and put it into tasks, because this is a global property

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.

you should still check if this fails (which is kept track of with io_fileSystem) before continuing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ooki

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wait, the checkmount on the filesystem class is private tho how can I see feedback of the init?

constexpr uint32_t SOC_TENTHS_UNAVAILABLE = UINT32_MAX;

FileSystemError soc_storage_status = FILE_MOUNT_FAILED;
bool soc_storage_ready = false;

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.

i think you can implicitly store this by making soc_fd an optional type, which forces an unwrap

Comment thread firmware/hexray/BMS/src/app/app_socStorage.cpp Outdated

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.

on the lowest of keys what is stopping us from storing the SOC from just inside app_soc?

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.

cause i think this can be massively simplified and just slapped in there

Comment thread firmware/hexray/BMS/src/tasks.cpp Outdated
Comment thread firmware/hexray/BMS/src/tasks.cpp
Comment thread firmware/hexray/BMS/src/tasks.cpp Outdated
@Lucien950

Copy link
Copy Markdown
Contributor

also I swear you are exposing a whole bunch of functions you don't use, if you don't use them please don't expose them

@KelmLelm
KelmLelm requested a review from Lucien950 May 25, 2026 14:06
can_rx_queue.init();
can_tx_queue.init();

app::can_tx::BMS_Hash_set(GIT_COMMIT_HASH);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

whoops

can_rx_queue.init();
can_tx_queue.init();

app::can_tx::BMS_Hash_set(GIT_COMMIT_HASH);

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.

Suggested change
app::can_tx::BMS_Hash_set(GIT_COMMIT_HASH);
app::can_tx::BMS_Hash_set(GIT_COMMIT_HASH);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BMS Battery Management System

Development

Successfully merging this pull request may close these issues.

2 participants