Taking photo using GR-LYCHEE through Pelion Device Management.

This firmware project works for GR-LYCHEE and GR-PEACH.

Steps to build this firmware with Mbed CLI

Import project

$ mbed import http://os.mbed.com/users/coisme/code/Pelion-GR-LYCHEE-camera-firmware/

Setting

  • Ethernet (GR-PEACH only)
    • Change the file name mbed_app.RZ_A1H_Ethernet.json to mbed_app.json
  • Wi-Fi
    • Change the Wi-Fi setting in mbed_app.json, i.e. nsapi.default-wifi-ssid and nsapi.default-wifi-password

If you haven't set your Pelion API key, run the following command.

$ mbed config -G CLOUD_SDK_API_KEY <API_KEY>

Setting for Pelion Device Management

$ mbed dm init -d "example.com" --model-name "PELION_DEMO" -q --force

Compile

For GR-LYCHEE:

$ mbed compile -t GCC_ARM -m GR_LYCHEE

For GR-PEACH:

$ mbed compile -t GCC_ARM -m RZ_A1H

Write the created .bin file to your GR-LYCHEE/PEACH.

That's it! :-)

LED Status Indicator

LEDs next to UB0 show the status of your GR-LYCHEE/PEACH.

LED#GR-LYCHEEGR-PEACHStatusDescription
LED1greenredNormalTurned on after the device is registered to Pelion Device Management successfully.
LED2yellowgreenErrorTurned on when the network initialization failed. Check your Wi-Fi setting.
LED3orangeblueErrorTurned on when the Pelion Device Management Client initialization failed. Check your SD card.
LED4redredErrorTurned on when the network is disconnected. Check your Wi-Fi network status.

Clear device identity

If you want to clear the device's identity, connect to the device via serial terminal. Then input r command. The device flushes the identity storage, then reboot.

Known Issues

  • client_error(6) -> Client in reconnection mode NetworkError appears when connecting to network, but eventually connection will be established.
  • Warning message "MBEDTLS_TEST_NULL_ENTROPY has been enabled. This configuration is not secure and is not suitable for production use" appears when compiling the project for GR-PEACH. This can be ignored in development stage.
