Skip to content

Rollup PR: #8686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
48d4a45
MCUXpresso: Update LPC Flash driver program page function
mmahadevan108 Oct 23, 2018
2de83fb
Unchain the queue when connection is stopped
Oct 29, 2018
d55f6a9
Check if a queue is present. Return an error otherwise
Oct 29, 2018
dcb97f9
InternetSocket: Fixed missing unlock before return
Nov 6, 2018
a360b00
Update peripheral pins
felser Nov 6, 2018
a0f3fdc
Compile time flag MBED_SD_CRC_ENABLE for CRC in SD
Oct 29, 2018
e7bdf3c
Corrected `INIT_FREQUENCY` macro SD is appended by tools
Oct 29, 2018
76930c0
KW41Z: Add Bootloader support
mmahadevan108 Nov 6, 2018
0cba0a3
Online: Include project root path
theotherjimmy Nov 6, 2018
be9e75c
update GCC startup script to align with armcc and iar
Nov 5, 2018
97ac4bb
Cosmetic coding changes of remove white space
Nov 6, 2018
2d10ceb
Sync mbed-client-cli files with v0.4.0
Nov 8, 2018
95e2b07
Resources: Compute parents using only header names
theotherjimmy Nov 8, 2018
6b386f5
Merge branch 'update_peripheral_pins' of ssh://github.com/MultiTechSy…
Nov 8, 2018
60ad33b
Merge branch 'mbed_client_cli_sync_v040' of ssh://github.com/artokin/…
Nov 8, 2018
20fc4da
Merge branch 'KW41Z_Add_Bootloader-Support' of ssh://github.com/NXPmi…
Nov 8, 2018
14a9824
Merge branch 'root-include-path' of ssh://github.com/theotherjimmy/mb…
Nov 8, 2018
e40c357
Merge branch 'internetsocket' of ssh://github.com/marcemmers/mbed-os …
Nov 8, 2018
a2bdc44
Merge branch 'fm_sdk' of ssh://github.com/jamesbeyond/mbed-os into ro…
Nov 8, 2018
62c0436
Merge branch 'flag_Crc' of ssh://github.com/deepikabhavnani/mbed-os i…
Nov 8, 2018
6ebc5be
Merge branch 'cellular_fsm' of ssh://github.com/marcemmers/mbed-os in…
Nov 8, 2018
b353136
Merge branch 'Fix_LPC_Flash_Driver' of ssh://github.com/NXPmicro/mbed…
Nov 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,15 @@
// Only HC block size is supported. Making this a static constant reduces code size.
const uint32_t SDBlockDevice::_block_size = BLOCK_SIZE_HC;

#if MBED_CONF_SD_CRC_ENABLED
SDBlockDevice::SDBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName cs, uint64_t hz, bool crc_on)
: _sectors(0), _spi(mosi, miso, sclk), _cs(cs), _is_initialized(0),
_crc_on(crc_on), _init_ref_count(0), _crc16(0, 0, false, false)
_init_ref_count(0), _crc_on(crc_on), _crc16(0, 0, false, false)
#else
SDBlockDevice::SDBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName cs, uint64_t hz, bool crc_on)
: _sectors(0), _spi(mosi, miso, sclk), _cs(cs), _is_initialized(0),
_init_ref_count(0)
#endif
{
_cs = 1;
_card_type = SDCARD_NONE;
Expand Down Expand Up @@ -293,10 +299,12 @@ int SDBlockDevice::_initialise_card()
return status;
}

#if MBED_CONF_SD_CRC_ENABLED
if (_crc_on) {
// Enable CRC
status = _cmd(CMD59_CRC_ON_OFF, _crc_on);
}
#endif

// Read OCR - CMD58 Response contains OCR register
if (BD_ERROR_OK != (status = _cmd(CMD58_READ_OCR, 0x0, 0x0, &response))) {
Expand Down Expand Up @@ -350,10 +358,15 @@ int SDBlockDevice::_initialise_card()
debug_if(SD_DBG, "Card Initialized: Version 1.x Card\n");
}

#if MBED_CONF_SD_CRC_ENABLED
if (!_crc_on) {
// Disable CRC
status = _cmd(CMD59_CRC_ON_OFF, _crc_on);
}
#else
status = _cmd(CMD59_CRC_ON_OFF, 0);
#endif

return status;
}

