MCCI Trusted Bootloader
Simple trusted bootloader and tools for small embedded systems
mccibootloaderboard_catenaabz_eeprom.c
Go to the documentation of this file.
1/*
2
3Module: mccibootloaderboard_catenaabz_eeprom.c
4
5Function:
6 EEPROM variables and accessors for bootloader for Catenas based on ABZ
7 and STM32L0.
8
9Copyright and License:
10 This file copyright (C) 2021 by
11
12 MCCI Corporation
13 3520 Krums Corners Road
14 Ithaca, NY 14850
15
16 See accompanying LICENSE file for copyright and license information.
17
18Author:
19 Terry Moore, MCCI Corporation March 2021
20
21*/
22
24#include "mcci_stm32l0xx.h"
25
26/****************************************************************************\
27|
28| Manifest constants & typedefs.
29|
30\****************************************************************************/
31
32
33/****************************************************************************\
34|
35| Read-only data.
36|
37\****************************************************************************/
38
39
40
41/****************************************************************************\
42|
43| Variables.
44|
45\****************************************************************************/
46
47McciBootloaderBoard_CatenaAbz_Eeprom_t *
49 {
50 extern void *g_McciBootloader_BootEepromBase;
51
52 /* convert to a pointer to the eeprom */
53 return (McciBootloaderBoard_CatenaAbz_Eeprom_t *)
54 &g_McciBootloader_BootEepromBase;
55 }
56
57bool
59 {
60 const McciBootloaderBoard_CatenaAbz_Eeprom_t * const pEeprom = McciBootloaderBoard_CatenaAbz_getEepromPointer();
61
62 if (pEeprom->fUpdateRequest == MCCI_BOOTLOADER_CATENA_ABZ_EEPROM_UPDATE_REQUEST)
63 return true;
64 else
65 return false;
66 }
67
68void
70 {
71 const McciBootloaderBoard_CatenaAbz_Eeprom_t * const pEeprom = McciBootloaderBoard_CatenaAbz_getEepromPointer();
72 uint32_t dwValue = fRequest ? MCCI_BOOTLOADER_CATENA_ABZ_EEPROM_UPDATE_REQUEST
73 : 0;
74
75 // if it's already set to the right value, just return.
76 if (pEeprom->fUpdateRequest == dwValue)
77 return;
78
79 // spin waiting for an operation
81 /* loop */;
82
83 // unlock
86
87 // the EEPROM should erase first, if needed.
88 // write data
89 McciArm_putReg((uint32_t)&pEeprom->fUpdateRequest, dwValue);
90
91 // wait for operation to complete
93 /* loop */;
94
95 // re-lock
99 );
100 }
101
102/**** end of mccibootloaderboard_catenaabz_eeprom.c ****/
static uint32_t McciArm_putRegOr(uint32_t reg, uint32_t orVal)
or 32-bit values to a cm0plus register
static uint32_t McciArm_getReg(uint32_t reg)
read a 32-bit value from a cm0plus register
static uint32_t McciArm_putReg(uint32_t reg, uint32_t val)
write a 32-bit value to a cm0plus register
McciBootloaderPlatform_SetUpdateFlagFn_t McciBootloaderBoard_CatenaAbz_setUpdate
#define MCCI_BOOTLOADER_CATENA_ABZ_EEPROM_UPDATE_REQUEST
the distinguished "update request" value
#define MCCI_STM32L0_REG_FLASH_PECR
Flash program and erase control register.
#define MCCI_STM32L0_REG_FLASH_PEKEYR_UNLOCK2
unlock word 2 for PECR
#define MCCI_STM32L0_REG_FLASH_PEKEYR
Flash PECR unlock key register.
#define MCCI_STM32L0_REG_FLASH_SR
Flash status register.
#define MCCI_STM32L0_REG_FLASH_PEKEYR_UNLOCK1
unlock word 1 for PECR
#define MCCI_STM32L0_REG_FLASH_SR_BSY
Busy doing write/erase.
#define MCCI_STM32L0_REG_FLASH_PECR_PELOCK
Lock the FLASH_PECR register.
bool McciBootloaderBoard_CatenaAbz_getUpdate(void)
McciBootloaderBoard_CatenaAbz_Eeprom_t * McciBootloaderBoard_CatenaAbz_getEepromPointer()