Merge pull request #8083 from ARMmbed/release-candidate

Release candidate for mbed-os-5.10.0-rc2
pull/8162/head mbed-os-5.10.0-rc2
Anna Bridge 2018-09-12 11:35:24 +01:00 committed by GitHub
commit dd2d159796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 2364 additions and 446 deletions

1666
TESTS/netsocket/README.md Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View File

@ -21,8 +21,8 @@ You need Icetea and mbed-cli that supports Icetea, installed.
Depending on a device, there might be a default network interface type defined in the mbed-os/targets/targets.json, which is used to locate a test-config file by default. Depending on a device, there might be a default network interface type defined in the mbed-os/targets/targets.json, which is used to locate a test-config file by default.
If there is not, or you want to use a different interface than the default, you need to provide a relevant test-config -file to the mbed test with --test-config option. If there is not, or you want to use a different interface than the default, you need to provide a relevant test-config -file to the mbed test with --test-config option.
The test-config file contains the necessary information for the test application, there are some test-config files located under mbed-os/tools/test-configs. The test-config file contains the necessary information for the test application, there are some test-config files located under mbed-os/tools/test_configs.
Devices which have their network drivers residing inside mbed-os can use generic test-configs like HeapBlockDeviceAndEthernetInterface.json and HeapBlockDeviceAndWifiInterface.json. Otherwise you need to use a device specific test-config. Devices which have their network drivers residing inside mbed-os can use generic test_configs like HeapBlockDeviceAndEthernetInterface.json and HeapBlockDeviceAndWifiInterface.json. Otherwise you need to use a device specific test-config.
### Running the tests ### Running the tests
@ -42,10 +42,10 @@ Some devices may offer multiple network interfaces to operate with. For example,
The tests can be run for either one of those using already existing test-config -files. The tests can be run for either one of those using already existing test-config -files.
To run the tests with Wi-Fi interface: To run the tests with Wi-Fi interface:
`>mbed test -m UBLOX_EVK_ODIN_W2 -t <toolchain> --icetea --test-config tools/test-configs/HeapBlockDeviceAndWifiInterface.json` `>mbed test -m UBLOX_EVK_ODIN_W2 -t <toolchain> --icetea --test-config tools/test_configs/HeapBlockDeviceAndWifiInterface.json`
To run the tests with ethernet interface: To run the tests with ethernet interface:
`>mbed test -m UBLOX_EVK_ODIN_W2 -t <toolchain> --icetea --test-config tools/test-configs/HeapBlockDeviceAndEthernetInterface.json` `>mbed test -m UBLOX_EVK_ODIN_W2 -t <toolchain> --icetea --test-config tools/test_configs/HeapBlockDeviceAndEthernetInterface.json`
#### Providing Wi-Fi access point information #### Providing Wi-Fi access point information

View File

@ -69,17 +69,17 @@ pip install "gcovr>=4.1"
> In case of running into problems see [troubleshooting](#troubleshooting) section. > In case of running into problems see [troubleshooting](#troubleshooting) section.
`UNITTESTS/mbed_unittest.py` contains testing scripts for Mbed OS unit testing. Mbed CLI supports unit testing through `mbed unittest` command with the same arguments. `UNITTESTS/mbed_unittest.py` contains testing scripts for Mbed OS unit testing. Mbed CLI supports unit testing through `mbed test --unittests` command with the same arguments.
### Testing with Mbed CLI ### Testing with Mbed CLI
``` ```
mbed unittest mbed test --unittests
``` ```
A subset of tests can be run by providing `-r` flag for the tool which runs tests matching a regular expression. A subset of tests can be run by providing `-r` flag for the tool which runs tests matching a regular expression.
e.g. `mbed unittest --run -r features_netsocket` e.g. `mbed test --unittests --run -r features_netsocket`
### Build manually without Python tools ### Build manually without Python tools
@ -144,7 +144,7 @@ Run ctest dashboard test and create test results:
Python tools use gcovr to build code coverage reports. Generate html report `UNITTESTS/build/coverage/index.html` with: Python tools use gcovr to build code coverage reports. Generate html report `UNITTESTS/build/coverage/index.html` with:
``` ```
mbed unittest --coverage html mbed test --unittests --coverage html
``` ```
To get coverage for a single test suite, run gcovr separately for suite coverage data directory. See [gcovr documentation](https://gcovr.com/guide.html#filter-options) for more information. To get coverage for a single test suite, run gcovr separately for suite coverage data directory. See [gcovr documentation](https://gcovr.com/guide.html#filter-options) for more information.
@ -211,10 +211,10 @@ A unit test definition file `unittest.cmake` requires variables to be set for a
#### Creating unit tests files with Mbed CLI #### Creating unit tests files with Mbed CLI
``` ```
mbed unittest --new <FILEPATH> mbed test --unittests --new <FILEPATH>
``` ```
E.g. `mbed unittest --new rtos/Semaphore.cpp` E.g. `mbed test --unittests --new rtos/Semaphore.cpp`
The generator script only creates the files required for a unit test. It does not write unit tests automatically nor does it handle source dependencies. The generator script only creates the files required for a unit test. It does not write unit tests automatically nor does it handle source dependencies.

View File

@ -27,7 +27,12 @@ rtos::Mutex::~Mutex()
return; return;
} }
osStatus rtos::Mutex::lock(unsigned int) osStatus rtos::Mutex::lock(void)
{
return osOK;
}
osStatus rtos::Mutex::lock(uint32_t millisec)
{ {
return osOK; return osOK;
} }

View File

@ -34,6 +34,14 @@ MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC():
mbed_crc_ctor(); mbed_crc_ctor();
} }
template<>
MbedCRC<POLY_32BIT_REV_ANSI, 32>::MbedCRC():
_initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(false), _reflect_remainder(false),
_crc_table((uint32_t *)Table_CRC_32bit_Rev_ANSI)
{
mbed_crc_ctor();
}
template<> template<>
MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(): MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC():
_initial_value(0), _final_xor(0), _reflect_data(true), _reflect_remainder(true), _initial_value(0), _final_xor(0), _reflect_data(true), _reflect_remainder(true),

View File

