@@ -69,14 +69,14 @@ const command_s efm32_cmd_list[] = {
6969/* Memory System Controller (MSC) Registers */
7070/* -------------------------------------------------------------------------- */
7171
72- #define EFM32_MSC_WRITECTRL (msc ) (msc + 0x00CU ) //(msc + 0x008U)
73- #define EFM32_MSC_WRITECMD (msc ) (msc + 0x010U)
74- #define EFM32_MSC_ADDRB (msc ) (msc + 0x014U)
75- #define EFM32_MSC_WDATA (msc ) (msc + 0x018U)
76- #define EFM32_MSC_STATUS (msc ) (msc + 0x01CU)
77- #define EFM32_MSC_IF (msc ) (msc + 0x020U)
78- #define EFM32_MSC_LOCK (msc ) (msc + 0x03CU)
79- #define EFM32_MSC_MASSLOCK (msc ) (msc + 0x040U)
72+ #define EFM32_MSC_WRITECTRL (msc ) (msc + 0x00cU ) //(msc + 0x008U)
73+ #define EFM32_MSC_WRITECMD (msc ) (msc + 0x010U)
74+ #define EFM32_MSC_ADDRB (msc ) (msc + 0x014U)
75+ #define EFM32_MSC_WDATA (msc ) (msc + 0x018U)
76+ #define EFM32_MSC_STATUS (msc ) (msc + 0x01cU)
77+ #define EFM32_MSC_IF (msc ) (msc + 0x020U)
78+ #define EFM32_MSC_LOCK (msc ) (msc + 0x03cU)
79+ #define EFM32_MSC_MASSLOCK (msc ) (msc + 0x040U)
8080
8181#define EFM32_MSC_LOCK_LOCKKEY 0x7025U
8282#define EFM32_MSC_MASSLOCK_LOCKKEY 0x0000U
@@ -104,7 +104,7 @@ const command_s efm32_cmd_list[] = {
104104#define EFM32_LOCK_BITS (EFM32_INFO + 0x4000U)
105105#define EFM32_V1_DI (EFM32_INFO + 0x8000U)
106106#define EFM32_V2_DI (EFM32_INFO + 0x81b0U)
107- #define EFR32FG23_DI (EFM32_INFO + 0x8000U)
107+ #define EFR32FG23_DI (EFM32_INFO + 0x8000U)
108108
109109/* -------------------------------------------------------------------------- */
110110/* Lock Bits (LB) */
@@ -263,44 +263,43 @@ const command_s efm32_cmd_list[] = {
263263/* Device Information (DI) Area for EFR32FG23 */
264264/* -------------------------------------------------------------------------- */
265265
266- #define EFR32FG23_DI_INFO (EFR32FG23_DI + 0x000U)
267- #define EFR32FG23_DI_PART (EFR32FG23_DI + 0x004U)
268- #define EFR32FG23_DI_MEMINFO (EFR32FG23_DI + 0x008U)
269- #define EFR32FG23_DI_MSIZE (EFR32FG23_DI + 0x00cU)
270- #define EFR32FG23_DI_PKGINFO (EFR32FG23_DI + 0x010U)
271- #define EFR32FG23_DI_CUSTOMINFO (EFR32FG23_DI + 0x014U)
272- #define EFR32FG23_DI_SWFIX (EFR32FG23_DI + 0x018U)
273- #define EFR32FG23_DI_SWCAPA0 (EFR32FG23_DI + 0x01cU)
274- #define EFR32FG23_DI_SWCAPA1 (EFR32FG23_DI + 0x020U)
275- #define EFR32FG23_DI_EXTINFO (EFR32FG23_DI + 0x028U)
276- #define EFR32FG23_DI_EUI48L (EFR32FG23_DI + 0x040U)
277- #define EFR32FG23_DI_EUI48H (EFR32FG23_DI + 0x044U)
278- #define EFR32FG23_DI_EUI64L (EFR32FG23_DI + 0x048U)
279- #define EFR32FG23_DI_EUI64H (EFR32FG23_DI + 0x04CU)
280- #define EFR32FG23_DI_CALTEMP (EFR32FG23_DI + 0x050U)
281- #define EFR32FG23_DI_EMUTEMP (EFR32FG23_DI + 0x054U)
282- #define EFR32FG23_DI_HFRCODPLLCALn (EFR32FG23_DI + 0x058U)
283- #define EFR32FG23_DI_HFRCOEM23CALn (EFR32FG23_DI + 0x0A0U)
284- #define EFR32FG23_DI_MODULENAME0 (EFR32FG23_DI + 0x130U)
285- #define EFR32FG23_DI_MODULENAME1 (EFR32FG23_DI + 0x134U)
286- #define EFR32FG23_DI_MODULENAME2 (EFR32FG23_DI + 0x138U)
287- #define EFR32FG23_DI_MODULENAME3 (EFR32FG23_DI + 0x13CU)
288- #define EFR32FG23_DI_MODULENAME4 (EFR32FG23_DI + 0x140U)
289- #define EFR32FG23_DI_MODULENAME5 (EFR32FG23_DI + 0x144U)
290- #define EFR32FG23_DI_MODULENAME6 (EFR32FG23_DI + 0x148U)
291- #define EFR32FG23_DI_MODULEINFO (EFR32FG23_DI + 0x14CU)
292- #define EFR32FG23_DI_MODXOCAL (EFR32FG23_DI + 0x150U)
293- #define EFR32FG23_DI_HFXOCAL (EFR32FG23_DI + 0x17CU)
294- #define EFR32FG23_DI_IADC0GAIN0 (EFR32FG23_DI + 0x180U)
295- #define EFR32FG23_DI_IADC0GAIN1 (EFR32FG23_DI + 0x184U)
296- #define EFR32FG23_DI_IADC0OFFSETCAL0 (EFR32FG23_DI + 0x188U)
297- #define EFR32FG23_DI_IADC0NORMALOFFSETCAL0 (EFR32FG23_DI + 0x18CU)
298- #define EFR32FG23_DI_IADC0NORMALOFFSETCAL1 (EFR32FG23_DI + 0x190U)
299- #define EFR32FG23_DI_IADC0HISPDOFFSETCAL0 (EFR32FG23_DI + 0x194U)
300- #define EFR32FG23_DI_IADC0HISPDOFFSETCAL1 (EFR32FG23_DI + 0x198U)
301- #define EFR32FG23_DI_LEGACY (EFR32FG23_DI + 0x1FCU)
302- #define EFR32FG23_DI_RTHERM (EFR32FG23_DI + 0x25CU)
303-
266+ #define EFR32FG23_DI_INFO (EFR32FG23_DI + 0x000U)
267+ #define EFR32FG23_DI_PART (EFR32FG23_DI + 0x004U)
268+ #define EFR32FG23_DI_MEMINFO (EFR32FG23_DI + 0x008U)
269+ #define EFR32FG23_DI_MSIZE (EFR32FG23_DI + 0x00cU)
270+ #define EFR32FG23_DI_PKGINFO (EFR32FG23_DI + 0x010U)
271+ #define EFR32FG23_DI_CUSTOMINFO (EFR32FG23_DI + 0x014U)
272+ #define EFR32FG23_DI_SWFIX (EFR32FG23_DI + 0x018U)
273+ #define EFR32FG23_DI_SWCAPA0 (EFR32FG23_DI + 0x01cU)
274+ #define EFR32FG23_DI_SWCAPA1 (EFR32FG23_DI + 0x020U)
275+ #define EFR32FG23_DI_EXTINFO (EFR32FG23_DI + 0x028U)
276+ #define EFR32FG23_DI_EUI48L (EFR32FG23_DI + 0x040U)
277+ #define EFR32FG23_DI_EUI48H (EFR32FG23_DI + 0x044U)
278+ #define EFR32FG23_DI_EUI64L (EFR32FG23_DI + 0x048U)
279+ #define EFR32FG23_DI_EUI64H (EFR32FG23_DI + 0x04cU)
280+ #define EFR32FG23_DI_CALTEMP (EFR32FG23_DI + 0x050U)
281+ #define EFR32FG23_DI_EMUTEMP (EFR32FG23_DI + 0x054U)
282+ #define EFR32FG23_DI_HFRCODPLLCALn (EFR32FG23_DI + 0x058U)
283+ #define EFR32FG23_DI_HFRCOEM23CALn (EFR32FG23_DI + 0x0a0U)
284+ #define EFR32FG23_DI_MODULENAME0 (EFR32FG23_DI + 0x130U)
285+ #define EFR32FG23_DI_MODULENAME1 (EFR32FG23_DI + 0x134U)
286+ #define EFR32FG23_DI_MODULENAME2 (EFR32FG23_DI + 0x138U)
287+ #define EFR32FG23_DI_MODULENAME3 (EFR32FG23_DI + 0x13cU)
288+ #define EFR32FG23_DI_MODULENAME4 (EFR32FG23_DI + 0x140U)
289+ #define EFR32FG23_DI_MODULENAME5 (EFR32FG23_DI + 0x144U)
290+ #define EFR32FG23_DI_MODULENAME6 (EFR32FG23_DI + 0x148U)
291+ #define EFR32FG23_DI_MODULEINFO (EFR32FG23_DI + 0x14cU)
292+ #define EFR32FG23_DI_MODXOCAL (EFR32FG23_DI + 0x150U)
293+ #define EFR32FG23_DI_HFXOCAL (EFR32FG23_DI + 0x17cU)
294+ #define EFR32FG23_DI_IADC0GAIN0 (EFR32FG23_DI + 0x180U)
295+ #define EFR32FG23_DI_IADC0GAIN1 (EFR32FG23_DI + 0x184U)
296+ #define EFR32FG23_DI_IADC0OFFSETCAL0 (EFR32FG23_DI + 0x188U)
297+ #define EFR32FG23_DI_IADC0NORMALOFFSETCAL0 (EFR32FG23_DI + 0x18cU)
298+ #define EFR32FG23_DI_IADC0NORMALOFFSETCAL1 (EFR32FG23_DI + 0x190U)
299+ #define EFR32FG23_DI_IADC0HISPDOFFSETCAL0 (EFR32FG23_DI + 0x194U)
300+ #define EFR32FG23_DI_IADC0HISPDOFFSETCAL1 (EFR32FG23_DI + 0x198U)
301+ #define EFR32FG23_DI_LEGACY (EFR32FG23_DI + 0x1fcU)
302+ #define EFR32FG23_DI_RTHERM (EFR32FG23_DI + 0x25cU)
304303
305304/* -------------------------------------------------------------------------- */
306305/* Constants */
@@ -445,7 +444,8 @@ static uint64_t efr32fg23_read_unique(target_s *t, uint8_t di_version)
445444 if (di_version != 3 )
446445 return 0 ;
447446
448- return (((uint64_t )target_mem32_read32 (t , EFR32FG23_DI_EUI64H ) & 0x000FU ) << 32U ) | target_mem32_read32 (t , EFR32FG23_DI_EUI64L );
447+ return (((uint64_t )target_mem32_read32 (t , EFR32FG23_DI_EUI64H ) & 0x000fU ) << 32U ) |
448+ target_mem32_read32 (t , EFR32FG23_DI_EUI64L );
449449}
450450
451451/* Reads the EFM32 flash size in kiB */
@@ -587,7 +587,8 @@ static void efm32_add_flash(target_s *t, target_addr_t addr, size_t length, size
587587/* Lookup device */
588588static efm32_device_s const * efm32_get_device (target_s * t , uint8_t di_version )
589589{
590- if (di_version == 0 ) return NULL ;
590+ if (di_version == 0 )
591+ return NULL ;
591592
592593 uint8_t part_family = efm32_read_part_family (t , di_version );
593594
@@ -631,9 +632,9 @@ bool efm32_probe(target_s *t)
631632 * DI_FAMILYNUM is 23
632633 */
633634 uint32_t pn = target_mem32_read32 (t , EFR32FG23_DI_PART );
634- uint8_t family = (pn >> 24 ) & 0x3f ; // Extract bits 29-24 (6 bits)
635+ uint8_t family = (pn >> 24 ) & 0x3f ; // Extract bits 29-24 (6 bits)
635636 uint8_t familynum = (pn >> 16 ) & 0x3f ; /* Extract family ID from bits 21-16 */
636- uint16_t devicenum = pn & 0xffff ; /* Extract DEVICENUM from bits 0-15 */
637+ uint16_t devicenum = pn & 0xffff ; /* Extract DEVICENUM from bits 0-15 */
637638
638639 /* Check for known EFR32FG23 OUIs */
639640 if (familynum == 23 && (family == 0 || family == 3 || family == 5 )) {
@@ -646,17 +647,15 @@ bool efm32_probe(target_s *t)
646647 char letter = 'A' + (devicenum / 1000 );
647648 uint16_t number = devicenum % 1000 ;
648649 DEBUG_INFO ("EFR32xG23 Device : %c%03u\n" , letter , number );
649- }
650- else {
650+ } else {
651651 DEBUG_INFO ("Could not determine EFM32/EFR32 device type, assuming version 1." );
652- di_version = 1 ;
652+ di_version = 1 ;
653653 }
654654 }
655655
656656 /* Read the part family, and reject if unknown */
657657 efm32_device_s const * device = efm32_get_device (t , di_version );
658- if (!device )
659- {
658+ if (!device ) {
660659 DEBUG_ERROR ("Could not find the EFM32 device in the lookup table.\n" );
661660 return false;
662661 }
@@ -675,7 +674,6 @@ bool efm32_probe(target_s *t)
675674 uint32_t ram_size = ram_kib * 0x400U ;
676675 uint32_t flash_page_size = device -> flash_page_size ;
677676
678-
679677 efm32_priv_s * priv_storage = calloc (1 , sizeof (* priv_storage ));
680678 if (!priv_storage ) { /* calloc failed: heap exhaustion */
681679 DEBUG_ERROR ("calloc: failed in %s\n" , __func__ );
@@ -703,8 +701,8 @@ bool efm32_probe(target_s *t)
703701 efm32_add_flash (t , 0x0fe10000 , device -> bootloader_size , flash_page_size );
704702 }
705703
706- target_mem32_write32 (t , 0x40008064U , 0xFFFFFFFFU );
707- target_mem32_write32 (t , 0x40008068U , 0x1FFFFFFFU );
704+ target_mem32_write32 (t , 0x40008064U , 0xffffffffU );
705+ target_mem32_write32 (t , 0x40008068U , 0x1fffffffU );
708706 target_add_commands (t , efm32_cmd_list , "EFM32" );
709707
710708 return true;
0 commit comments