From 76f17499abf7691289889564730c8528f2212ca0 Mon Sep 17 00:00:00 2001 From: CTXz Date: Mon, 1 Apr 2024 12:35:49 +0200 Subject: [PATCH] Dump.py + Target Fw: Updated version numbers for next release Signed-off-by: CTXz --- dump.py | 4 ++-- target/Makefile | 2 +- target/main.c | 27 ++++++++++++++------------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/dump.py b/dump.py index 1632173..8fdcfc5 100644 --- a/dump.py +++ b/dump.py @@ -38,7 +38,7 @@ from serial import Serial, SerialException BAUDRATE = 9600 -SCRIPT_VERSION = "1.4" +SCRIPT_VERSION = "1.5" REQ_ATTACK_BOARD_VERSION = "1.x" SERIAL_TIMEOUT_S = 0.5 SRAM_START = 0x20000000 @@ -514,7 +514,7 @@ def get_target_fw_bin(bin_path: str, usart: int): if read_bytes % 16 == 0: print("\n" + hex(0x8000000 + read_bytes) + ": ", end="") - + # Convert to hex string and print data = data.hex() print(" " + data, end="") diff --git a/target/Makefile b/target/Makefile index e498b76..da156ad 100644 --- a/target/Makefile +++ b/target/Makefile @@ -22,7 +22,7 @@ # - clean: Remove all build files # - release: Create a release tarball containing all target firmware binaries -RELEASE_VERSION=1.3 +RELEASE_VERSION=1.4 BUILD_OUT=build CC=arm-none-eabi-gcc LD=arm-none-eabi-ld diff --git a/target/main.c b/target/main.c index f7536e4..0b30285 100644 --- a/target/main.c +++ b/target/main.c @@ -1,7 +1,7 @@ /* * Authors: JohannesObermaier, Patrick Pedersen * - * Target Firmware Version: 1.3 + * Target Firmware Version: 1.4 * * Dumps the entire flash memory of the target board * and sends it over UART, where it is then received @@ -31,8 +31,8 @@ const char DUMP_START_MAGIC[] = {0x10, 0xAD, 0xDA, 0x7A}; //// Peripheral registers -#define _IWDG_KR (*(uint16_t*)0x40003000) -#define _WDG_SW (*(uint32_t*)0x1FFFF800 & 1UL<<16) // Page 20: https://www.st.com/resource/en/programming_manual/pm0075-stm32f10xxx-flash-memory-microcontrollers-stmicroelectronics.pdf +#define _IWDG_KR (*(uint16_t *)0x40003000) +#define _WDG_SW (*(uint32_t *)0x1FFFF800 & 1UL << 16) // Page 20: https://www.st.com/resource/en/programming_manual/pm0075-stm32f10xxx-flash-memory-microcontrollers-stmicroelectronics.pdf // RCC #define RCC_APB1ENR (*(uint32_t *)0x4002101Cu) @@ -148,8 +148,9 @@ USART *init_usart3() #endif -void refresh_iwdg(void){ - if(iwdg_enabled) +void refresh_iwdg(void) +{ + if (iwdg_enabled) { _IWDG_KR = 0xAAAA; } @@ -162,9 +163,9 @@ const uint8_t txtMap[] = "0123456789ABCDEF"; void writeChar(uint8_t const chr) { while (!(usart->SR & USART_SR_TXE)) - { - refresh_iwdg(); // A byte takes ~1ms to be send at 9600, so there's plenty of time to reset the IWDG - /* wait */ + { + refresh_iwdg(); // A byte takes ~1ms to be send at 9600, so there's plenty of time to reset the IWDG + /* wait */ } usart->DR = chr; @@ -205,7 +206,7 @@ void alertCrash(uint32_t crashId) { while (1) { - refresh_iwdg(); // Keep refreshing IWDG to prevent reset + refresh_iwdg(); // Keep refreshing IWDG to prevent reset } } @@ -214,7 +215,7 @@ void alertCrash(uint32_t crashId) // Called by stage 2 in entry.S int main(void) { - iwdg_enabled = (_WDG_SW == 0); // Check WDG_SW bit. + iwdg_enabled = (_WDG_SW == 0); // Check WDG_SW bit. refresh_iwdg(); /* Init USART */ @@ -236,14 +237,14 @@ int main(void) } uint32_t const *addr = (uint32_t *)0x08000000; - while (((uintptr_t)addr) < (0x08000000U + (1024UL * 1024UL))) // Try dumping up to 1M. When reaching unimplemented memory, it will cause hard fault and stop. + while (((uintptr_t)addr) < (0x08000000U + (1024UL * 1024UL))) // Try dumping up to 1M. When reaching unimplemented memory, it will cause hard fault and stop. { writeWord(*addr); ++addr; } - while(1) // End + while (1) // End { - refresh_iwdg(); // Keep refreshing IWDG to prevent reset + refresh_iwdg(); // Keep refreshing IWDG to prevent reset } }