Skip to content
This repository was archived by the owner on Aug 23, 2024. It is now read-only.

Commit 4b21686

Browse files
committed
Prebuilt firmware added
1 parent d49d39b commit 4b21686

31 files changed

Lines changed: 187 additions & 106 deletions

MicroPython_BUILD/BUILD.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export CROSS_COMPILE=xtensa-esp32-elf-
172172

173173
for arg in "${POSITIONAL_ARGS[@]}"
174174
do
175-
if [ "${arg}" == "all" ] || [ "${arg}" == "flash" ] || [ "${arg}" == "makefs" ] || [ "${arg}" == "flashfs" ] || [ "${arg}" == "makefatfs" ] || [ "${arg}" == "flashfatfs" ] || [ "${arg}" == "firmware" ]; then
175+
if [ "${arg}" == "all" ] || [ "${arg}" == "flash" ] || [ "${arg}" == "makefs" ] || [ "${arg}" == "flashfs" ] || [ "${arg}" == "makefatfs" ] || [ "${arg}" == "flashfatfs" ]; then
176176
set_partitions ${APP_SIZE}
177177
if [ $? -ne 0 ]; then
178178
exit 1

MicroPython_BUILD/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ INTERNALFS_IMAGE_COMPONENT_PATH := $(PWD)/components/internalfs_image
1919
# ##########################################################################
2020

2121

22-
ESPTOOLPY_SERIAL = $(IDF_PATH)/components/esptool_py/esptool/esptool.py --chip esp32 --port $(CONFIG_ESPTOOLPY_PORT) --baud $(CONFIG_ESPTOOLPY_BAUD) --before $(CONFIG_ESPTOOLPY_BEFORE) --after $(CONFIG_ESPTOOLPY_AFTER)
23-
2422
echo_flash_cmd:
25-
echo $(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z,-u) $(ESPTOOL_WRITE_FLASH_OPTIONS) $(ESPTOOL_ALL_FLASH_ARGS) | sed -e 's:'$(PWD)/build/'::g'
23+
@echo "esptool.py --chip esp32 --port $(CONFIG_ESPTOOLPY_PORT) --baud $(CONFIG_ESPTOOLPY_BAUD) --before $(CONFIG_ESPTOOLPY_BEFORE) --after $(CONFIG_ESPTOOLPY_AFTER) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z,-u) $(ESPTOOL_WRITE_FLASH_OPTIONS) 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin"
2624

2725
makefs:
2826
@echo "Making spiffs image; Flash address: $(CONFIG_MICROPY_INTERNALFS_START), Size: $(CONFIG_MICROPY_INTERNALFS_SIZE) KB ..."

MicroPython_BUILD/components/micropython/esp32/libs/tft/tft.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static void _drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, color_t co
275275
swap(y0, y1);
276276
}
277277

278-
int16_t dx = x1 - x0, dy = abs(y1 - y0);;
278+
int16_t dx = x1 - x0, dy = abs(y1 - y0);
279279
int16_t err = dx >> 1, ystep = -1, xs = x0, dlen = 0;
280280

