Skip to content

Commit 86723f7

Browse files
Jamie Smithszsampolat-ahmetozersaccli8
authored
Synchronize changes with Mbed upstream: September 2023 edition (#185)
* Fix null pointer dereferencing Add null check for return values of functions that are mostly (but not always) checked for null. E.g., since 98% of calls to protocol_stack_interface_info_get_by_id check for null, it is likely that the function can return null values in some cases, and omitting the check could crash the program. * Update MAX32660 peripheral drivers with final ones that use by SDK * Apply MAX32660 delta Update mbed hal function as per of SDK update Signed-off-by: Sadik.Ozer <[email protected]> * M2354: Fix debug failure in Mbed Studio In Mbed Studio, debugging, based on pyOCD, requires Mbed OS application code starting on the sector boundary. Modification list: 1. Update TF-M import assets with MCUboot header padding to sector aligned 2. Following above, change header size argument (-H) in wrapper.py command line 3. Following below, fix min-write-size (--align) to 4 (per flash_area_align()) in wrapper.py command line https://docs.mcuboot.com/design.html#image-trailer Related issue: ARMmbed#15417 * Do not clear interrupt flag during initialization This causes issue for repeaded initialization while using BufferedSerial mode Signed-off-by: Sadik.Ozer <[email protected]> * MAX32660, MAX32670 UART performance improvement Signed-off-by: Sadik.Ozer <[email protected]> * Handle negative values passed to close() Calling close() with negative numbers causes out-of-bounds indexing of the filehandles array. For example, this can happen if open() returns an error and the value is later passed to close(). * Moved a { to the same line as if Moved a { to the same line as if * add nullpointer check in LWIP::socket_close * Fix crash when using FDCAN3 RX IRQ on STM32G473 (and others) * connectivity: drivers: Update Nuvoton M467 EMAC DMA_IE ctl In IRQ Handler, to disable some interrupt type of DMA error. It could avoid unexpected repeated interrupt.The masked bit of DMA_IE could be recovered in next EMAC IRQ event. Signed-off-by: cyliang tw <[email protected]> * Add workaround for G474 hardfault * update drivers STM32WL CUBE V1.3.0 * Changed static to weak * Fix: Do not disable SPI for manual drive mode during transaction setup It has been reported that disabling SPI module causes glitch for manual SS drive mode Signed-off-by: Sadik.Ozer <[email protected]> * make cellular event queue size configurable update unit tests --------- Signed-off-by: Sadik.Ozer <[email protected]> Signed-off-by: cyliang tw <[email protected]> Co-authored-by: Mingjie Shen <[email protected]> Co-authored-by: Ahmet Polat <[email protected]> Co-authored-by: Sadik.Ozer <[email protected]> Co-authored-by: Chun-Chieh Li <[email protected]> Co-authored-by: alrvid <[email protected]> Co-authored-by: Jost, Chris <[email protected]> Co-authored-by: Joseph Duchesne <[email protected]> Co-authored-by: cyliang tw <[email protected]> Co-authored-by: Maxim Markin <[email protected]> Co-authored-by: Charles <[email protected]> Co-authored-by: Lukas Karel <[email protected]>
1 parent 162acab commit 86723f7

File tree

295 files changed

+27406
-12399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+27406
-12399
lines changed

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att/att_eatt.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static uint8_t eattL2cCocAcceptCback(dmConnId_t connId, uint8_t numChans)
267267
{
268268
eattConnCb_t *pCcb = eattGetConnCb(connId);
269269

270-
if ((pCcb->state == EATT_CONN_STATE_INITIATING) || (pCcb->state == EATT_CONN_STATE_RECONFIG))
270+
if (!pCcb || (pCcb->state == EATT_CONN_STATE_INITIATING) || (pCcb->state == EATT_CONN_STATE_RECONFIG))
271271
{
272272
// Reject all requests while busy connecting and configuring channels
273273
return 0;
@@ -348,6 +348,10 @@ static void eattReqNextChannels(dmConnId_t connId)
348348
eattConnCb_t *pConnCb = eattGetConnCb(connId);
349349
uint8_t numChans = pEattCfg->numChans - EattGetNumChannelsInUse(connId);
350350

351+
if (!pConnCb) {
352+
return;
353+
}
354+
351355
numChans = (numChans > L2C_MAX_EN_CHAN) ? L2C_MAX_EN_CHAN : numChans;
352356

353357
EATT_TRACE_INFO1("eattReqNextChannels: numChans: %d", numChans);
@@ -783,7 +787,7 @@ static void eattDmCback(dmEvt_t *pDmEvt)
783787
* \param connId DM channel ID.
784788
* \param slot EATT slot.
785789
*
786-
* \return None
790+
* \return L2CAP channel identifier.
787791
*/
788792
/*************************************************************************************************/
789793
uint16_t eattGetCid(dmConnId_t connId, uint8_t slot)
@@ -795,6 +799,7 @@ uint16_t eattGetCid(dmConnId_t connId, uint8_t slot)
795799
else
796800
{
797801
eattConnCb_t *pCcb = eattGetConnCb(connId);
802+
WSF_ASSERT(pCcb);
798803
return pCcb->pChanCb[slot-1].cid;
799804
}
800805
}

connectivity/FEATURE_BLE/source/generic/SecurityDb.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ void SecurityDb::get_entry_local_keys(
6363

6464
/* set flags connected */
6565
SecurityDistributionFlags_t* flags = get_distribution_flags(correct_handle);
66+
if (!flags) {
67+
cb(*db_handle, NULL);
68+
return;
69+
}
6670
flags->connected = true;
6771

6872
/* update peer address */
6973
SecurityDistributionFlags_t* old_flags = get_distribution_flags(*db_handle);
74+
if (!old_flags) {
75+
cb(*db_handle, NULL);
76+
return;
77+
}
7078
flags->peer_address = old_flags->peer_address;
7179
flags->peer_address_is_public = old_flags->peer_address_is_public;
7280

connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,9 @@ void SecurityManager::on_connected(
16611661
cb->db_entry = _db->open_entry(peer_address_type, peer_address);
16621662

16631663
SecurityDistributionFlags_t* flags = _db->get_distribution_flags(cb->db_entry);
1664+
if (!flags) {
1665+
return;
1666+
}
16641667

16651668
flags->peer_address = peer_address;
16661669
flags->peer_address_is_public =

connectivity/cellular/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
"at-handler-buffer-size" : {
4949
"help": "Size of the AT handler buffer",
5050
"value": 32
51+
},
52+
"event-queue-size": {
53+
"help": "The amount of events the default EventQueue should store",
54+
"value": 10
5155
}
5256
}
5357
}

connectivity/cellular/source/framework/device/CellularDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ CellularDevice::CellularDevice() :
3939
#if MBED_CONF_CELLULAR_USE_SMS
4040
_sms_ref_count(0),
4141
#endif //MBED_CONF_CELLULAR_USE_SMS
42-
_info_ref_count(0), _queue(10 * EVENTS_EVENT_SIZE), _state_machine(0),
42+
_info_ref_count(0), _queue(MBED_CONF_CELLULAR_EVENT_QUEUE_SIZE * EVENTS_EVENT_SIZE), _state_machine(0),
4343
_status_cb(), _nw(0)
4444
#ifdef MBED_CONF_RTOS_PRESENT
4545
, _queue_thread(osPriorityNormal, 2048, NULL, "cellular_queue")

connectivity/cellular/tests/UNITTESTS/framework/device/athandler/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ target_compile_definitions(${TEST_NAME}
1515
DEVICE_INTERRUPTIN=1
1616
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
1717
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
18+
MBED_CONF_CELLULAR_EVENT_QUEUE_SIZE=10
1819
MBED_CONF_RTOS_PRESENT=1
1920
)
2021

connectivity/cellular/tests/UNITTESTS/framework/device/cellularcontext/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ target_compile_definitions(${TEST_NAME}
2121
DEVICE_INTERRUPTIN=1
2222
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
2323
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
24+
MBED_CONF_CELLULAR_EVENT_QUEUE_SIZE=10
2425
)
2526

2627
target_sources(${TEST_NAME}

connectivity/cellular/tests/UNITTESTS/framework/device/cellulardevice/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ target_compile_definitions(${TEST_NAME}
1919
DEVICE_INTERRUPTIN=1
2020
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
2121
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
22+
MBED_CONF_CELLULAR_EVENT_QUEUE_SIZE=10
2223
)
2324

2425
target_sources(${TEST_NAME}

connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ target_compile_definitions(${TEST_NAME}
2020
DEVICE_INTERRUPTIN=1
2121
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
2222
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
23+
MBED_CONF_CELLULAR_EVENT_QUEUE_SIZE=10
2324
)
2425

2526
target_sources(${TEST_NAME}

connectivity/drivers/emac/TARGET_NUVOTON_EMAC/TARGET_M460/m460_eth.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ void EMAC0_IRQHandler(void)
325325
uint32_t interrupt,dma_status_reg, mac_status_reg;
326326
int status;
327327
uint32_t dma_addr;
328+
uint32_t dma_ie = DmaIntEnable;
328329

329330
// Check GMAC interrupt
330331
mac_status_reg = synopGMACReadReg((u32 *)gmacdev->MacBase, GmacInterruptStatus);
@@ -401,6 +402,7 @@ void EMAC0_IRQHandler(void)
401402
if(interrupt & synopGMACDmaRxNormal) {
402403
//NU_RAW_Debug(("rx\n"));
403404
NU_RAW_Debug(("%s:: Rx Normal \r\n", __FUNCTION__));
405+
dma_ie &= ~DmaIntRxNormMask; // disable RX interrupt
404406
// to handle received data
405407
if (nu_eth_txrx_cb != NULL) {
406408
nu_eth_txrx_cb('R', nu_userData);
@@ -409,16 +411,17 @@ void EMAC0_IRQHandler(void)
409411

410412
if(interrupt & synopGMACDmaRxAbnormal) {
411413
mbed_error_printf("%s::Abnormal Rx Interrupt Seen \r\n",__FUNCTION__);
412-
gmacdev->synopGMACNetStats.rx_over_errors++;
413-
if(gmacdev->GMAC_Power_down == 0) { // If Mac is not in powerdown
414-
synopGMAC_resume_dma_rx(gmacdev);//To handle GBPS with 12 descriptors
414+
if(gmacdev->GMAC_Power_down == 0) { // If Mac is not in powerdown
415+
gmacdev->synopGMACNetStats.rx_over_errors++;
416+
dma_ie &= ~DmaIntRxAbnMask;
417+
synopGMAC_resume_dma_rx(gmacdev); //To handle GBPS with 12 descriptors
415418
}
416419
}
417420

418421
if(interrupt & synopGMACDmaRxStopped) {
419422
mbed_error_printf("%s::Receiver stopped seeing Rx interrupts \r\n",__FUNCTION__); //Receiver gone in to stopped state
420423
if(gmacdev->GMAC_Power_down == 0) { // If Mac is not in powerdown
421-
gmacdev->synopGMACNetStats.rx_over_errors++;
424+
gmacdev->synopGMACNetStats.rx_over_errors++;
422425
synopGMAC_enable_dma_rx(gmacdev);
423426
}
424427
}
@@ -450,13 +453,13 @@ void EMAC0_IRQHandler(void)
450453
synopGMAC_take_desc_ownership_tx(gmacdev);
451454

452455
synopGMAC_enable_dma_tx(gmacdev);
453-
mbed_error_printf("%s::Transmission Resumed\n",__FUNCTION__);
456+
mbed_error_printf("%s::Transmission Resumed\n", __FUNCTION__);
454457
}
455458
}
456459

457460
/* Enable the interrupt before returning from ISR*/
458461
// if( !(interrupt & synopGMACDmaRxNormal)) { /* RxNormal will enable INT in numaker_eth_trigger_rx */
459-
synopGMAC_enable_interrupt(gmacdev,DmaIntEnable);
462+
synopGMAC_enable_interrupt(gmacdev, dma_ie);
460463
// }
461464
return;
462465
}
@@ -515,7 +518,10 @@ int numaker_eth_get_rx_buf(uint16_t *len, uint8_t **buf)
515518
// synopGMAC_disable_dma_rx(gmacdev); // it will encounter DMA interrupt status as "Receiver stopped seeing Rx interrupts"
516519
*len = synop_handle_received_data(NU_M460_INTF, buf);
517520
dump_desc(gmacdev->RxBusyDesc);
518-
if( *len <= 0 ) return -1; /* No available RX frame */
521+
if( *len <= 0 ) {
522+
synopGMAC_enable_interrupt(gmacdev, DmaIntEnable);
523+
return -1; /* No available RX frame */
524+
}
519525

520526
// length of payload should be <= 1514
521527
if (*len > (NU_ETH_MAX_FLEN - 4)) {

0 commit comments

Comments
 (0)