From 402781f49c7bbd035678fbed211594989858fcde Mon Sep 17 00:00:00 2001 From: Eduard Iten Date: Thu, 26 Feb 2026 11:07:35 +0100 Subject: [PATCH] sync --- firmware/src/audio.c | 8 +++++++- firmware/src/protocol.c | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/firmware/src/audio.c b/firmware/src/audio.c index f545d34..af5426c 100644 --- a/firmware/src/audio.c +++ b/firmware/src/audio.c @@ -77,7 +77,7 @@ static int audio_fill_slab_from_cache(void *block) return -ENODATA; } - bytes_read = fs_read(&cached_file, bytes, AUDIO_BLOCK_SIZE); + bytes_read = fs_read(&cached_file, bytes, AUDIO_BLOCK_SIZE/2); if (bytes_read < 0) { LOG_ERR("fs_read failed: %d", (int)bytes_read); @@ -96,6 +96,12 @@ static int audio_fill_slab_from_cache(void *block) cached_file_eof = true; } + for (int i = AUDIO_BLOCK_SIZE/2 - 1; i >= 0; i--) + { + bytes[2*i + 1] = bytes[i]; + bytes[2*i] = bytes[i]; + } + return 0; } diff --git a/firmware/src/protocol.c b/firmware/src/protocol.c index f80e0cb..e46ccdc 100644 --- a/firmware/src/protocol.c +++ b/firmware/src/protocol.c @@ -25,7 +25,7 @@ static protocol_cmd_t current_command = CMD_INVALID; void send_ok() { const char *response = "OK\n"; - LOG_DBG("Sending response: %s", response); + LOG_DBG("Sending response: OK"); usb_write_buffer((const uint8_t *)response, strlen(response)); } @@ -33,7 +33,7 @@ void send_error(int32_t error_code) { char response[32]; snprintf(response, sizeof(response), "ERR %d\n", error_code); - LOG_DBG("Sending response: %s", response); + LOG_DBG("Sending response: ERR %d", error_code); usb_write_buffer((const uint8_t *)response, strlen(response)); } @@ -86,6 +86,7 @@ int put_binary_file(const char *filename, ssize_t filesize, uint32_t expected_cr size_t accumulated = 0; fs_file_t_init(&file); + fs_unlink(filename); LOG_DBG("Opening file '%s' for writing (expected size: %zd bytes, expected CRC32: 0x%08x)", filename, filesize, expected_crc32); rc = fs_open(&file, filename, FS_O_CREATE | FS_O_WRITE); if (rc < 0)