Skip to content

Commit 3a91bda

Browse files
committed
Changed to using bare metal profile for flash savings
1 parent fb7db7d commit 3a91bda

File tree

6 files changed

+121
-15
lines changed

6 files changed

+121
-15
lines changed

default_bd.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* default_bd.cpp
3+
*
4+
* Created on: Jul 30, 2020
5+
* Author: gdbeckstein
6+
*/
7+
8+
#include "BlockDevice.h"
9+
10+
#if COMPONENT_SPIF
11+
#include "components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h"
12+
#endif
13+
14+
#if COMPONENT_QSPIF
15+
#include "components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h"
16+
#endif
17+
18+
#if COMPONENT_DATAFLASH
19+
#include "components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h"
20+
#endif
21+
22+
#if COMPONENT_SD
23+
#include "components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h"
24+
25+
#if (STATIC_PINMAP_READY)
26+
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);
27+
#endif
28+
#endif
29+
30+
BlockDevice *BlockDevice::get_default_instance()
31+
{
32+
#if COMPONENT_SPIF
33+
34+
static SPIFBlockDevice default_bd;
35+
36+
return &default_bd;
37+
38+
#elif COMPONENT_QSPIF
39+
40+
static QSPIFBlockDevice default_bd;
41+
42+
return &default_bd;
43+
44+
#elif COMPONENT_DATAFLASH
45+
46+
static DataFlashBlockDevice default_bd;
47+
48+
return &default_bd;
49+
50+
#elif COMPONENT_SD
51+
52+
#if (STATIC_PINMAP_READY)
53+
static SDBlockDevice default_bd(
54+
static_spi_pinmap,
55+
MBED_CONF_SD_SPI_CS
56+
);
57+
#else
58+
static SDBlockDevice default_bd;
59+
#endif
60+
61+
return &default_bd;
62+
63+
#else
64+
65+
return NULL;
66+
67+
#endif
68+
69+
}
70+

ep-oc-mcu.lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/EmbeddedPlanet/ep-oc-mcu/#e482995c2a9346cbf5b78deb3b396f54c6ad75c1

flash_map.cpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

mbed_app.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
{
2+
"requires": ["bare-metal", "mbedtls", "mcuboot", "flashiap-block-device", "spif-driver", "qspif", "mbed-trace"],
23
"target_overrides": {
34
"*": {
4-
"target.restrict_size": "0x20000"
5+
"target.restrict_size": "0x20000",
6+
"target.c_lib": "small"
57
},
68
"NRF52840_DK": {
9+
"target.device_has_remove": ["ITM"],
710
"target.features_add": ["STORAGE"],
811
"target.features_remove": ["CRYPTOCELL310"],
912
"target.macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],
1013
"target.components_add": ["QSPIF", "FLASHIAP"]
1114
},
1215
"EP_AGORA": {
16+
"target.device_has_remove": ["ITM"],
1317
"target.features_add": ["STORAGE"],
1418
"target.features_remove": ["CRYPTOCELL310"],
1519
"target.macros_remove": ["MBEDTLS_CONFIG_HW_SUPPORT"],

tinycbor.lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/EmbeddedPlanet/tinycbor/#c49bb8f5f158c9f37b7cef5bb9eb7ee0a9eb6707

user_main.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* user_main.cpp
3+
*
4+
* Created on: Jul 30, 2020
5+
* Author: gdbeckstein
6+
*/
7+
8+
#include "BlockDevice.h"
9+
10+
/** Enable serial bootloader feature by default */
11+
#ifndef MBED_CONF_APP_SERIAL_BOOTLOADER_ENABLE
12+
#define MBED_CONF_APP_SERIAL_BOOTLOADER_ENABLE 1
13+
#endif
14+
15+
#if MBED_CONF_APP_SERIAL_BOOTLOADER_ENABLE
16+
17+
#include "rtos/ThisThread.h"
18+
#include <chrono>
19+
20+
#define BOOT_WAIT_TIMEOUT 5s
21+
22+
using namespace std::chrono;
23+
24+
#endif // MBED_CONF_APP_SERIAL_BOOTLOADER_ENABLE
25+
26+
mbed::BlockDevice* mcuboot_secondary_bd;
27+
28+
void mbed_mcuboot_user_init(void) {
29+
30+
mbed::BlockDevice* mcuboot_secondary_bd = mbed::BlockDevice::get_default_instance();
31+
32+
// Initialize the secondary/update candidate block device
33+
mcuboot_secondary_bd->init();
34+
35+
#if MBED_CONF_APP_SERIAL_BOOTLOADER_ENABLE
36+
37+
// Set up the serial bootloader
38+
39+
#endif // MBED_CONF_APP_SERIAL_BOOTLOADER_ENABLE
40+
41+
}
42+
43+
44+

0 commit comments

Comments
 (0)