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

Commit 24c3576

Browse files
authored
Merge pull request #473 from pycom/Dev
Push latest Dev changes into Release/v1.20
2 parents 58398d3 + 783192e commit 24c3576

File tree

277 files changed

+4573
-2129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+4573
-2129
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ user.props
3636
.pydevproject
3737
.settings
3838
.launch
39+
.vscode
3940

4041
# Key files (for Flash Encryption and Secure Boot)
4142
secure_boot_signing_key.pem

Jenkinsfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ node {
99
stage('Checkout') {
1010
checkout scm
1111
sh 'rm -rf esp-idf'
12-
sh 'git clone --depth=1 --recursive -b idf_v3.2 https://github.com/pycom/pycom-esp-idf.git esp-idf'
12+
sh 'git clone --recursive -b idf_v3.3.1 https://github.com/pycom/pycom-esp-idf.git esp-idf'
13+
IDF_HASH=get_idf_hash()
14+
dir('esp-idf'){
15+
sh 'git checkout ' + IDF_HASH
16+
sh 'git submodule update --init --recursive'
17+
}
1318
}
14-
19+
1520
stage('git-tag') {
1621
PYCOM_VERSION=get_version()
1722
GIT_TAG = sh (script: 'git rev-parse --short HEAD', returnStdout: true).trim()
@@ -85,7 +90,8 @@ def flashBuild(short_name, version, variant) {
8590
unstash 'esp32Tools'
8691
unstash 'tests'
8792
unstash 'tools'
88-
sh 'python esp32/tools/fw_updater/updater.py --port ' + device_name +' flash -t esp32/build-' + variant + '/' + board_name + '-' + version + '.tar.gz'
93+
sh 'python esp32/tools/fw_updater/updater.py --noexit --port ' + device_name +' flash -t esp32/build-' + variant + '/' + board_name + '-' + version + '.tar.gz'
94+
sh 'python esp32/tools/fw_updater/updater.py --port ' + device_name +' pybytes --auto_start False'
8995
}
9096
}
9197
}
@@ -114,6 +120,11 @@ def get_version() {
114120
matcher ? matcher[0][1].trim().replace('"','') : null
115121
}
116122