@ -275,7 +275,7 @@ public:
p_crc = (uint32_t)(p_crc << (8 - width)); p_crc = (uint32_t)(p_crc << (8 - width));
} }
// Optimized algorithm for 32BitANSI does not need additional reflect_remainder // Optimized algorithm for 32BitANSI does not need additional reflect_remainder
if ((TABLE == _mode) && (POLY_32BIT_ANSI == polynomial)) { if ((TABLE == _mode) && (POLY_32BIT_REV_ANSI == polynomial)) {
*crc = (p_crc ^ _final_xor) & get_crc_mask(); *crc = (p_crc ^ _final_xor) & get_crc_mask();
} else { } else {
*crc = (reflect_remainder(p_crc) ^ _final_xor) & get_crc_mask(); *crc = (reflect_remainder(p_crc) ^ _final_xor) & get_crc_mask();
@ -415,7 +415,6 @@ private:
int32_t bitwise_compute_partial(const void *buffer, crc_data_size_t size, uint32_t *crc) const int32_t bitwise_compute_partial(const void *buffer, crc_data_size_t size, uint32_t *crc) const
{ {
MBED_ASSERT(crc != NULL); MBED_ASSERT(crc != NULL);
MBED_ASSERT(buffer != NULL);
const uint8_t *data = static_cast<const uint8_t *>(buffer); const uint8_t *data = static_cast<const uint8_t *>(buffer);
uint32_t p_crc = *crc; uint32_t p_crc = *crc;
@ -460,7 +459,6 @@ private:
int32_t table_compute_partial(const void *buffer, crc_data_size_t size, uint32_t *crc) const int32_t table_compute_partial(const void *buffer, crc_data_size_t size, uint32_t *crc) const
{ {
MBED_ASSERT(crc != NULL); MBED_ASSERT(crc != NULL);
MBED_ASSERT(buffer != NULL);
const uint8_t *data = static_cast<const uint8_t *>(buffer); const uint8_t *data = static_cast<const uint8_t *>(buffer);
uint32_t p_crc = *crc; uint32_t p_crc = *crc;
@ -480,11 +478,19 @@ private:
} }
} else { } else {
uint32_t *crc_table = (uint32_t *)_crc_table; uint32_t *crc_table = (uint32_t *)_crc_table;
if (POLY_32BIT_REV_ANSI == polynomial) {
for (crc_data_size_t i = 0; i < size; i++) { for (crc_data_size_t i = 0; i < size; i++) {
p_crc = (p_crc >> 4) ^ crc_table[(p_crc ^ (data[i] >> 0)) & 0xf]; p_crc = (p_crc >> 4) ^ crc_table[(p_crc ^ (data[i] >> 0)) & 0xf];
p_crc = (p_crc >> 4) ^ crc_table[(p_crc ^ (data[i] >> 4)) & 0xf]; p_crc = (p_crc >> 4) ^ crc_table[(p_crc ^ (data[i] >> 4)) & 0xf];
} }
} }
else {
for (crc_data_size_t byte = 0; byte < size; byte++) {
data_byte = reflect_bytes(data[byte]) ^ (p_crc >> (width - 8));
p_crc = crc_table[data_byte] ^ (p_crc << 8);
}
}
}
*crc = p_crc & get_crc_mask(); *crc = p_crc & get_crc_mask();
return 0; return 0;
} }
@ -497,6 +503,11 @@ private:
MBED_STATIC_ASSERT(width <= 32, "Max 32-bit CRC supported"); MBED_STATIC_ASSERT(width <= 32, "Max 32-bit CRC supported");
#ifdef DEVICE_CRC #ifdef DEVICE_CRC
if (POLY_32BIT_REV_ANSI == polynomial) {
_crc_table = (uint32_t *)Table_CRC_32bit_Rev_ANSI;
_mode = TABLE;
return;
}
crc_mbed_config_t config; crc_mbed_config_t config;
config.polynomial = polynomial; config.polynomial = polynomial;
config.width = width; config.width = width;
@ -510,10 +521,14 @@ private:
return; return;
} }
#endif #endif
switch (polynomial) { switch (polynomial) {
case POLY_32BIT_ANSI: case POLY_32BIT_ANSI:
_crc_table = (uint32_t *)Table_CRC_32bit_ANSI; _crc_table = (uint32_t *)Table_CRC_32bit_ANSI;
break; break;
case POLY_32BIT_REV_ANSI:
_crc_table = (uint32_t *)Table_CRC_32bit_Rev_ANSI;
break;
case POLY_8BIT_CCITT: case POLY_8BIT_CCITT:
_crc_table = (uint32_t *)Table_CRC_8bit_CCITT; _crc_table = (uint32_t *)Table_CRC_8bit_CCITT;
break; break;

View File

@ -91,7 +91,7 @@ qspi_status_t QSPI::set_frequency(int hz)
return ret_status; return ret_status;
} }
qspi_status_t QSPI::read(unsigned int address, char *rx_buffer, size_t *rx_length) qspi_status_t QSPI::read(int address, char *rx_buffer, size_t *rx_length)
{ {
qspi_status_t ret_status = QSPI_STATUS_ERROR; qspi_status_t ret_status = QSPI_STATUS_ERROR;
@ -115,7 +115,7 @@ qspi_status_t QSPI::read(unsigned int address, char *rx_buffer, size_t *rx_lengt
return ret_status; return ret_status;
} }
qspi_status_t QSPI::write(unsigned int address, const char *tx_buffer, size_t *tx_length) qspi_status_t QSPI::write(int address, const char *tx_buffer, size_t *tx_length)
{ {
qspi_status_t ret_status = QSPI_STATUS_ERROR; qspi_status_t ret_status = QSPI_STATUS_ERROR;
@ -139,7 +139,7 @@ qspi_status_t QSPI::write(unsigned int address, const char *tx_buffer, size_t *t
return ret_status; return ret_status;
} }
qspi_status_t QSPI::read(unsigned int instruction, unsigned int alt, unsigned int address, char *rx_buffer, size_t *rx_length) qspi_status_t QSPI::read(int instruction, int alt, int address, char *rx_buffer, size_t *rx_length)
{ {
qspi_status_t ret_status = QSPI_STATUS_ERROR; qspi_status_t ret_status = QSPI_STATUS_ERROR;
@ -163,7 +163,7 @@ qspi_status_t QSPI::read(unsigned int instruction, unsigned int alt, unsigned in
return ret_status; return ret_status;
} }
qspi_status_t QSPI::write(unsigned int instruction, unsigned int alt, unsigned int address, const char *tx_buffer, size_t *tx_length) qspi_status_t QSPI::write(int instruction, int alt, int address, const char *tx_buffer, size_t *tx_length)
{ {
qspi_status_t ret_status = QSPI_STATUS_ERROR; qspi_status_t ret_status = QSPI_STATUS_ERROR;
@ -187,7 +187,7 @@ qspi_status_t QSPI::write(unsigned int instruction, unsigned int alt, unsigned i
return ret_status; return ret_status;
} }
qspi_status_t QSPI::command_transfer(unsigned int instruction, int address, const char *tx_buffer, size_t tx_length, const char *rx_buffer, size_t rx_length) qspi_status_t QSPI::command_transfer(int instruction, int address, const char *tx_buffer, size_t tx_length, const char *rx_buffer, size_t rx_length)
{ {
qspi_status_t ret_status = QSPI_STATUS_ERROR; qspi_status_t ret_status = QSPI_STATUS_ERROR;

View File

@ -44,8 +44,12 @@ namespace mbed {
* *
* #include "mbed.h" * #include "mbed.h"
* *
* #define CMD_WRITE 0x02
* #define CMD_READ 0x03
* #define ADDRESS 0x1000
*
* // hardware ssel (where applicable) * // hardware ssel (where applicable)
* QSPI qspi_device(QSPI_PIN_IO0, QSPI_PIN_IO1, QSPI_PIN_IO2, QSPI_PIN_IO3, QSPI_PIN_SCK, QSPI_PIN_CSN); // io0, io1, io2, io3, sclk, ssel * QSPI qspi_device(QSPI_FLASH1_IO0, QSPI_FLASH1_IO1, QSPI_FLASH1_IO2, QSPI_FLASH1_IO3, QSPI_FLASH1_SCK, QSPI_FLASH1_CSN); // io0, io1, io2, io3, sclk, ssel
* *
* *
* int main() { * int main() {
@ -53,10 +57,14 @@ namespace mbed {
* char rx_buf[4]; * char rx_buf[4];
* int buf_len = sizeof(tx_buf); * int buf_len = sizeof(tx_buf);
* *
* int result = qspi_device.write( 0x12 , 0x100000 , 0 , tx_buf, &buf_len ); * qspi_status_t result = qspi_device.write(CMD_WRITE, 0, ADDRESS, tx_buf, &buf_len);
* if( !result ) printf("Write failed"); * if (result != QSPI_STATUS_OK) {
* int result = qspi_device.read( 0x13 , 0x100000 , 0 , rx_buf, &buf_len ); * printf("Write failed");
* if( !result ) printf("Read failed"); * }
* result = qspi_device.read(CMD_READ, 0, ADDRESS, rx_buf, &buf_len);
* if (result != QSPI_STATUS_OK) {
* printf("Read failed");
* }
* *
* } * }
* @endcode * @endcode
@ -118,7 +126,7 @@ public:
* @returns * @returns
* Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads. * Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads.
*/ */
qspi_status_t read(unsigned int address, char *rx_buffer, size_t *rx_length); qspi_status_t read(int address, char *rx_buffer, size_t *rx_length);
/** Write to QSPI peripheral using custom write instruction /** Write to QSPI peripheral using custom write instruction
* *
@ -129,12 +137,12 @@ public:
* @returns * @returns
* Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads. * Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads.
*/ */
qspi_status_t write(unsigned int address, const char *tx_buffer, size_t *tx_length); qspi_status_t write(int address, const char *tx_buffer, size_t *tx_length);
/** Read from QSPI peripheral using custom read instruction, alt values /** Read from QSPI peripheral using custom read instruction, alt values
* *
* @param instruction Instruction value to be used in instruction phase * @param instruction Instruction value to be used in instruction phase
* @param alt Alt value to be used in instruction phase * @param alt Alt value to be used in Alternate-byte phase. Use -1 for ignoring Alternate-byte phase
* @param address Address to be accessed in QSPI peripheral * @param address Address to be accessed in QSPI peripheral
* @param rx_buffer Buffer for data to be read from the peripheral * @param rx_buffer Buffer for data to be read from the peripheral
* @param rx_length Pointer to a variable containing the length of rx_buffer, and on return this variable will be updated with the actual number of bytes read * @param rx_length Pointer to a variable containing the length of rx_buffer, and on return this variable will be updated with the actual number of bytes read
@ -142,12 +150,12 @@ public:
* @returns * @returns
* Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads. * Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads.
*/ */
qspi_status_t read(unsigned int instruction, unsigned int alt, unsigned int address, char *rx_buffer, size_t *rx_length); qspi_status_t read(int instruction, int alt, int address, char *rx_buffer, size_t *rx_length);
/** Write to QSPI peripheral using custom write instruction, alt values /** Write to QSPI peripheral using custom write instruction, alt values
* *
* @param instruction Instruction value to be used in instruction phase * @param instruction Instruction value to be used in instruction phase
* @param alt Alt value to be used in instruction phase * @param alt Alt value to be used in Alternate-byte phase. Use -1 for ignoring Alternate-byte phase
* @param address Address to be accessed in QSPI peripheral * @param address Address to be accessed in QSPI peripheral
* @param tx_buffer Buffer containing data to be sent to peripheral * @param tx_buffer Buffer containing data to be sent to peripheral
* @param tx_length Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written * @param tx_length Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written
@ -155,12 +163,12 @@ public:
* @returns * @returns
* Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads. * Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads.
*/ */
qspi_status_t write(unsigned int instruction, unsigned int alt, unsigned int address, const char *tx_buffer, size_t *tx_length); qspi_status_t write(int instruction, int alt, int address, const char *tx_buffer, size_t *tx_length);
/** Perform a transaction to write to an address(a control register) and get the status results /** Perform a transaction to write to an address(a control register) and get the status results
* *
* @param instruction Instruction value to be used in instruction phase * @param instruction Instruction value to be used in instruction phase
* @param address Some instruction might require address. Use -1 for ignoring the address value * @param address Some instruction might require address. Use -1 if no address
* @param tx_buffer Buffer containing data to be sent to peripheral * @param tx_buffer Buffer containing data to be sent to peripheral
* @param tx_length Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written * @param tx_length Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written
* @param rx_buffer Buffer for data to be read from the peripheral * @param rx_buffer Buffer for data to be read from the peripheral
@ -169,7 +177,7 @@ public:
* @returns * @returns
* Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads. * Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads.
*/ */
qspi_status_t command_transfer(unsigned int instruction, int address, const char *tx_buffer, size_t tx_length, const char *rx_buffer, size_t rx_length); qspi_status_t command_transfer(int instruction, int address, const char *tx_buffer, size_t tx_length, const char *rx_buffer, size_t rx_length);
protected: protected:
/** Acquire exclusive access to this SPI bus /** Acquire exclusive access to this SPI bus

View File

@ -108,12 +108,48 @@ extern const uint16_t Table_CRC_16bit_IBM[MBED_CRC_TABLE_SIZE] = {
0x220, 0x8225, 0x822f, 0x22a, 0x823b, 0x23e, 0x234, 0x8231, 0x8213, 0x216, 0x21c, 0x8219 0x220, 0x8225, 0x822f, 0x22a, 0x823b, 0x23e, 0x234, 0x8231, 0x8213, 0x216, 0x21c, 0x8219
}; };
extern const uint32_t Table_CRC_32bit_ANSI[MBED_OPTIMIZED_CRC_TABLE_SIZE] = { extern const uint32_t Table_CRC_32bit_ANSI[MBED_CRC_TABLE_SIZE] = {
0x0, 0x4c11db7, 0x9823b6e, 0xd4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x18aeb13, 0x54bf6a4, 0x808d07d, 0xcc9cdca,
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
0x315d626, 0x7d4cb91, 0xa97ed48, 0xe56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, 0x29f3d35, 0x65e2082, 0xb1d065b, 0xfdc1bec,
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};
extern const uint32_t Table_CRC_32bit_Rev_ANSI[MBED_OPTIMIZED_CRC_TABLE_SIZE] = {
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
}; };
/** @}*/ /** @}*/
} // namespace mbed } // namespace mbed

View File

@ -30,7 +30,8 @@ extern const uint8_t Table_CRC_7Bit_SD[MBED_CRC_TABLE_SIZE];
extern const uint8_t Table_CRC_8bit_CCITT[MBED_CRC_TABLE_SIZE]; extern const uint8_t Table_CRC_8bit_CCITT[MBED_CRC_TABLE_SIZE];
extern const uint16_t Table_CRC_16bit_CCITT[MBED_CRC_TABLE_SIZE]; extern const uint16_t Table_CRC_16bit_CCITT[MBED_CRC_TABLE_SIZE];
extern const uint16_t Table_CRC_16bit_IBM[MBED_CRC_TABLE_SIZE]; extern const uint16_t Table_CRC_16bit_IBM[MBED_CRC_TABLE_SIZE];
extern const uint32_t Table_CRC_32bit_ANSI[MBED_OPTIMIZED_CRC_TABLE_SIZE]; extern const uint32_t Table_CRC_32bit_ANSI[MBED_CRC_TABLE_SIZE];
extern const uint32_t Table_CRC_32bit_Rev_ANSI[MBED_OPTIMIZED_CRC_TABLE_SIZE];
/** @}*/ /** @}*/
} // namespace mbed } // namespace mbed

View File

@ -1,5 +1,12 @@
# Change Log # Change Log
## [v4.6.3](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.6.3)
- Bug fix: Remove timed out blockwise message from resend queue. If blockwise message was timed out message was still kept in the resend queue which causes unnecessary reconnections on client side.
- Documentation: Document all the available macros.
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.6.2...v4.6.3)
## [v4.6.2](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.6.2) ## [v4.6.2](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.6.2)
Do not clear block2 in subsequent block request. Do not clear block2 in subsequent block request.

View File

@ -36,7 +36,6 @@
/** /**
* \def SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE * \def SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE
*
* \brief For Message blockwising * \brief For Message blockwising
* Init value for the maximum payload size to be sent and received at one blockwise message * Init value for the maximum payload size to be sent and received at one blockwise message
* Setting of this value to 0 with SN_COAP_BLOCKWISE_ENABLED will disable this feature, and * Setting of this value to 0 with SN_COAP_BLOCKWISE_ENABLED will disable this feature, and
@ -45,19 +44,8 @@
*/ */
#undef SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* 0 */ // < Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 #undef SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /* 0 */ // < Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024
/**
* \def COAP_DISABLE_OBS_FEATURE
*
* \brief Disables CoAP 'obs' sending feature
* as part of registration message, this might be
* needed to be enabled for some strict LWM2M server implementation.
* By default, this feature is disabled.
*/
#undef COAP_DISABLE_OBS_FEATURE
/** /**
* \def SN_COAP_DISABLE_RESENDINGS * \def SN_COAP_DISABLE_RESENDINGS
*
* \brief Disables resending feature. Resending feature should not be needed * \brief Disables resending feature. Resending feature should not be needed
* when using CoAP with TCP transport for example. By default resendings are * when using CoAP with TCP transport for example. By default resendings are
* enabled. Set to 1 to disable. * enabled. Set to 1 to disable.
@ -66,15 +54,20 @@
/** /**
* \def SN_COAP_RESENDING_QUEUE_SIZE_MSGS * \def SN_COAP_RESENDING_QUEUE_SIZE_MSGS
*
* \brief Sets the number of messages stored * \brief Sets the number of messages stored
* in the resending queue. Default is 2 * in the resending queue. Default is 2
*/ */
#undef SN_COAP_RESENDING_QUEUE_SIZE_MSGS /* 2 */ // < Default re-sending queue size - defines how many messages can be stored. Setting this to 0 disables feature #undef SN_COAP_RESENDING_QUEUE_SIZE_MSGS /* 2 */ // < Default re-sending queue size - defines how many messages can be stored. Setting this to 0 disables feature
/**
* \def DEFAULT_RESPONSE_TIMEOUT
* \brief Sets the CoAP re-send interval in seconds.
* By default is 10 seconds.
*/
#undef DEFAULT_RESPONSE_TIMEOUT
/** /**
* \def SN_COAP_RESENDING_QUEUE_SIZE_BYTES * \def SN_COAP_RESENDING_QUEUE_SIZE_BYTES
*
* \brief Sets the size of the re-sending buffer. * \brief Sets the size of the re-sending buffer.
* Setting this to 0 disables this feature. * Setting this to 0 disables this feature.
* By default, this feature is disabled. * By default, this feature is disabled.
@ -83,7 +76,6 @@
/** /**
* \def SN_COAP_MAX_INCOMING_MESSAGE_SIZE * \def SN_COAP_MAX_INCOMING_MESSAGE_SIZE
*
* \brief Sets the maximum size (in bytes) that * \brief Sets the maximum size (in bytes) that
* mbed Client will allow to be handled while * mbed Client will allow to be handled while
* receiving big payload in blockwise mode. * receiving big payload in blockwise mode.
@ -115,6 +107,75 @@
*/ */
#undef SN_COAP_BLOCKWISE_ENABLED /* 0 */ #undef SN_COAP_BLOCKWISE_ENABLED /* 0 */
/**
* \def SN_COAP_RESENDING_MAX_COUNT
* \brief Defines how many times CoAP library tries to re-send the CoAP packet.
* By default value is 3.
*/
#undef SN_COAP_RESENDING_MAX_COUNT /* 3 */
/**
* \def SN_COAP_MAX_ALLOWED_RESENDING_COUNT
* \brief Maximum allowed count of re-sending that can be set at runtime via
* 'sn_coap_protocol_set_retransmission_parameters()' API.
* By default value is 6.
*/
#undef SN_COAP_MAX_ALLOWED_RESENDING_COUNT /* 6 */
/**
* \def SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT
* \brief Maximum allowed re-send interval in seconds that can be set at runtime via
* 'sn_coap_protocol_set_retransmission_parameters()' API.
* By default value is 40.
*/
#undef SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT /* 40 */
/**
* \def SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS
* \brief Maximum allowed count of messages that can be stored into resend buffer at runtime via
* 'sn_coap_protocol_set_retransmission_buffer()' API.
* By default value is 6.
*/
#undef SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS /* 6 */
/**
* \def SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES
* \brief Maximum size of messages in bytes that can be stored into resend buffer at runtime via
* 'sn_coap_protocol_set_retransmission_buffer()' API.
* By default value is 512.
*/
#undef SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES /* 512 */
/**
* \def SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT
* \brief Maximum allowed number of saved messages for message duplicate searching
* that can be set via 'sn_coap_protocol_set_duplicate_buffer_size' API.
* By default value is 6.
*/
#undef SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT
/**
* \def SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED
* \brief Maximum time in seconds howe long message is kept for duplicate detection.
* By default 60 seconds.
*/
#undef SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED
/**
* \def SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
* \brief Maximum time in seconds how long (messages and payload) are be stored for blockwising.
* Longer time will increase the memory consumption in lossy networks.
* By default 60 seconds.
*/
#undef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
/**
* \def SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE
* \brief Maximum size of blockwise message that can be received.
* By default 65535 bytes.
*/
#undef SN_COAP_MAX_INCOMING_BLOCK_MESSAGE_SIZE
#ifdef MBED_CLIENT_USER_CONFIG_FILE #ifdef MBED_CLIENT_USER_CONFIG_FILE
#include MBED_CLIENT_USER_CONFIG_FILE #include MBED_CLIENT_USER_CONFIG_FILE
#endif #endif

View File

@ -1,6 +1,6 @@
{ {
"name": "mbed-coap", "name": "mbed-coap",
"version": "4.6.2", "version": "4.6.3",
"description": "COAP library", "description": "COAP library",
"keywords": [ "keywords": [
"coap", "coap",

View File

@ -1559,6 +1559,7 @@ static void sn_coap_protocol_handle_blockwise_timout(struct coap_s *handle)
/* Notify the application about the time out */ /* Notify the application about the time out */
removed_blocwise_msg_ptr->coap_msg_ptr->coap_status = COAP_STATUS_BUILDER_BLOCK_SENDING_FAILED; removed_blocwise_msg_ptr->coap_msg_ptr->coap_status = COAP_STATUS_BUILDER_BLOCK_SENDING_FAILED;
removed_blocwise_msg_ptr->coap_msg_ptr->msg_id = removed_blocwise_msg_ptr->msg_id; removed_blocwise_msg_ptr->coap_msg_ptr->msg_id = removed_blocwise_msg_ptr->msg_id;
sn_coap_protocol_delete_retransmission(handle, removed_blocwise_msg_ptr->msg_id);
handle->sn_coap_rx_callback(removed_blocwise_msg_ptr->coap_msg_ptr, NULL, removed_blocwise_msg_ptr->param); handle->sn_coap_rx_callback(removed_blocwise_msg_ptr->coap_msg_ptr, NULL, removed_blocwise_msg_ptr->param);
} }

View File

@ -242,10 +242,6 @@ typedef enum lora_events {
* 'link_check_resp' callback. The result is thus transported to the application * 'link_check_resp' callback. The result is thus transported to the application
* via callback function provided. * via callback function provided.
* *
* As can be seen from declaration, mbed::Callback<void(uint8_t, uint8_t)> *link_check_resp)
* carries two parameters. First one is Demodulation Margin and the second one
* is number of gateways involved in the path to network server.
*
* 'battery_level' callback goes in the down direction, i.e., it informs * 'battery_level' callback goes in the down direction, i.e., it informs
* the stack about the battery level by calling a function provided * the stack about the battery level by calling a function provided
* by the upper layers. * by the upper layers.
@ -257,11 +253,16 @@ typedef struct {
mbed::Callback<void(lorawan_event_t)> events; mbed::Callback<void(lorawan_event_t)> events;
/** /**
* Optional * This callback is optional
*
* The first parameter to the callback function is the demodulation margin, and the second
* parameter is the number of gateways that successfully received the last request.
*/ */
mbed::Callback<void(uint8_t, uint8_t)> link_check_resp; mbed::Callback<void(uint8_t, uint8_t)> link_check_resp;
/** /**
* This callback is optional. If the callback is not set, the stack returns 255 to gateway.
*
* Battery level return value must follow the specification * Battery level return value must follow the specification
* for DevStatusAns MAC command: * for DevStatusAns MAC command:
* *

View File

@ -1 +1 @@
mbedtls-2.13.0 mbedtls-2.13.1

View File

@ -27,7 +27,7 @@
# #
# Set the mbed TLS release to import (this can/should be edited before import) # Set the mbed TLS release to import (this can/should be edited before import)
MBED_TLS_RELEASE ?= mbedtls-2.13.0 MBED_TLS_RELEASE ?= mbedtls-2.13.1
# Translate between mbed TLS namespace and mbed namespace # Translate between mbed TLS namespace and mbed namespace
TARGET_PREFIX:=../ TARGET_PREFIX:=../

View File

@ -152,12 +152,21 @@
/** /**
* \def MBEDTLS_HAVE_TIME_DATE * \def MBEDTLS_HAVE_TIME_DATE
* *
* System has time.h and time(), gmtime() and the clock is correct. * System has time.h, time(), and an implementation for
* mbedtls_platform_gmtime_r() (see below).
* The time needs to be correct (not necesarily very accurate, but at least * The time needs to be correct (not necesarily very accurate, but at least
* the date should be correct). This is used to verify the validity period of * the date should be correct). This is used to verify the validity period of
* X.509 certificates. * X.509 certificates.
* *
* Comment if your system does not have a correct clock. * Comment if your system does not have a correct clock.
*
* \note mbedtls_platform_gmtime_r() is an abstraction in platform_util.h that
* behaves similarly to the gmtime_r() function from the C standard. Refer to
* the documentation for mbedtls_platform_gmtime_r() for more information.
*
* \note It is possible to configure an implementation for
* mbedtls_platform_gmtime_r() at compile-time by using the macro
* MBEDTLS_PLATFORM_GMTIME_R_ALT.
*/ */
//#define MBEDTLS_HAVE_TIME_DATE //#define MBEDTLS_HAVE_TIME_DATE
@ -3115,6 +3124,25 @@
*/ */
//#define MBEDTLS_PLATFORM_ZEROIZE_ALT //#define MBEDTLS_PLATFORM_ZEROIZE_ALT
/**
* Uncomment the macro to let Mbed TLS use your alternate implementation of
* mbedtls_platform_gmtime_r(). This replaces the default implementation in
* platform_util.c.
*
* gmtime() is not a thread-safe function as defined in the C standard. The
* library will try to use safer implementations of this function, such as
* gmtime_r() when available. However, if Mbed TLS cannot identify the target
* system, the implementation of mbedtls_platform_gmtime_r() will default to
* using the standard gmtime(). In this case, calls from the library to
* gmtime() will be guarded by the global mutex mbedtls_threading_gmtime_mutex
* if MBEDTLS_THREADING_C is enabled. We recommend that calls from outside the
* library are also guarded with this mutex to avoid race conditions. However,
* if the macro MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, Mbed TLS will
* unconditionally use the implementation for mbedtls_platform_gmtime_r()
* supplied at compile time.
*/
//#define MBEDTLS_PLATFORM_GMTIME_R_ALT
/* \} name SECTION: Customisation configuration options */ /* \} name SECTION: Customisation configuration options */
/* Target and application specific configurations */ /* Target and application specific configurations */

View File

@ -25,7 +25,17 @@
#ifndef MBEDTLS_PLATFORM_UTIL_H #ifndef MBEDTLS_PLATFORM_UTIL_H
#define MBEDTLS_PLATFORM_UTIL_H #define MBEDTLS_PLATFORM_UTIL_H
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include <stddef.h> #include <stddef.h>
#if defined(MBEDTLS_HAVE_TIME_DATE)
#include "mbedtls/platform_time.h"
#include <time.h>
#endif /* MBEDTLS_HAVE_TIME_DATE */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -55,6 +65,37 @@ extern "C" {
*/ */
void mbedtls_platform_zeroize( void *buf, size_t len ); void mbedtls_platform_zeroize( void *buf, size_t len );
#if defined(MBEDTLS_HAVE_TIME_DATE)
/**
* \brief Platform-specific implementation of gmtime_r()
*
* The function is a thread-safe abstraction that behaves
* similarly to the gmtime_r() function from Unix/POSIX.
*
* Mbed TLS will try to identify the underlying platform and
* make use of an appropriate underlying implementation (e.g.
* gmtime_r() for POSIX and gmtime_s() for Windows). If this is
* not possible, then gmtime() will be used. In this case, calls
* from the library to gmtime() will be guarded by the mutex
* mbedtls_threading_gmtime_mutex if MBEDTLS_THREADING_C is
* enabled. It is recommended that calls from outside the library
* are also guarded by this mutex.
*
* If MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, then Mbed TLS will
* unconditionally use the alternative implementation for
* mbedtls_platform_gmtime_r() supplied by the user at compile time.
*
* \param tt Pointer to an object containing time (in seconds) since the
* epoch to be converted
* \param tm_buf Pointer to an object where the results will be stored
*
* \return Pointer to an object of type struct tm on success, otherwise
* NULL
*/
struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
struct tm *tm_buf );
#endif /* MBEDTLS_HAVE_TIME_DATE */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -99,6 +99,17 @@ extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
#if defined(MBEDTLS_FS_IO) #if defined(MBEDTLS_FS_IO)
extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex; extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
#endif #endif
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
/* This mutex may or may not be used in the default definition of
* mbedtls_platform_gmtime_r(), but in order to determine that,
* we need to check POSIX features, hence modify _POSIX_C_SOURCE.
* With the current approach, this declaration is orphaned, lacking
* an accompanying definition, in case mbedtls_platform_gmtime_r()
* doesn't need it, but that's not a problem. */
extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_R_ALT */
#endif /* MBEDTLS_THREADING_C */ #endif /* MBEDTLS_THREADING_C */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -40,16 +40,16 @@
*/ */
#define MBEDTLS_VERSION_MAJOR 2 #define MBEDTLS_VERSION_MAJOR 2
#define MBEDTLS_VERSION_MINOR 13 #define MBEDTLS_VERSION_MINOR 13
#define MBEDTLS_VERSION_PATCH 0 #define MBEDTLS_VERSION_PATCH 1
/** /**
* The single version number has the following structure: * The single version number has the following structure:
* MMNNPP00 * MMNNPP00
* Major version | Minor version | Patch version * Major version | Minor version | Patch version
*/ */
#define MBEDTLS_VERSION_NUMBER 0x020D0000 #define MBEDTLS_VERSION_NUMBER 0x020D0100
#define MBEDTLS_VERSION_STRING "2.13.0" #define MBEDTLS_VERSION_STRING "2.13.1"
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.13.0" #define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.13.1"
#if defined(MBEDTLS_VERSION_C) #if defined(MBEDTLS_VERSION_C)

View File

@ -20,6 +20,14 @@
* This file is part of Mbed TLS (https://tls.mbed.org) * This file is part of Mbed TLS (https://tls.mbed.org)
*/ */
/*
* Ensure gmtime_r is available even with -std=c99; must be defined before
* config.h, which pulls in glibc's features.h. Harmless on other platforms.
*/
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200112L
#endif
#if !defined(MBEDTLS_CONFIG_FILE) #if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h" #include "mbedtls/config.h"
#else #else
@ -27,6 +35,7 @@
#endif #endif
#include "mbedtls/platform_util.h" #include "mbedtls/platform_util.h"
#include "mbedtls/threading.h"
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
@ -65,3 +74,62 @@ void mbedtls_platform_zeroize( void *buf, size_t len )
memset_func( buf, 0, len ); memset_func( buf, 0, len );
} }
#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */ #endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
#include <time.h>
#if !defined(_WIN32) && (defined(unix) || \
defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \
defined(__MACH__)))
#include <unistd.h>
#endif /* !_WIN32 && (unix || __unix || __unix__ ||
* (__APPLE__ && __MACH__)) */
#if !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \
( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \
_POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) )
/*
* This is a convenience shorthand macro to avoid checking the long
* preprocessor conditions above. Ideally, we could expose this macro in
* platform_util.h and simply use it in platform_util.c, threading.c and
* threading.h. However, this macro is not part of the Mbed TLS public API, so
* we keep it private by only defining it in this file
*/
#if ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) )
#define PLATFORM_UTIL_USE_GMTIME
#endif /* ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) */
#endif /* !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \
( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \
_POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) */
struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
struct tm *tm_buf )
{
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
return( ( gmtime_s( tm_buf, tt ) == 0 ) ? tm_buf : NULL );
#elif !defined(PLATFORM_UTIL_USE_GMTIME)
return( gmtime_r( tt, tm_buf ) );
#else
struct tm *lt;
#if defined(MBEDTLS_THREADING_C)
if( mbedtls_mutex_lock( &mbedtls_threading_gmtime_mutex ) != 0 )
return( NULL );
#endif /* MBEDTLS_THREADING_C */
lt = gmtime( tt );
if( lt != NULL )
{
memcpy( tm_buf, lt, sizeof( struct tm ) );
}
#if defined(MBEDTLS_THREADING_C)
if( mbedtls_mutex_unlock( &mbedtls_threading_gmtime_mutex ) != 0 )
return( NULL );
#endif /* MBEDTLS_THREADING_C */
return( ( lt == NULL ) ? NULL : tm_buf );
#endif /* _WIN32 && !EFIX64 && !EFI32 */
}
#endif /* MBEDTLS_HAVE_TIME_DATE && MBEDTLS_PLATFORM_GMTIME_R_ALT */

View File

@ -19,6 +19,14 @@
* This file is part of mbed TLS (https://tls.mbed.org) * This file is part of mbed TLS (https://tls.mbed.org)
*/ */
/*
* Ensure gmtime_r is available even with -std=c99; must be defined before
* config.h, which pulls in glibc's features.h. Harmless on other platforms.
*/
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200112L
#endif
#if !defined(MBEDTLS_CONFIG_FILE) #if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h" #include "mbedtls/config.h"
#else #else
@ -29,6 +37,36 @@
#include "mbedtls/threading.h" #include "mbedtls/threading.h"
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
#if !defined(_WIN32) && (defined(unix) || \
defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \
defined(__MACH__)))
#include <unistd.h>
#endif /* !_WIN32 && (unix || __unix || __unix__ ||
* (__APPLE__ && __MACH__)) */
#if !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \
( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \
_POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) )
/*
* This is a convenience shorthand macro to avoid checking the long
* preprocessor conditions above. Ideally, we could expose this macro in
* platform_util.h and simply use it in platform_util.c, threading.c and
* threading.h. However, this macro is not part of the Mbed TLS public API, so
* we keep it private by only defining it in this file
*/
#if ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) )
#define THREADING_USE_GMTIME
#endif /* ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) */
#endif /* !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \
( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \
_POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) */
#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_R_ALT */
#if defined(MBEDTLS_THREADING_PTHREAD) #if defined(MBEDTLS_THREADING_PTHREAD)
static void threading_mutex_init_pthread( mbedtls_threading_mutex_t *mutex ) static void threading_mutex_init_pthread( mbedtls_threading_mutex_t *mutex )
{ {
@ -114,6 +152,9 @@ void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t *
#if defined(MBEDTLS_FS_IO) #if defined(MBEDTLS_FS_IO)
mbedtls_mutex_init( &mbedtls_threading_readdir_mutex ); mbedtls_mutex_init( &mbedtls_threading_readdir_mutex );
#endif #endif
#if defined(THREADING_USE_GMTIME)
mbedtls_mutex_init( &mbedtls_threading_gmtime_mutex );
#endif
} }
/* /*
@ -124,6 +165,9 @@ void mbedtls_threading_free_alt( void )
#if defined(MBEDTLS_FS_IO) #if defined(MBEDTLS_FS_IO)
mbedtls_mutex_free( &mbedtls_threading_readdir_mutex ); mbedtls_mutex_free( &mbedtls_threading_readdir_mutex );
#endif #endif
#if defined(THREADING_USE_GMTIME)
mbedtls_mutex_free( &mbedtls_threading_gmtime_mutex );
#endif
} }
#endif /* MBEDTLS_THREADING_ALT */ #endif /* MBEDTLS_THREADING_ALT */
@ -136,5 +180,8 @@ void mbedtls_threading_free_alt( void )
#if defined(MBEDTLS_FS_IO) #if defined(MBEDTLS_FS_IO)
mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex MUTEX_INIT; mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex MUTEX_INIT;
#endif #endif
#if defined(THREADING_USE_GMTIME)
mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex MUTEX_INIT;
#endif
#endif /* MBEDTLS_THREADING_C */ #endif /* MBEDTLS_THREADING_C */

