Skip to content

Commit

Permalink
Merge pull request #8 from liangyingy/master
Browse files Browse the repository at this point in the history
feature/T-PicoC3: Add T-PicoC3 board

- Support T-PicoC3
- Add st7789 module
  • Loading branch information
lbuque authored Jun 1, 2022
2 parents 609cd9e + e7dfbcd commit b778f35
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 15 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: c

branches:
only:
- master


jobs:
include:
- stage: micropython_build
env: NAME="micropython build"
install:
- sudo apt-get update
- sudo apt-get install git make python3 python3-pip cmake
script:
- cp config_T5-4.7 config
- make
- cp config_T-CALL config
- make
- cp config_T-SIM7000G config
- make
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,27 @@ $ cp config_T5-4.7 config
$ make
```

### T-T-CALL SIM800
### T-CALL SIM800

```shell
$ cp config_T-CALL config
$ make
```

### T-PicoC3

```shell
$ cp config_T-PicoC3 config
$ sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
$ make
```

## Supported Boards

- TTGO T-SIM7000G
- TTGO T5-4.7
- TTGO T-T-CALL SIM800
- LilyGo T-SIM7000G
- LilyGo T5-4.7
- LilyGo T-T-CALL SIM800
- LilyGo T-PicoC3

## Modules

Expand Down
2 changes: 2 additions & 0 deletions config_T-PicoC3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_TARGET=rp2
CONFIG_BOARD=LILYGO_T_PicoC3
17 changes: 17 additions & 0 deletions extmod/display/st7789/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

define st7789/info
PKG_NAME:=st7789
PKG_SOURCE_URL:=https://github.com/russhughes/st7789_mpy.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=master
PKG_SOURCE_MD5:=
endef

include $(INCLUDE_DIR)/download.mk
include $(INCLUDE_DIR)/package.mk

# PKG_DEPEND:=LilyGo-EPD47
# $(foreach var, $(PKG_DEPEND), make -C $(TOP_DIR)/libs/$(var);)
all:
$(eval $(st7789/info))
$(call Package/prereq,$(TARGET_BUILD_DIR))
3 changes: 3 additions & 0 deletions extmod/display/st7789/src/micropython.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(ST7789_DIR ${CMAKE_BINARY_DIR}/../st7789)

include(${ST7789_DIR}/st7789/micropython.cmake)
4 changes: 4 additions & 0 deletions extmod/micropython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ endif()

if(EXTMOD_GSM)
include(${CMAKE_CURRENT_LIST_DIR}/network/gsm/src/micropython.cmake)
endif()

if(EXTMOD_ST7789)
include(${CMAKE_CURRENT_LIST_DIR}/display/st7789/src/micropython.cmake)
endif()
9 changes: 4 additions & 5 deletions include/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ endef
##
##
define Package/patches
cd $(1) ; \
quilt import $(2)/* ; \
quilt push -a ; \
cd - ; \
for patch in `ls $(2)` ; \
do \
if [ ! -e $(1)/prereq_$$patch ]; then \
cd $(1) && \
git apply --stat $(2)/$$patch && \
git apply --check $(2)/$$patch && \
git apply $(2)/$$patch && \
cd - && \
touch $(1)/prereq_$$patch ; \
fi ; \
done
Expand Down
6 changes: 3 additions & 3 deletions micropython/micropython.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ define micropython/info
PKG_NAME:=micropython
PKG_SOURCE_URL:=https://github.com/micropython/micropython.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=v1.17
PKG_SOURCE_VERSION:=v1.18
PKG_SOURCE_MD5:=639c7fcbe62a8252cf9367147d94c150
endef

define micropython/prereq
$(eval $(micropython/info))
$(call Package/prereq,$(BUILD_DIR))
$(call Package/patches,$(BUILD_DIR)/$(PKG_NAME),$(TOP_DIR)/$(PKG_NAME)/patches)
$(call Package/prereq,$(TARGET_BUILD_DIR))
$(call Package/patches,$(TARGET_BUILD_DIR)/$(PKG_NAME),$(TOP_DIR)/$(PKG_NAME)/patches)
endef
133 changes: 133 additions & 0 deletions micropython/patches/006-Add-LILYGO_T-PicoC3-board.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
Index: micropython/lib/pico-sdk/src/boards/include/boards/lilygo_t_picoc3.h
===================================================================
--- /dev/null
+++ micropython/lib/pico-sdk/src/boards/include/boards/lilygo_t_picoc3.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+// -----------------------------------------------------
+// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
+// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
+// -----------------------------------------------------
+
+// This header may be included by other board headers as "boards/pico.h"
+
+#ifndef _BOARDS_PICO_H
+#define _BOARDS_PICO_H
+
+// For board detection
+#define RASPBERRYPI_PICO
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 0
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 0
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 1
+#endif
+
+// --- LED ---
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 25
+#endif
+// no PICO_DEFAULT_WS2812_PIN
+
+// --- I2C ---
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 0
+#endif
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN 4
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 5
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 0
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 18
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 19
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 16
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 17
+#endif
+
+// --- FLASH ---
+
+#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
+
+#ifndef PICO_FLASH_SPI_CLKDIV
+#define PICO_FLASH_SPI_CLKDIV 2
+#endif
+
+#ifndef PICO_FLASH_SIZE_BYTES
+#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
+#endif
+
+// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
+#define PICO_SMPS_MODE_PIN 23
+
+#ifndef PICO_RP2040_B0_SUPPORTED
+#define PICO_RP2040_B0_SUPPORTED 1
+#endif
+
+#endif
Index: micropython/ports/rp2/boards/LILYGO_T_PicoC3/board.json
===================================================================
--- /dev/null
+++ micropython/ports/rp2/boards/LILYGO_T_PicoC3/board.json
@@ -0,0 +1,23 @@
+{
+ "deploy": [
+ "../deploy.md"
+ ],
+ "docs": "",
+ "features": [
+ "WiFi ESP32-C3",
+ "Bluetooth ESP32-C3",
+ "LCD ST7789",
+ "SPI Flash 4MB",
+ "Battery",
+ "USB TYPE-C"
+ ],
+ "id": "rp2-pico",
+ "images": [
+ "rp2-pico.jpg"
+ ],
+ "mcu": "rp2040",
+ "product": "Pico",
+ "thumbnail": "",
+ "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/",
+ "vendor": "Raspberry Pi"
+}
Index: micropython/ports/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.cmake
===================================================================
--- /dev/null
+++ micropython/ports/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.cmake
@@ -0,0 +1,2 @@
+# cmake file for Raspberry Pi Pico
+set(EXTMOD_ST7789 1)
\ No newline at end of file
Index: micropython/ports/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.h
===================================================================
--- /dev/null
+++ micropython/ports/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.h
@@ -0,0 +1,3 @@
+// Board and hardware specific configuration
+#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"
+#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)
6 changes: 3 additions & 3 deletions target/esp32.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ endef
define esp32/compile
$(TARGET_BUILD_DIR)/esp-idf/install.sh
. $(TARGET_BUILD_DIR)/esp-idf/export.sh && \
make -C $(BUILD_DIR)/micropython/ports/esp32 \
BOARD=$(BOARD) BUILD=$(BUILD_DIR)/$(TARGET)/$(BOARD) \
make -C $(TARGET_BUILD_DIR)/micropython/ports/esp32 \
BOARD=$(BOARD) BUILD=$(TARGET_BUILD_DIR)/$(BOARD) \
USER_C_MODULES=$(TOP_DIR)/extmod/micropython.cmake \
EXTMOD_FROZEN_DIR=$(TOP_DIR)/extmod
endef
Expand All @@ -38,7 +38,7 @@ endef
define esp32/install
[ -d $(BIN_DIR) ] && mkdir -p $(BIN_DIR)/esp32/$(BOARD)
img_name=LilyGo-MicroPython_$(TARGET)_$(BOARD) && \
cd $(BUILD_DIR)/micropython && \
cd $(TARGET_BUILD_DIR)/micropython && \
micropython_version=`git show -s --pretty=format:%h` && \
img_name=$${img_name}_MPY-$${micropython_version} && \
cd $(TARGET_BUILD_DIR)/$(PKG_NAME) && \
Expand Down
43 changes: 43 additions & 0 deletions target/rp2.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

include $(INCLUDE_DIR)/download.mk
include $(INCLUDE_DIR)/package.mk

define rp2/info
PKG_NAME:=
PKG_SOURCE_URL:=
PKG_SOURCE_PROTO:=
PKG_SOURCE_VERSION:=
PKG_SOURCE_MD5:=
endef

# $(call DownloadMethod/git,$(PKG_NAME),$(PKG_SOURCE_URL),$(PKG_SOURCE_VERSION)) ;
define rp2/prereq
# sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
@echo "Please pre-install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential"
endef

##
## $(1) MODULES
##
define rp2/compile
make -C $(TARGET_BUILD_DIR)/micropython/mpy-cross && \
cd $(TARGET_BUILD_DIR)/micropython/ports/rp2 && \
make BOARD=$(BOARD) BUILD=$(BUILD_DIR)/$(TARGET)/$(BOARD) \
USER_C_MODULES=$(TOP_DIR)/extmod/micropython.cmake \
EXTMOD_FROZEN_DIR=$(TOP_DIR)/extmod && \
cd -
endef


define rp2/install
[ -d $(BIN_DIR) ] && mkdir -p $(BIN_DIR)/rp2/$(BOARD)
img_name=LilyGo-MicroPython_$(TARGET)_$(BOARD) && \
cd $(TARGET_BUILD_DIR)/micropython && \
micropython_version=`git show -s --pretty=format:%h` && \
img_name=$${img_name}_MPY-$${micropython_version} && \
time=`date +"%Y%m%d"` && \
img_name=$${img_name}_B$${time} && \
md5=`md5sum $(TARGET_BUILD_DIR)/$(BOARD)/firmware.bin | awk '{print $$1}'` && \
img_name=$${img_name}_$${md5:0:10} && \
cp $(TARGET_BUILD_DIR)/$(BOARD)/firmware.uf2 $(BIN_DIR)/rp2/$(BOARD)/$${img_name}.uf2
endef

0 comments on commit b778f35

Please sign in to comment.