From cdf63f0d42d976e6fe5b1df4e445b4fdffb4c9d7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 12 Sep 2023 12:54:24 +0200 Subject: [PATCH 1/5] PDEC DTB update --- linux/ipcore/PdecConfig.cpp | 2 ++ linux/ipcore/PdecHandler.cpp | 29 ++++++++++++++++++----------- linux/ipcore/PdecHandler.h | 4 ++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/linux/ipcore/PdecConfig.cpp b/linux/ipcore/PdecConfig.cpp index 19423862..b5e71a28 100644 --- a/linux/ipcore/PdecConfig.cpp +++ b/linux/ipcore/PdecConfig.cpp @@ -190,6 +190,7 @@ ReturnValue_t PdecConfig::createFirstWord(uint32_t* word) { return result; } *word |= static_cast(positiveWindow); + printf("Word 1: 0x%08x\n", *word); return returnvalue::OK; } @@ -205,6 +206,7 @@ ReturnValue_t PdecConfig::createSecondWord(uint32_t* word) { *word |= (static_cast(negativeWindow) << 24); *word |= (HIGH_AU_MAP_ID << 16); *word |= (ENABLE_DERANDOMIZER << 8); + printf("Word 2: 0x%08x\n", *word); return returnvalue::OK; } diff --git a/linux/ipcore/PdecHandler.cpp b/linux/ipcore/PdecHandler.cpp index c7266710..34f045a5 100644 --- a/linux/ipcore/PdecHandler.cpp +++ b/linux/ipcore/PdecHandler.cpp @@ -53,23 +53,30 @@ ReturnValue_t PdecHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - ReturnValue_t result = returnvalue::OK; - UioMapper regMapper(uioNames.registers); - result = regMapper.getMappedAdress(®isterBaseAddress, UioMapper::Permissions::READ_WRITE); + ReturnValue_t result = + regMapper.getMappedAdress(®isterBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != returnvalue::OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } - UioMapper configMemMapper(uioNames.configMemory); - result = configMemMapper.getMappedAdress(&memoryBaseAddress, UioMapper::Permissions::READ_WRITE); - if (result != returnvalue::OK) { + + int fd = 0; + if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) { + sif::error << "PdecHandler::initialize: Opening /dev/mem failed" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + }; + memoryBaseAddress = static_cast( + mmap(0, PDEC_CFG_MEM_SIZE, static_cast(UioMapper::Permissions::READ_WRITE), MAP_SHARED, + fd, PDEC_RAM_PHY_ADDR)); + if (memoryBaseAddress == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; - } else { - pdecConfig.setMemoryBaseAddress(memoryBaseAddress); } - UioMapper ramMapper(uioNames.ramMemory); - result = ramMapper.getMappedAdress(&ramBaseAddress, UioMapper::Permissions::READ_WRITE); - if (result != returnvalue::OK) { + pdecConfig.setMemoryBaseAddress(memoryBaseAddress); + + ramBaseAddress = static_cast(mmap(0, PDEC_RAM_SIZE, + static_cast(UioMapper::Permissions::READ_WRITE), + MAP_SHARED, fd, PDEC_RAM_PHY_ADDR)); + if (ramBaseAddress == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/linux/ipcore/PdecHandler.h b/linux/ipcore/PdecHandler.h index 11ae4de3..19968da6 100644 --- a/linux/ipcore/PdecHandler.h +++ b/linux/ipcore/PdecHandler.h @@ -51,6 +51,10 @@ class PdecHandler : public SystemObject, public ReceivesParameterMessagesIF { public: static constexpr dur_millis_t IRQ_TIMEOUT_MS = 500; + static constexpr uint32_t PDEC_CFG_MEM_SIZE = 0x1000; + static constexpr uint32_t PDEC_CFG_MEM_PHY_ADDR = 0x24000000; + static constexpr uint32_t PDEC_RAM_SIZE = 0x10000; + static constexpr uint32_t PDEC_RAM_PHY_ADDR = 0x26000000; enum class Modes { POLLED, IRQ }; From a697368297cd86b38639c6752b486bffb9c87927 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 12 Sep 2023 13:18:49 +0200 Subject: [PATCH 2/5] remove diagnostic printouts --- linux/ipcore/PdecConfig.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux/ipcore/PdecConfig.cpp b/linux/ipcore/PdecConfig.cpp index b5e71a28..19423862 100644 --- a/linux/ipcore/PdecConfig.cpp +++ b/linux/ipcore/PdecConfig.cpp @@ -190,7 +190,6 @@ ReturnValue_t PdecConfig::createFirstWord(uint32_t* word) { return result; } *word |= static_cast(positiveWindow); - printf("Word 1: 0x%08x\n", *word); return returnvalue::OK; } @@ -206,7 +205,6 @@ ReturnValue_t PdecConfig::createSecondWord(uint32_t* word) { *word |= (static_cast(negativeWindow) << 24); *word |= (HIGH_AU_MAP_ID << 16); *word |= (ENABLE_DERANDOMIZER << 8); - printf("Word 2: 0x%08x\n", *word); return returnvalue::OK; } From 695f5fa5bc49fe2204762d8bc9b506ea85413c30 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 12 Sep 2023 13:31:03 +0200 Subject: [PATCH 3/5] changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 550901d9..34b83251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,13 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +## Changed + +- Changed the memory initialized for the PDEC Config Memory and the PDEC RAM by using `mmap` + directly and ignoring UIO. This makes the OBSW compatible to a device tree update, where those + memory segments are marked reserved and are thus not properly accessible through the UIO API + anymore. This change should be downwards compatible to older device trees. + # [v6.5.1] 2023-09-12 - Bumped `eive-tmtc` to v5.5.0. From ca4e90ad97125eb4df8365189c34c07f4f23653c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Sep 2023 18:13:16 +0200 Subject: [PATCH 4/5] important fix --- linux/ipcore/PdecHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/ipcore/PdecHandler.cpp b/linux/ipcore/PdecHandler.cpp index 34f045a5..8f86ee9c 100644 --- a/linux/ipcore/PdecHandler.cpp +++ b/linux/ipcore/PdecHandler.cpp @@ -67,7 +67,7 @@ ReturnValue_t PdecHandler::initialize() { }; memoryBaseAddress = static_cast( mmap(0, PDEC_CFG_MEM_SIZE, static_cast(UioMapper::Permissions::READ_WRITE), MAP_SHARED, - fd, PDEC_RAM_PHY_ADDR)); + fd, PDEC_CFG_MEM_PHY_ADDR)); if (memoryBaseAddress == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } From d4a87ee7898db0e5bf98ee50711d2a2943b685f9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Sep 2023 16:32:22 +0200 Subject: [PATCH 5/5] prep v6.6.0 --- CHANGELOG.md | 2 ++ CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34b83251..8403fcf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +# [v6.6.0] 2023-09-18 + ## Changed - Changed the memory initialized for the PDEC Config Memory and the PDEC RAM by using `mmap` diff --git a/CMakeLists.txt b/CMakeLists.txt index ba4289c2..65038b76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ cmake_minimum_required(VERSION 3.13) set(OBSW_VERSION_MAJOR 6) -set(OBSW_VERSION_MINOR 5) -set(OBSW_VERSION_REVISION 1) +set(OBSW_VERSION_MINOR 6) +set(OBSW_VERSION_REVISION 0) # set(CMAKE_VERBOSE TRUE)