View File

@ -29,10 +29,6 @@
* http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
*/ */
/* Ensure gmtime_r is available even with -std=c99; must be included before
* config.h, which pulls in glibc's features.h. Harmless on other platforms. */
#define _POSIX_C_SOURCE 200112L
#if !defined(MBEDTLS_CONFIG_FILE) #if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h" #include "mbedtls/config.h"
#else #else
@ -67,6 +63,7 @@
#include "mbedtls/platform_time.h" #include "mbedtls/platform_time.h"
#endif #endif
#if defined(MBEDTLS_HAVE_TIME_DATE) #if defined(MBEDTLS_HAVE_TIME_DATE)
#include "mbedtls/platform_util.h"
#include <time.h> #include <time.h>
#endif #endif
@ -901,11 +898,7 @@ static int x509_get_current_time( mbedtls_x509_time *now )
int ret = 0; int ret = 0;
tt = mbedtls_time( NULL ); tt = mbedtls_time( NULL );
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) lt = mbedtls_platform_gmtime_r( &tt, &tm_buf );
lt = gmtime_s( &tm_buf, &tt ) == 0 ? &tm_buf : NULL;
#else
lt = gmtime_r( &tt, &tm_buf );
#endif
if( lt == NULL ) if( lt == NULL )
ret = -1; ret = -1;

