Skip to content

Commit

Permalink
stm32l4: Fix detection logic
Browse files Browse the repository at this point in the history
* Extract the device entry recorded during _probe, in _attach, from ->target_storage not ->priv (AP)
* Check for nonzero device_id, because *device is either sentinel or a valid pointer into LUT
  • Loading branch information
ALTracer committed Jan 6, 2025
1 parent 88edfc7 commit 74fd17d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/target/stm32l4.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ bool stm32l4_probe(target_s *const target)
* part by using ap->partno, we try again reading the L4 DBGMCU_IDCODE address.
*/
const stm32l4_device_info_s *device = stm32l4_get_device_info(ap->partno);
if (!device)
if (!device->device_id)
device = stm32l4_get_device_info(target_mem32_read16(target, STM32L4_DBGMCU_IDCODE) & 0xfffU);

/*
Expand Down Expand Up @@ -764,7 +764,7 @@ static bool stm32l4_attach(target_s *const target)
return false;

/* Extract the device structure from the priv storage and enable the Flash if on an L55 part */
const stm32l4_device_info_s *const device = ((stm32l4_priv_s *)target->priv)->device;
const stm32l4_device_info_s *const device = ((stm32l4_priv_s *)target->target_storage)->device;
if (device->family == STM32L4_FAMILY_L55x)
stm32l5_flash_enable(target);

Expand Down

0 comments on commit 74fd17d

Please sign in to comment.