From 9ce06192b5d3ed0631863cb2c17f28387f894003 Mon Sep 17 00:00:00 2001 From: ALTracer <11005378+ALTracer@users.noreply.github.com> Date: Sat, 17 Aug 2024 22:51:47 +0300 Subject: [PATCH] s32k3xx: Replace assert with runtime logged error * Pulling __assert_func() and fiprintf() costs ~1.5 KiB of BMF flash * Target flash layer is guaranteed to call this with len=writesize anyways --- src/target/s32k3xx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/target/s32k3xx.c b/src/target/s32k3xx.c index f79fac94ee6..395cb87018b 100644 --- a/src/target/s32k3xx.c +++ b/src/target/s32k3xx.c @@ -23,8 +23,6 @@ * the XML memory map and Flash memory programming. */ -#include - #include "command.h" #include "general.h" #include "target.h" @@ -250,7 +248,11 @@ static bool s32k3xx_flash_erase(target_flash_s *const flash, target_addr_t addr, static bool s32k3xx_flash_write(target_flash_s *flash, target_addr_t dest, const void *src, size_t len) { - assert(len == flash->writesize); + if (len != flash->writesize) { + DEBUG_ERROR("%s: len %" PRIu32 " does not match writesize %" PRIu32 "!\n", __func__, (uint32_t)len, + (uint32_t)flash->writesize); + return false; + } const uint32_t *const s_data = src; s32k3xx_flash_prepare(flash);