ota2 is deprecated
parent
674fa669df
commit
2097fbb000
|
@ -37,7 +37,6 @@ main: obj/$(PROJ_NAME).bin
|
|||
./tools/dfu-util-$(MACHINE) --reset-stm32 -a 0 -s 0x08000000
|
||||
|
||||
ota: obj/$(PROJ_NAME).bin
|
||||
#./tools/ota2.py $<
|
||||
curl http://192.168.0.10/stupdate --upload-file $<
|
||||
|
||||
ifneq ($(wildcard ../.git/HEAD),)
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
import socket
|
||||
from hexdump import hexdump
|
||||
import time
|
||||
from tqdm import tqdm
|
||||
|
||||
def cmd(sock, d1, d2=0, dat=None):
|
||||
if dat == None:
|
||||
dat = "\x00"*0x10
|
||||
sock.send(chr(d1) + chr(0xff^d1) + chr(d2) + chr(0xff^d2) + dat)
|
||||
|
||||
def main():
|
||||
cntl = socket.create_connection(("192.168.0.10", 3333))
|
||||
|
||||
cntl.send("br")
|
||||
time.sleep(0.1)
|
||||
|
||||
dat = open(sys.argv[1]).read()
|
||||
dat += "\xff"*(0x10-(len(dat)%0x10))
|
||||
print "flashing 0x%X bytes" % len(dat)
|
||||
|
||||
sock = socket.create_connection(("192.168.0.10", 1337))
|
||||
|
||||
# unlock flash
|
||||
cmd(sock, 0x10)
|
||||
sock.recv(0x100)
|
||||
|
||||
# erase sector
|
||||
cmd(sock, 0x11, 1)
|
||||
sock.recv(0x100)
|
||||
|
||||
# wait for erase
|
||||
while 1:
|
||||
cmd(sock, 0xf)
|
||||
ret = sock.recv(0x100)
|
||||
if ret[-4:] == "\xde\xad\xd0\x0d":
|
||||
break
|
||||
time.sleep(0.05)
|
||||
|
||||
# program
|
||||
for i in tqdm(range(0, len(dat), 0x10)):
|
||||
td = dat[i:i+0x10]
|
||||
cmd(sock, 0x12, 4, td)
|
||||
ret = sock.recv(0x100)
|
||||
#hexdump(ret)
|
||||
assert ret[0x30:0x40] == td
|
||||
|
||||
# reboot normal
|
||||
cntl.send("nr")
|
||||
time.sleep(0.1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -216,7 +216,6 @@ void loop();
|
|||
|
||||
void ICACHE_FLASH_ATTR web_init();
|
||||
void ICACHE_FLASH_ATTR elm327_init();
|
||||
void ICACHE_FLASH_ATTR st_ota_init();
|
||||
|
||||
void ICACHE_FLASH_ATTR user_init()
|
||||
{
|
||||
|
@ -261,7 +260,6 @@ void ICACHE_FLASH_ATTR user_init()
|
|||
wifi_init();
|
||||
|
||||
// support ota upgrades
|
||||
st_ota_init();
|
||||
elm327_init();
|
||||
web_init();
|
||||
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
#include "ets_sys.h"
|
||||
#include "osapi.h"
|
||||
#include "gpio.h"
|
||||
#include "os_type.h"
|
||||
#include "user_interface.h"
|
||||
#include "espconn.h"
|
||||
|
||||
#include "driver/gpio16.h"
|
||||
#include "driver/uart.h"
|
||||
|
||||
#define ST_OTA_PORT 3333
|
||||
|
||||
static struct espconn ota_conn;
|
||||
static esp_tcp ota_proto;
|
||||
|
||||
#define ST_RESET_PIN 16
|
||||
|
||||
// for out of band access
|
||||
static void ICACHE_FLASH_ATTR ota_rx_cb(void *arg, char *data, uint16_t len) {
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (data[i] == 'n') {
|
||||
// no boot mode (pull high)
|
||||
gpio_output_set((1 << 4), 0, (1 << 4), 0);
|
||||
} else if (data[i] == 'b') {
|
||||
// boot mode (pull low)
|
||||
gpio_output_set(0, (1 << 4), (1 << 4), 0);
|
||||
} else if (data[i] == 'r') {
|
||||
// reset the ST
|
||||
gpio16_output_conf();
|
||||
gpio16_output_set(0);
|
||||
os_delay_us(10000);
|
||||
gpio16_output_set(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ICACHE_FLASH_ATTR ota_tcp_connect_cb(void *arg) {
|
||||
struct espconn *conn = (struct espconn *)arg;
|
||||
os_printf("ST OTA connection received from "IPSTR":%d\n",
|
||||
IP2STR(conn->proto.tcp->remote_ip), conn->proto.tcp->remote_port);
|
||||
|
||||
espconn_regist_recvcb(conn, ota_rx_cb);
|
||||
//espconn_regist_disconcb(conn, ota_disc_cb);
|
||||
//espconn_regist_reconcb(conn, ota_recon_cb);
|
||||
|
||||
char message[] = "ST control v2\r\n";
|
||||
espconn_send(&ota_conn, message, strlen(message));
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR st_ota_init() {
|
||||
// control listener
|
||||
ota_proto.local_port = ST_OTA_PORT;
|
||||
ota_conn.type = ESPCONN_TCP;
|
||||
ota_conn.state = ESPCONN_NONE;
|
||||
ota_conn.proto.tcp = &ota_proto;
|
||||
espconn_regist_connectcb(&ota_conn, ota_tcp_connect_cb);
|
||||
espconn_accept(&ota_conn);
|
||||
}
|
||||
|
Loading…
Reference in New Issue