Skip to content

Commit d05e79d

Browse files
committed
Merge branch 'main' of https://github.com/lvgl-micropython/lvgl_micropython into sw_rotate_for_all_bus_new
# Conflicts: # builder/toml_reader.py # ext_mod/lcd_bus/esp32_include/rgb565_dither.h # ext_mod/lcd_bus/esp32_src/rgb565_dither.c # ext_mod/lcd_bus/micropython.cmake # make.py
2 parents 5f6e685 + 2a6c2e0 commit d05e79d

File tree

16 files changed

+476
-77
lines changed

16 files changed

+476
-77
lines changed

.github/workflows/macOS.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
run: |
2323
brew install --force ninja
2424
brew install --force sdl2
25+
brew install --force libffi
2526
git submodule update --init -- lib/pycparser
2627
git submodule update --init --jobs 4 -- lib/micropython
2728
git submodule update --init --jobs 4 -- lib/lvgl
@@ -57,7 +58,6 @@ jobs:
5758

5859
- name: Install Dependencies
5960
run: |
60-
brew install --force ninja
6161
git submodule update --init -- lib/pycparser
6262
git submodule update --init --jobs 4 -- lib/micropython
6363
git submodule update --init --jobs 4 -- lib/lvgl

README.md

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ used to be.
8787
- [*Model/Variant*](#model/variant)
8888
- [*Model/Variant specific options*](#model/variant-specific-options)
8989
- [*ESP32 options*](#esp32-options)
90+
- [*Custom Boards*](https://github.com/lvgl-micropython/lvgl_micropython/tree/main/custom_board_and_toml_examples/README.md#custom-boards)
91+
- [*TOML Example*](https://github.com/lvgl-micropython/lvgl_micropython/tree/main/custom_board_and_toml_examples/README.md#toml-example)
9092
- [*Global Options (optional)*](#global-options-(optional))
9193
- [*Input/Output*](#input/output)
9294
- [*Other global options*](#other-global-options)
@@ -586,49 +588,9 @@ Options specific to the ESP32-S2, ESP32-S3, ESP32-C3 and ESP32-C6 processors:
586588
* `--enable-cdc-repl={y/n}`: Enable/disable REPL output over CDC on the USB pins
587589
* `--enable-jtag-repl={y/n}`: Enable/disable REPL output over JTAG on the USB pins
588590

591+
* `--custom-board-path={path to custom board}`: [Custom Board](https://github.com/lvgl-micropython/lvgl_micropython/tree/main/custom_board_and_toml_examples/README.md#custom-boards)
592+
* `--toml={path to .toml file}`: [TOML Example](https://github.com/lvgl-micropython/lvgl_micropython/tree/main/custom_board_and_toml_examples/README.md#toml-example)
589593

590-
This next option is abailable for all ESP32 series MCU's I placed it here instead of above
591-
because it is going to need some in depth explaining. This is for advanced users.
592-
593-
* `--custom-board-path`
594-
595-
I added the ability to provide a path to a custom board. There are a few requirememnts for
596-
this to work properly. The path needs to point to the folder that holds the board specification
597-
files. Here is a list of required files.
598-
599-
* `board.json`: This file outlines what the board is. At a minimum the file needs to contain the following.
600-
```
601-
{
602-
"mcu": "{MCU}"
603-
}
604-
```
605-
where `{MCU}` is one of the follwing:
606-
607-
* esp32
608-
* esp32s2
609-
* exp32s3
610-
* exp32c3
611-
* exp32c6
612-
613-
* `sdkconfig.board`: This file contains all of the ESP-IDF specific config settings. If you don't know
614-
what needs to be set in here then please ask me for assistance.
615-
* `mpconfigboard.h`: MicroPython config settings. If you don't know what needs to be set in here then
616-
please ask me for assistance.
617-
* `mpconfigboard.cmake`: Build script. At a minimum the following should be in the build script.
618-
`{MCU}` is replaced with one of the options from the list of MCU's above.
619-
`{BOARD_CONATINING_FOLDER}` if the name of the folder these files are located in.
620-
```
621-
set(IDF_TARGET {MCU})
622-
623-
set(SDKCONFIG_DEFAULTS
624-
boards/sdkconfig.base
625-
${SDKCONFIG_IDF_VERSION_SPECIFIC}
626-
boards/{BOARD_CONATINING_FOLDER}/sdkconfig.board
627-
)
628-
```
629-
630-
* `partition.csv`: This file dictates what the partitions are supposed to be on the ESP32. As for assistance
631-
If you do not know how to create one of these.
632594

633595
<br>
634596

builder/esp32.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -528,31 +528,6 @@ def esp32_args(extra_args):
528528

529529
def parse_args(extra_args, lv_cflags, brd):
530530
global board
531-
global custom_board_path
532-
533-
esp_argParser = ArgumentParser(prefix_chars='-')
534-
esp_argParser.add_argument(
535-
'--custom-board-path',
536-
dest='custom_board_path',
537-
default=None,
538-
action='store'
539-
)
540-
esp_args, extra_args = esp_argParser.parse_known_args(extra_args)
541-
542-
custom_board_path = esp_args.custom_board_path
543-
544-
if custom_board_path is not None:
545-
if not os.path.exists(custom_board_path):
546-
raise RuntimeError(
547-
'Supplied custom board path does not exist.'
548-
)
549-
parent_folder_name = os.path.split(custom_board_path)[-1]
550-
551-
dst_path = f'lib/micropython/ports/esp32/boards/{parent_folder_name}'
552-
shutil.copytree(custom_board_path, dst_path)
553-
554-
if brd is None:
555-
brd = parent_folder_name
556531

557532
if brd is None:
558533
brd = 'ESP32_GENERIC'
@@ -1120,7 +1095,8 @@ def update_mpconfigport():
11201095
'#ifdef MICROPY_HW_ESP_USB_SERIAL_JTAG',
11211096
'#undef MICROPY_HW_ESP_USB_SERIAL_JTAG',
11221097
'#endif',
1123-
f'#define MICROPY_HW_ESP_USB_SERIAL_JTAG ({int(enable_jtag_repl.lower() == "y")})'
1098+
f'#define MICROPY_HW_ESP_USB_SERIAL_JTAG ({int(enable_jtag_repl.lower() == "y")})',
1099+
'#define USB_SERIAL_JTAG_PACKET_SZ_BYTES (64)'
11241100
])
11251101

11261102
repl_data.extend([

builder/macOS.py

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
mpy_cross as _mpy_cross
1313
)
1414

15-
1615
from . import unix
16+
from . import spawn
1717

1818

1919
unix.REAL_PORT = 'macOS'
@@ -58,7 +58,82 @@ def build_sdl(_):
5858
unix.build_sdl = build_sdl
5959

6060

61+
def is_homebrew_arm(cmd):
62+
ret_val, output = spawn(cmd, out_to_screen=False)
63+
if ret_val:
64+
if cmd[0][0] == '/opt/homebrew/bin/brew':
65+
raise RuntimeError('Unable to locate homebrew installation')
66+
67+
return is_homebrew_arm([['/opt/homebrew/bin/brew', 'config']])
68+
69+
data = {line.split(':', 1)[0].strip(): line.split(':', 1)[1].strip() for
70+
line in output.split('\n')}
71+
72+
if 'macOS' not in data:
73+
raise RuntimeError('Unable to determine Homebrew CPU type')
74+
75+
if 'arm64' in data['macOS']:
76+
if 'Rosetta 2' not in data:
77+
if cmd[0][0] != '/opt/homebrew/bin/brew':
78+
return is_homebrew_arm([['/opt/homebrew/bin/brew', 'config']])
79+
80+
raise RuntimeError('Unable to determine Homebrew platform')
81+
82+
if data['Rosetta 2'] == 'true':
83+
if cmd[0][0] != '/opt/homebrew/bin/brew':
84+
return is_homebrew_arm([['/opt/homebrew/bin/brew', 'config']])
85+
86+
raise RuntimeError('Unable to locate Homebrew for Arm processors.')
87+
88+
return True, cmd[0][0]
89+
90+
return False, cmd[0][0]
91+
92+
6193
def submodules():
94+
is_arm, brew_path = is_homebrew_arm([['brew', 'config']])
95+
96+
if is_arm:
97+
ret, out = spawn([[brew_path, 'info', 'libffi']], out_to_screen=False)
98+
if ret:
99+
print(out)
100+
sys.exit(ret)
101+
102+
if 'Installed\n' not in out:
103+
print(out)
104+
raise RuntimeError('libffi is not installed')
105+
106+
out = out.split('Installed\n', 1)[-1]
107+
alt_path = out.split('(', 1)[0].strip().split('Cellar', 1)[0]
108+
109+
if 'export LDFLAGS=' in out:
110+
out = out.split('export LDFLAGS="', 1)[-1]
111+
ldflags = out.split('"', 1)[0]
112+
else:
113+
ldflags = f'"-L{alt_path}opt/libffi/lib"'
114+
115+
if 'export CPPFLAGS=' in out:
116+
out = out.split('export CPPFLAGS="', 1)[-1]
117+
cflags = out.split('"', 1)[0]
118+
else:
119+
cflags = f'"-I{alt_path}opt/libffi/include"'
120+
121+
ret, out = spawn([[brew_path, 'info', 'sdl2']], out_to_screen=False)
122+
123+
if ret:
124+
print(out)
125+
sys.exit(ret)
126+
127+
if 'Installed\n' not in out:
128+
print(out)
129+
raise RuntimeError('sdl2 is not installed')
130+
131+
ldflags += f' "-L{alt_path}lib"'
132+
cflags += f' "-I{alt_path}include"'
133+
134+
os.environ['LDFLAGS'] = f'{ldflags}'
135+
os.environ['CFLAGS'] = f'{cflags}'
136+
62137
berkeley_db = os.path.abspath('lib/micropython/lib/berkeley-db-1.xx/README')
63138

64139
if not os.path.exists(berkeley_db):
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"mcu": "esp32s3",
3+
"product": "Custom ESP32-S3 display board",
4+
"url": "https://www.come_manufacturer.com/board.html",
5+
"vendor": "Vendor name of board"
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set(IDF_TARGET esp32s3)
2+
3+
set(SDKCONFIG_DEFAULTS
4+
boards/sdkconfig.base
5+
${SDKCONFIG_IDF_VERSION_SPECIFIC}
6+
boards/sdkconfig.usb
7+
boards/sdkconfig.ble
8+
boards/sdkconfig.spiram_sx
9+
boards/sdkconfig.spiram_oct
10+
boards/sdkconfig.240mhz
11+
boards/MY_CUSTOM_BOARD/sdkconfig.board
12+
)
13+
14+
list(APPEND MICROPY_DEF_BOARD
15+
MICROPY_HW_BOARD_NAME="custom ESP32 board"
16+
)
17+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef MICROPY_HW_BOARD_NAME
2+
// Can be set by mpconfigboard.cmake.
3+
#define MICROPY_HW_BOARD_NAME "Custom ESP32S3 board"
4+
#endif
5+
#define MICROPY_HW_MCU_NAME "ESP32S3"
6+
7+
// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
8+
#define MICROPY_HW_ENABLE_UART_REPL (1)
9+
10+
#define MICROPY_HW_I2C0_SCL (9)
11+
#define MICROPY_HW_I2C0_SDA (8)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
[MCU.esp32]
3+
BOARD = "MY_CUSTOM_BOARD"
4+
5+
6+
[I80Bus.display_bus]
7+
data0 = 9
8+
data1 = 46
9+
data2 = 3
10+
data3 = 8
11+
data4 = 18
12+
data5 = 17
13+
data6 = 16
14+
data7 = 15
15+
dc = 0
16+
wr = 47
17+
cs = -1
18+
freq = 20000000
19+
20+
21+
[I2C.Bus.i2c_bus]
22+
host = 0
23+
scl = 5
24+
sda = 6
25+
freq = 100000
26+
27+
28+
[I2C.Device.indev_device]
29+
bus = "i2c_bus"
30+
dev_id = "ft6x36.I2C_ADDR"
31+
reg_bits = "ft6x36.BITS"
32+
33+
34+
[ST7796.display]
35+
data_bus = "display_bus"
36+
display_width = 320
37+
display_height = 480
38+
backlight_pin = 45
39+
color_byte_order = "st7789.BYTE_ORDER_BGR"
40+
color_space = "lv.COLOR_FORMAT.RGB565"
41+
rgb565_byte_swap = true
42+
43+
[ST7796.display.init]
44+
params = []
45+
46+
[FT6x36.indev]
47+
device = "indev_device"
48+
49+
[display.set_color_inversion]
50+
params = [true]
51+
52+
[display.set_rotation]
53+
params = ["lv.DISPLAY_ROTATION._90"]
54+
55+
[display.set_backlight]
56+
params = [100]
57+
58+
[task_handler.TaskHandler]
59+
params=[]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Notes: the offset of the partition table itself is set in
2+
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
3+
# Name, Type, SubType, Offset, Size, Flags
4+
nvs, data, nvs, 0x9000, 0x6000,
5+
phy_init, data, phy, 0xf000, 0x1000,
6+
factory, app, factory, 0x10000, 0x2F0000,
7+
vfs, data, fat, 0x300000, 0x1D00000,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
2+
3+
CONFIG_FREERTOS_HZ=1000
4+
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
5+
6+
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
7+
CONFIG_ESPTOOLPY_FLASHFREQ_120M=y
8+
CONFIG_ESPTOOLPY_FLASHSIZE_32MB=y
9+
10+
CONFIG_SPIRAM_SPEED_120M=y
11+
CONFIG_SPIRAM_IGNORE_NOTFOUND=n
12+
CONFIG_SPIRAM_RODATA=y
13+
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
14+
15+
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
16+
CONFIG_COMPILER_OPTIMIZATION_PERF=y
17+
18+
CONFIG_PARTITION_TABLE_CUSTOM=y
19+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="boards/MY_CUSTOM_BOARD/partitions.csv"
20+
21+
CONFIG_LWIP_LOCAL_HOSTNAME="my_custom_board"
22+
23+
CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID=n
24+
CONFIG_TINYUSB_DESC_USE_DEFAULT_PID=n
25+
CONFIG_TINYUSB_DESC_CUSTOM_VID=0x2341
26+
CONFIG_TINYUSB_DESC_CUSTOM_PID=0x056B
27+
CONFIG_TINYUSB_DESC_MANUFACTURER_STRING="MyCustomBoard"
28+
CONFIG_TINYUSB_DESC_PRODUCT_STRING="Custom ESP32"
29+

0 commit comments

Comments
 (0)