Skip to content

Commit

Permalink
[ext] json example store data in flash_reserved
Browse files Browse the repository at this point in the history
  • Loading branch information
hshose committed Mar 20, 2024
1 parent 61010f5 commit 9017d04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/nucleo_g474re/json/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

// ----------------------------------------------------------------------------

extern "C" const uint32_t __rom_end[];
extern "C" const uint32_t __flash_reserved_start[];

using json = nlohmann::json;

constexpr auto max_flash_pages{64};
constexpr auto max_flash_pages{256};

namespace data
{
Expand Down Expand Up @@ -99,9 +100,9 @@ main()
for (const auto& byte : alice_binary) { MODM_LOG_INFO.printf(" 0x%02x", byte); }
MODM_LOG_INFO << modm::endl;

// put BSON in first flash page after program
// put BSON in reserved flash
uint32_t err{0};
const size_t page_start = Flash::getPage(reinterpret_cast<uint32_t>(&__rom_end)) + 1;
const size_t page_start = Flash::getPage(reinterpret_cast<uint32_t>(&__flash_reserved_start)) + 1;
const size_t num_bytes = alice_binary.size();
const size_t flash_page_size = Flash::getSize(page_start);
const size_t end_page = page_start + (num_bytes + flash_page_size - 1) / flash_page_size;
Expand Down
1 change: 1 addition & 0 deletions examples/nucleo_g474re/json/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<extends>modm:nucleo-g474re</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_g474re/json</option>
<option name="modm:platform:cortex-m:linkerscript.flash_reserved">1024*16</option>
</options>
<modules>
<module>modm:debug</module>
Expand Down

0 comments on commit 9017d04

Please sign in to comment.