View File

@ -397,6 +397,7 @@ void NFCEEPROM::continue_read()
_driver->read_bytes(_eeprom_address, ac_buffer_builder_write_position(buffer_builder), _ndef_buffer_read_sz - _eeprom_address); _driver->read_bytes(_eeprom_address, ac_buffer_builder_write_position(buffer_builder), _ndef_buffer_read_sz - _eeprom_address);
} else { } else {
// Done, close session // Done, close session
_current_op = nfc_eeprom_read_end_session;
_operation_result = NFC_OK; _operation_result = NFC_OK;
_driver->end_session(); _driver->end_session();
} }

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,14 @@
#include "errno.h" #include "errno.h"
#include "lfs.h" #include "lfs.h"
#include "lfs_util.h" #include "lfs_util.h"
#include "MbedCRC.h"
extern "C" void lfs_crc(uint32_t *crc, const void *buffer, size_t size)
{
uint32_t initial_xor = *crc;
MbedCRC<POLY_32BIT_REV_ANSI, 32> ct(initial_xor, 0x0, true, false);
ct.compute((void *)buffer, size, (uint32_t *) crc);
}
////// Conversion functions ////// ////// Conversion functions //////
static int lfs_toerror(int err) static int lfs_toerror(int err)

View File

@ -6,11 +6,10 @@
*/ */
#include "lfs_util.h" #include "lfs_util.h"
// Only compile if user does not provide custom config // Only compile if user does not provide custom config
#ifndef LFS_CONFIG #ifndef LFS_CONFIG
#ifndef __MBED__
// Software CRC implementation with small lookup table
void lfs_crc(uint32_t *restrict crc, const void *buffer, size_t size) { void lfs_crc(uint32_t *restrict crc, const void *buffer, size_t size) {
static const uint32_t rtable[16] = { static const uint32_t rtable[16] = {
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
@ -20,12 +19,10 @@ void lfs_crc(uint32_t *restrict crc, const void *buffer, size_t size) {
}; };
const uint8_t *data = buffer; const uint8_t *data = buffer;
for (size_t i = 0; i < size; i++) { for (size_t i = 0; i < size; i++) {
*crc = (*crc >> 4) ^ rtable[(*crc ^ (data[i] >> 0)) & 0xf]; *crc = (*crc >> 4) ^ rtable[(*crc ^ (data[i] >> 0)) & 0xf];
*crc = (*crc >> 4) ^ rtable[(*crc ^ (data[i] >> 4)) & 0xf]; *crc = (*crc >> 4) ^ rtable[(*crc ^ (data[i] >> 4)) & 0xf];
} }
} }
#endif
#endif #endif

View File

@ -80,15 +80,17 @@ MBED_WEAK FileSystem *FileSystem::get_default_instance()
{ {
#if COMPONENT_SPIF || COMPONENT_DATAFLASH #if COMPONENT_SPIF || COMPONENT_DATAFLASH
static LittleFileSystem default_fs("fs", BlockDevice::get_default_instance()); static LittleFileSystem flash("flash", BlockDevice::get_default_instance());
flash.set_as_default();
return &default_fs; return &flash;
#elif COMPONENT_SD #elif COMPONENT_SD
static FATFileSystem default_fs("fs", BlockDevice::get_default_instance()); static FATFileSystem sdcard("sd", BlockDevice::get_default_instance());
sdcard.set_as_default();
return &default_fs; return &sdcard;
#else #else

View File

@ -33,6 +33,7 @@ typedef enum crc_polynomial {
POLY_16BIT_CCITT = 0x1021, // x16+x12+x5+1 POLY_16BIT_CCITT = 0x1021, // x16+x12+x5+1
POLY_16BIT_IBM = 0x8005, // x16+x15+x2+1 POLY_16BIT_IBM = 0x8005, // x16+x15+x2+1
POLY_32BIT_ANSI = 0x04C11DB7, // x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1 POLY_32BIT_ANSI = 0x04C11DB7, // x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1
POLY_32BIT_REV_ANSI = 0xEDB88320
} crc_polynomial_t; } crc_polynomial_t;
typedef struct crc_mbed_config { typedef struct crc_mbed_config {

View File

@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include <cstring>
#include "platform/FileBase.h" #include "platform/FileBase.h"
#include "platform/FileLike.h" #include "platform/FileLike.h"
#include "platform/FileHandle.h" #include "platform/FileHandle.h"
@ -21,6 +23,7 @@ namespace mbed {
FileBase *FileBase::_head = NULL; FileBase *FileBase::_head = NULL;
SingletonPtr<PlatformMutex> FileBase::_mutex; SingletonPtr<PlatformMutex> FileBase::_mutex;
FileBase *FileBase::_default = NULL;
FileBase::FileBase(const char *name, PathType t) : _next(NULL), FileBase::FileBase(const char *name, PathType t) : _next(NULL),
_name(name), _name(name),
@ -52,26 +55,41 @@ FileBase::~FileBase()
p->_next = _next; p->_next = _next;
} }
} }
if (_default == this) {
_default == NULL;
}
_mutex->unlock(); _mutex->unlock();
if (getPathType() == FilePathType) { if (getPathType() == FilePathType) {
extern void remove_filehandle(FileHandle * file); extern void remove_filehandle(FileHandle *file);
remove_filehandle(static_cast<FileHandle *>(static_cast<FileLike *>(this))); remove_filehandle(static_cast<FileLike *>(this));
} }
} }
void FileBase::set_as_default()
{
_mutex->lock();
_default = this;
_mutex->unlock();
}
FileBase *FileBase::lookup(const char *name, unsigned int len) FileBase *FileBase::lookup(const char *name, unsigned int len)
{ {
_mutex->lock(); _mutex->lock();
FileBase *p = _head; FileBase *p = _head;
while (p != NULL) { while (p != NULL) {
/* Check that p->_name matches name and is the correct length */ /* Check that p->_name matches name and is the correct length */
if (p->_name != NULL && std::strncmp(p->_name, name, len) == 0 && std::strlen(p->_name) == len) { if (p->_name != NULL && len == std::strlen(p->_name) && std::memcmp(p->_name, name, len) == 0) {
_mutex->unlock(); _mutex->unlock();
return p; return p;
} }
p = p->_next; p = p->_next;
} }
if (len == (sizeof "default") - 1 && std::memcmp("default", name, len) == 0) {
return _default;
}
_mutex->unlock(); _mutex->unlock();
return NULL; return NULL;
} }

