Hi! I have been stuck on this simple issue for several days now, and hope someone here can help explain what I am missing.
I am trying to implement Kocherga in a system and have encountered a problem with integrating the app descriptor.
Running kocherga_image.py on the .bin fails to find an uninitialized app descriptor, manualy checking with a hexeditor I have also been unable to find a descriptor.
This minimal application recreates my issue:
#include <cstdio>
#include <cstdint>
#include <array>
#include <cstddef>
struct AppDescriptor
{
std::uint64_t magic = 0x5E4415146FC0C4C7ULL;
std::array<std::uint8_t, 8> signature{{'A', 'P', 'D', 'e', 's', 'c', '0', '0'}};
std::uint64_t image_crc = 0; // Populated after build
std::uint32_t image_size = 0; // Populated after build
[[maybe_unused]] std::array<std::byte, 4> _reserved_a{};
std::uint8_t version_major = 1;
std::uint8_t version_minor = 5;
std::uint8_t flags =
#if RELEASE_BUILD
1
#else
2
#endif
;
[[maybe_unused]] std::array<std::byte, 1> _reserved_b{};
std::uint32_t build_timestamp_utc = 6432;
std::uint64_t vcs_revision_id = 6537653;
[[maybe_unused]] std::array<std::byte, 16> _reserved_c{};
struct Flags
{
static constexpr std::uint8_t ReleaseBuild = 1U;
static constexpr std::uint8_t DirtyBuild = 2U;
};
};
int main()
{
static const volatile AppDescriptor g_app_descriptor __attribute__((used));
// Optionally, use explicit placement near the beginning of the binary:
// __attribute__((used, section(".app_descriptor")));
// and define the .app_descriptor section in the linker file.
printf("HelloWorld\n");
}
I am building the application with platformio using c++17 and stm32cube.