Skip to content

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream

License

Notifications You must be signed in to change notification settings

Wiznet/micropython-microbit-v2

 
 

Repository files navigation

Ethernet Example Getting Started

These sections will guide you through a series of steps from configuring development environment to running ethernet examples using the micro:bit with WIZnet's ethernet products.

Hardware requirements

The Ethernet examples make use of the WIZnet Ethernet Products' Ethernet I/O module, which incorporates WIZnet's W5100S or W5500 Ethernet chip, in conjunction with the micro:bit board.

Pin Diagram

I/O Pin Name Descri ption
O P_16 Connected to CSn on WIZnet Chip
O P_15 Connected to MOSI on WIZnet Chip
I P_14 Connected to MISO on WIZnet Chip
O P_13 Connected to SCLK on WIZnet Chip
O P_12 Connected to RSTn on WIZnet Chip
I P_9 Connected to INTn on WIZnet Chip

Development environment configuration

To test the ethernet examples, the development environment must be configured to micro:bit and WIZnet.

  • Required development environment

    • Thonny (that makes it easier to use micropython)
  • If you must be need to compile the micropython ,your pc should be use Linux or Unix environment.

    To compile microbit-micropython, use a Docker image instead of setting up a separate environment. For instructions on how to use Docker, refer to the following Git page.


Wiznet5K Library

Building

  1. Download

If the ethernet examples are cloned, the library set as a submodule is an empty directory. Therefore, if you want to download the library set as a submodule together, clone the ethernet examples with the following Git command.

/* Change directory */
// change to the directory to clone
$ cd [user path]

/* Clone */
$ git clone https://github.com/Wiznet/micropython-microbit-v2.git
  1. Patch

Some libraries configured as submodules need to be manually patched using the Git commands found in their respective library directories. To do this, execute the shell script provided below. This action is only required to be performed once.

$ cd micropython-microbit-v2
$ git submodule init
$ git submodule update
$ ./run_patchs.sh
  1. configuring the chip version

The patch is complete, enter the information for the WIZnet chip you are using. Input the Chip Version W5100S or W5500 in the file at the following path.

  • lib/micropython/lib/wiznet5k/Ethernet/wizchip_conf.h
  • src/codal_port/mpconfigport.h
#define _WIZCHIP_                      W5100S   // W5100, W5100S, W5200, W5300, W5500
  1. compile

The build steps from this example have been obtained from the project README. Proceed with the compilation.

# First we prepare the project, this initial docker command only has to be run once
$ docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest make -C lib/micropython/mpy-cross
# Now we are ready to build using the Makefile in the src folder
$ docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest make -C src

The compilation is finished, a MICROBIT.hexfile will be generated in the /srcdirectory.

Deploying firmware to the device

If you want to use the firmware without build, you can use the below firmware.

Upload the MICROBIT.hex firmware to the micro:bit board. Connecting the micro:bit board to your PC. Copy the firmware into the microbit folder.

Ethernet example structure

Ethernet examples are available at micropython-microbit-v2/examples directory. As of now, following examples are provided.

About

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 92.8%
  • C++ 4.5%
  • Python 1.6%
  • Other 1.1%