View File

@ -18,9 +18,6 @@
typedef int FILEHANDLE; typedef int FILEHANDLE;
#include <cstdio>
#include <cstring>
#include "platform/platform.h" #include "platform/platform.h"
#include "platform/SingletonPtr.h" #include "platform/SingletonPtr.h"
#include "platform/PlatformMutex.h" #include "platform/PlatformMutex.h"
@ -55,9 +52,11 @@ public:
static FileBase *get(int n); static FileBase *get(int n);
/* disallow copy constructor and assignment operators */ void set_as_default();
private: private:
static FileBase *_head; static FileBase *_head;
static FileBase *_default;
static SingletonPtr<PlatformMutex> _mutex; static SingletonPtr<PlatformMutex> _mutex;
FileBase *_next; FileBase *_next;

View File

@ -237,11 +237,6 @@ typedef enum {
TSI_ELEC0 = PTB16, TSI_ELEC0 = PTB16,
TSI_ELEC1 = PTB17, TSI_ELEC1 = PTB17,
SPI_MOSI = PTD2,
SPI_MISO = PTD3,
SPI_CLK = PTD1,
SPI_PERSISTENT_MEM_CS = PTC2,
// Not connected // Not connected
NC = (int)0xFFFFFFFF NC = (int)0xFFFFFFFF
} PinName; } PinName;

