|
| 1 | +# Instructions to build the NINAW10 and esp_hosted firmware |
| 2 | + |
| 3 | +# 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. Follow the |
| 11 | +instructions in the README.md document of the NINA firmware to |
| 12 | +download the NINA firmware and the esp-idf. |
| 13 | + |
| 14 | +## Get the ESP32 development environment. |
| 15 | + |
| 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); // SPI-device, DMA-channel, MOSI, MISO, SCK, CS, ACK |
| 36 | + |
| 37 | + // for Airlift: |
| 38 | + SPISClass SPIS(VSPI_HOST, 1, 14, 23, 18, 5, 33); // SPI-device, DMA-channel, MOSI, MISO, SCK, CS, ACK |
| 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 | +Sample script to create the combined firmware: |
| 66 | + |
| 67 | + #!/usr/bin/env python |
| 68 | + |
| 69 | + import sys; |
| 70 | + |
| 71 | + booloaderData = open("build/bootloader/bootloader.bin", "rb").read() |
| 72 | + partitionData = open("build/partitions.bin", "rb").read() |
| 73 | + phyData = open("data/phy.bin", "rb").read() |
| 74 | + certsData = open("data/roots.pem", "rb").read() |
| 75 | + appData = open("build/nina-fw.bin", "rb").read() |
| 76 | + |
| 77 | + # calculate the output binary size, app offset |
| 78 | + outputSize = 0x30000 + len(appData) |
| 79 | + if (outputSize % 1024): |
| 80 | + outputSize += 1024 - (outputSize % 1024) |
| 81 | + |
| 82 | + # allocate and init to 0xff |
| 83 | + outputData = bytearray(b'\xff') * outputSize |
| 84 | + |
| 85 | + # copy data: bootloader, partitions, app |
| 86 | + for i in range(0, len(booloaderData)): |
| 87 | + outputData[0x1000 + i] = booloaderData[i] |
| 88 | + |
| 89 | + for i in range(0, len(partitionData)): |
| 90 | + outputData[0x8000 + i] = partitionData[i] |
| 91 | + |
| 92 | + for i in range(0, len(phyData)): |
| 93 | + outputData[0xf000 + i] = phyData[i] |
| 94 | + |
| 95 | + for i in range(0, len(certsData)): |
| 96 | + outputData[0x10000 + i] = certsData[i] |
| 97 | + |
| 98 | + # zero terminate the pem file |
| 99 | + outputData[0x10000 + len(certsData)] = 0 |
| 100 | + |
| 101 | + for i in range(0, len(appData)): |
| 102 | + outputData[0x30000 + i] = appData[i] |
| 103 | + |
| 104 | + |
| 105 | + outputFilename = "NINA_W102.bin" |
| 106 | + if (len(sys.argv) > 1): |
| 107 | + outputFilename = sys.argv[1] |
| 108 | + |
| 109 | + # write out |
| 110 | + with open(outputFilename,"w+b") as f: |
| 111 | + f.seek(0) |
| 112 | + f.write(outputData) |
| 113 | + |
| 114 | +The combined firmware file will be `NINA_W102.bin`. This |
| 115 | +file can be loaded to the target module using e.g. espflash.py. |
| 116 | + |
| 117 | +# Esp-hosted firmware |
| 118 | + |
| 119 | +The esp-hosted firmware should work with all ESP32 modules. Tested with |
| 120 | +a ESP32 classic and a ESP32C3. |
| 121 | + |
| 122 | +## Get the esp-hosted source code |
| 123 | + |
| 124 | +The source code repository is at: |
| 125 | + |
| 126 | +https://github.com/espressif/esp-hosted.git |
| 127 | + |
| 128 | +The code for the esp-hosted network adapter is at: |
| 129 | + |
| 130 | +esp_hosted_fg/esp/esp_driver |
| 131 | + |
| 132 | +The commit used for these instructions is `244b864`. Newer version are |
| 133 | +not tested. |
| 134 | + |
| 135 | +## Get the ESP32 development environment. |
| 136 | + |
| 137 | +Follow the instructions in the README.md of micropython/ports/esp32. |
| 138 | +Check out v5.5.1. Run in the esp-idf directory: |
| 139 | + |
| 140 | + ./install.sh |
| 141 | + git submodule sync |
| 142 | + git submodule update --init |
| 143 | + . export.sh |
| 144 | + |
| 145 | +## Check the UART pins. |
| 146 | + |
| 147 | +The UART pins for bluetooth are defined in the file: |
| 148 | + |
| 149 | +esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_bt.h |
| 150 | + |
| 151 | +The UART settings used for the airlift module with ESP32 are: |
| 152 | + |
| 153 | + #define BT_TX_PIN 1 |
| 154 | + #define BT_RX_PIN 3 |
| 155 | + #define BT_RTS_PIN 14 |
| 156 | + #define BT_CTS_PIN 33 |
| 157 | + |
| 158 | +The UART settings used for the NINAW102 module with ESP32 are: |
| 159 | + |
| 160 | + #define BT_TX_PIN 1 |
| 161 | + #define BT_RX_PIN 3 |
| 162 | + #define BT_RTS_PIN 12 |
| 163 | + #define BT_CTS_PIN 33 |
| 164 | + |
| 165 | +The respective pin assignments can be found in the table below. |
| 166 | +The only difference between the Arduino Airlift and NINAW102 module |
| 167 | +is for the RTS/MOSI pin. If you use a custom ESP32 device and want to |
| 168 | +use different pins, you can change the pin numbers as needed. |
| 169 | + |
| 170 | +## Set the configuration in sdkconfig |
| 171 | + |
| 172 | +The SPI and Bluetooth configuration is stored in teh file sdkconfig. Call |
| 173 | +`idf.py menuconfig` in a terminal window to create or modify the |
| 174 | +sdkconfig configuration file. |
| 175 | + |
| 176 | +Change/verify the settings as follows: |
| 177 | + |
| 178 | +### SPI configuration |
| 179 | + |
| 180 | +- At `Example Configuration → Transport layer` select `SPI`. |
| 181 | +- At `Example Configuration → SPI Full-duplex Configuration → SPI controller to use` select VSPI. |
| 182 | +- At `Example Configuration → SPI Full-duplex Configuration → Hosted SPI GPIOs`set the GPIO pins to MOSI=14 (Airlift) or 12 (NINAW102), MISO=23, CLK=18, CS=5, handshake=33, data ready interupt=0, Reset=-1. |
| 183 | +- Clear `Example Configuration → SPI Full-duplex Configuration → Deassert Handshake when SPI CS is deasserted` |
| 184 | +- Set `Example Configuration → SPI Full-duplex Configuration → SPI checksum ENABLE/DISABLE`. |
| 185 | +- Set `Example Configuration → Enable Mempool` |
| 186 | +- Set `Example Configuration → Start CLI at slave` |
| 187 | +- Set `Example Configuration → Wi-Fi control` to `Host manages Wi-Fi` |
| 188 | + |
| 189 | + |
| 190 | +### Bluetooth configuration. |
| 191 | + |
| 192 | +- Set `Component config → Bluetooth → Bluetooth → Host` to Disabled. |
| 193 | +- Set `Component config → Bluetooth → Bluetooth → Controller` to Enabled |
| 194 | +- Set `Component config → Bluetooth → Controller Options → Bluetooth controller mode (BR/EDR/BLE/DUALMODE)` to `BLE Only`. |
| 195 | +- Set `Component config → Bluetooth → Controller Options → HCI mode` to `UART(H4)`. |
| 196 | +- In `Component config → Bluetooth → Controller Options → HCI UART(H4)` select UART 1, 460800 Baud and **disable flow control**. |
| 197 | + |
| 198 | +### PHY config |
| 199 | + |
| 200 | +- At `Component config → PHY` set `Max WiFi TX power` to 20 (default). |
| 201 | +- AT `Component config → PHY` enable `Reduce PHY TX power when brownout reset` |
| 202 | + |
| 203 | +After that, save the configuration by pressing the letter 'S'. That |
| 204 | +creates the file skdconfig or rewrites it after changes. |
| 205 | + |
| 206 | +## Build the firmware |
| 207 | + |
| 208 | +Build the firmware using: |
| 209 | + |
| 210 | +idf.py build |
| 211 | + |
| 212 | +Create the combined firmware with the command: |
| 213 | + |
| 214 | +python -m esptool --chip esp32 merge_bin --flash_mode dio --flash_size keep --flash_freq 40m -o esp_hosted.bin 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0xd000 build/ota_data_initial.bin 0x10000 build/network_adapter.bin |
| 215 | + |
| 216 | +The combined firmware file will be `esp_hosted.bin`. This |
| 217 | +file can be installed in the target module using e.g. espflash.py. |
| 218 | + |
| 219 | + |
| 220 | +# NINAW102 and esp-hosted pins assignments |
| 221 | + |
| 222 | +Mapping between firmware signal names and ESP32 pins for the NINA |
| 223 | +firmware and esp_hosted firmware |
| 224 | + |
| 225 | + ======== ========== ======== ======= ======= |
| 226 | + NINAW102 esp_hosted NINAW102 Airlift Airlift |
| 227 | + Name Name pin Name pin |
| 228 | + ======== ========== ======== ======= ======= |
| 229 | + MOSI MOSI 12 MOSI 14 |
| 230 | + MISO MISO 23 MISO 23 |
| 231 | + SCK SCK 18 SCK 18 |
| 232 | + GPIO1/CS CS 5 CS 5 |
| 233 | + ACK HANDSHAKE 33 Busy 33 |
| 234 | + RESET RESET EN Reset EN |
| 235 | + GPIO0 DATAREADY 0 GP0 0 |
| 236 | + TX TX 1 TX 1 |
| 237 | + RX TX 3 RX 3 |
| 238 | + RTS MOSI/RTS 12 - 14 |
| 239 | + CTS CTS 33 - 33 |
| 240 | + ======== ========== ======== ======= ======= |
| 241 | + |
0 commit comments