Compare commits

...

2 Commits

3 changed files with 50 additions and 10 deletions

View File

@ -21,6 +21,7 @@ struct safety_memory_header {
uint32_t boot_status_offset; /**< @brief Offset of the safety_memory_boot_status struct (in 32 bit words)*/
uint32_t config_overrides_offset; /**< @brief Offset address of override entries */
uint32_t config_overrides_len; /**< @brief Length of override entries in words */
uint32_t firmware_update_filename; /**< @brief Filename of the firmware update. This string is at maximum 256 bytes long including the 0 terminator */
uint32_t err_memory_offset; /**< @brief Offset of the error memory */
uint32_t err_memory_end; /**< @brief End of the error memory. This points to the word after the error memory, containing the CRC of the whole backup RAM. */
uint32_t crc; /**< @brief CRC of the header */

View File

@ -214,16 +214,21 @@ static void show_error_memory(GtkTreeView *tree_view, const unsigned char *memor
valid = true;
break;
case 4:
header.firmware_update_filename = dat;
interpret = new_string_printf("Offset of FW update filename: %u", dat);
valid = true;
break;
case 5:
header.err_memory_offset = dat;
interpret = new_string_printf("Error memory offset addr: %u", dat);
valid = true;
break;
case 5:
case 6:
header.err_memory_end = dat;
interpret = new_string_printf("Error memory end ptr: %u", dat);
valid = true;
break;
case 6:
case 7:
header.crc = dat;
valid = check_err_mem_header(&header, &expected_value);
if (valid) {
@ -235,7 +240,7 @@ static void show_error_memory(GtkTreeView *tree_view, const unsigned char *memor
}
break;
}
if (i <= 6) {
if (i <= 7) {
state = ENTRY_STATE_INVALID;
goto print;
}

View File

@ -321,20 +321,54 @@ void __attribute__((noreturn)) Reset_Handler(void) {
while (1);
}
/* Move the Stack pointer to CCMRAM
/* Move the stack and the stack pointer to CCMRAM
* This allows us to perform a RAM test on the main RAM.
* Note: sp is not required to be inside the clobber list!
*/
__asm__ __volatile__ ("mov sp, %0\n\t" :: "r"(0x10000000UL + (64U * 1024UL)) :);
/* R2 holds the amount of bytes / words on the stack. */
__asm__ __volatile__ (
"mov r2, sp\n" /* Move stack pointer to register 2 */
"sub r2, %[stacktop], r2\n" /* Subtract stackpointer from top of ram => byte usage */
"mov r3, sp\n" /* Init r3 with first word address to copy (stack pointer) */
"sub r4, %[ccmtop], r2\n" /* Init r4 with first address to copy to! This will be the new stack pointer! */
"mov r5, r4\n" /* R5 will be the new stackpointer after we are finished copying */
"copyloop:\n"
"cmp r3, %[stacktop]\n" /* Check if we still have word to copy. If not => finish */
"beq finish\n"
"ldr.w r6, [r3, #0]\n" /* Load word from [r3] and store into [r4] */
"str.w r6, [r4, #0]\n"
"add r3, #4\n" /* Increment pointers */
"add r4, #4\n"
"b copyloop\n" /* go back to loop head */
"finish:\n"
"mov sp, r5\n" /* Set the new stack pointer to the beginning of the copied area */
:
: [stacktop]"r"(&__ld_top_of_stack), [ccmtop]"r"(0x10000000UL + (64U * 1024UL))
: "memory", "r2", "r3", "r4", "r5", "r6");
if (startup_test_perform_system_ram_check()) {
while (1);
}
/* Move the stack pointer back. Note: This only works if this function does not use the stack for variables.
* Otherwise everything will be broken.
*/
__asm__ __volatile__ ("mov sp, %0\n\t" :: "r"(&__ld_top_of_stack) :);
/* Move the stack back to system ram */
__asm__ __volatile__ (
"mov r2, sp\n" /* Move stack pointer to register 2 */
"sub r2, %[ccmtop], r2\n" /* Subtract stackpointer from top of ccmram => byte usage */
"mov r3, sp\n" /* Init r3 with first word address to copy (stack pointer) */
"sub r4, %[stacktop], r2\n" /* Init r4 with first address to copy to! This will be the new stack pointer! */
"mov r5, r4\n" /* R5 will be the new stackpointer after we are finished copying */
"copyloop_2:\n"
"cmp r3, %[ccmtop]\n" /* Check if we still have word to copy. If not => finish */
"beq finish_2\n"
"ldr.w r6, [r3, #0]\n" /* Load word from [r3] and store into [r4] */
"str.w r6, [r4, #0]\n"
"add r3, #4\n" /* Increment pointers */
"add r4, #4\n"
"b copyloop_2\n" /* go back to loop head */
"finish_2:\n"
"mov sp, r5\n" /* Set the new stack pointer to the beginning of the copied area */
:
: [stacktop]"r"(&__ld_top_of_stack), [ccmtop]"r"(0x10000000UL + (64U * 1024UL))
: "memory", "r2", "r3", "r4", "r5", "r6");
/**
* RAM tests destroyed our values. So we have to copy them again...