View File

@ -236,11 +236,6 @@ typedef enum {
TSI_ELEC0 = PTB16, TSI_ELEC0 = PTB16,
TSI_ELEC1 = PTB17, TSI_ELEC1 = PTB17,
SPI_MOSI = PTD2,
SPI_MISO = PTD3,
SPI_SCK = PTD1,
SPI_PERSISTENT_MEM_CS = PTD0,
// Not connected // Not connected
NC = (int)0xFFFFFFFF NC = (int)0xFFFFFFFF
} PinName; } PinName;

View File

@ -242,11 +242,6 @@ typedef enum {
TSI_ELEC0 = PTB16, TSI_ELEC0 = PTB16,
TSI_ELEC1 = PTB17, TSI_ELEC1 = PTB17,
SPI_MOSI = PTD6,
SPI_MISO = PTD7,
SPI_SCK = PTD5,
SPI_PERSISTENT_MEM_CS = PTD4,
// Not connected // Not connected
NC = (int)0xFFFFFFFF NC = (int)0xFFFFFFFF
} PinName; } PinName;

View File

@ -242,11 +242,6 @@ typedef enum {
DAC0_OUT = 0xFEFE, /* DAC does not have Pin Name in RM */ DAC0_OUT = 0xFEFE, /* DAC does not have Pin Name in RM */
SPI_MOSI = PTE3,
SPI_MISO = PTE1,
SPI_SCK = PTE2,
SPI_PERSISTENT_MEM_CS = PTE4,
// Not connected // Not connected
NC = (int)0xFFFFFFFF NC = (int)0xFFFFFFFF
} PinName; } PinName;

View File

@ -134,11 +134,6 @@ typedef enum {
A4 = PTC2, A4 = PTC2,
A5 = PTC1, A5 = PTC1,
SPI_MOSI = PTD6,
SPI_MISO = PTD7,
SPI_SCK = PTD5,
SPI_PERSISTENT_MEM_CS = PTD4,
// Not connected // Not connected
NC = (int)0xFFFFFFFF NC = (int)0xFFFFFFFF
} PinName; } PinName;

View File

@ -243,11 +243,6 @@ typedef enum {
DAC0_OUT = 0xFEFE, /* DAC does not have Pin Name in RM */ DAC0_OUT = 0xFEFE, /* DAC does not have Pin Name in RM */
SPI_MOSI = PTD6,
SPI_MISO = PTD7,
SPI_SCK = PTD5,
SPI_PERSISTENT_MEM_CS = PTD4,
// Not connected // Not connected
NC = (int)0xFFFFFFFF NC = (int)0xFFFFFFFF
} PinName; } PinName;

View File

@ -9,13 +9,13 @@
#define MBED_APP_SIZE 0x80000 #define MBED_APP_SIZE 0x80000
#endif #endif
/* If app_start is 0, do not set aside space for the softdevice */ /* If softdevice is present, set aside space for it */
#if MBED_APP_START == 0 #if defined(SOFTDEVICE_PRESENT)
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x10000
#else
#define MBED_RAM_START 0x200031D0 #define MBED_RAM_START 0x200031D0
#define MBED_RAM_SIZE 0xCE30 #define MBED_RAM_SIZE 0xCE30
#else
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x10000
#endif #endif
#define MBED_RAM0_START MBED_RAM_START #define MBED_RAM0_START MBED_RAM_START

View File

@ -25,13 +25,13 @@
#define MBED_APP_SIZE 0x80000 #define MBED_APP_SIZE 0x80000
#endif #endif
/* If app_start is 0, do not set aside space for the softdevice */ /* If softdevice is present, set aside space for it */
#if MBED_APP_START == 0 #if defined(SOFTDEVICE_PRESENT)
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x10000
#else
#define MBED_RAM_START 0x200031D0 #define MBED_RAM_START 0x200031D0
#define MBED_RAM_SIZE 0xCE30 #define MBED_RAM_SIZE 0xCE30
#else
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x10000
#endif #endif
#define MBED_RAM0_START MBED_RAM_START #define MBED_RAM0_START MBED_RAM_START

View File

@ -11,13 +11,13 @@ if (!isdefinedsymbol(MBED_APP_SIZE)) {
define symbol MBED_APP_SIZE = 0x80000; define symbol MBED_APP_SIZE = 0x80000;
} }
/* If app_start is 0, do not set aside space for the softdevice */ /* If softdevice is present, set aside space for it */
if (MBED_APP_START == 0) { if (isdefinedsymbol(SOFTDEVICE_PRESENT)) {
define symbol MBED_RAM_START = 0x20000000;
define symbol MBED_RAM_SIZE = 0x10000;
} else {
define symbol MBED_RAM_START = 0x200031D0; define symbol MBED_RAM_START = 0x200031D0;
define symbol MBED_RAM_SIZE = 0xCE30; define symbol MBED_RAM_SIZE = 0xCE30;
} else {
define symbol MBED_RAM_START = 0x20000000;
define symbol MBED_RAM_SIZE = 0x10000;
} }
define symbol MBED_RAM0_START = MBED_RAM_START; define symbol MBED_RAM0_START = MBED_RAM_START;

View File

@ -198,11 +198,6 @@ typedef enum {
SPIS_PSELSS = P1_1, SPIS_PSELSS = P1_1,
SPIS_PSELSCK = P1_4, SPIS_PSELSCK = P1_4,
SPI_MOSI = p20,
SPI_MISO = p21,
SPI_SCK = p19,
SPI_PERSISTENT_MEM_CS = p17,
I2C_SDA0 = p26, I2C_SDA0 = p26,
I2C_SCL0 = p27, I2C_SCL0 = p27,

View File

@ -128,11 +128,6 @@ typedef enum {
SW2 = PA_15, SW2 = PA_15,
SW3 = PA_14, SW3 = PA_14,
SPI_MOSI = PD_13,
SPI_MISO = PD_14,
SPI_SCK = PD_15,
SPI_PERSISTENT_MEM_CS = PD_12,
} PinName; } PinName;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -128,11 +128,6 @@ typedef enum {
SW2 = PG_15, SW2 = PG_15,
SW3 = PF_11, SW3 = PF_11,
SPI_MOSI = D11,
SPI_MISO = D12,
SPI_SCK = D13,
SPI_PERSISTENT_MEM_CS = D10,
} PinName; } PinName;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -131,11 +131,6 @@ typedef enum {
SW1 = PC_12, SW1 = PC_12,
SW2 = PC_13, SW2 = PC_13,
SPI_MOSI = PF_0,
SPI_MISO = PD_15,
SPI_SCK = PD_14,
SPI_PERSISTENT_MEM_CS = PD_13,
} PinName; } PinName;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -148,11 +148,6 @@ typedef enum {
SDSCLK = P1_29, SDSCLK = P1_29,
SDSSEL = P1_12, SDSSEL = P1_12,
SPI_MOSI = SDMOSI,
SPI_MISO = SDMISO,
SPI_SCK = SDSCLK,
SPI_PERSISTENT_MEM_CS = SDSSEL,
// Not connected // Not connected
NC = (int)0xFFFFFFFF, NC = (int)0xFFFFFFFF,
} PinName; } PinName;

View File

@ -149,12 +149,6 @@ typedef enum {
I2C_SDA2 = P0_10, // pin used by application board I2C_SDA2 = P0_10, // pin used by application board
I2C_SCL = I2C_SCL2, I2C_SCL = I2C_SCL2,
I2C_SDA = I2C_SDA2, I2C_SDA = I2C_SDA2,
SPI_MOSI = p5,
SPI_MISO = p6,
SPI_SCK = p7,
SPI_PERSISTENT_MEM_CS = p8
} PinName; } PinName;
typedef enum { typedef enum {

View File

@ -117,11 +117,6 @@ typedef enum {
I2C_SCL = D15, I2C_SCL = D15,
I2C_SDA = D14, I2C_SDA = D14,
SPI_MOSI = p5,
SPI_MISO = p6,
SPI_SCK = p7,
SPI_PERSISTENT_MEM_CS = p8,
// Not connected // Not connected
NC = (int)0xFFFFFFFF NC = (int)0xFFFFFFFF
} PinName; } PinName;

View File

@ -128,13 +128,7 @@ typedef enum {
A2 = P1_8, A2 = P1_8,
A3 = P1_10, A3 = P1_10,
A4 = P1_4, A4 = P1_4,
A5 = P1_5, A5 = P1_5
SPI_MOSI = P0_20,
SPI_MISO = P0_18,
SPI_SCK = P0_19,
SPI_PERSISTENT_MEM_CS = P1_2
} PinName; } PinName;

View File

@ -89,11 +89,6 @@ typedef enum {
// Standardized button names // Standardized button names
BUTTON1 = USER_BUTTON0, BUTTON1 = USER_BUTTON0,
SPI_MOSI = P5_6,
SPI_MISO = P5_7,
SPI_SCK = P5_4,
SPI_PERSISTENT_MEM_CS = P5_5,
// Not connected // Not connected
NC = (int)0xFFFFFFFF NC = (int)0xFFFFFFFF
} PinName; } PinName;

View File

@ -216,9 +216,7 @@ typedef enum {
D15 = PB_2, D15 = PB_2,
D16 = PA_1, D16 = PA_1,
D17 = PA_0, D17 = PA_0,
D18 = PE_5, D18 = PE_5
SPI_PERSISTENT_MEM_CS = D9
} PinName; } PinName;

View File

