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

Tbeamv1 support #387

Open
wants to merge 16 commits into
base: Dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Finally, before building, export the IDF_PATH variable

This repository contains submodules! Clone using the --recursive option:

$ git clone --recursive https://github.com/pycom/pycom-micropython-sigfox.git
$ git clone --recursive https://github.com/nunomcruz/pycom-micropython-sigfox.git

Alternatively checkout the modules manually:

Expand Down Expand Up @@ -141,7 +141,8 @@ You can change the board type by using the BOARD variable:

We currently support the following BOARD types:

WIPY LOPY SIPY GPY FIPY LOPY4
WIPY LOPY SIPY GPY FIPY LOPY4 TBEAMv1


For OEM modules, please use the following BOARD type:

Expand All @@ -152,6 +153,14 @@ L04: LOPY4
G01: GPY
```

Additionaly we also support a third party BOARD from TTGO, the T-Beam version 1, please use the following BOARD type:

TBEAMv1

More info on this board can be found here: https://github.com/LilyGO/TTGO-T-Beam

This should also work on other versions of the T-Beam, and other ESP32 boards with 4MB Flash and 4MB PSRAM.

To specify a serial port other than /dev/ttyUSB0, use ESPPORT variable:

$ # On MacOS
Expand Down Expand Up @@ -179,7 +188,7 @@ To create a release package that can be flashed with the Pycom firmware tool:
To create a release package for all currently supported Pycom boards:

$ cd esp32
$ for BOARD in WIPY LOPY SIPY GPY FIPY LOPY4; do make BOARD=$BOARD clean && make BOARD=$BOARD release; done
$ for BOARD in WIPY LOPY SIPY GPY FIPY LOPY4 TBEAMv1; do make BOARD=$BOARD clean && make BOARD=$BOARD release; done

To specify a directory other than the default build/ directory:

Expand All @@ -190,7 +199,7 @@ To specify a directory other than the default build/ directory:
To create a release package for all currently supported Pycom boards in a directory other than the default build/ directory:

$ cd esp32
$ for BOARD in WIPY LOPY SIPY GPY FIPY LOPY4; do make BOARD=$BOARD clean && make BOARD=$BOARD RELEASE_DIR=~/pycom-packages release; done
$ for BOARD in WIPY LOPY SIPY GPY FIPY LOPY4 TBEAMv1; do make BOARD=$BOARD clean && make BOARD=$BOARD RELEASE_DIR=~/pycom-packages release; done

To inclue a step for copying IDF libs from IDF_PATH specify the following variable in the make command

Expand All @@ -203,6 +212,8 @@ To Buiild the firmware with Pybytes libs use the following make variable
To Disable RGB Led control use the following make variable

RGB_LED=disable

The RGB_LED is only enabled by default on Pycom boards

## Steps for using Secure Boot and Flash Encryption

Expand Down
12 changes: 8 additions & 4 deletions esp32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ PYGATE_ENABLED ?= 0
MOD_COAP_ENABLED ?= 1

# LORA is enabled by default for supported boards
ifeq ($(BOARD), $(filter $(BOARD), LOPY LOPY4 FIPY))
ifeq ($(BOARD), $(filter $(BOARD), LOPY LOPY4 FIPY TBEAMv1))
MOD_LORA_ENABLED ?= 1
else
MOD_LORA_ENABLED ?= 0
endif

# SIGFOX is enabled by default for supported boards
ifeq ($(BOARD), $(filter $(BOARD), SIPY LOPY4 FIPY))
ifeq ($(BOARD), $(filter $(BOARD), SIPY LOPY4 FIPY TBEAMv1))
MOD_SIGFOX_ENABLED ?= 1
else
MOD_SIGFOX_ENABLED ?= 0
Expand Down Expand Up @@ -83,7 +83,11 @@ RELEASE_DIR ?= $(BUILD_DIR)
COPY_IDF_LIB ?= 0

LTE_LOG_BUFF ?= 0
RGB_LED ?= enable
ifeq ($(BOARD), $(filter $(BOARD), TBEAMv1))
RGB_LED ?= disable
else
RGB_LED ?= enable
endif

# by default openthread over LoRa is enabled
OPENTHREAD = off
Expand Down Expand Up @@ -132,7 +136,7 @@ CFLAGS_XTENSA = -DESP_PLATFORM -Wpointer-arith -Wall -Werror=all -Wno-error=unus
CFLAGS_XTENSA_OPT = -Os
CFLAGS_XTENSA_PSRAM = -mfix-esp32-psram-cache-issue

CFLAGS = $(CFLAGS_XTENSA) $(CFLAGS_XTENSA_PSRAM) $(CFLAGS_XTENSA_OPT) -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)
CFLAGS = $(CFLAGS_XTENSA) $(CFLAGS_XTENSA_PSRAM) $(CFLAGS_XTENSA_OPT) -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD) -DBOARD_$(BOARD)
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
CFLAGS_SIGFOX = $(CFLAGS_XTENSA) -O2 -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)

Expand Down
30 changes: 20 additions & 10 deletions esp32/application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ ifeq ($(BOARD), $(filter $(BOARD), LOPY FIPY))
OBJ += $(addprefix $(BUILD)/, $(APP_LORA_SRC_C:.c=.o) $(APP_LIB_LORA_SRC_C:.c=.o) $(APP_SX1272_SRC_C:.c=.o) $(APP_MODS_LORA_SRC_C:.c=.o))
endif

ifeq ($(BOARD), $(filter $(BOARD), LOPY4))
ifeq ($(BOARD), $(filter $(BOARD), LOPY4 TBEAMv1))
OBJ += $(addprefix $(BUILD)/, $(APP_LORA_SRC_C:.c=.o) $(APP_LIB_LORA_SRC_C:.c=.o) $(APP_SX1276_SRC_C:.c=.o) $(APP_MODS_LORA_SRC_C:.c=.o))
endif

Expand All @@ -406,7 +406,7 @@ ifeq ($(BOARD), $(filter $(BOARD), LOPY FIPY))
OBJ += $(addprefix $(BUILD)/, $(APP_LORA_SRC_C:.c=.o) $(APP_LIB_LORA_SRC_C:.c=.o) $(APP_SX1272_SRC_C:.c=.o) $(APP_MODS_LORA_SRC_C:.c=.o))
endif

ifeq ($(BOARD), $(filter $(BOARD), LOPY4))
ifeq ($(BOARD), $(filter $(BOARD), LOPY4 TBEAMv1))
OBJ += $(addprefix $(BUILD)/, $(APP_LORA_SRC_C:.c=.o) $(APP_LIB_LORA_SRC_C:.c=.o) $(APP_SX1276_SRC_C:.c=.o) $(APP_MODS_LORA_SRC_C:.c=.o))
endif

Expand All @@ -416,7 +416,7 @@ ifeq ($(MOD_SIGFOX_ENABLED), 1)
ifeq ($(BOARD), $(filter $(BOARD), SIPY))
OBJ += $(addprefix $(BUILD)/, $(APP_SIGFOX_MOD_SRC_C:.c=.o))
endif
ifeq ($(BOARD), $(filter $(BOARD), LOPY4 FIPY))
ifeq ($(BOARD), $(filter $(BOARD), LOPY4 FIPY TBEAMv1))
OBJ += $(addprefix $(BUILD)/, $(APP_SIGFOX_MOD_SRC_C:.c=.o))
endif
endif
Expand All @@ -427,7 +427,7 @@ endif

# add OPENTHREAD code only if flag enabled and for LOPY, LOPY4 and FIPY
ifeq ($(OPENTHREAD), on)
ifeq ($(BOARD), $(filter $(BOARD), LOPY LOPY4 FIPY))
ifeq ($(BOARD), $(filter $(BOARD), LOPY LOPY4 FIPY TBEAMv1))
OBJ += $(addprefix $(BUILD)/, $(APP_LORA_OPENTHREAD_SRC_C:.c=.o) $(APP_MOD_MESH_SRC_C:.c=.o))
endif
endif # ifeq ($(OPENTHREAD), on)
Expand All @@ -454,10 +454,10 @@ BOOT_OBJ = $(addprefix $(BUILD)/, $(BOOT_SRC_C:.c=.o))

# List of sources for qstr extraction
SRC_QSTR += $(APP_MODS_SRC_C) $(APP_UTIL_SRC_C) $(APP_STM_SRC_C) $(APP_LIB_SRC_C) $(SRC_MOD)
ifeq ($(BOARD), $(filter $(BOARD), LOPY LOPY4 FIPY))
ifeq ($(BOARD), $(filter $(BOARD), LOPY LOPY4 FIPY TBEAMv1))
SRC_QSTR += $(APP_MODS_LORA_SRC_C)
endif
ifeq ($(BOARD), $(filter $(BOARD), SIPY LOPY4 FIPY))
ifeq ($(BOARD), $(filter $(BOARD), SIPY LOPY4 FIPY TBEAMv1))
ifeq ($(MOD_SIGFOX_ENABLED), 1)
SRC_QSTR += $(APP_SIGFOX_MOD_SRC_C)
endif
Expand All @@ -467,7 +467,7 @@ SRC_QSTR += $(APP_MODS_LTE_SRC_C)
endif

ifeq ($(OPENTHREAD), on)
ifeq ($(BOARD), $(filter $(BOARD), LOPY LOPY4 FIPY))
ifeq ($(BOARD), $(filter $(BOARD), LOPY LOPY4 FIPY TBEAMv1))
SRC_QSTR += $(APP_MOD_MESH_SRC_C)
endif
endif # ifeq ($(OPENTHREAD), on)
Expand Down Expand Up @@ -535,6 +535,16 @@ endif
ifeq ($(BOARD), LOPY)
APP_BIN = $(BUILD)/lopy.bin
endif
ifeq ($(BOARD), TBEAMv1)
APP_BIN = $(BUILD)/tbeamv1.bin
ifeq ($(MOD_SIGFOX_ENABLED), 1)
$(BUILD)/sigfox/radio_sx127x.o: CFLAGS = $(CFLAGS_SIGFOX)
$(BUILD)/sigfox/timer.o: CFLAGS = $(CFLAGS_SIGFOX)
$(BUILD)/sigfox/transmission.o: CFLAGS = $(CFLAGS_SIGFOX)
$(BUILD)/sigfox/targets/%.o: CFLAGS = $(CFLAGS_SIGFOX)
$(BUILD)/lora/spi-board.o: CFLAGS = $(CFLAGS_SIGFOX)
endif
endif
ifeq ($(BOARD), LOPY4)
APP_BIN = $(BUILD)/lopy4.bin
ifeq ($(MOD_SIGFOX_ENABLED), 1)
Expand Down Expand Up @@ -754,7 +764,7 @@ else
ifeq ($(BOARD), $(filter $(BOARD), SIPY))
$(ECHO) "$(ESPTOOLPY_WRITE_FLASH) 0x0 $(BOOTLOADER_REFLASH_DIGEST_ENC) $(PART_OFFSET) $(PART_BIN_ENCRYPT_8MB) $(APP_OFFSET) $(APP_BIN_ENCRYPT)"
$(ECHO) "Generating Encrypted Images for 4MB devices, you can use make flash and it would be handled automatically!"
endif #($(BOARD), $(filter $(BOARD), SIPY))
endif #($(BOARD), $(filter $(BOARD), SIPY TBEAMv1))
$(ECHO) "$(ESPTOOLPY_WRITE_FLASH) 0x0 $(BOOTLOADER_REFLASH_DIGEST_ENC) $(PART_OFFSET) $(PART_BIN_ENCRYPT_4MB) $(APP_OFFSET) $(APP_BIN_ENCRYPT)"
endif #ifeq ($(BOARD), $(filter $(BOARD), FIPY GPY LOPY4))
$(ECHO) $(SEPARATOR)
Expand Down Expand Up @@ -837,10 +847,10 @@ endif
ifeq ($(BOARD), $(filter $(BOARD), FIPY GPY LOPY4))
$(ECHO) "$(ESPTOOLPY_WRITE_FLASH) 0x0 $(BOOTLOADER_REFLASH_DIGEST_ENC) $(PART_OFFSET) $(PART_BIN_ENCRYPT_8MB) $(APP_OFFSET) $(APP_BIN_ENCRYPT)"
else
ifeq ($(BOARD), $(filter $(BOARD), SIPY))
ifeq ($(BOARD), $(filter $(BOARD), SIPY TBEAMv1))
$(ECHO) "$(ESPTOOLPY_WRITE_FLASH) 0x0 $(BOOTLOADER_REFLASH_DIGEST_ENC) $(PART_OFFSET) $(PART_BIN_ENCRYPT_8MB) $(APP_OFFSET) $(APP_BIN_ENCRYPT)"
$(ECHO) "Generating Encrypted Images for 4MB devices, you can use make flash and it would be handled automatically!"
endif #($(BOARD), $(filter $(BOARD), SIPY))
endif #($(BOARD), $(filter $(BOARD), SIPY TBEAMv1))
$(ECHO) "$(ESPTOOLPY_WRITE_FLASH) 0x0 $(BOOTLOADER_REFLASH_DIGEST_ENC) $(PART_OFFSET) $(PART_BIN_ENCRYPT_4MB) $(APP_OFFSET) $(APP_BIN_ENCRYPT)"
endif #ifeq ($(BOARD), $(filter $(BOARD), FIPY GPY LOPY4))
$(ECHO) $(SEPARATOR)
Expand Down
36 changes: 36 additions & 0 deletions esp32/boards/TBEAMv1/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2019, Pycom Limited.
*
* This software is licensed under the GNU GPL version 3 or any
* later version, with permitted additional terms. For more information
* see the Pycom Licence v1.0 document supplied with this file, or
* available at https://www.pycom.io/opensource/licensing
*/

#define TBEAMv1

#define MICROPY_HW_BOARD_NAME "TBEAMv1"
#define MICROPY_PY_SYS_PLATFORM "TBEAMv1"
#define MICROPY_HW_HB_PIN_NUM (0)
#define MICROPY_HW_SAFE_PIN_NUM (25)

#define DEFAULT_AP_SSID "TBEAMv1-wlan"

#define MICROPY_LPWAN_DIO_PIN

extern uint32_t micropy_hw_flash_size;

extern uint32_t micropy_hw_antenna_diversity_pin_num;

extern bool micropy_lpwan_use_reset_pin;
extern uint32_t micropy_lpwan_reset_pin_num;
extern uint32_t micropy_lpwan_reset_pin_index;
extern void * micropy_lpwan_reset_pin;

extern uint32_t micropy_lpwan_dio_pin_num;
extern uint32_t micropy_lpwan_dio_pin_index;
extern void * micropy_lpwan_dio_pin;

extern uint32_t micropy_lpwan_ncs_pin_num;
extern uint32_t micropy_lpwan_ncs_pin_index;
extern void * micropy_lpwan_ncs_pin;
26 changes: 26 additions & 0 deletions esp32/boards/TBEAMv1/pins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
G3,GPIO3,P0
G1,GPIO1,P1
G0,GPIO0,P2
G4,GPIO4,P3
G15,GPIO15,P4
G5,GPIO5,P5
G27,GPIO27,P6
G19,GPIO19,P7
G2,GPIO2,P8
G12,GPIO12,P9
G13,GPIO13,P10
G22,GPIO22,P11
G21,GPIO21,P12
G36,GPI36,P13
G37,GPI37,P14
G38,GPI38,P15
G39,GPI39,P16
G35,GPI35,P17
G34,GPI34,P18
G32,GPIO32,P19
G33,GPIO33,P20
G26,GPIO26,P21
G25,GPIO25,P22
G14,GPIO14,P23
G18,GPIO18,P97
G23,GPIO23,P98
13 changes: 13 additions & 0 deletions esp32/boards/TBEAMv1/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
["e", "0x1000", "0x40000"],
["e", "0x41000", "0x40000"],
["e", "0x81000", "0x40000"],
["e", "0xC1000", "0x40000"],
["e", "0x101000", "0x40000"],
["e", "0x141000", "0x40000"],
["e", "0x181000", "0x40000"],
["e", "0x1C1000", "0x40000"],
["w", "0x1000", "bootloader.bin"],
["w", "0x8000", "partitions_4MB.bin"],
["w", "0x10000", "tbeamv1.bin"]
]
13 changes: 13 additions & 0 deletions esp32/boards/TBEAMv1/script2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version" : "2.1",
"partitions" : {
"factory" : ["0x10000", "0x1AE000"],
"ota_0" : ["0x210000", "0x1AE000"],
"otadata" : ["0x1FF000", "0x1000"]
},
"script" : [
["w", "bootloader", "bootloader.bin"],
["w", "partitions", "partitions_4MB.bin"],
["w", "factory", "tbeamv1.bin"]
]
}
13 changes: 13 additions & 0 deletions esp32/boards/TBEAMv1/script_4MB
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version" : "2.1",
"partitions" : {
"factory" : ["0x10000", "0x1AE000"],
"ota_0" : ["0x1C0000", "0x1AE000"],
"otadata" : ["0x1BE000", "0x1000"]
},
"script" : [
["w", "bootloader", "bootloader.bin"],
["w", "partitions", "partitions_4MB.bin"],
["w", "factory", "tbeamv1.bin"]
]
}
13 changes: 13 additions & 0 deletions esp32/boards/TBEAMv1/script_4MB_enc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version" : "2.1",
"partitions" : {
"factory" : ["0x10000", "0x1AE000"],
"ota_0" : ["0x1C0000", "0x1AE000"],
"otadata" : ["0x1BE000", "0x1000"]
},
"script" : [
["w", "secureboot", "bootloader-reflash-digest.bin_enc"],
["w", "partitions", "partitions_4MB.bin_enc"],
["w", "factory", "tbeamv1.bin_enc"]
]
}
13 changes: 13 additions & 0 deletions esp32/boards/TBEAMv1/script_8MB
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version" : "2.1",
"partitions" : {
"factory" : ["0x10000", "0x1EF000"],
"ota_0" : ["0x210000", "0x1EF000"],
"otadata" : ["0x1FF000", "0x1000"]
},
"script" : [
["w", "bootloader", "bootloader.bin"],
["w", "partitions", "partitions_8MB.bin"],
["w", "factory", "lopy4.bin"]
]
}
13 changes: 13 additions & 0 deletions esp32/boards/TBEAMv1/script_8MB_enc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version" : "2.1",
"partitions" : {
"factory" : ["0x10000", "0x1EF000"],
"ota_0" : ["0x210000", "0x1EF000"],
"otadata" : ["0x1FF000", "0x1000"]
},
"script" : [
["w", "secureboot", "bootloader-reflash-digest.bin_enc"],
["w", "partitions", "partitions_8MB.bin_enc"],
["w", "factory", "lopy4.bin_enc"]
]
}
2 changes: 1 addition & 1 deletion esp32/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def parse_af_file(self, filename, pin_col, pinname_col, af_start_col):
raise ValueError("Invalid pin number {:s} in row {:s}".format(row[pin_col]), row)
pin = Pin(row[pinname_col], pin_num)
# FIXME: hack to force the SX1272 pins to be available
if row[pinname_col] == 'GPIO17' or row[pinname_col] == 'GPIO18' or row[pinname_col] == 'GPIO23':
if row[pinname_col] == 'GPIO17' or row[pinname_col] == 'GPIO18' or row[pinname_col] == 'GPIO26' or row[pinname_col] == 'GPIO23' or row[pinname_col] == 'GPIO14':
pin.board_pin = True
self.cpu_pins.append(NamedPin(row[pinname_col], pin))
# af_idx = 0
Expand Down
5 changes: 5 additions & 0 deletions esp32/fatfs/src/drivers/sflash_diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ DRESULT sflash_disk_init (void) {
if (!sflash_init_done) {
// this is how we diferentiate flash sizes in Pycom modules
if (esp32_get_chip_rev() > 0) {
#if defined(BOARD_TBEAMv1)
sflash_start_address = SFLASH_START_ADDR_4MB;
sflash_fs_sector_count = SFLASH_FS_SECTOR_COUNT_4MB;
#else
sflash_start_address = SFLASH_START_ADDR_8MB;
sflash_fs_sector_count = SFLASH_FS_SECTOR_COUNT_8MB;
#endif
} else {
sflash_start_address = SFLASH_START_ADDR_4MB;
sflash_fs_sector_count = SFLASH_FS_SECTOR_COUNT_4MB;
Expand Down
Loading