Files
micropython/ports/stm32/mboot/version.c
Victor Rajewski 61e2931f86
Some checks failed
unix port / macos (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
JavaScript code lint and formatting with Biome / eslint (push) Failing after 0s
Check code formatting / code-formatting (push) Failing after 0s
Check spelling with codespell / codespell (push) Failing after 0s
Build docs / build (push) Failing after 0s
Check examples / embedding (push) Failing after 0s
Package mpremote / build (push) Failing after 0s
.mpy file format and tools / test (push) Failing after 0s
Build ports metadata / build (push) Failing after 0s
cc3200 port / build (push) Failing after 0s
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Failing after 0s
esp32 port / build_idf (esp32_build_s3_c3) (push) Failing after 0s
esp8266 port / build (push) Failing after 0s
mimxrt port / build (push) Failing after 0s
nrf port / build (push) Failing after 0s
powerpc port / build (push) Failing after 0s
qemu port / build_and_test_arm (push) Failing after 0s
qemu port / build_and_test_rv32 (push) Failing after 0s
renesas-ra port / build_renesas_ra_board (push) Failing after 0s
rp2 port / build (push) Failing after 0s
samd port / build (push) Failing after 0s
stm32 port / build_stm32 (stm32_misc_build) (push) Failing after 0s
stm32 port / build_stm32 (stm32_nucleo_build) (push) Failing after 0s
stm32 port / build_stm32 (stm32_pyb_build) (push) Failing after 0s
unix port / minimal (push) Failing after 0s
unix port / reproducible (push) Failing after 0s
unix port / standard (push) Failing after 0s
unix port / standard_v2 (push) Failing after 0s
unix port / coverage (push) Failing after 0s
unix port / coverage_32bit (push) Failing after 0s
unix port / nanbox (push) Failing after 0s
unix port / float (push) Failing after 0s
unix port / stackless_clang (push) Failing after 0s
unix port / float_clang (push) Failing after 0s
unix port / settrace (push) Failing after 0s
unix port / settrace_stackless (push) Failing after 0s
unix port / qemu_mips (push) Failing after 0s
unix port / qemu_arm (push) Failing after 0s
unix port / qemu_riscv64 (push) Failing after 0s
webassembly port / build (push) Failing after 0s
windows port / cross-build-on-linux (push) Failing after 0s
zephyr port / build (push) Failing after 0s
Python code lint and formatting with ruff / ruff (push) Failing after 0s
stm32/mboot: Add mboot version string.
Adds a configurable version string to a known location at the end of mboot
flash section.  Also stores the options mboot was built with, eg usb and
which filesystems are supported.

A board can override the defaults, or disable the version string entirely
by setting MBOOT_VERSION_ALLOCATED_BYTES=0.

Signed-off-by: Victor Rajewski <victor@allumeenergy.com.au>
2025-01-02 12:59:14 +11:00

63 lines
1.7 KiB
C

#include "mboot.h"
#include "genhdr/mpversion.h"
#if defined(MBOOT_VERSION_ALLOCATED_BYTES) && MBOOT_VERSION_ALLOCATED_BYTES > 0
#ifndef MBOOT_VERSION
#define MBOOT_VERSION "mboot-" MICROPY_GIT_TAG
#endif
#if MBOOT_VERSION_INCLUDE_OPTIONS // if this is defined, append a list of build options e.g. fat.lfs2
#define MBOOT_VERSION_USB MBOOT_VERSION "+usb" // USB is always included
#if defined(MBOOT_I2C_SCL)
#define MBOOT_VERSION_I2C MBOOT_VERSION_USB ".i2c"
#else
#define MBOOT_VERSION_I2C MBOOT_VERSION_USB
#endif
#if MBOOT_ADDRESS_SPACE_64BIT
#define MBOOT_VERSION_64BIT MBOOT_VERSION_I2C ".64"
#else
#define MBOOT_VERSION_64BIT MBOOT_VERSION_I2C
#endif
#if MBOOT_VFS_FAT
#define MBOOT_VERSION_FAT MBOOT_VERSION_64BIT ".fat"
#else
#define MBOOT_VERSION_FAT MBOOT_VERSION_64BIT
#endif
#if MBOOT_VFS_LFS1
#define MBOOT_VERSION_LFS1 MBOOT_VERSION_FAT ".lfs1"
#else
#define MBOOT_VERSION_LFS1 MBOOT_VERSION_FAT
#endif
#if MBOOT_VFS_LFS2
#define MBOOT_VERSION_LFS2 MBOOT_VERSION_LFS1 ".lfs2"
#else
#define MBOOT_VERSION_LFS2 MBOOT_VERSION_LFS1
#endif
#if MBOOT_VFS_RAW
#define MBOOT_VERSION_RAW MBOOT_VERSION_LFS2 ".raw"
#else
#define MBOOT_VERSION_RAW MBOOT_VERSION_LFS2
#endif
#define MBOOT_VERSION_FINAL MBOOT_VERSION_RAW
#else // MBOOT_VERSION_INCLUDE_OPTIONS
#define MBOOT_VERSION_FINAL MBOOT_VERSION
#endif // MBOOT_VERSION_INCLUDE_OPTIONS
// Ensure we don't overrun the allocated space
_Static_assert(sizeof(MBOOT_VERSION_FINAL) <= MBOOT_VERSION_ALLOCATED_BYTES + 1, "mboot version string is too long");
// Cuts off the null terminator
const char mboot_version[sizeof(MBOOT_VERSION_FINAL) - 1] __attribute__((section(".mboot_version"))) __attribute__ ((__used__)) = MBOOT_VERSION_FINAL;
#endif