Skip to content

Commit

Permalink
Dump.py + Target Fw: Updated version numbers for next release
Browse files Browse the repository at this point in the history
Signed-off-by: CTXz <[email protected]>
  • Loading branch information
CTXz committed Apr 1, 2024
1 parent cfc4c29 commit 76f1749
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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="")
Expand Down
2 changes: 1 addition & 1 deletion target/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions target/main.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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
}
}

Expand All @@ -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 */
Expand All @@ -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
}
}

0 comments on commit 76f1749

Please sign in to comment.