Skip to content

Stm32f7 ethernet fix for IAR issue #3387 #3473

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2016

Conversation

adustm
Copy link
Member

@adustm adustm commented Dec 20, 2016

Description

See the detailed explanation of the issue here
A few sentences describing the overall goals of the pull request's commits.
#3387
The ethernet buffers are located in the SRAM1 memory that has data cache enable.
Extract from the mbed.map:

DMARxDscrTab            0x20012aa4    0x80  Data  Gb  stm32f7_emac.o [8]
DMATxDscrTab            0x20012b24    0x80  Data  Gb  stm32f7_emac.o [8]
Rx_Buff                 0x20012ba4  0x17d0  Data  Gb  stm32f7_emac.o [8]
Tx_Buff                 0x20014374  0x17d0  Data  Gb  stm32f7_emac.o [8]

The DMA descriptors are written by the CPU, and kept in cache.
The Ethernet IP is then reading the DMA descriptor in the SRAM1 memory, that does not contains the requested information (still in cache)
You can see in the Reference Manual of STM32F746 that we set an address for the DMA descriptor to the ETH registers, and that the IP is reading this address directly.
http://www.st.com/resource/en/reference_manual/dm00124865.pdf page 1586 for ETH_DMATDLAR

It used to work before because those buffers' allocation was hard coded on 0x2000xxxx
This memory is the DTCM ram, 0 wait state, no cache. It can remain like this, but it is not the best performance choice (because when Ethernet is accessing the datas, the CPU is blocked).

The best choice is then to use SRAM1 and disable the data cache. The SRAM1 and SRAM2 are really fast and the system performance should not suffer from this choice.

Status

READY

Todos

I was able to fix features-feature_lwip-tests-mbedmicro-net-udp_echo_client test with this bug fix.
@geky or someone else, could you check that it also solves the issue #3387 ?

Steps to test or reproduce

before this PR :
mbed test -m NUCLEO_F746ZG -t IAR -n features-feature_lwip-tests-mbedmicro-net-udp_echo_client was failing
now it works

@adustm
Copy link
Member Author

adustm commented Dec 20, 2016

Hi @0xc0170
Master and release branches have diverged ? My PR is based on mbed-os-5.3.0

What am I supposed to do ?
Kind regards
Armelle

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 20, 2016

Master and release branches have diverged ? My PR is based on mbed-os-5.3.0

Develop on master please, can you take your commits and based them on top of the master please?

@adustm
Copy link
Member Author

adustm commented Dec 20, 2016

Rebase done. but it seems that the example is not working on the latest version of mbed-os, for some other reasons (and not only with IAR this time)
There have been a lot of changes recently... don't know where it comes from.

@bridadan
Copy link
Contributor

@adustm I checked out your branch locally and tried running the following command:

mbed test -m NUCLEO_F746ZG -t IAR -n features-feature_lwip-tests-mbedmicro-net-udp_echo_client -v

However my test failed with the following log:

mbedgt: mbed-host-test-runner: started
[1482266522.09][HTST][INF] host test executor ver. 1.1.6
[1482266522.09][HTST][INF] copy image onto target...
[1482266522.09][COPY][INF] Waiting up to 60 sec for '08160221052A601C3A6EF937' mount point (current is 'E:')...
        1 file(s) copied.
