Skip to content

Stm32 on board RMII ethernet #3671

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

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bcce22c
stm32: Integrate lwip with Wiznet MACRAW mode.
dpgeorge Oct 17, 2017
430968f
extmod/modlwip: Add work-around for bug in lwIP 1.4 with unset snw_wnd.
dpgeorge Oct 20, 2017
e760322
stm32: Enable ussl module via axtls.
dpgeorge Oct 20, 2017
86e62f8
stm32: Add useful networking modules: upip, urequests, uasyncio.
dpgeorge Oct 20, 2017
df3866b
stm32/lwipopts: Incr lwIP mem size and TCP wind for improved throughput.
dpgeorge Oct 23, 2017
d147d70
stm32/network_wiznet: Remove netif before adding if it already exists.
dpgeorge Oct 23, 2017
68fc071
extmod/modlwip: Guard patch with check for specific lwIP version.
dpgeorge Oct 23, 2017
6026fcb
stm32/Makefile: Fixes to build with axtls and lwip.
dpgeorge Oct 23, 2017
f141352
stm32/mpconfigport.h: Provide typedefs for ssize_t and off_t.
dpgeorge Oct 27, 2017
385d264
stm32/network_wiznet: Enable Ethernet MAC filtering.
dpgeorge Oct 31, 2017
1fc4cb6
extmod/modlwip: Commit TCP out data to lower layers if buffer gets full.
dpgeorge Oct 31, 2017
d97eb89
stm32/rng: Use yasmarang() for rng_get() if MCU doesn't have HW RNG.
dpgeorge Nov 23, 2017
7c198bc
First commit. Original README.md is moved to README-org.md and new RE…
boochow Dec 9, 2017
fee48bb
HAL ethernet module enabled, network_wiznet5k module disabled
boochow Dec 9, 2017
d4cd79a
HAL ethernet module enabled
boochow Dec 9, 2017
3784ac4
add ethernet module to modnetwork
boochow Dec 9, 2017
faf2562
add ethernetif.c from STM32CubeMX sample (STM32Cube_FW_F7_V1.8.0/Proj…
boochow Dec 9, 2017
357782d
stm32: STM32 ethernet driver integrated.
boochow Dec 10, 2017
db5734a
stm32:network_ethernet.c change interface name from ETHERNET to Ethernet
boochow Dec 10, 2017
36be59c
stm32: MICROPY_PY_ETH flag added to Makefile and modnetwork.c
boochow Dec 10, 2017
6f584fa
stm32: ethernetif.c selects hal header file according to MCU_SERIES C…
boochow Dec 10, 2017
c536aa9
stm32:NUCLEO_F767ZI/stm32f7xx_hal_conf.h corrected PHY_CONFIG_DELAY v…
boochow Dec 10, 2017
54d0945
stm32:Makefile
boochow Dec 10, 2017
7c28703
stm32: network_ethernet.c add lwipopts.h inclusion
boochow Dec 10, 2017
511dd0f
stm32: ethernet dma table/data buffer moved to fixed RAM area(0x2002000)
boochow Dec 11, 2017
3afffea
stm32: Makefile: remove unnecessary blank line
boochow Dec 11, 2017
aba222f
stm32: boards/stm32f767.ld comments corrected
boochow Dec 11, 2017
01f88b7
stm32: DMA description table size and ethernet buffer size corrected
boochow Dec 12, 2017
ff21d0f
stm32: added "how to build" section to README.md
boochow Dec 12, 2017
7eeb6cb
stm32: add support for building wiznet5k macraw mode ethernet
boochow Dec 12, 2017
34717d6
stm32: ethernetif.c pin configuration changed to refer pin.csv and mp…
boochow Dec 15, 2017
ec8c91c
stm32: added: generate mac address from hardware id
boochow Dec 15, 2017
e8bf46c
stm32:boards/stm32f767.ld rename ETH_BUFx to ETH_RXDMA,ETH_TXDMA,ETH_…
boochow Dec 16, 2017
a27715d
stm32: network_ethernet.c removed ethernetif_init call in ethernet_lw…
boochow Dec 16, 2017
524b249
stm32: ethernetif.c removed unnecessary comment lines.
boochow Dec 16, 2017
885a88a
stm32: boards/NUCLEO_F767ZI/stm32f7x_hal_conf.h shortend PHY_RESET_DE…
boochow Dec 16, 2017
2ee0720
stm32: ethernetif.c mac address generator changed to use fnv-1 hash a…
boochow Dec 16, 2017
140d539
add ethernet DMA descriptor table
forester3 Mar 12, 2018
aa1f92e
add RMII_* pin definitions
forester3 Mar 12, 2018
84f8098
uncomment HAL_ETH_MODULE_ENABLED
forester3 Mar 12, 2018
cabde93
add pin definitions for Ethernet RII Interface
forester3 Mar 12, 2018
88aa21d
Update README.md for F7-disco board
forester3 Mar 12, 2018
49956af
amend repository URL
forester3 Mar 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions README-org.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
[![Build Status](https://travis-ci.org/micropython/micropython.png?branch=master)](https://travis-ci.org/micropython/micropython) [![Coverage Status](https://coveralls.io/repos/micropython/micropython/badge.png?branch=master)](https://coveralls.io/r/micropython/micropython?branch=master)

The MicroPython project
=======================
<p align="center">
<img src="https://raw.githubusercontent.com/micropython/micropython/master/logo/upython-with-micro.jpg" alt="MicroPython Logo"/>
</p>

This is the MicroPython project, which aims to put an implementation
of Python 3.x on microcontrollers and small embedded systems.
You can find the official website at [micropython.org](http://www.micropython.org).

WARNING: this project is in beta stage and is subject to changes of the
code-base, including project-wide name changes and API changes.

MicroPython implements the entire Python 3.4 syntax (including exceptions,
`with`, `yield from`, etc., and additionally `async`/`await` keywords from
Python 3.5). The following core datatypes are provided: `str` (including
basic Unicode support), `bytes`, `bytearray`, `tuple`, `list`, `dict`, `set`,
`frozenset`, `array.array`, `collections.namedtuple`, classes and instances.
Builtin modules include `sys`, `time`, and `struct`, etc. Select ports have
support for `_thread` module (multithreading). Note that only a subset of
Python 3 functionality is implemented for the data types and modules.

MicroPython can execute scripts in textual source form or from precompiled
bytecode, in both cases either from an on-device filesystem or "frozen" into
the MicroPython executable.

See the repository http://github.com/micropython/pyboard for the MicroPython
board (PyBoard), the officially supported reference electronic circuit board.

Major components in this repository:
- py/ -- the core Python implementation, including compiler, runtime, and
core library.
- mpy-cross/ -- the MicroPython cross-compiler which is used to turn scripts
into precompiled bytecode.
- ports/unix/ -- a version of MicroPython that runs on Unix.
- ports/stm32/ -- a version of MicroPython that runs on the PyBoard and similar
STM32 boards (using ST's Cube HAL drivers).
- ports/minimal/ -- a minimal MicroPython port. Start with this if you want
to port MicroPython to another microcontroller.
- tests/ -- test framework and test scripts.
- docs/ -- user documentation in Sphinx reStructuredText format. Rendered
HTML documentation is available at http://docs.micropython.org (be sure
to select needed board/port at the bottom left corner).

Additional components:
- ports/bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used
mostly to control code size.
- ports/teensy/ -- a version of MicroPython that runs on the Teensy 3.1
(preliminary but functional).
- ports/pic16bit/ -- a version of MicroPython for 16-bit PIC microcontrollers.
- ports/cc3200/ -- a version of MicroPython that runs on the CC3200 from TI.
- ports/esp8266/ -- an experimental port for ESP8266 WiFi modules.
- extmod/ -- additional (non-core) modules implemented in C.
- tools/ -- various tools, including the pyboard.py module.
- examples/ -- a few example Python scripts.

The subdirectories above may include READMEs with additional info.

"make" is used to build the components, or "gmake" on BSD-based systems.
You will also need bash, gcc, and Python (at least 2.7 or 3.3).

The Unix version
----------------

The "unix" port requires a standard Unix environment with gcc and GNU make.
x86 and x64 architectures are supported (i.e. x86 32- and 64-bit), as well
as ARM and MIPS. Making full-featured port to another architecture requires
writing some assembly code for the exception handling and garbage collection.
Alternatively, fallback implementation based on setjmp/longjmp can be used.

To build (see section below for required dependencies):

$ git submodule update --init
$ cd ports/unix
$ make axtls
$ make

Then to give it a try:

$ ./micropython
>>> list(5 * x + y for x in range(10) for y in [4, 2, 1])

Use `CTRL-D` (i.e. EOF) to exit the shell.
Learn about command-line options (in particular, how to increase heap size
which may be needed for larger applications):

$ ./micropython --help

Run complete testsuite:

$ make test

Unix version comes with a builtin package manager called upip, e.g.:

$ ./micropython -m upip install micropython-pystone
$ ./micropython -m pystone

Browse available modules on
[PyPI](https://pypi.python.org/pypi?%3Aaction=search&term=micropython).
Standard library modules come from
[micropython-lib](https://github.com/micropython/micropython-lib) project.

External dependencies
---------------------

Building MicroPython ports may require some dependencies installed.

For Unix port, `libffi` library and `pkg-config` tool are required. On
Debian/Ubuntu/Mint derivative Linux distros, install `build-essential`
(includes toolchain and make), `libffi-dev`, and `pkg-config` packages.

Other dependencies can be built together with MicroPython. This may
be required to enable extra features or capabilities, and in recent
versions of MicroPython, these may be enabled by default. To build
these additional dependencies, first fetch git submodules for them:

$ git submodule update --init

Use the same command to get the latest versions of dependencies, as
they are updated from time to time. After that, in the port directory
(e.g. `ports/unix/`), execute:

$ make deplibs

This will build all available dependencies (regardless whether they
are used or not). If you intend to build MicroPython with additional
options (like cross-compiling), the same set of options should be passed
to `make deplibs`. To actually enable/disable use of dependencies, edit
`ports/unix/mpconfigport.mk` file, which has inline descriptions of the options.
For example, to build SSL module (required for `upip` tool described above,
and so enabled by dfeault), `MICROPY_PY_USSL` should be set to 1.

For some ports, building required dependences is transparent, and happens
automatically. They still need to be fetched with the git submodule command
above.

The STM32 version
-----------------

The "stm32" port requires an ARM compiler, arm-none-eabi-gcc, and associated
bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils,
arm-none-eabi-gcc and arm-none-eabi-newlib packages. Otherwise, try here:
https://launchpad.net/gcc-arm-embedded

To build:

$ git submodule update --init
$ cd ports/stm32
$ make

You then need to get your board into DFU mode. On the pyboard, connect the
3V3 pin to the P1/DFU pin with a wire (on PYBv1.0 they are next to each other
on the bottom left of the board, second row from the bottom).

Then to flash the code via USB DFU to your device:

$ make deploy

This will use the included `tools/pydfu.py` script. If flashing the firmware
does not work it may be because you don't have the correct permissions, and
need to use `sudo make deploy`.
See the README.md file in the ports/stm32/ directory for further details.

Contributing
------------

MicroPython is an open-source project and welcomes contributions. To be
productive, please be sure to follow the
[Contributors' Guidelines](https://github.com/micropython/micropython/wiki/ContributorGuidelines)
and the [Code Conventions](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md).
Note that MicroPython is licenced under the MIT license, and all contributions
should follow this license.
184 changes: 16 additions & 168 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,174 +1,22 @@
[![Build Status](https://travis-ci.org/micropython/micropython.png?branch=master)](https://travis-ci.org/micropython/micropython) [![Coverage Status](https://coveralls.io/repos/micropython/micropython/badge.png?branch=master)](https://coveralls.io/r/micropython/micropython?branch=master)
# MicroPython branch: stm32-ethernet-F7DISC

The MicroPython project
=======================
<p align="center">
<img src="https://raw.githubusercontent.com/micropython/micropython/master/logo/upython-with-micro.jpg" alt="MicroPython Logo"/>
</p>
This branch contains STM32 ethernet module for LwIP.

This is the MicroPython project, which aims to put an implementation
of Python 3.x on microcontrollers and small embedded systems.
You can find the official website at [micropython.org](http://www.micropython.org).
Current supported board is STM32F746G-Discovery and NUCLEO_F767ZI.
(I don't test NUCLEO_F767ZI and WIZnet module, because I don't have.)

WARNING: this project is in beta stage and is subject to changes of the
code-base, including project-wide name changes and API changes.
## How to build

MicroPython implements the entire Python 3.4 syntax (including exceptions,
`with`, `yield from`, etc., and additionally `async`/`await` keywords from
Python 3.5). The following core datatypes are provided: `str` (including
basic Unicode support), `bytes`, `bytearray`, `tuple`, `list`, `dict`, `set`,
`frozenset`, `array.array`, `collections.namedtuple`, classes and instances.
Builtin modules include `sys`, `time`, and `struct`, etc. Select ports have
support for `_thread` module (multithreading). Note that only a subset of
Python 3 functionality is implemented for the data types and modules.
```
git clone -b stm32-ethernet-F7DISC https://github.com/forester3/micropython.git
cd micropython
git submodule update --init
make -C mpy-cross
make -C ports/stm32 MICROPY_PY_ETH=RMII BOARD=STM32F7DISC
```

MicroPython can execute scripts in textual source form or from precompiled
bytecode, in both cases either from an on-device filesystem or "frozen" into
the MicroPython executable.
## How to build original WIZnet5K MACRAW mode support

See the repository http://github.com/micropython/pyboard for the MicroPython
board (PyBoard), the officially supported reference electronic circuit board.

Major components in this repository:
- py/ -- the core Python implementation, including compiler, runtime, and
core library.
- mpy-cross/ -- the MicroPython cross-compiler which is used to turn scripts
into precompiled bytecode.
- ports/unix/ -- a version of MicroPython that runs on Unix.
- ports/stm32/ -- a version of MicroPython that runs on the PyBoard and similar
STM32 boards (using ST's Cube HAL drivers).
- ports/minimal/ -- a minimal MicroPython port. Start with this if you want
to port MicroPython to another microcontroller.
- tests/ -- test framework and test scripts.
- docs/ -- user documentation in Sphinx reStructuredText format. Rendered
HTML documentation is available at http://docs.micropython.org (be sure
to select needed board/port at the bottom left corner).

Additional components:
- ports/bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used
mostly to control code size.
- ports/teensy/ -- a version of MicroPython that runs on the Teensy 3.1
(preliminary but functional).
- ports/pic16bit/ -- a version of MicroPython for 16-bit PIC microcontrollers.
- ports/cc3200/ -- a version of MicroPython that runs on the CC3200 from TI.
- ports/esp8266/ -- an experimental port for ESP8266 WiFi modules.
- extmod/ -- additional (non-core) modules implemented in C.
- tools/ -- various tools, including the pyboard.py module.
- examples/ -- a few example Python scripts.

The subdirectories above may include READMEs with additional info.

"make" is used to build the components, or "gmake" on BSD-based systems.
You will also need bash, gcc, and Python (at least 2.7 or 3.3).

The Unix version
----------------

The "unix" port requires a standard Unix environment with gcc and GNU make.
x86 and x64 architectures are supported (i.e. x86 32- and 64-bit), as well
as ARM and MIPS. Making full-featured port to another architecture requires
writing some assembly code for the exception handling and garbage collection.
Alternatively, fallback implementation based on setjmp/longjmp can be used.

To build (see section below for required dependencies):

$ git submodule update --init
$ cd ports/unix
$ make axtls
$ make

Then to give it a try:

$ ./micropython
>>> list(5 * x + y for x in range(10) for y in [4, 2, 1])

Use `CTRL-D` (i.e. EOF) to exit the shell.
Learn about command-line options (in particular, how to increase heap size
which may be needed for larger applications):

$ ./micropython --help

Run complete testsuite:

$ make test

Unix version comes with a builtin package manager called upip, e.g.:

$ ./micropython -m upip install micropython-pystone
$ ./micropython -m pystone

Browse available modules on
[PyPI](https://pypi.python.org/pypi?%3Aaction=search&term=micropython).
Standard library modules come from
[micropython-lib](https://github.com/micropython/micropython-lib) project.

External dependencies
---------------------

Building MicroPython ports may require some dependencies installed.

For Unix port, `libffi` library and `pkg-config` tool are required. On
Debian/Ubuntu/Mint derivative Linux distros, install `build-essential`
(includes toolchain and make), `libffi-dev`, and `pkg-config` packages.

Other dependencies can be built together with MicroPython. This may
be required to enable extra features or capabilities, and in recent
versions of MicroPython, these may be enabled by default. To build
these additional dependencies, first fetch git submodules for them:

$ git submodule update --init

Use the same command to get the latest versions of dependencies, as
they are updated from time to time. After that, in the port directory
(e.g. `ports/unix/`), execute:

$ make deplibs

This will build all available dependencies (regardless whether they
are used or not). If you intend to build MicroPython with additional
options (like cross-compiling), the same set of options should be passed
to `make deplibs`. To actually enable/disable use of dependencies, edit
`ports/unix/mpconfigport.mk` file, which has inline descriptions of the options.
For example, to build SSL module (required for `upip` tool described above,
and so enabled by dfeault), `MICROPY_PY_USSL` should be set to 1.

For some ports, building required dependences is transparent, and happens
automatically. They still need to be fetched with the git submodule command
above.

The STM32 version
-----------------

The "stm32" port requires an ARM compiler, arm-none-eabi-gcc, and associated
bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils,
arm-none-eabi-gcc and arm-none-eabi-newlib packages. Otherwise, try here:
https://launchpad.net/gcc-arm-embedded

To build:

$ git submodule update --init
$ cd ports/stm32
$ make

You then need to get your board into DFU mode. On the pyboard, connect the
3V3 pin to the P1/DFU pin with a wire (on PYBv1.0 they are next to each other
on the bottom left of the board, second row from the bottom).

Then to flash the code via USB DFU to your device:

$ make deploy

This will use the included `tools/pydfu.py` script. If flashing the firmware
does not work it may be because you don't have the correct permissions, and
need to use `sudo make deploy`.
See the README.md file in the ports/stm32/ directory for further details.

Contributing
------------

MicroPython is an open-source project and welcomes contributions. To be
productive, please be sure to follow the
[Contributors' Guidelines](https://github.com/micropython/micropython/wiki/ContributorGuidelines)
and the [Code Conventions](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md).
Note that MicroPython is licenced under the MIT license, and all contributions
should follow this license.
```
make -C ports/stm32 MICROPY_PY_ETH=WIZNET5K MICROPY_PY_WIZNET5K=5500 BOARD=YOUR_BOARD
```
1 change: 1 addition & 0 deletions drivers/wiznet5k/ethernet/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ int32_t WIZCHIP_EXPORT(recvfrom)(uint8_t sn, uint8_t * buf, uint16_t len, uint8_
// read peer's IP address, port number & packet length
sock_remained_size[sn] = head[0];
sock_remained_size[sn] = (sock_remained_size[sn] <<8) + head[1];
sock_remained_size[sn] -= 2; // len includes 2 len bytes
if(sock_remained_size[sn] > 1514)
{
WIZCHIP_EXPORT(close)(sn);
Expand Down
8 changes: 4 additions & 4 deletions drivers/wiznet5k/ethernet/w5200/w5200.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@

#include "w5200.h"

#define SMASK (0x7ff) /* tx buffer mask */
#define RMASK (0x7ff) /* rx buffer mask */
#define SSIZE (2048) /* max tx buffer size */
#define RSIZE (2048) /* max rx buffer size */
#define SMASK (16*1024-1) /* tx buffer mask */
#define RMASK (16*1024-1) /* rx buffer mask */
#define SSIZE (16*1024) /* max tx buffer size */
#define RSIZE (16*1024) /* max rx buffer size */

#define TXBUF_BASE (0x8000)
#define RXBUF_BASE (0xc000)
Expand Down
Loading