123+
def get_idf_hash() {
124+
def matcher = readFile('esp32/Makefile') =~ 'IDF_HASH=(.+)'
125+
matcher ? matcher[0][1].trim().replace('"','') : null
126+
}
127+
117128
def get_firmware_name(short_name) {
118129
node {
119130
def node_info = sh (script: 'cat ${JENKINS_HOME}/pycom-ic.conf || exit 0', returnStdout: true).trim()

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ board (PyBoard), the officially supported reference electronic circuit board.
2626
The following components are actively maintained by Pycom:
2727
- py/ -- the core Python implementation, including compiler, runtime, and
2828
core library.
29-
- exp32/ -- a version of MicroPython that runs on the ESP32 based boards from Pycom.
29+
- esp32/ -- a version of MicroPython that runs on the ESP32 based boards from Pycom.
3030
- tests/ -- test framework and test scripts.
3131

3232
Additional components:
@@ -74,7 +74,7 @@ Then when you need the toolchain you can type ``get_esp32`` on the command line
7474
You also need the ESP IDF along side this repository in order to build the ESP32 port.
7575
To get it:
7676

77-
$ git clone --recursive -b idf_v3.2 https://github.com/pycom/pycom-esp-idf.git
77+
$ git clone --recursive -b idf_v3.3.1 https://github.com/pycom/pycom-esp-idf.git
7878

7979
After cloning, if you did not specify the --recursive option, make sure to checkout all the submodules:
8080

docs/library/ussl.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ network sockets, both client-side and server-side.
114114

115115
SSL sockets inherit all methods and from the standard sockets, see the :mod:`usocket` module.
116116

117+
.. function:: ssl.save_session(sock)
118+
119+
Takes an instance sock of ssl.SSLSocket, and returns an instance of ssl.SSLSession representing saved session data from the socket, which can be used to resume a SSL session later. Example::
120+
121+
import socket
122+
import ssl
123+
addr = socket.getaddrinfo('www.google.com', 443)[0][-1]
124+
sock_one = ssl.wrap_socket(socket.socket())
125+
sock_one.connect(addr) # performs a full ssl handshake
126+
session = ssl.save_session(sock_one)
127+
sock_one.close()
128+
sock_one = None
129+
sock_two = ssl.wrap_socket(socket.socket(), saved_session=session)
130+
sock_two.connect(addr) # resumes using saved session, resulting in a faster handshake
131+
117132
Exceptions
118133
----------
119134

docs/license.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2323
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
THE SOFTWARE.
2525

26-
Copyright (c) 2019, Pycom Limited.
26+
Copyright (c) 2020, Pycom Limited.
2727

2828
This software is licensed under the GNU GPL version 3 or any
2929
later version, with permitted additional terms. For more information

drivers/sx127x/sx1272/sx1272.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is derived from the MicroPython project, http://micropython.org/
33
*
4-
* Copyright (c) 2019, Pycom Limited and its licensors.
4+
* Copyright (c) 2020, Pycom Limited and its licensors.
55
*
66
* This software is licensed under the GNU GPL version 3 or any later version,
77
* with permitted additional terms. For more information see the Pycom Licence

drivers/sx127x/sx1276/sx1276.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is derived from the MicroPython project, http://micropython.org/
33
*
4-
* Copyright (c) 2019, Pycom Limited and its licensors.
4+
* Copyright (c) 2020, Pycom Limited and its licensors.
55
*
66
* This software is licensed under the GNU GPL version 3 or any later version,
77
* with permitted additional terms. For more information see the Pycom Licence

esp32/Makefile

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright © 2019, Pycom Limited.
2+
# Copyright © 2020, Pycom Limited.
33
#
44
# This software is licensed under the GNU GPL version 3 or any
55
# later version, with permitted additional terms. For more information
@@ -14,7 +14,7 @@ ifeq ($(wildcard boards/$(BOARD)/.),)
1414
$(error Invalid BOARD specified)
1515
endif
1616

17-
IDF_VERSION=3.2
17+
IDF_HASH=6ec081c
1818

1919
TARGET ?= boot_app
2020

@@ -103,17 +103,10 @@ LIBS = -L$(ESP_IDF_COMP_PATH)/esp32/lib -L$(ESP_IDF_COMP_PATH)/esp32/ld -L$(ESP_
103103
$(ESP_IDF_COMP_PATH)/newlib/lib/libc-psram-workaround.a \
104104
-lfreertos -ljson -ljsmn -llwip -lnewlib -lvfs -lopenssl -lmbedtls -lwpa_supplicant \
105105
-lxtensa-debug-module -lbt -lsdmmc -lsoc -lheap -lbootloader_support -lmicro-ecc \
106-
-u ld_include_panic_highint_hdl -lsmartconfig_ack -lmesh -lesp_ringbuf -lcoap -lmdns
107-
ifeq ($(BOARD), $(filter $(BOARD), FIPY))
108-
LIBS += sigfox/modsigfox_fipy.a
109-
endif
110-
111-
ifeq ($(BOARD), $(filter $(BOARD), LOPY4))
112-
LIBS += sigfox/modsigfox_lopy4.a
113-
endif
114-
115-
ifeq ($(BOARD), $(filter $(BOARD), SIPY))
116-
LIBS += sigfox/modsigfox_sipy.a
106+
-u ld_include_panic_highint_hdl -lsmartconfig_ack -lmesh -lesp_ringbuf -lcoap -lmdns -lefuse -lespcoredump -lapp_update
107+
ifeq ($(BOARD), $(filter $(BOARD), SIPY LOPY4 FIPY))
108+
LIBS += sigfox/modsigfox_$(BOARD).a
109+
$(BUILD)/application.elf: sigfox/modsigfox_$(BOARD).a
117110
endif
118111

119112
ifeq ($(OPENTHREAD), on)
@@ -134,7 +127,7 @@ endif #ifeq ($(LTE_LOG_BUFF),1)
134127

135128
B_LIBS = -Lbootloader/lib -Lbootloader -L$(BUILD)/bootloader -L$(ESP_IDF_COMP_PATH)/esp32/ld \
136129
-L$(ESP_IDF_COMP_PATH)/esp32/lib -llog -lcore -lbootloader_support \
137-
-lspi_flash -lsoc -lmicro-ecc -lgcc -lstdc++ -lgcov
130+
-lspi_flash -lsoc -lmicro-ecc -lgcc -lstdc++ -lgcov -lefuse
138131

139132
# objcopy paramters, to transform a binary file into an object file
140133
OBJCOPY_EMBED_ARGS = --input-target binary --output-target elf32-xtensa-le --binary-architecture xtensa --rename-section .data=.rodata.embedded

esp32/PyJTAG/Readme.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Short readme for how to use the PyJTAG
2+
3+
## Setup
4+
Generally follow these rules to setup JTAG debugging on your OS: https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/jtag-debugging/index.html
5+
6+
Download link for OpenOCD for ESP32 from Espressif: https://github.com/espressif/openocd-esp32/releases
7+
8+
9+
## Build the firmware
10+
Create the firmware with `BTYPE=debug` flag.
11+
12+
Note: Do not use the default pins assigned to UART, SPI, CAN because they are used by the JTAG. Pins not to be used: P4, P9, P10, P23.
13+
14+
## Setup the PyJTAG board
15+
16+
PyJTAG's switches:
17+
* ESP32 JTAG: all turned ON
18+
* ESP32 B.LOADER: all turned ON except SAFE_BOOT_SW which is OFF
19+
* TO LTE UART 1/2: does not matter
20+
* CURRENT SHUNTS: connected
21+
22+
Place the Pycom board with the reset button towards the Current Shunts. Now connect the PyJTAG via usb. You will see four new USB devices. On Linux this will look like this:
23+
```
24+
$ lsusb -d 0403:
25+
Bus 001 Device 010: ID 0403:6011 Future Technology Devices International, Ltd FT4232H Quad HS USB-UART/FIFO IC
26+
$ ls /dev/ttyUSB?
27+
/dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3
28+
```
29+
30+
## Start OCD
31+
32+
Go to `esp32` folder in Firmware-Development repository and run:
33+
```
34+
PATH_TO_OPENOCD/bin/openocd -s PATH_TO_OPENOCD/share/openocd/scripts -s PyJTAG -f PyJTAG/interface/ftdi/esp32-pycom.cfg -f PyJTAG/board/esp32-pycom.cfg
35+
```
36+
37+
Output should be like:
38+
```
39+
Open On-Chip Debugger v0.10.0-esp32-20191114 (2019-11-14-14:15)
40+
Licensed under GNU GPL v2
41+
For bug reports, read
42+
http://openocd.org/doc/doxygen/bugs.html
43+
none separate
44+
adapter speed: 20000 kHz
45+
Info : Configured 2 cores
46+
Info : Listening on port 6666 for tcl connections
47+
Info : Listening on port 4444 for telnet connections
48+
Error: type 'esp32' is missing virt2phys
49+
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
50+
Info : clock speed 20000 kHz
51+
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
52+
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
53+
Info : Listening on port 3333 for gdb connections
54+
```
55+
56+
## Start GDB
57+
58+
When OpenOCD is running, start GDB from `esp32` folder. Assuming you have a FIPY:
59+
```
60+
xtensa-esp32-elf-gdb -x PyJTAG/gdbinit build/FIPY/debug/application.elf
61+
```
62+
63+
In `PyJTAG/gdbinit` a breakpoint is configured at `TASK_Micropython`, so execution should stop there first:
64+
65+
```
66+
Thread 1 hit Temporary breakpoint 1, TASK_Micropython (pvParameters=0x0) at mptask.c:136
67+
```
68+
69+
70+
## REPL
71+
72+
Connect to `/dev/ttyUSB2` to reach the REPL terminal over usb serial. E.g. using pymakr in Atom.
73+
74+
## Troubleshooting
75+
If openocd says "Error: Connect failed", try to close gdb and openocd and start over.
76+
77+
If `/dev/ttyUSB0` doesn't show up or disappears, disconnect the PyJTAG board, reconnect and start over.
78+
79+
It can be advisable to use the `gdb` from the latest xtensa toolchain, even if an earlier version is used to build the firmware.
80+
81+
If `gdb` does not reach the `Thread 1 hit Temporary breakpoint ...` line, close and reopen `gdb`.
82+
83+
84+
## Versions
85+
There are two generations of PyJTAG boards:
86+
87+
1) First generation with green PCB has three blocks of switches. (Make sure SAFE_BOOT_SW is off.)
88+
2) Second generation with black PCB and two blocks of switches.
89+
90+
Both generation boards can be equipped with pogo pins that connect to the bottom of the development board and allow LTE debugging. There can either be pins that connect to a GPy or pins that conenct to a FiPy.
91+
92+
To reach the modem UART connect to `/dev/ttyUSB1`.
93+
94+
## Extra
95+
A few more details are here: https://pycomiot.atlassian.net/wiki/spaces/FIR/pages/966295564/Usage+of+PyJTAG
96+

esp32/PyJTAG/board/esp32-pycom.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set ESP32_FLASH_VOLTAGE 3.3
2+
source [find target/esp32-pycom.cfg]

esp32/PyJTAG/gdbinit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target remote :3333
2+
mon reset halt
3+
flushregs
4+
thb TASK_Micropython
5+
c
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Driver for the FT4232HL JTAG chip on the Pycom's PyJTAG board
3+
#
4+
5+
6+
interface ftdi
7+
ftdi_vid_pid 0x0403 0x6011
8+
9+
# interface 1 is the uart
10+
ftdi_channel 0
11+
12+
# TCK, TDI, TDO, TMS: ADBUS0-3
13+
# LEDs: ACBUS4-7
14+
15+
ftdi_layout_init 0x0008 0xf00b
16+
#ftdi_layout_signal LED -data 0x1000
17+
#ftdi_layout_signal LED2 -data 0x2000
18+
#ftdi_layout_signal LED3 -data 0x4000
19+
#ftdi_layout_signal LED4 -data 0x8000
20+
21+
# ESP32 series chips do not have a TRST input, and the SRST line is connected
22+
# to the EN pin.
23+
# The target code doesn't handle SRST reset properly yet, so this is
24+
# commented out:
25+
# ftdi_layout_signal nSRST -oe 0x0020
26+
27+
reset_config none
28+
29+
# The speed of the JTAG interface, in KHz. If you get DSR/DIR errors (and they
30+
# do not relate to OpenOCD trying to read from a memory range without physical
31+
# memory being present there), you can try lowering this.
32+
#
33+
# On DevKit-J, this can go as high as 20MHz if CPU frequency is 80MHz, or 26MHz
34+
# if CPU frequency is 160MHz or 240MHz.
35+
adapter_khz 20000

esp32/PyJTAG/target/esp32-pycom.cfg

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# The ESP32 only supports JTAG.
2+
transport select jtag
3+
4+
# Source the ESP common configuration file
5+
source [find target/esp_common.cfg]
6+
7+
if { [info exists CHIPNAME] } {
8+
set _CHIPNAME $CHIPNAME
9+
} else {
10+
set _CHIPNAME esp32
11+
}
12+
13+
if { [info exists CPUTAPID] } {
14+
set _CPUTAPID $CPUTAPID
15+
} else {
16+
set _CPUTAPID 0x120034e5
17+
}
18+
19+
if { [info exists ESP32_ONLYCPU] } {
20+
set _ONLYCPU $ESP32_ONLYCPU
21+
} else {
22+
set _ONLYCPU 3
23+
}
24+
25+
if { [info exists ESP32_FLASH_VOLTAGE] } {
26+
set _FLASH_VOLTAGE $ESP32_FLASH_VOLTAGE
27+
} else {
28+
set _FLASH_VOLTAGE 3.3
29+
}
30+
31+
set _TARGETNAME $_CHIPNAME
32+
set _CPU0NAME cpu0
33+
set _CPU1NAME cpu1
34+
set _TAPNAME $_CHIPNAME.$_CPU0NAME
35+
36+
jtag newtap $_CHIPNAME $_CPU0NAME -irlen 5 -expected-id $_CPUTAPID
37+
if { $_ONLYCPU != 1 } {
38+
jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -expected-id $_CPUTAPID
39+
} else {
40+
jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -disable -expected-id $_CPUTAPID
41+
}
42+
43+
if { $_RTOS == "none" } {
44+
target create $_TARGETNAME esp32 -endian little -chain-position $_TAPNAME
45+
} else {
46+
target create $_TARGETNAME esp32 -endian little -chain-position $_TAPNAME -rtos $_RTOS
47+
}
48+
49+
configure_esp_workarea $_TARGETNAME 0x40090000 0x3400 0x3FFC0000 0x6000
50+
configure_esp_flash_bank $_TARGETNAME $_TARGETNAME $_FLASH_SIZE
51+
52+
esp32 flashbootstrap $_FLASH_VOLTAGE
53+
esp32 maskisr on
54+
if { $_SEMIHOST_BASEDIR != "" } {
55+
esp32 semihost_basedir $_SEMIHOST_BASEDIR
56+
}
57+
if { $_FLASH_SIZE == 0 } {
58+
gdb_breakpoint_override hard
59+
}
60+
61+
# special function to program ESP32, it differs from the original 'program' that
62+
# it verifies written image by reading flash directly, instead of reading memory mapped flash regions
63+
proc program_esp32 {filename args} {
64+
program_esp $filename $args
65+
}
66+
67+
add_help_text program_esp32 "write an image to flash, address is only required for binary images. verify, reset, exit are optional"
68+
add_usage_text program_esp32 "<filename> \[address\] \[verify\] \[reset\] \[exit\]"
69+

0 commit comments

Comments
 (0)