Expand Down Expand Up @@ -649,7 +662,6 @@ uint8_t SDBlockDevice::_cmd_spi(SDBlockDevice::cmdSupported cmd, uint32_t arg)
{
uint8_t response;
char cmdPacket[PACKET_SIZE];
uint32_t crc;

// Prepare the command packet
cmdPacket[0] = SPI_CMD(cmd);
Expand All @@ -658,10 +670,14 @@ uint8_t SDBlockDevice::_cmd_spi(SDBlockDevice::cmdSupported cmd, uint32_t arg)
cmdPacket[3] = (arg >> 8);
cmdPacket[4] = (arg >> 0);

#if MBED_CONF_SD_CRC_ENABLED
uint32_t crc;
if (_crc_on) {
_crc7.compute((void *)cmdPacket, 5, &crc);
cmdPacket[5] = (char)(crc | 0x01);
} else {
} else
#endif
{
// CMD0 is executed in SD mode, hence should have correct CRC
// CMD8 CRC verification is always enabled
switch (cmd) {
Expand Down Expand Up @@ -874,6 +890,7 @@ int SDBlockDevice::_read_bytes(uint8_t *buffer, uint32_t length)
crc = (_spi.write(SPI_FILL_CHAR) << 8);
crc |= _spi.write(SPI_FILL_CHAR);

#if MBED_CONF_SD_CRC_ENABLED
if (_crc_on) {
uint32_t crc_result;
// Compute and verify checksum
Expand All @@ -885,6 +902,7 @@ int SDBlockDevice::_read_bytes(uint8_t *buffer, uint32_t length)
return SD_BLOCK_DEVICE_ERROR_CRC;
}
}
#endif

_deselect();
return 0;
Expand All @@ -907,6 +925,7 @@ int SDBlockDevice::_read(uint8_t *buffer, uint32_t length)
crc = (_spi.write(SPI_FILL_CHAR) << 8);
crc |= _spi.write(SPI_FILL_CHAR);

#if MBED_CONF_SD_CRC_ENABLED
if (_crc_on) {
uint32_t crc_result;
// Compute and verify checksum
Expand All @@ -917,6 +936,7 @@ int SDBlockDevice::_read(uint8_t *buffer, uint32_t length)
return SD_BLOCK_DEVICE_ERROR_CRC;
}
}
#endif

return 0;
}
Expand All @@ -933,10 +953,12 @@ uint8_t SDBlockDevice::_write(const uint8_t *buffer, uint8_t token, uint32_t len
// write the data
_spi.write((char *)buffer, length, NULL, 0);

#if MBED_CONF_SD_CRC_ENABLED
if (_crc_on) {
// Compute CRC
_crc16.compute((void *)buffer, length, &crc);
}
#endif

// write the checksum CRC16
_spi.write(crc >> 8);
Expand Down
4 changes: 3 additions & 1 deletion components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ class SDBlockDevice : public BlockDevice {
uint32_t _erase_size;
bool _is_initialized;
bool _dbg;
bool _crc_on;
uint32_t _init_ref_count;

#if MBED_CONF_SD_CRC_ENABLED
bool _crc_on;
mbed::MbedCRC<POLY_7BIT_SD, 7> _crc7;
mbed::MbedCRC<POLY_16BIT_CCITT, 16> _crc16;
#endif
};

#endif /* DEVICE_SPI */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"FSFAT_SDCARD_INSTALLED": 1,
"CMD_TIMEOUT": 10000,
"CMD0_IDLE_STATE_RETRIES": 5,
"SD_INIT_FREQUENCY": 100000
"INIT_FREQUENCY": 100000,
"CRC_ENABLED": 1
},
"target_overrides": {
"DISCO_F051R8": {
Expand Down
9 changes: 9 additions & 0 deletions features/cellular/easy_cellular/CellularConnectionFSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ void CellularConnectionFSM::stop()
_queue_thread = NULL;
}

if (_at_queue) {
_at_queue->chain(NULL);
_at_queue = NULL;
}

if (_power) {
_cellularDevice->close_power();
_power = NULL;
Expand Down Expand Up @@ -131,6 +136,10 @@ nsapi_error_t CellularConnectionFSM::init()
}

_at_queue = _cellularDevice->get_queue();
if (!_at_queue) {
stop();
return NSAPI_ERROR_NO_MEMORY;
}
_at_queue->chain(&_queue);

_retry_count = 0;
Expand Down
24 changes: 22 additions & 2 deletions features/frameworks/mbed-client-cli/mbed-client-cli/ns_cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ uint8_t cmd_history_size(uint8_t max);
* \param fmt console print function (like printf)
*/
#if defined(__GNUC__) || defined(__CC_ARM)
void cmd_printf(const char *fmt, ...) __attribute__ ((__format__(__printf__, 1, 2)));
void cmd_printf(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
#else
void cmd_printf(const char *fmt, ...);
#endif
Expand All @@ -139,7 +139,7 @@ void cmd_printf(const char *fmt, ...);
* \param ap list of parameters needed by format string. This must correspond properly with the conversion specifier.
*/
#if defined(__GNUC__) || defined(__CC_ARM)
void cmd_vprintf(const char *fmt, va_list ap) __attribute__ ((__format__(__printf__, 1, 0)));
void cmd_vprintf(const char *fmt, va_list ap) __attribute__((__format__(__printf__, 1, 0)));
#else
void cmd_vprintf(const char *fmt, va_list ap);
#endif
Expand Down Expand Up @@ -273,6 +273,26 @@ void cmd_alias_add(const char *alias, const char *value);
* \param value Value for variable. Values can contains white spaces and '"' or '"' characters.
*/
void cmd_variable_add(char *variable, char *value);
/**
* Add integer variable to interpreter.
* Variables are replaced with values before executing a command.
* \code
cmd_variable_add_int("world", 2);
cmd_exe("echo $world"); // this is now same as 'echo 2' .
* \endcode
* \param variable Variable name, which will be replaced in interpreter.
* \param value Value for variable

*/
void cmd_variable_add_int(char *variable, int value);
/**
* Request screen size from host
* Response are stored to variables:
* COLUMNS and LINES - as integer values.
* Note: Require terminal that handle request codes, like screen.
*/
void cmd_request_screen_size(void);


/** find command parameter index by key.
* e.g.
Expand Down
Loading