[1482266528.78][HTST][INF] starting host test process...
[1482266529.16][CONN][INF] starting connection process...
[1482266529.16][CONN][INF] notify event queue about extra 60 sec timeout for serial port pooling
[1482266529.16][CONN][INF] initializing serial port listener...
[1482266529.16][PLGN][INF] Waiting up to 60 sec for '08160221052A601C3A6EF937' serial port (current is 'COM258')...
[1482266529.17][HTST][INF] setting timeout to: 60 sec
[1482266529.70][SERI][INF] serial(port=COM258, baudrate=9600, timeout=0.01)
[1482266529.71][SERI][INF] reset device using 'default' plugin...
[1482266529.96][SERI][INF] waiting 1.00 sec after reset
[1482266530.96][SERI][INF] wait for it...
[1482266530.99][SERI][TXD] mbedmbedmbedmbedmbedmbedmbedmbedmbedmbed
[1482266530.99][CONN][INF] sending up to 2 __sync packets (specified with --sync=2)
[1482266530.99][CONN][INF] sending preamble '578859db-d273-45b4-b1a2-67e2dc4d6dbb'
[1482266531.04][SERI][TXD] {{__sync;578859db-d273-45b4-b1a2-67e2dc4d6dbb}}
[1482266531.09][CONN][RXD] mbedmbedmbedmbedmbedmbedmbedmbed
[1482266531.14][CONN][INF] found SYNC in stream: {{__sync;578859db-d273-45b4-b1a2-67e2dc4d6dbb}} it is #0 sent, queued...
[1482266531.15][HTST][INF] sync KV found, uuid=578859db-d273-45b4-b1a2-67e2dc4d6dbb, timestamp=1482266531.144000
[1482266531.16][CONN][INF] found KV pair in stream: {{__version;1.3.0}}, queued...
[1482266531.17][HTST][INF] DUT greentea-client version: 1.3.0
[1482266531.18][CONN][INF] found KV pair in stream: {{__timeout;20}}, queued...
[1482266531.18][HTST][INF] setting timeout to: 20 sec
[1482266531.22][CONN][INF] found KV pair in stream: {{__host_test_name;udp_echo_client}}, queued...
[1482266531.23][HTST][INF] host test class: '<class 'udp_echo_client.UDPEchoClientTest'>'
[1482266531.23][HTST][INF] host test setup() call...
[1482266531.23][HTST][INF] CALLBACKs updated
[1482266531.23][HTST][INF] host test detected: udp_echo_client
[1482266548.05][CONN][RXD] UDP client IP Address is
[1482266548.07][CONN][INF] found KV pair in stream: {{host_ip; }}, queued...
[1482266548.09][SERI][TXD] {{host_ip;None}}
[1482266548.11][CONN][INF] found KV pair in stream: {{host_port; }}, queued...
[1482266548.14][SERI][TXD] {{host_port;0}}
[1482266548.20][CONN][RXD] MBED: UDP Server IP address received: None:0
[1482266548.23][CONN][RXD] [00] sent...-3005 Bytes
[1482266548.25][CONN][RXD] [00] recv...-3005 Bytes
[1482266548.28][CONN][INF] found KV pair in stream: {{max_heap_usage;0}}, queued...
[1482266548.29][HTST][ERR] orphan event in main phase: {{max_heap_usage;0}}, timestamp=1482266548.282000
[1482266548.29][CONN][INF] found KV pair in stream: {{end;failure}}, queued...
[1482266548.30][HTST][INF] __notify_complete(False)
[1482266548.31][CONN][INF] found KV pair in stream: {{__exit;0}}, queued...
[1482266548.32][HTST][INF] __exit(0)
[1482266548.32][HTST][INF] __exit_event_queue received
[1482266548.32][HTST][INF] test suite run finished after 17.13 sec...
[1482266548.32][CONN][INF] received special even '__host_test_finished' value='True', finishing
[1482266548.33][HTST][INF] CONN exited with code: 0
[1482266548.33][HTST][INF] No events in queue
[1482266548.33][HTST][INF] stopped consuming events
[1482266548.33][HTST][INF] host test result() call skipped, received: False
[1482266548.33][HTST][INF] calling blocking teardown()
[1482266548.33][HTST][INF] teardown() finished
[1482266548.33][HTST][INF] {{result;failure}}
mbedgt: checking for GCOV data...
mbedgt: mbed-host-test-runner: stopped and returned 'FAIL'
mbedgt: test case summary event not found
        no test case report present, assuming test suite to be a single test case!
        test suite: features-feature_lwip-tests-mbedmicro-net-udp_echo_client
        test case: features-feature_lwip-tests-mbedmicro-net-udp_echo_client
mbedgt: test on hardware with target id: 08160221052A601C3A6EF937
mbedgt: test suite 'features-feature_lwip-tests-mbedmicro-net-udp_echo_client' ....................... FAIL in 26.75 sec
        test case: 'features-feature_lwip-tests-mbedmicro-net-udp_echo_client' ....................... FAIL in 26.75 sec
mbedgt: test case summary: 0 passes, 1 failure
mbedgt: all tests finished!

Can you confirm that you're seeing the same failure on your side as well?

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 21, 2016

Seems to me that rebase was not done correctly as there are 2 commits that are already on master?

@adustm adustm force-pushed the stm32f7_ethernet_dbg branch from b5c0165 to 27feaa5 Compare December 22, 2016 16:45
@adustm
Copy link
Member Author

adustm commented Dec 22, 2016

Hello @0xc0170
I had wrongly managed the autosquash option. It is now fixed. I moved the fix from the system init to the Ethernet init, so that it does not disable the Data cache when ethernet is not used.

