-
Notifications
You must be signed in to change notification settings - Fork 15
/
default_bd.cpp
84 lines (59 loc) · 1.6 KB
/
default_bd.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* default_bd.cpp
*
* Created on: Jul 30, 2020
* Author: gdbeckstein
*/
#include "BlockDevice.h"
#include "SlicingBlockDevice.h"
#if COMPONENT_SPIF
#include "SPIFBlockDevice.h"
#endif
#if COMPONENT_QSPIF
#include "QSPIFBlockDevice.h"
#endif
#if COMPONENT_DATAFLASH
#include "DataFlashBlockDevice.h"
#endif
#if COMPONENT_SD
#include "SDBlockDevice.h"
#if (STATIC_PINMAP_READY)
const spi_pinmap_t static_spi_pinmap = get_spi_pinmap(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, NC);
#endif
#endif
BlockDevice *BlockDevice::get_default_instance()
{
#if COMPONENT_SPIF
static SPIFBlockDevice default_bd;
return &default_bd;
#elif COMPONENT_QSPIF
static QSPIFBlockDevice default_bd;
return &default_bd;
#elif COMPONENT_DATAFLASH
static DataFlashBlockDevice default_bd;
return &default_bd;
#elif COMPONENT_SD
#if (STATIC_PINMAP_READY)
static SDBlockDevice default_bd(
static_spi_pinmap,
MBED_CONF_SD_SPI_CS
);
#else
static SDBlockDevice default_bd;
#endif
return &default_bd;
#else
return NULL;
#endif
}
/**
* You can override this function to suit your hardware/memory configuration
* By default it simply returns what is returned by BlockDevice::get_default_instance();
*/
mbed::BlockDevice* get_secondary_bd(void) {
// In this case, our flash is much larger than a single image so
// slice it into the size of an image slot
mbed::BlockDevice* default_bd = mbed::BlockDevice::get_default_instance();
static mbed::SlicingBlockDevice sliced_bd(default_bd, 0x0, MCUBOOT_SLOT_SIZE);
return &sliced_bd;
}