@ -228,7 +228,6 @@ typedef enum {
SPI_MISO = PA_6, SPI_MISO = PA_6,
SPI_SCK = PA_5, SPI_SCK = PA_5,
SPI_CS = PB_6, SPI_CS = PB_6,
SPI_PERSISTENT_MEM_CS = PB_6,
PWM_OUT = PB_3, PWM_OUT = PB_3,
/**** OSCILLATOR pins ****/ /**** OSCILLATOR pins ****/

View File

@ -186,12 +186,9 @@ typedef enum {
SPI_MOSI = SPI1_MOSI, SPI_MOSI = SPI1_MOSI,
SPI_MISO = SPI1_MISO, SPI_MISO = SPI1_MISO,
SPI_SCK = SPI1_SCK, SPI_SCK = SPI1_SCK,
SPI_CS1 = PA_3, //LCD CS SPI_CS1 = PA_3, //LCD CS
SPI_CS2 = PA_15, //SD Card CS SPI_CS2 = PA_15, //SD Card CS
SPI_PERSISTENT_MEM_CS = SPI_CS2,
SERIAL_TX = PA_2, SERIAL_TX = PA_2,
SERIAL_RX = PA_3, SERIAL_RX = PA_3,
SERIAL_RTS = PA_0, SERIAL_RTS = PA_0,

View File

@ -219,7 +219,6 @@ typedef enum {
SPI_MISO = P_7, SPI_MISO = P_7,
SPI_SCK = P_6, SPI_SCK = P_6,
SPI_CS = P_5, SPI_CS = P_5,
SPI_PERSISTENT_MEM_CS = P_33,
// STDIO for console print // STDIO for console print
#ifdef MBED_CONF_TARGET_STDIO_UART_TX #ifdef MBED_CONF_TARGET_STDIO_UART_TX

View File

@ -271,7 +271,6 @@ typedef enum {
SPI_MISO = P_25, SPI_MISO = P_25,
SPI_SCK = P_24, SPI_SCK = P_24,
SPI_CS = P_22, SPI_CS = P_22,
SPI_PERSISTENT_MEM_CS = P_36,
// STDIO for console print // STDIO for console print
#ifdef MBED_CONF_TARGET_STDIO_UART_TX #ifdef MBED_CONF_TARGET_STDIO_UART_TX

View File

@ -151,8 +151,6 @@ typedef enum {
SPI_MISO = D12, SPI_MISO = D12,
SPI_CLK = D13, SPI_CLK = D13,
SPI_NSS = D10, SPI_NSS = D10,
SPI_PERSISTENT_MEM_CS = SPI_NSS,
// STDIO for console print // STDIO for console print
#ifdef MBED_CONF_TARGET_STDIO_UART_TX #ifdef MBED_CONF_TARGET_STDIO_UART_TX

View File

@ -176,7 +176,6 @@ typedef enum {
SPI_MISO = SPI0_MISO, SPI_MISO = SPI0_MISO,
SPI_SCK = SPI0_SCK, SPI_SCK = SPI0_SCK,
SPI_CS = SPI0_CS, SPI_CS = SPI0_CS,
SPI_PERSISTENT_MEM_CS = PG_4,
// STDIO for console print // STDIO for console print
#ifdef MBED_CONF_TARGET_STDIO_UART_TX #ifdef MBED_CONF_TARGET_STDIO_UART_TX

View File

@ -168,12 +168,11 @@ typedef enum {
SPI0_CS = D10, SPI0_CS = D10,
SPI1_CS = D9, SPI1_CS = D9,
SPI_MOSI = SPI0_MOSI, SPI_MOSI = SPI0_MOSI,
SPI_MISO = SPI0_MISO, SPI_MISO = SPI0_MISO,
SPI_SCK = SPI0_SCK, SPI_SCK = SPI0_SCK,
SPI_CS = SPI0_CS, SPI_CS = SPI0_CS,
SPI_PERSISTENT_MEM_CS = SPI_CS,
// Standardized button names // Standardized button names
BUTTON1 = SW0, BUTTON1 = SW0,

View File

@ -133,7 +133,6 @@ typedef enum {
SPI_MISO = PB_4, SPI_MISO = PB_4,
SPI_SCK = PB_3, SPI_SCK = PB_3,
SPI_CS = PA_11, SPI_CS = PA_11,
SPI_PERSISTENT_MEM_CS = PA_11,
PWM_OUT = PB_0, PWM_OUT = PB_0,
/**** OSCILLATOR pins ****/ /**** OSCILLATOR pins ****/

View File

@ -239,16 +239,7 @@ typedef enum {
SPI_MISO = D12, SPI_MISO = D12,
SPI_SCK = D13, SPI_SCK = D13,
SPI_CS = D10, SPI_CS = D10,
SPI_PERSISTENT_MEM_CS = D10,
PWM_OUT = D9, PWM_OUT = D9,
#ifdef DEVICE_QSPI
QSPI_PIN_IO0 = PE_12,
QSPI_PIN_IO1 = PE_13,
QSPI_PIN_IO2 = PE_14,
QSPI_PIN_IO3 = PE_15,
QSPI_PIN_SCK = PE_10,
QSPI_PIN_CSN = PE_11,
#endif
/**** USB pins ****/ /**** USB pins ****/
USB_OTG_FS_DM = PA_11, USB_OTG_FS_DM = PA_11,

View File

@ -208,7 +208,6 @@ typedef enum {
SPI_MISO = PA_6, SPI_MISO = PA_6,
SPI_SCK = PA_5, SPI_SCK = PA_5,
SPI_CS = PB_6, SPI_CS = PB_6,
SPI_PERSISTENT_MEM_CS = PB_6,
PWM_OUT = PB_3, PWM_OUT = PB_3,
/**** USB pins ****/ /**** USB pins ****/

View File

@ -124,7 +124,6 @@ typedef enum {
SPI_SCK = PA_5, SPI_SCK = PA_5,
SPI_CS0 = PA_4, SPI_CS0 = PA_4,
SPI_CS = SPI_CS0, SPI_CS = SPI_CS0,
SPI_PERSISTENT_MEM_CS = PB_12,
I2C1_SDA = PB_11, I2C1_SDA = PB_11,
I2C1_SCL = PB_10, I2C1_SCL = PB_10,

View File

@ -38,8 +38,6 @@
extern uint32_t __mbed_sbrk_start; extern uint32_t __mbed_sbrk_start;
extern uint32_t __mbed_krbs_start; extern uint32_t __mbed_krbs_start;
#define STM32L4_HEAP_ALIGN 32
#define STM32L4_ALIGN_UP(X, ALIGN) (((X) + (ALIGN) - 1) & ~((ALIGN) - 1))
/** /**
* The default implementation of _sbrk() (in platform/mbed_retarget.cpp) for GCC_ARM requires one-region model (heap and * The default implementation of _sbrk() (in platform/mbed_retarget.cpp) for GCC_ARM requires one-region model (heap and
* stack share one region), which doesn't fit two-region model (heap and stack are two distinct regions), for example, * stack share one region), which doesn't fit two-region model (heap and stack are two distinct regions), for example,
@ -50,10 +48,10 @@ extern uint32_t __mbed_krbs_start;
void *__wrap__sbrk(int incr) void *__wrap__sbrk(int incr)
{ {
static uint32_t heap_ind = (uint32_t) &__mbed_sbrk_start; static uint32_t heap_ind = (uint32_t) &__mbed_sbrk_start;
uint32_t heap_ind_old = STM32L4_ALIGN_UP(heap_ind, STM32L4_HEAP_ALIGN); uint32_t heap_ind_old = heap_ind;
uint32_t heap_ind_new = STM32L4_ALIGN_UP(heap_ind_old + incr, STM32L4_HEAP_ALIGN); uint32_t heap_ind_new = heap_ind_old + incr;
if (heap_ind_new > &__mbed_krbs_start) { if (heap_ind_new > (uint32_t)&__mbed_krbs_start) {
errno = ENOMEM; errno = ENOMEM;
return (void *) - 1; return (void *) - 1;
} }

View File

@ -74,13 +74,7 @@ typedef enum {
/* Board Controller */ /* Board Controller */
STDIO_UART_TX = USBTX, STDIO_UART_TX = USBTX,
STDIO_UART_RX = USBRX, STDIO_UART_RX = USBRX
SPI_MOSI = PC6,
SPI_MISO = PC7,
SPI_SCK = PC8,
SPI_PERSISTENT_MEM_CS = PC9
} PinName; } PinName;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1161,7 +1161,7 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None,
release_version - get the matrix for this major version number release_version - get the matrix for this major version number
""" """
# Only use it in this function so building works without extra modules # Only use it in this function so building works without extra modules
from prettytable import PrettyTable from prettytable import PrettyTable, HEADER
release_version = _lowercase_release_version(release_version) release_version = _lowercase_release_version(release_version)
version_release_targets = {} version_release_targets = {}
version_release_target_names = {} version_release_target_names = {}
@ -1183,7 +1183,7 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None,
# All tests status table print # All tests status table print
columns = prepend_columns + unique_supported_toolchains columns = prepend_columns + unique_supported_toolchains
table_printer = PrettyTable(columns) table_printer = PrettyTable(columns, junction_char="|", hrules=HEADER)
# Align table # Align table
for col in columns: for col in columns:
table_printer.align[col] = "c" table_printer.align[col] = "c"
@ -1271,10 +1271,10 @@ def print_build_memory_usage(report):
Positional arguments: Positional arguments:
report - Report generated during build procedure. report - Report generated during build procedure.
""" """
from prettytable import PrettyTable from prettytable import PrettyTable, HEADER
columns_text = ['name', 'target', 'toolchain'] columns_text = ['name', 'target', 'toolchain']
columns_int = ['static_ram', 'total_flash'] columns_int = ['static_ram', 'total_flash']
table = PrettyTable(columns_text + columns_int) table = PrettyTable(columns_text + columns_int, junction_char="|", hrules=HEADER)
for col in columns_text: for col in columns_text:
table.align[col] = 'l' table.align[col] = 'l'

View File

@ -19,7 +19,7 @@ import json
from argparse import ArgumentParser from argparse import ArgumentParser
from copy import deepcopy from copy import deepcopy
from collections import defaultdict from collections import defaultdict
from prettytable import PrettyTable from prettytable import PrettyTable, HEADER
from jinja2 import FileSystemLoader, StrictUndefined from jinja2 import FileSystemLoader, StrictUndefined
from jinja2.environment import Environment from jinja2.environment import Environment
@ -726,7 +726,7 @@ class MemapParser(object):
columns = ['Module'] columns = ['Module']
columns.extend(self.print_sections) columns.extend(self.print_sections)
table = PrettyTable(columns) table = PrettyTable(columns, junction_char="|", hrules=HEADER)
table.align["Module"] = "l" table.align["Module"] = "l"
for col in self.print_sections: for col in self.print_sections:
table.align[col] = 'r' table.align[col] = 'r'

View File

@ -23,7 +23,7 @@
"asm": [], "asm": [],
"c": ["-D__ASSERT_MSG", "-std=gnu99"], "c": ["-D__ASSERT_MSG", "-std=gnu99"],
"cxx": ["-fno-rtti", "-std=gnu++98"], "cxx": ["-fno-rtti", "-std=gnu++98"],
"ld": ["--verbose", "--remove", "--show_full_path"] "ld": ["--verbose", "--remove", "--show_full_path", "--legacyalign"]
}, },
"ARM": { "ARM": {
"common": ["-c", "--gnu", "-Otime", "--split_sections", "common": ["-c", "--gnu", "-Otime", "--split_sections",

View File

@ -22,7 +22,7 @@
"asm": [], "asm": [],
"c": ["-D__ASSERT_MSG", "-std=gnu99"], "c": ["-D__ASSERT_MSG", "-std=gnu99"],
"cxx": ["-fno-rtti", "-std=gnu++98"], "cxx": ["-fno-rtti", "-std=gnu++98"],
"ld": ["--show_full_path"] "ld": ["--show_full_path", "--legacyalign"]
}, },
"ARM": { "ARM": {
"common": ["-c", "--gnu", "-Otime", "--split_sections", "common": ["-c", "--gnu", "-Otime", "--split_sections",

View File

@ -22,7 +22,7 @@
"asm": [], "asm": [],
"c": ["-D__ASSERT_MSG", "-std=gnu99"], "c": ["-D__ASSERT_MSG", "-std=gnu99"],
"cxx": ["-fno-rtti", "-std=gnu++98"], "cxx": ["-fno-rtti", "-std=gnu++98"],
"ld": ["--show_full_path"] "ld": ["--show_full_path", "--legacyalign"]
}, },
"ARM": { "ARM": {
"common": ["-c", "--gnu", "-Ospace", "--split_sections", "common": ["-c", "--gnu", "-Ospace", "--split_sections",

View File

@ -32,7 +32,7 @@ import threading
import ctypes import ctypes
import functools import functools
from colorama import Fore, Back, Style from colorama import Fore, Back, Style
from prettytable import PrettyTable from prettytable import PrettyTable, HEADER
from copy import copy, deepcopy from copy import copy, deepcopy
from time import sleep, time from time import sleep, time
@ -766,7 +766,7 @@ class SingleTestRunner(object):
result_dict[test[TEST_INDEX]][test[TOOLCHAIN_INDEX]] = test[RESULT_INDEX] result_dict[test[TEST_INDEX]][test[TOOLCHAIN_INDEX]] = test[RESULT_INDEX]
pt_cols = ["Target", "Test ID", "Test Description"] + unique_target_toolchains pt_cols = ["Target", "Test ID", "Test Description"] + unique_target_toolchains
pt = PrettyTable(pt_cols) pt = PrettyTable(pt_cols, junction_char="|", hrules=HEADER)
for col in pt_cols: for col in pt_cols:
pt.align[col] = "l" pt.align[col] = "l"
pt.padding_width = 1 # One space between column edges and contents (default) pt.padding_width = 1 # One space between column edges and contents (default)
@ -794,7 +794,7 @@ class SingleTestRunner(object):
result = "Test summary:\n" result = "Test summary:\n"
# Pretty table package is used to print results # Pretty table package is used to print results
pt = PrettyTable(["Result", "Target", "Toolchain", "Test ID", "Test Description", pt = PrettyTable(["Result", "Target", "Toolchain", "Test ID", "Test Description",
"Elapsed Time (sec)", "Timeout (sec)", "Loops"]) "Elapsed Time (sec)", "Timeout (sec)", "Loops"], junction_char="|", hrules=HEADER)
pt.align["Result"] = "l" # Left align pt.align["Result"] = "l" # Left align
pt.align["Target"] = "l" # Left align pt.align["Target"] = "l" # Left align
pt.align["Toolchain"] = "l" # Left align pt.align["Toolchain"] = "l" # Left align
@ -1328,7 +1328,7 @@ def print_muts_configuration_from_json(json_data, join_delim=", ", platform_filt
# Prepare pretty table object to display all MUTs # Prepare pretty table object to display all MUTs
pt_cols = ["index"] + muts_info_cols pt_cols = ["index"] + muts_info_cols
pt = PrettyTable(pt_cols) pt = PrettyTable(pt_cols, junction_char="|", hrules=HEADER)
for col in pt_cols: for col in pt_cols:
pt.align[col] = "l" pt.align[col] = "l"
@ -1366,7 +1366,7 @@ def print_test_configuration_from_json(json_data, join_delim=", "):
# Prepare pretty table object to display test specification # Prepare pretty table object to display test specification
pt_cols = ["mcu"] + sorted(toolchains_info_cols) pt_cols = ["mcu"] + sorted(toolchains_info_cols)
pt = PrettyTable(pt_cols) pt = PrettyTable(pt_cols, junction_char="|", hrules=HEADER)
for col in pt_cols: for col in pt_cols:
pt.align[col] = "l" pt.align[col] = "l"
@ -1455,7 +1455,7 @@ def get_avail_tests_summary_table(cols=None, result_summary=True, join_delim=','
'duration'] if cols is None else cols 'duration'] if cols is None else cols
# All tests status table print # All tests status table print
pt = PrettyTable(test_properties) pt = PrettyTable(test_properties, junction_char="|", hrules=HEADER)
for col in test_properties: for col in test_properties:
pt.align[col] = "l" pt.align[col] = "l"
pt.align['duration'] = "r" pt.align['duration'] = "r"
@ -1495,7 +1495,7 @@ def get_avail_tests_summary_table(cols=None, result_summary=True, join_delim=','
if result_summary and not platform_filter: if result_summary and not platform_filter:
# Automation result summary # Automation result summary
test_id_cols = ['automated', 'all', 'percent [%]', 'progress'] test_id_cols = ['automated', 'all', 'percent [%]', 'progress']
pt = PrettyTable(test_id_cols) pt = PrettyTable(test_id_cols, junction_char="|", hrules=HEADER)
pt.align['automated'] = "r" pt.align['automated'] = "r"
pt.align['all'] = "r" pt.align['all'] = "r"
pt.align['percent [%]'] = "r" pt.align['percent [%]'] = "r"
@ -1509,7 +1509,7 @@ def get_avail_tests_summary_table(cols=None, result_summary=True, join_delim=','
# Test automation coverage table print # Test automation coverage table print
test_id_cols = ['id', 'automated', 'all', 'percent [%]', 'progress'] test_id_cols = ['id', 'automated', 'all', 'percent [%]', 'progress']
pt = PrettyTable(test_id_cols) pt = PrettyTable(test_id_cols, junction_char="|", hrules=HEADER)
pt.align['id'] = "l" pt.align['id'] = "l"
pt.align['automated'] = "r" pt.align['automated'] = "r"
pt.align['all'] = "r" pt.align['all'] = "r"

View File

@ -706,8 +706,8 @@ class mbedToolchain:
self._add_defines_from_region(region) self._add_defines_from_region(region)
if region.active: if region.active:
for define in [ for define in [
("%s_START" % active_region_name, region.start), ("%s_START" % active_region_name, "0x%x" % region.start),
("%s_SIZE" % active_region_name, region.size) ("%s_SIZE" % active_region_name, "0x%x" % region.size)
]: ]:
define_string = self.make_ld_define(*define) define_string = self.make_ld_define(*define)
self.ld.append(define_string) self.ld.append(define_string)
@ -747,6 +747,11 @@ class mbedToolchain:
self.config_data = config_data self.config_data = config_data
# new configuration data can change labels, so clear the cache # new configuration data can change labels, so clear the cache
self.labels = None self.labels = None
# pass info about softdevice presence to linker (see NRF52)
if "SOFTDEVICE_PRESENT" in config_data[1]:
define_string = self.make_ld_define("SOFTDEVICE_PRESENT", config_data[1]["SOFTDEVICE_PRESENT"].macro_value)
self.ld.append(define_string)
self.flags["ld"].append(define_string)
self.add_regions() self.add_regions()
# Creates the configuration header if needed: # Creates the configuration header if needed:

View File

@ -325,7 +325,7 @@ class ARM(mbedToolchain):
@staticmethod @staticmethod
def make_ld_define(name, value): def make_ld_define(name, value):
return "--predefine=\"-D%s=0x%x\"" % (name, value) return "--predefine=\"-D%s=%s\"" % (name, value)
@staticmethod @staticmethod
def redirect_symbol(source, sync, build_dir): def redirect_symbol(source, sync, build_dir):
@ -426,7 +426,7 @@ class ARMC6(ARM_STD):
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file] self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
# Add linking time preprocessor macro __DOMAIN_NS # Add linking time preprocessor macro __DOMAIN_NS
if target.core == "Cortex-M23-NS" or self.target.core == "Cortex-M33-NS": if target.core == "Cortex-M23-NS" or self.target.core == "Cortex-M33-NS":
define_string = self.make_ld_define("__DOMAIN_NS", 1) define_string = self.make_ld_define("__DOMAIN_NS", "0x1")
self.flags["ld"].append(define_string) self.flags["ld"].append(define_string)
asm_cpu = { asm_cpu = {

View File

@ -293,7 +293,7 @@ class GCC(mbedToolchain):
@staticmethod @staticmethod
def make_ld_define(name, value): def make_ld_define(name, value):
return "-D%s=0x%x" % (name, value) return "-D%s=%s" % (name, value)
@staticmethod @staticmethod
def redirect_symbol(source, sync, build_dir): def redirect_symbol(source, sync, build_dir):

View File

@ -273,7 +273,7 @@ class IAR(mbedToolchain):
@staticmethod @staticmethod
def make_ld_define(name, value): def make_ld_define(name, value):
return "--config_def %s=0x%x" % (name, value) return "--config_def %s=%s" % (name, value)
@staticmethod @staticmethod
def redirect_symbol(source, sync, build_dir): def redirect_symbol(source, sync, build_dir):