M CMakeLists.txt => CMakeLists.txt +8 -0
@@ 379,6 379,14 @@ if (${PROJECT_TARGET} STREQUAL "TARGET_Linux")
-C ${PACKAGE_STAGING_DIRECTORY}/Standalone "."
DEPENDS package-standalone-staged
)
+ add_custom_target(
+ eeprom_image ALL
+ DEPENDS genlittlefs
+ DEPENDS assets
+ COMMAND ${CMAKE_BINARY_DIR}/genlittlefs -b 128 -s 32768 --overwrite --image ${CMAKE_BINARY_DIR}/eeprom.img ${CMAKE_BINARY_DIR}/sys/personalization.json
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMENT "Generate eeprom image"
+ )
endif()
if (${PROJECT_TARGET} STREQUAL "TARGET_RT1051")
M image/CMakeLists.txt => image/CMakeLists.txt +1 -0
@@ 7,6 7,7 @@ add_custom_target(
assets
COMMAND rsync -ravu --delete
${ASSETS_SOURCE_DIR}/.boot.json*
+ ${ASSETS_SOURCE_DIR}/personalization.json
${ASSETS_DEST_DIR}
COMMAND rsync -ravu --delete
${ASSETS_SOURCE_DIR}/assets
A image/personalization.json => image/personalization.json +9 -0
@@ 0,0 1,9 @@
+{
+ "serial" : "00000000000000",
+ "case_colour" : "nocase",
+ "pcb_mb_version" : "0v0",
+ "pcb_um_version" : "0v0",
+ "pcb_lm_version" : "0v0",
+ "pcb_am_version" : "0v0",
+ "battery_revision" : "0v0"
+}
M module-vfs/drivers/src/purefs/fs/filesystem_littlefs.cpp => module-vfs/drivers/src/purefs/fs/filesystem_littlefs.cpp +1 -1
@@ 134,7 134,7 @@ namespace
return -ERANGE;
}
cfg->block_count = total_siz / cfg->block_size - 1;
- cfg->lookahead_size = std::min<lfs_size_t>(131072, cfg->block_count);
+ cfg->lookahead_size = std::min<lfs_size_t>(131072U, ((cfg->block_count >> 3U) + 1U) << 3U);
cfg->read_size = cfg->block_size;
cfg->prog_size = cfg->block_size;
cfg->cache_size = cfg->block_size;
M module-vfs/include/user/purefs/filesystem_paths.hpp => module-vfs/include/user/purefs/filesystem_paths.hpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 12,6 12,7 @@ namespace purefs
namespace dir
{
std::filesystem::path getRootDiskPath() noexcept;
+ std::filesystem::path getMfgConfPath() noexcept;
std::filesystem::path getUserDiskPath() noexcept;
std::filesystem::path getCurrentOSPath() noexcept;
std::filesystem::path getPreviousOSPath() noexcept;
M module-vfs/src/purefs/filesystem_paths.cpp => module-vfs/src/purefs/filesystem_paths.cpp +8 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <purefs/filesystem_paths.hpp>
@@ 6,6 6,7 @@
namespace
{
constexpr inline auto PATH_SYS = "/sys";
+ constexpr inline auto PATH_CONF = "/mfgconf";
constexpr inline auto PATH_USER = "user";
constexpr inline auto PATH_CURRENT = "current";
constexpr inline auto PATH_PREVIOUS = "previous";
@@ 29,6 30,12 @@ namespace purefs
{
return std::filesystem::path{eMMC_disk};
}
+
+ std::filesystem::path getMfgConfPath() noexcept
+ {
+ return std::filesystem::path{PATH_CONF};
+ }
+
std::filesystem::path getUserDiskPath() noexcept
{
return std::filesystem::path{eMMC_disk} / PATH_USER;
M module-vfs/src/purefs/vfs_subsystem.cpp => module-vfs/src/purefs/vfs_subsystem.cpp +24 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <purefs/fs/filesystem.hpp>
@@ 19,6 19,7 @@ namespace purefs::subsystem
namespace
{
constexpr auto default_blkdev_name = "emmc0";
+ constexpr auto default_nvrom_name = "nvrom0";
constexpr auto fat_part_code = 0x0b;
constexpr auto lfs_part_code = 0x9e;
constexpr auto old_layout_part_count = 2;
@@ 26,6 27,7 @@ namespace purefs::subsystem
constexpr auto boot_size_limit = 16384L;
constexpr auto block_size_max_shift = 21;
constexpr auto block_size_min_shift = 8;
+ constexpr uint32_t nvrom_lfs_block_size = 128U;
namespace json
{
constexpr auto os_type = "ostype";
@@ 123,6 125,16 @@ namespace purefs::subsystem
LOG_FATAL("Unable to register block device with error %i", err);
return {};
}
+ const auto nvrom_bdev = internal::create_default_nvm_device();
+ if (nvrom_bdev) {
+ err = disk_mgr->register_device(nvrom_bdev, default_nvrom_name, blkdev::flags::no_parts_scan);
+ if (err) {
+ LOG_WARN("Unable to register NVROM device err %i. Maybe running on rev>T7", err);
+ }
+ }
+ else {
+ LOG_WARN("No NVROM driver available for this platform");
+ }
auto fs_core = std::make_shared<fs::filesystem>(disk_mgr);
err = fs_core->register_filesystem("vfat", std::make_shared<fs::drivers::filesystem_vfat>());
if (err) {
@@ 207,6 219,17 @@ namespace purefs::subsystem
const auto boot_dir_name = parse_boot_json_directory(json_file);
const auto user_dir = (dir::getRootDiskPath() / boot_dir_name).string();
fs::internal::set_default_thread_cwd(user_dir);
+
+ // Mount NVRAM memory
+ err = vfs->mount(default_nvrom_name,
+ purefs::dir::getMfgConfPath().c_str(),
+ "littlefs",
+ fs::mount_flags::read_only,
+ &nvrom_lfs_block_size);
+ if (err) {
+ LOG_WARN("Unable to mount NVROM partition err %i. Maybe running on rev>T7", err);
+ err = 0;
+ }
return err;
}