Skip to content

Commit

Permalink
stm32l4: Add UID command
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed May 12, 2024
1 parent 4504836 commit 7933ed3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/target/stm32l4.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@
* - https://www.st.com/resource/en/reference_manual/rm0434-multiprotocol-wireless-32bit-mcu-armbased-cortexm4-with-fpu-bluetooth-lowenergy-and-802154-radio-solution-stmicroelectronics.pdf
*/

#include <limits.h>
#include <assert.h>
#include "general.h"
#include "target.h"
#include "target_internal.h"
#include "cortexm.h"
#include "stm32_common.h"
#include <limits.h>
#include <assert.h>

static bool stm32l4_cmd_erase_bank1(target_s *t, int argc, const char **argv);
static bool stm32l4_cmd_erase_bank2(target_s *t, int argc, const char **argv);
static bool stm32l4_cmd_option(target_s *t, int argc, const char **argv);
static bool stm32l4_cmd_uid(target_s *t, int argc, const char **argv);

static bool stm32l4_attach(target_s *t);
static void stm32l4_detach(target_s *t);
Expand All @@ -67,6 +69,7 @@ const command_s stm32l4_cmd_list[] = {
{"erase_bank1", stm32l4_cmd_erase_bank1, "Erase entire bank1 flash memory"},
{"erase_bank2", stm32l4_cmd_erase_bank2, "Erase entire bank2 flash memory"},
{"option", stm32l4_cmd_option, "Manipulate option bytes"},
{"uid", stm32l4_cmd_uid, "Print unique device ID"},
{NULL, NULL, NULL},
};

Expand Down Expand Up @@ -137,6 +140,7 @@ const command_s stm32l4_cmd_list[] = {
#define STM32L4_DBGMCU_IDCODE_PHYS 0xe0042000U
#define STM32L5_DBGMCU_IDCODE_PHYS 0xe0044000U

#define STM32L4_UID_BASE 0x1fff7590U
#define STM32L4_FLASH_SIZE_REG 0x1fff75e0U
#define STM32L5_FLASH_SIZE_REG 0x0bfa05e0U
#define STM32U5_FLASH_SIZE_REG 0x0bfa07a0U
Expand Down Expand Up @@ -984,3 +988,11 @@ static bool stm32l4_cmd_option(target_s *t, int argc, const char **argv)
}
return true;
}

/* Read and decode Unique Device ID register of L4 and G4 */
static bool stm32l4_cmd_uid(target_s *t, int argc, const char **argv)
{
(void)argc;
(void)argv;
return stm32_uid(t, STM32L4_UID_BASE);
}

0 comments on commit 7933ed3

Please sign in to comment.