281281
if (y0 < y1) ystep = 1;
@@ -2438,9 +2438,9 @@ void TFT_jpg_image(int x, int y, uint8_t scale, char *fname, uint8_t *buf, int s
24382438
dev.linbuf[1] = NULL;
24392439
dev.linbuf_idx = 0;
24402440

2441+
dev.fhndl = NULL;
24412442
if (fname == NULL) {
24422443
// image from buffer
2443-
dev.fhndl = NULL;
24442444
dev.membuff = buf;
24452445
dev.bufsize = size;
24462446
dev.bufptr = 0;

MicroPython_BUILD/components/micropython/esp32/machine_hw_spi.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ typedef struct _machine_hw_spi_obj_t {
7474
} state;
7575
} machine_hw_spi_obj_t;
7676

77+
extern uint8_t disp_used_spi_host;
7778

7879
//-----------------------------------------------------------------
7980
int checkSPIBUS(int8_t bus, int8_t mosi, uint8_t miso, uint8_t sck)
8081
{
82+
if ((disp_used_spi_host > 0) && (MPy_SPIbus[disp_used_spi_host]->mosi_io_num >= 0)) return -3; // bus used by display driver
8183
if (MPy_SPIbus[bus] == NULL) return -2; // bus not available
8284
if (MPy_SPIbus[bus]->mosi_io_num < 0) return 1; // bus not configured, free to use
8385

@@ -141,8 +143,11 @@ STATIC void machine_hw_spi_init_internal(
141143
}
142144
#endif
143145

144-
bus_state = checkSPIBUS(host, mosi, miso,sck);
145-
if (bus_state < 0) {
146+
bus_state = checkSPIBUS(host, mosi, miso, sck);
147+
if (bus_state == -3) {
148+
mp_raise_ValueError("SPI host already used by display driver");
149+
}
150+
else if (bus_state < 0) {
146151
mp_raise_ValueError("SPI host already used with different configuration");
147152
}
148153
self->host = host;

MicroPython_BUILD/components/micropython/esp32/moddisplay.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ typedef struct _display_tft_obj_t {
7474
uint32_t tp_caly;
7575
} display_tft_obj_t;
7676

77+
extern int checkSPIBUS(int8_t bus, int8_t mosi, uint8_t miso, uint8_t sck);
78+
7779
STATIC display_tft_obj_t display_tft_obj;
7880
const mp_obj_type_t display_tft_type;
7981

82+
uint8_t disp_used_spi_host = 0;
83+
8084
// constructor(id, ...)
8185
//-----------------------------------------------------------------------------------------------------------------
8286
STATIC mp_obj_t display_tft_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@@ -198,7 +202,13 @@ STATIC mp_obj_t display_tft_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
198202
mp_raise_msg(&mp_type_OSError, "Unsupported SPI host");
199203
}
200204
#endif
201-
if ((args[ARG_type].u_int < 0) || (args[ARG_type].u_int >= DISP_TYPE_MAX)) {
205+
206+
int bus_state = checkSPIBUS(args[ARG_host].u_int, args[ARG_mosi].u_int, args[ARG_miso].u_int, args[ARG_clk].u_int);
207+
if (bus_state != 1) {
208+
mp_raise_ValueError("SPI host already used by SPI module with different configuration");
209+
}
210+
211+
if ((args[ARG_type].u_int < 0) || (args[ARG_type].u_int >= DISP_TYPE_MAX)) {
202212
mp_raise_msg(&mp_type_OSError, "Unsupported display type");
203213
}
204214

@@ -227,6 +237,7 @@ STATIC mp_obj_t display_tft_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
227237
self->miso = args[ARG_miso].u_int;
228238
self->mosi = args[ARG_mosi].u_int;
229239
self->clk = args[ARG_clk].u_int;
240+
230241
self->cs = args[ARG_cs].u_int;
231242
self->dc = args[ARG_dc].u_int;
232243

@@ -342,6 +353,7 @@ STATIC mp_obj_t display_tft_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
342353
mp_printf(&mp_plat_print, "Touch panel CS pin not specified, touch not enabled!\n");
343354
}
344355
}
356+
disp_used_spi_host = args[ARG_host].u_int;
345357

346358
// ================================
347359
// ==== Initialize the Display ====
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
## Prebuilt firmwares
3+
4+
5+
Default configuration is used.
6+
7+
Available firmwares:
8+
9+
| Directory | Description |
10+
| - | - |
11+
|**esp32** | MicroPython, single partition layout, 4MB Flash |
12+
|**esp32_ota** | MicroPython, dual partition layout, OTA enabled, 4MB Flash |
13+
|**esp32_psram** | MicroPython, single partition layout, 4MB Flash & 4MB SPIRAM |
14+
|**esp32_ota** | MicroPython, dual partition layout, OTA enabled, 4MB Flash & 4MB SPIRAM |
15+
16+
17+
All firmwares are configured with 1 MB SPIFFS file system.<br>
18+
Telnet server, FTP server and mDNS are enabled.
19+
20+
To flash, use **esptool.py**.
21+
22+
You can use the `flash.sh` script, run it in its directory.
23+
24+
**Edit the** `flash.sh` **and set the correct usb port for your board.**
1.21 MB
Binary file not shown.
19.1 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
3 KB
Binary file not shown.

0 commit comments

Comments
 (0)