Skip to content

Commit 126bfd5

Browse files
Debugging EMAC reboot test
1 parent df8ebd7 commit 126bfd5

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

connectivity/drivers/emac/TARGET_STM/STM32EthMACv2.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace mbed {
138138

139139
void STM32EthMACv2::RxDMA::stopDMA() {
140140
// Disable Rx DMA
141-
base->DMACTCR &= ~ETH_DMACRCR_SR;
141+
base->DMACRCR &= ~ETH_DMACRCR_SR;
142142
}
143143

144144
#if __DCACHE_PRESENT
@@ -254,8 +254,6 @@ namespace mbed {
254254
// Note: Following code is based on HAL_Eth_Init() from the HAL
255255
/* Init the low level hardware : GPIO, CLOCK, NVIC. */
256256
EthInitPinmappings();
257-
258-
259257
#ifdef TARGET_STM32H7
260258
// Use RMII
261259
HAL_SYSCFG_ETHInterfaceSelect(SYSCFG_ETH_RMII);

connectivity/drivers/emac/include/GenericEthDMA.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,14 @@ namespace mbed {
160160
// Free any buffers associated with the descriptor
161161
if (descStackBuffers[txReclaimIndex] != nullptr) {
162162
memory_manager->free(descStackBuffers[txReclaimIndex]);
163+
descStackBuffers[txReclaimIndex] = nullptr;
163164
}
164165

165166
// Update counters
166167
txReclaimIndex = (txReclaimIndex + 1) % MBED_CONF_NSAPI_EMAC_TX_NUM_DESCS;
167168
++txDescsOwnedByApplication;
168169

169-
tr_debug("Reclaimed descriptor %zu", txReclaimIndex);
170+
tr_info("Reclaimed descriptor %zu", txReclaimIndex);
170171

171172
returnedAnyDescriptors = true;
172173
}
@@ -211,7 +212,7 @@ namespace mbed {
211212
}
212213
}
213214

214-
tr_debug("Transmitting packet of length %lu in %zu buffers and %zu descs\n",
215+
tr_info("Transmitting packet of length %lu in %zu buffers and %zu descs\n",
215216
memory_manager->get_total_len(buf), memory_manager->count_buffers(buf), neededDescs);
216217

217218
// Step 2: Copy packet if needed
@@ -431,7 +432,7 @@ namespace mbed {
431432
rxBuildIndex = (rxBuildIndex + 1) % RX_NUM_DESCS;
432433
}
433434

434-
tr_debug("buildRxDescriptors(): Returned %zu descriptors.", origRxDescsOwnedByApplication - rxDescsOwnedByApplication);
435+
tr_info("buildRxDescriptors(): Returned %zu descriptors.", origRxDescsOwnedByApplication - rxDescsOwnedByApplication);
435436
}
436437

437438
bool rxHasPackets_ISR() override {
@@ -584,7 +585,7 @@ namespace mbed {
584585
}
585586
#endif
586587

587-
tr_debug("Returning packet of length %lu, start %p from Rx descriptors %zu-%zu\n",
588+
tr_info("Returning packet of length %lu, start %p from Rx descriptors %zu-%zu\n",
588589
memory_manager->get_total_len(headBuffer), memory_manager->get_ptr(headBuffer), *firstDescIdx, *lastDescIdx);
589590

590591
return headBuffer;

connectivity/netsocket/tests/TESTS/network/emac/emac_test_initialize.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ void test_emac_initialize()
4747
/*
4848
* Test which powers the EMAC down and then up again
4949
*/
50-
void test_emac_power_down_and_power_up() {
50+
void test_emac_power_down_and_power_up()
51+
{
5152
EmacTestNetworkStack::get_instance().get_emac()->power_down();
5253

53-
TEST_ASSERT_TRUE(EmacTestNetworkStack::get_instance().get_emac()->power_up())
54+
// Note: Currently the EMAC does not deliver a link state change to down callback when powered down.
55+
// Might change that in the future but for now we need to deliver the callback manually.
56+
emac_if_link_state_change_cb(false);
57+
58+
TEST_ASSERT_TRUE(EmacTestNetworkStack::get_instance().get_emac()->power_up());
5459
}
5560

5661
#endif // defined(MBED_CONF_RTOS_PRESENT)

connectivity/netsocket/tests/TESTS/network/emac/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
4747
Case cases[] = {
4848
Case("EMAC initialize", test_emac_initialize),
4949
Case("EMAC broadcast", test_emac_broadcast), // note: this test case has the side effect of finding the CTP server MAC address and saving it
50-
Case("EMAC unicast", test_emac_unicast),
5150
Case("EMAC power down and power up", test_emac_power_down_and_power_up),
52-
Case("EMAC unicast again after power cycle", test_emac_unicast),
51+
Case("EMAC broadcast again after power cycle", test_emac_broadcast),
52+
Case("EMAC unicast", test_emac_unicast),
5353
Case("EMAC unicast frame length", test_emac_unicast_frame_len),
5454
Case("EMAC unicast burst", test_emac_unicast_burst),
5555
Case("EMAC unicast long", test_emac_unicast_long),

0 commit comments

Comments
 (0)