Committer:
Osamu Koizumi
Date:
Wed Apr 10 12:46:02 2019 +0900
Revision:
14:0480150782c8
Parent:
0:6d2053b84a92
Use LEDs as error indicator.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:6d2053b84a92 1 /*
MACRUM 0:6d2053b84a92 2 * Copyright (c) 2018 ARM Limited. All rights reserved.
MACRUM 0:6d2053b84a92 3 * SPDX-License-Identifier: Apache-2.0
MACRUM 0:6d2053b84a92 4 * Licensed under the Apache License, Version 2.0 (the License); you may
MACRUM 0:6d2053b84a92 5 * not use this file except in compliance with the License.
MACRUM 0:6d2053b84a92 6 * You may obtain a copy of the License at
MACRUM 0:6d2053b84a92 7 *
MACRUM 0:6d2053b84a92 8 * http://www.apache.org/licenses/LICENSE-2.0
MACRUM 0:6d2053b84a92 9 *
MACRUM 0:6d2053b84a92 10 * Unless required by applicable law or agreed to in writing, software
MACRUM 0:6d2053b84a92 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
MACRUM 0:6d2053b84a92 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MACRUM 0:6d2053b84a92 13 * See the License for the specific language governing permissions and
MACRUM 0:6d2053b84a92 14 * limitations under the License.
MACRUM 0:6d2053b84a92 15 */
MACRUM 0:6d2053b84a92 16 #include "BlockDevice.h"
MACRUM 0:6d2053b84a92 17 #include "FileSystem.h"
MACRUM 0:6d2053b84a92 18 #include "FATFileSystem.h"
MACRUM 0:6d2053b84a92 19 #include "LittleFileSystem.h"
MACRUM 0:6d2053b84a92 20
MACRUM 0:6d2053b84a92 21 #if COMPONENT_SPIF
MACRUM 0:6d2053b84a92 22 #include "SPIFBlockDevice.h"
MACRUM 0:6d2053b84a92 23 #endif
MACRUM 0:6d2053b84a92 24
MACRUM 0:6d2053b84a92 25 #if COMPONENT_QSPIF
MACRUM 0:6d2053b84a92 26 #include "QSPIFBlockDevice.h"
MACRUM 0:6d2053b84a92 27 #endif
MACRUM 0:6d2053b84a92 28
MACRUM 0:6d2053b84a92 29 #if COMPONENT_DATAFLASH
MACRUM 0:6d2053b84a92 30 #include "DataFlashBlockDevice.h"
MACRUM 0:6d2053b84a92 31 #endif
MACRUM 0:6d2053b84a92 32
MACRUM 0:6d2053b84a92 33 #if COMPONENT_SD
MACRUM 0:6d2053b84a92 34 #include "SDBlockDevice.h"
MACRUM 0:6d2053b84a92 35 #endif
MACRUM 0:6d2053b84a92 36
MACRUM 0:6d2053b84a92 37 #if COMPONENT_FLASHIAP
MACRUM 0:6d2053b84a92 38 #include "FlashIAPBlockDevice.h"
MACRUM 0:6d2053b84a92 39 #endif
MACRUM 0:6d2053b84a92 40
MACRUM 0:6d2053b84a92 41 #if COMPONENT_NUSD
MACRUM 0:6d2053b84a92 42 #include "NuSDBlockDevice.h"
MACRUM 0:6d2053b84a92 43 #endif
MACRUM 0:6d2053b84a92 44
MACRUM 0:6d2053b84a92 45 using namespace mbed;
MACRUM 0:6d2053b84a92 46
MACRUM 0:6d2053b84a92 47 // Align a value to a specified size.
MACRUM 0:6d2053b84a92 48 // Parameters :
MACRUM 0:6d2053b84a92 49 // val - [IN] Value.
MACRUM 0:6d2053b84a92 50 // size - [IN] Size.
MACRUM 0:6d2053b84a92 51 // Return : Aligned value.
MACRUM 0:6d2053b84a92 52 static inline uint32_t align_up(uint32_t val, uint32_t size)
MACRUM 0:6d2053b84a92 53 {
MACRUM 0:6d2053b84a92 54 return (((val - 1) / size) + 1) * size;
MACRUM 0:6d2053b84a92 55 }
MACRUM 0:6d2053b84a92 56
MACRUM 0:6d2053b84a92 57 BlockDevice *BlockDevice::get_default_instance()
MACRUM 0:6d2053b84a92 58 {
MACRUM 0:6d2053b84a92 59 #if COMPONENT_SPIF
MACRUM 0:6d2053b84a92 60
MACRUM 0:6d2053b84a92 61 static SPIFBlockDevice default_bd(
MACRUM 0:6d2053b84a92 62 MBED_CONF_SPIF_DRIVER_SPI_MOSI,
MACRUM 0:6d2053b84a92 63 MBED_CONF_SPIF_DRIVER_SPI_MISO,
MACRUM 0:6d2053b84a92 64 MBED_CONF_SPIF_DRIVER_SPI_CLK,
MACRUM 0:6d2053b84a92 65 MBED_CONF_SPIF_DRIVER_SPI_CS,
MACRUM 0:6d2053b84a92 66 MBED_CONF_SPIF_DRIVER_SPI_FREQ
MACRUM 0:6d2053b84a92 67 );
MACRUM 0:6d2053b84a92 68
MACRUM 0:6d2053b84a92 69 return &default_bd;
MACRUM 0:6d2053b84a92 70
MACRUM 0:6d2053b84a92 71 #elif COMPONENT_QSPIF
MACRUM 0:6d2053b84a92 72
MACRUM 0:6d2053b84a92 73 static QSPIFBlockDevice default_bd(
MACRUM 0:6d2053b84a92 74 MBED_CONF_QSPIF_QSPI_IO0,
MACRUM 0:6d2053b84a92 75 MBED_CONF_QSPIF_QSPI_IO1,
MACRUM 0:6d2053b84a92 76 MBED_CONF_QSPIF_QSPI_IO2,
MACRUM 0:6d2053b84a92 77 MBED_CONF_QSPIF_QSPI_IO3,
MACRUM 0:6d2053b84a92 78 MBED_CONF_QSPIF_QSPI_SCK,
MACRUM 0:6d2053b84a92 79 MBED_CONF_QSPIF_QSPI_CSN,
MACRUM 0:6d2053b84a92 80 MBED_CONF_QSPIF_QSPI_POLARITY_MODE,
MACRUM 0:6d2053b84a92 81 MBED_CONF_QSPIF_QSPI_FREQ
MACRUM 0:6d2053b84a92 82 );
MACRUM 0:6d2053b84a92 83
MACRUM 0:6d2053b84a92 84 return &default_bd;
MACRUM 0:6d2053b84a92 85
MACRUM 0:6d2053b84a92 86 #elif COMPONENT_DATAFLASH
MACRUM 0:6d2053b84a92 87
MACRUM 0:6d2053b84a92 88 static DataFlashBlockDevice default_bd(
MACRUM 0:6d2053b84a92 89 MBED_CONF_DATAFLASH_SPI_MOSI,
MACRUM 0:6d2053b84a92 90 MBED_CONF_DATAFLASH_SPI_MISO,
MACRUM 0:6d2053b84a92 91 MBED_CONF_DATAFLASH_SPI_CLK,
MACRUM 0:6d2053b84a92 92 MBED_CONF_DATAFLASH_SPI_CS
MACRUM 0:6d2053b84a92 93 );
MACRUM 0:6d2053b84a92 94
MACRUM 0:6d2053b84a92 95 return &default_bd;
MACRUM 0:6d2053b84a92 96
MACRUM 0:6d2053b84a92 97 #elif COMPONENT_SD
MACRUM 0:6d2053b84a92 98
MACRUM 0:6d2053b84a92 99 static SDBlockDevice default_bd(
MACRUM 0:6d2053b84a92 100 MBED_CONF_SD_SPI_MOSI,
MACRUM 0:6d2053b84a92 101 MBED_CONF_SD_SPI_MISO,
MACRUM 0:6d2053b84a92 102 MBED_CONF_SD_SPI_CLK,
MACRUM 0:6d2053b84a92 103 MBED_CONF_SD_SPI_CS
MACRUM 0:6d2053b84a92 104 );
MACRUM 0:6d2053b84a92 105
MACRUM 0:6d2053b84a92 106 return &default_bd;
MACRUM 0:6d2053b84a92 107
MACRUM 0:6d2053b84a92 108 #elif COMPONENT_NUSD
MACRUM 0:6d2053b84a92 109
MACRUM 0:6d2053b84a92 110 static NuSDBlockDevice default_bd;
MACRUM 0:6d2053b84a92 111
MACRUM 0:6d2053b84a92 112 return &default_bd;
MACRUM 0:6d2053b84a92 113
MACRUM 0:6d2053b84a92 114 #elif COMPONENT_FLASHIAP
MACRUM 0:6d2053b84a92 115
MACRUM 0:6d2053b84a92 116 #if (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE == 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS == 0xFFFFFFFF)
MACRUM 0:6d2053b84a92 117
MACRUM 0:6d2053b84a92 118 size_t flash_size;
MACRUM 0:6d2053b84a92 119 uint32_t start_address;
MACRUM 0:6d2053b84a92 120 uint32_t bottom_address;
MACRUM 0:6d2053b84a92 121 FlashIAP flash;
MACRUM 0:6d2053b84a92 122
MACRUM 0:6d2053b84a92 123 int ret = flash.init();
MACRUM 0:6d2053b84a92 124 if (ret != 0) {
MACRUM 0:6d2053b84a92 125 return 0;
MACRUM 0:6d2053b84a92 126 }
MACRUM 0:6d2053b84a92 127
MACRUM 0:6d2053b84a92 128 //Find the start of first sector after text area
MACRUM 0:6d2053b84a92 129 bottom_address = align_up(FLASHIAP_ROM_END, flash.get_sector_size(FLASHIAP_ROM_END));
MACRUM 0:6d2053b84a92 130 start_address = flash.get_flash_start();
MACRUM 0:6d2053b84a92 131 flash_size = flash.get_flash_size();
MACRUM 0:6d2053b84a92 132
MACRUM 0:6d2053b84a92 133 ret = flash.deinit();
MACRUM 0:6d2053b84a92 134
MACRUM 0:6d2053b84a92 135 static FlashIAPBlockDevice default_bd(bottom_address, start_address + flash_size - bottom_address);
MACRUM 0:6d2053b84a92 136
MACRUM 0:6d2053b84a92 137 #else
MACRUM 0:6d2053b84a92 138
MACRUM 0:6d2053b84a92 139 static FlashIAPBlockDevice default_bd;
MACRUM 0:6d2053b84a92 140
MACRUM 0:6d2053b84a92 141 #endif
MACRUM 0:6d2053b84a92 142
MACRUM 0:6d2053b84a92 143 return &default_bd;
MACRUM 0:6d2053b84a92 144
MACRUM 0:6d2053b84a92 145 #else
MACRUM 0:6d2053b84a92 146
MACRUM 0:6d2053b84a92 147 return NULL;
MACRUM 0:6d2053b84a92 148
MACRUM 0:6d2053b84a92 149 #endif
MACRUM 0:6d2053b84a92 150
MACRUM 0:6d2053b84a92 151 }
MACRUM 0:6d2053b84a92 152
MACRUM 0:6d2053b84a92 153 FileSystem *FileSystem::get_default_instance()
MACRUM 0:6d2053b84a92 154 {
MACRUM 0:6d2053b84a92 155 #if COMPONENT_SPIF || COMPONENT_QSPIF || COMPONENT_DATAFLASH || COMPONENT_NUSD
MACRUM 0:6d2053b84a92 156
MACRUM 0:6d2053b84a92 157 static LittleFileSystem flash("flash", BlockDevice::get_default_instance());
MACRUM 0:6d2053b84a92 158 flash.set_as_default();
MACRUM 0:6d2053b84a92 159
MACRUM 0:6d2053b84a92 160 return &flash;
MACRUM 0:6d2053b84a92 161
MACRUM 0:6d2053b84a92 162 #elif COMPONENT_SD
MACRUM 0:6d2053b84a92 163
MACRUM 0:6d2053b84a92 164 static FATFileSystem sdcard("sd", BlockDevice::get_default_instance());
MACRUM 0:6d2053b84a92 165 sdcard.set_as_default();
MACRUM 0:6d2053b84a92 166
MACRUM 0:6d2053b84a92 167 return &sdcard;
MACRUM 0:6d2053b84a92 168
MACRUM 0:6d2053b84a92 169 #elif COMPONENT_FLASHIAP
MACRUM 0:6d2053b84a92 170
MACRUM 0:6d2053b84a92 171 static LittleFileSystem flash("flash", BlockDevice::get_default_instance());
MACRUM 0:6d2053b84a92 172 flash.set_as_default();
MACRUM 0:6d2053b84a92 173
MACRUM 0:6d2053b84a92 174 return &flash;
MACRUM 0:6d2053b84a92 175
MACRUM 0:6d2053b84a92 176 #else
MACRUM 0:6d2053b84a92 177
MACRUM 0:6d2053b84a92 178 return NULL;
MACRUM 0:6d2053b84a92 179
MACRUM 0:6d2053b84a92 180 #endif
MACRUM 0:6d2053b84a92 181
MACRUM 0:6d2053b84a92 182 }