Skip to content

Commit 688b0b6

Browse files
committed
Add "at91samd restore" command
Applies safe fuse values to bricked SAMD21
1 parent 76b0521 commit 688b0b6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/flash/nor/at91samd.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,18 @@ COMMAND_HANDLER(samd_handle_eeprom_command)
940940
return res;
941941
}
942942

943+
COMMAND_HANDLER(samd_handle_restore_safe_command)
944+
{
945+
uint32_t user_row_0_dfl = 0xD9FEC7FF;
946+
uint32_t user_row_1_dfl = 0xFFFFFE5D;
947+
int res = ERROR_OK;
948+
949+
struct target *target = get_current_target(CMD_CTX);
950+
res = samd_modify_user_row(target, user_row_0_dfl, 0, 31);
951+
res |= samd_modify_user_row(target, user_row_1_dfl, 32, 63);
952+
return res;
953+
}
954+
943955
COMMAND_HANDLER(samd_handle_bootloader_command)
944956
{
945957
int res = ERROR_OK;
@@ -1047,6 +1059,12 @@ static const struct command_registration at91samd_exec_command_handlers[] = {
10471059
"Changes are stored immediately but take affect after the MCU is"
10481060
"reset.",
10491061
},
1062+
{
1063+
.name = "restore",
1064+
.handler = samd_handle_restore_safe_command,
1065+
.mode = COMMAND_EXEC,
1066+
.help = "Restores safe USER ROW (FUSES) values",
1067+
},
10501068
COMMAND_REGISTRATION_DONE
10511069
};
10521070

0 commit comments

Comments
 (0)