Skip to content

Commit 1d451fa

Browse files
committed
micropython/espflash/README: Add build instructions.
This is for both the NINAW10 firmware and the esp_hosted firmware. Signed-off-by: robert-hh <[email protected]>
1 parent ab3b2aa commit 1d451fa

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

micropython/espflash/README.md

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
Instructions on building the NINAW10 and esp_hosted firmware
2+
3+
# Building the NINAW10 firmware
4+
5+
The NINAW10 firmware only works with classic ESP32 devices. No support
6+
for newer models like ESP32C3.
7+
8+
## Get the NINAW10 Arduino source code
9+
10+
The link is https://github.com/arduino/nina-fw.git.
11+
12+
## Get the ESP32 development environment.
13+
14+
Follow the instructions in the README.md document of the NINA firmware to
15+
download the NINA firmware and the esp-idf.
16+
The NINA firmware needs esp-idf v3.3.1 up to v3.3.4. After installing
17+
the esp-idf version, run:
18+
19+
./install.sh
20+
git submodule sync
21+
git submodule update --init
22+
. export.sh
23+
24+
in the esp-idf directory.
25+
26+
## Check the SPI and UART pins.
27+
28+
Change SPI pins at the end of this file:
29+
30+
nina-fw-1.5.0-Arduino/arduino/libraries/SPIS/src/SPIS.cpp
31+
32+
Suitable settings:
33+
34+
// for NINA W102:
35+
SPISClass SPIS(VSPI_HOST, 1, 12, 23, 18, 5, 33);
36+
37+
// for Airlift:
38+
SPISClass SPIS(VSPI_HOST, 1, 14, 23, 18, 5, 33);
39+
40+
41+
Change UART pins at about line 123 in this file:
42+
43+
nina-fw-1.5.0-Arduino/main/sketch.ino.cpp
44+
45+
Suitable settings:
46+
47+
// Airlift
48+
uart_set_pin(UART_NUM_1, 1, 3, 33, 14); // TX, RX, RTS, CTS
49+
50+
// W102
51+
uart_set_pin(UART_NUM_1, 1, 3, 33, 12); // TX, RX, RTS, CTS
52+
53+
The respective pin assignments can be found below in the pin table.
54+
The only difference between the Arduino Airlift and NINAW102 module
55+
is for the RTS/MOSI pin. If you use a custom ESP32 device and want to
56+
use different pins, you can change the pin numbers as needed.
57+
58+
## Build the firmware
59+
60+
Call `make RELEASE=1 NANO_RP2040_CONNECT=1` to build the firmware.
61+
Run combine.py with `python combine.py` to get a combined firmware
62+
file, which can be loaded to the target module using e.g. espflash.py.
63+
The file name will be `NINA_W102.bin`.
64+
65+
# Building the esp-hosted firmware
66+
67+
The esp-hosted firmware should work with all ESP32 modules. Tested with
68+
a ESP32 classic and a ESP32C3.
69+
70+
## Get the esp-hosted source code
71+
72+
The source code repository is at:
73+
74+
https://github.com/espressif/esp-hosted.git
75+
76+
The code for the esp-hosted network adapter is at:
77+
78+
esp_hosted_fg/esp/esp_driver
79+
80+
## Get the ESP32 development environment.
81+
82+
Follow the instructions in the README.md of micropython/ports/esp32.
83+
84+
./install.sh
85+
git submodule sync
86+
git submodule update --init
87+
88+
in the esp-idf directory.
89+
90+
## Check the SPI and UART pins.
91+
92+
The SPI pins are defined in the file:
93+
94+
esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c
95+
96+
The SPI settings used for the airlift module with ESP32 are:
97+
98+
#define GPIO_MOSI 14
99+
#define GPIO_MISO 23
100+
#define GPIO_SCLK 18
101+
#define GPIO_CS 5
102+
103+
The UART pins for bluetooth are defined in the file:
104+
105+
esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_bt.h
106+
107+
The UART settings used for the airlift module with ESP32 are:
108+
109+
#define BT_TX_PIN 1
110+
#define BT_RX_PIN 3
111+
#define BT_RTS_PIN 14
112+
#define BT_CTS_PIN 23
113+
114+
The respective pin assignments can be found ni the table below.
115+
The only difference between the Arduino Airlift and NINAW102 module
116+
is for the RTS/MOSI pin. If you use a custom ESP32 device and want to
117+
use different pins, you can change the pin numbers as needed.
118+
119+
## Build the firmware
120+
121+
Build the firmware using:
122+
123+
idf.py build
124+
125+
Create the combined firmware with the script:
126+
127+
#!/usr/bin/env python
128+
129+
import sys;
130+
131+
booloaderData = open("build/bootloader/bootloader.bin", "rb").read()
132+
partitionData = open("build/partition_table/partition-table.bin", "rb").read()
133+
otaData = open("build/ota_data_initial.bin", "rb").read()
134+
network_adapterData = open("build/network_adapter.bin", "rb").read()
135+
136+
# calculate the output binary size, app offset
137+
outputSize = 0x10000 + len(network_adapterData)
138+
if (outputSize % 1024):
139+
outputSize += 1024 - (outputSize % 1024)
140+
141+
# allocate and init to 0xff
142+
outputData = bytearray(b'\xff') * outputSize
143+
144+
# copy data: bootloader, partitions, app
145+
for i in range(0, len(booloaderData)):
146+
outputData[0x1000 + i] = booloaderData[i]
147+
148+
for i in range(0, len(partitionData)):
149+
outputData[0x8000 + i] = partitionData[i]
150+
151+
for i in range(0, len(otaData)):
152+
outputData[0xd000 + i] = otaData[i]
153+
154+
for i in range(0, len(network_adapterData)):
155+
outputData[0x10000 + i] = network_adapterData[i]
156+
157+
outputFilename = "esp_hosted_airlift.bin"
158+
if (len(sys.argv) > 1):
159+
outputFilename = sys.argv[1]
160+
161+
# write out
162+
with open(outputFilename,"w+b") as f:
163+
f.seek(0)
164+
f.write(outputData)
165+
166+
The combined firmware file will be `esp_hosted_airlift.bin`. This
167+
file can be loaded to the target module using e.g. espflash.py.
168+
169+
170+
# NINAW10 and esp-hosted pins assignments
171+
172+
Mapping between firmware signal names and ESP32 pins for the NINA
173+
firmware and esp_hosted firmware
174+
175+
======== ========== ======== ======= =======
176+
NINAW10 esp_hosted NINA Airlift Airlift
177+
Name Name W102 pin Name pin
178+
======== ========== ======== ======= =======
179+
MOSI MOSI 12 MOSI 14
180+
MISO MISO 23 MISO 23
181+
SCK SCK 18 SCK 18
182+
GPIO1/CS CS 5 CS 5
183+
ACK HANDSHAKE 33 Busy 33
184+
RESET RESET EN Reset EN
185+
GPIO0 DATAREADY 0 GP0 0
186+
TX TX 1 TX 1
187+
RX TX 3 RX 3
188+
RTS MOSI/RTS 12 - 14
189+
CTS CTS 33 - 33
190+
======== ========== ======== ======= =======
191+

0 commit comments

Comments
 (0)