CycloneBOOT 2.6.6
Secure Bootloader for ARM Cortex-M MCU
Loading...
Searching...
No Matches
memory.h File Reference

CycloneBOOT Memory Layer Abstraction. More...

#include "boot_config.h"
#include "core/flash.h"
#include "os_port.h"
#include <stdint.h>
#include <stdlib.h>
#include "core/cboot_error.h"
#include "error.h"
#include "core/fs.h"
#include "memory_ex.h"

Go to the source code of this file.

Classes

struct  Slot
 Slot Type definition. More...
 
struct  MemoryInfo
 Memory Information. More...
 
struct  Memory
 Memory Definition. More...
 

Macros

#define NB_MEMORIES   1
 
#define NB_MAX_MEMORY_SLOTS   2
 
#define MEMORIES_FS_SUPPORT   DISABLED
 
#define EXTERNAL_MEMORY_SUPPORT   DISABLED
 

Enumerations

enum  MemoryType { MEMORY_TYPE_FLASH , MEMORY_TYPE_FS , MEMORY_TYPE_EEPROM }
 Memory Type definition.
 
enum  MemoryRole { MEMORY_ROLE_PRIMARY , MEMORY_ROLE_SECONDARY }
 Memory Role definition.
 
enum  MemoryStatus { MEMORY_STATUS_BUSY , MEMORY_STATUS_ERROR , MEMORY_STATUS_OK }
 Memory status definition.
 
enum  MemoryWriteFlag { MEMORY_WRITE_DEFAULT_FLAG , MEMORY_WRITE_FORCE_FLAG , MEMORY_WRITE_RESET_FLAG }
 Memory write flag definition.
 
enum  SlotType { SLOT_TYPE_DIRECT = 1 , SLOT_TYPE_FILE }
 Slot Type definition.
 
enum  SlotStatus { SLOT_STATUS_BUSY , SLOT_STATUS_ERROR , SLOT_STATUS_OK }
 Slot status definition.
 
enum  SlotContentType {
  SLOT_CONTENT_NONE = 0x00 , SLOT_CONTENT_APP = 0x01 , SLOT_CONTENT_UPDATE = 0x02 , SLOT_CONTENT_BACKUP = 0x04 ,
  SLOT_CONTENT_BINARY = 0x08 , SLOT_CONTENT_DATA = 0x10 , SLOT_CONTENT_CONFIGURATION = 0x20 , SLOT_CONTENT_BOOT = 0x40 ,
  SLOT_CONTENT_FACTORY = 0x80
}
 Slot Type definition.
 

Functions

cboot_error_t memoryInit (Memory *memories, size_t nbMemories)
 Memory initialization function.
 
cboot_error_t memoryDeInit (Memory *memories, size_t nbMemories)
 Memory de-initialization function.
 
cboot_error_t memoryGetInfo (Memory *memory, MemoryInfo *info)
 Memory get driver information function.
 
cboot_error_t memoryGetSlotStatus (Slot *slot, SlotStatus *status)
 Get Memory Status function.
 
cboot_error_t memoryWriteSlot (Slot *slot, uint32_t offset, uint8_t *buffer, size_t length, size_t *written, uint8_t flag)
 Write Data into Memory function.
 
cboot_error_t memoryReadSlot (Slot *slot, uint32_t offset, uint8_t *buffer, size_t length)
 Read Data from Memory function.
 
cboot_error_t memoryEraseSlot (Slot *slot, uint32_t offset, size_t length)
 Erase Data from Memory function.
 
cboot_error_t memoryCopySlot (Slot *src, Slot *dst, size_t bytesNumber)
 Make a backup of the internal slot.
 
void memoryCompareSlot (Slot *src, Slot *dst, uint8_t *result)
 Compare two given slots metadata.
 
cboot_error_t memoryCompareSlotContent (Slot *src, Slot *dst, uint8_t *result)
 Compare two given slots content.
 
cboot_error_t memoryCleanup (Memory *memories, size_t nbMemories)
 Memory cleanup function.
 
cboot_error_t memoryGetSlotByCType (Memory *memory, uint8_t slotCType, Slot **slot)
 Search a slot in memory that match the given slot content type.
 
cboot_error_t memoryGetMemoryByRole (Memory *memories, size_t nb_memories, MemoryRole role, Memory **memory)
 
void memoryInitWriteBuffer (void)
 Initialize memory write buffer.
 
void memoryResetWriteBuffer (void)
 Reset memory write buffer.
 

Detailed Description

CycloneBOOT Memory Layer Abstraction.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2021-2026 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneBOOT Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.6.6

Function Documentation

◆ memoryCompareSlot()

void memoryCompareSlot ( Slot *  src,
Slot *  dst,
uint8_t *  result 
)

Compare two given slots metadata.

Compare two given slots metadata.

◆ memoryCompareSlotContent()

cboot_error_t memoryCompareSlotContent ( Slot *  src,
Slot *  dst,
uint8_t *  result 
)

Compare two given slots content.

Compare two given slots content.

◆ memoryCopySlot()

cboot_error_t memoryCopySlot ( Slot *  src,
Slot *  dst,
size_t  bytesNumber 
)

Make a backup of the internal slot.

Make a backup of the internal slot.

Parameters
[in]srcPointer to source slot to copy from
[out]dstPointer to destination slot to copy in
[in]bytesNumbernumber of bytes to be copied from src slot to dst slot
Returns
Status code

◆ memoryGetSlotByCType()

cboot_error_t memoryGetSlotByCType ( Memory *  memory,
uint8_t  slotCType,
Slot **  slot 
)

Search a slot in memory that match the given slot content type.

Parameters
memoryPointer to memory in which we are looking for
slotCTypeSlot content type we are looking for
slotPointer to the slot we are looking for
Returns
cboot_error_t