@bridadan I have made many tests before and after the fix to convince you. I still have an issue with the udp_echo_client for the NUCLEO_F746ZG_IAR. Either is does not connect at all, either it does, but stops after a few loop of send/receive. I cannot figure out why, and it has probably nothing to do with the current bug fix.
I think I am ready for the merge this time:

BEFORE the PR (results from mbed-os-5.3.0):

+-------------------+---------------+----------------------------------------------------------------------+---------+--------------------+-------------+
| target            | platform_name | test suite                                                           | result  | elapsed_time (sec) | copy_method |
+-------------------+---------------+----------------------------------------------------------------------+---------+--------------------+-------------+
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-gethostbyname              | FAIL    | 64.8               | shell       |
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-nist_internet_time_service | OK      | 50.94              | shell       |
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-tcp_client_echo            | FAIL    | 63.23              | shell       |
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-tcp_client_hello_world     | OK      | 50.13              | shell       |
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-udp_echo_client            | FAIL    | 63.32              | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-gethostbyname              | FAIL    | 63.2               | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-nist_internet_time_service | TIMEOUT | 106.82             | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-tcp_client_echo            | FAIL    | 62.95              | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-tcp_client_hello_world     | FAIL    | 62.46              | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-udp_echo_client            | FAIL    | 63.01              | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-gethostbyname              | FAIL    | 62.69              | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-nist_internet_time_service | TIMEOUT | 105.52             | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-tcp_client_echo            | FAIL    | 62.45              | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-tcp_client_hello_world     | FAIL    | 62.54              | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-udp_echo_client            | FAIL    | 62.67              | shell       |
+-------------------+---------------+----------------------------------------------------------------------+---------+--------------------+-------------+

AFTER THE PR:

+-------------------+---------------+----------------------------------------------------------------------+---------+--------------------+-------------+
| target            | platform_name | test suite                                                           | result  | elapsed_time (sec) | copy_method |
+-------------------+---------------+----------------------------------------------------------------------+---------+--------------------+-------------+
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-gethostbyname              | OK      | 20.58              | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-nist_internet_time_service | OK      | 20.76              | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-tcp_client_echo            | OK      | 20.8               | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-tcp_client_hello_world     | OK      | 21.74              | shell       |
| NUCLEO_F746ZG-IAR | NUCLEO_F746ZG | features-feature_lwip-tests-mbedmicro-net-udp_echo_client            | FAIL (*)| 33.84              | shell       | 
+-------------------+---------------+----------------------------------------------------------------------+---------+--------------------+-------------+
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-gethostbyname              | OK  (**)| 19.49              | shell       | 
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-nist_internet_time_service | OK      | 18.68              | shell       |
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-tcp_client_echo            | OK      | 18.9               | shell       |
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-tcp_client_hello_world     | OK      | 18.85              | shell       |
| NUCLEO_F767ZI-IAR | NUCLEO_F767ZI | features-feature_lwip-tests-mbedmicro-net-udp_echo_client            | OK      | 19.47              | shell       |
+-------------------+---------------+----------------------------------------------------------------------+---------+--------------------+-------------+
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-gethostbyname              | OK      | 19.85              | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-nist_internet_time_service | OK      | 25.61              | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-tcp_client_echo            | OK      | 19.72              | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-tcp_client_hello_world     | OK      | 27.52              | shell       |
| DISCO_F746NG-IAR  | DISCO_F746NG  | features-feature_lwip-tests-mbedmicro-net-udp_echo_client            | OK      | 22.18              | shell       |
+-------------------+---------------+----------------------------------------------------------------------+---------+--------------------+-------------+

(*)either it connect but crashes after several loops, either it does not connect
(**)not systematic
@jeromecoutant , the results you had will improve once this PR will be merged.
@geky, let me know if this solves your issue #3387

Merry Christmas to all of you
Armelle

…se the DMA

descriptors if they are located in SRAM1 and SRAM2
@0xc0170
Copy link
Contributor

0xc0170 commented Dec 23, 2016

@adustm Thanks ! We will review it

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 23, 2016

/morph test-nightly

@0xc0170 0xc0170 requested a review from geky December 23, 2016 13:22
@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1322

All builds and test passed!

Copy link
Contributor

@bridadan bridadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adustm @0xc0170 The results are definitely an improvement, so I'm ok with this coming in. We'll have to look at the NUCLEO_F746ZG more in the future.

@0xc0170 0xc0170 merged commit c6a1109 into ARMmbed:master Dec 30, 2016
@adustm adustm deleted the stm32f7_ethernet_dbg branch January 3, 2017 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants