Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Belling BL0942 #1

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3c22036
damn - reverse that commit!
btsimonh Feb 2, 2022
59be458
fix python language error
ExploWare Feb 16, 2022
0261323
Merge pull request #1 from ExploWare/patch-1
openshwprojects Feb 17, 2022
1370a3c
Update README.md
btsimonh Mar 6, 2022
59103c5
Update README.md
openshwprojects Apr 13, 2022
d1a7309
Add a workaround for boot_protocol baud rate reply.
zopieux Apr 14, 2022
d00367b
Merge pull request #4 from zopieux/fix-boot
btsimonh Apr 14, 2022
b3ab75c
Update README.md
openshwprojects Apr 18, 2022
e44c57a
Update README.md
openshwprojects Apr 18, 2022
a0ac7af
save file even if crc fails
openshwprojects May 8, 2022
adaf64c
adding info to windows installation
yarix Sep 3, 2022
ba32e7f
Update README.md
atc1441 Sep 6, 2022
54b589f
Merge pull request #7 from yarix/patch-1
openshwprojects Sep 8, 2022
e4a1abe
Merge pull request #8 from atc1441/patch-1
openshwprojects Sep 8, 2022
6095d6b
Update README.md
openshwprojects Jan 8, 2023
4da2a3c
Create requirements.txt
kquinsland Jan 14, 2023
323d418
Update README.md
kquinsland Jan 14, 2023
fd4726e
Merge pull request #13 from kquinsland/kquinsland-patch-1
openshwprojects Jan 17, 2023
61c07f1
Update README.md
openshwprojects Mar 13, 2023
6a218b6
add all flash ,such as GD / puya / TH / ESMT ...
yq1515 Mar 14, 2024
651a6a0
Fix uart write Drain timeout
zuckschwerdt Apr 7, 2024
e2e66d3
Add more flash chip identifiers
zuckschwerdt Apr 7, 2024
ce6703c
Merge pull request #15 from zuckschwerdt/fix-drain
openshwprojects Apr 11, 2024
c7ea7a5
Merge pull request #14 from yq1515/master
openshwprojects Apr 11, 2024
a3afe87
Merge branch 'master' into feat-flash
openshwprojects Apr 11, 2024
1661378
Merge pull request #16 from zuckschwerdt/feat-flash
openshwprojects Apr 11, 2024
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
70 changes: 60 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# NOTE- THIS REPO HAS MOVE TO https://github.com/OpenBekenIOT



# What is this?

This repo is a fork of a Beken repo which can program BK7321 series devices over serial using the serial bootloader.

It is mostly used to flash our Tasmota replacement on BK7231T/BK7231N, for details see here:

https://github.com/openshwprojects/OpenBK7231T_App

HID has been disabled so that you don't need to find the relevant libraries, to enable easy windows use.

It has been modified to
Expand All @@ -16,27 +16,76 @@ It has been modified to

3/ spiprogram has been added - this works on a Raspberry pi using it's native SPI - see SPIFlash.md and rpi3install.md

* pairs with https://github.com/btsimonh/tuya-iotos-embeded-sdk-wifi-ble-bk7231t
# [Youtube guide for flashing BK7231N with hid_download_py](https://www.youtube.com/watch?v=2e1SUQNMrgY&ab_channel=Elektrodacom)
You can also check our other videos related to flashing IoT devices.

# Blog post about BK7231N flashing by Zorruno

https://zorruno.com/2022/zemismart-ks-811-with-openbk7231n-openbeken/

# Detailed examples of flashing Beken chips

Please see our detailed step by step guides for more information:

https://www.elektroda.com/rtvforum/topic3880540.html

https://www.elektroda.com/rtvforum/topic3875654.html

https://www.elektroda.com/rtvforum/topic3874289.html

# Install for Debian/Ubuntu/Linux Mint

## Installation

```
```shell
$ apt install python3-hid python3-serial python3-tqdm
$ python3 setup.py install --user
```

Or use `requirements.txt` with `pip`:

```shell
# If you use mkvenv, it will pick up the requirements.txt for you
$ mkvenv
Creating hid_download_py-master-uD7eej0e virtualenv
created virtual environment CPython3.10.8.final.0-64 in 86ms
<...>
Found a requirements.txt file. Install? [y/N]: Y
Collecting hid
Using cached hid-1.0.5-py3-none-any.whl
Collecting pyserial
Using cached pyserial-3.5-py2.py3-none-any.whl (90 kB)
Collecting tqdm
Using cached tqdm-4.64.1-py2.py3-none-any.whl (78 kB)
Installing collected packages: pyserial, hid, tqdm
Successfully installed hid-1.0.5 pyserial-3.5 tqdm-4.64.1
# Or with regular `pip`
$ pip3 install -r requirements.txt
Collecting hid
Using cached hid-1.0.5-py3-none-any.whl
Collecting pyserial
Using cached pyserial-3.5-py2.py3-none-any.whl (90 kB)
Collecting tqdm
Using cached tqdm-4.64.1-py2.py3-none-any.whl (78 kB)
Installing collected packages: pyserial, hid, tqdm
Successfully installed hid-1.0.5 pyserial-3.5 tqdm-4.64.1
```

## Windows

Create a python virtual environment
* Download hidapi from https://github.com/libusb/hidapi/releases, extrat it to somewhere in windows %PATH%
* Create a python virtual environment

run install.bat to install the needed packages
* run `install.bat` to install the needed packages


## SPI Usage

see SPIFlash.md for instructions on how to unbrick devices using a raspberry pi...


## HID Usage

(disabled in this repo)

```
Expand Down Expand Up @@ -78,17 +127,18 @@ optional arguments:
-l LENGTH, --length LENGTH
length to read, defaults to 0x1000
-b BAUDRATE, --baudrate BAUDRATE
burn uart baudrate, defaults to 1500000
burn uart baudrate, defaults to 921600
-u, --unprotect unprotect flash first, used by BK7231N
-r, --read read flash
-w, --write read flash
-w, --write write flash
-p, --unpackage unPackage firmware
```

* For chips exclude `BK7231N`, download address defaults to `0x11000`, **don't** set `-u` option.

* For `BK7231N`, set download address to `0x0`, and **set** `-u` option.

* note that the default baud rate is 921600 - it connects first at 115200, then sends a command to change the baudrate. So if you get a connection, but then 'Set Baudrate Failed', it could be that your connections/uart are not capable of the default 921600 baud, so try a lower one. If you get 'write sector failed', this can also be a mis-communication, so lower the baud rate. Common 'faster' baud rates are 115200, 230400, 460800, 576000, 921600, 1500000. uartprogram's default used to be 1.5Mbit, but we reduced it to 921600 for better reliability - but this may still be too high for some USB devices & connections.

## examples:

Expand Down
9 changes: 9 additions & 0 deletions bkutils/boot_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ def CheckRespond_WriteReg(buf, regAddr, val):
return True if len(cBuf) <= len(buf) and cBuf == buf[:len(cBuf)] else False

def CheckRespond_SetBaudRate(buf, baudrate, dly_ms):
# It seems like multiple people are affected by the baud rate reply
# containing two concatenated messages, with the one we need (baud rate reply)
# arriving second. Therefore ignore the unexpected-but-actually-expected
# message if it's there.
# https://github.com/OpenBekenIOT/hid_download_py/issues/3
unexpected = bytearray([0x04, 0x0e, 0x05, 0x01, 0xe0, 0xfc, 0x01, 0x00])
if buf[:len(unexpected)] == unexpected:
buf = buf[len(unexpected):]
print("caution: ignoring unexpected reply in SetBaudRate")
cBuf =bytearray([0x04,0x0e,0x05,0x01,0xe0,0xfc,CMD_SetBaudRate,0,0,0,0,0])
cBuf[2]=3+1+4+1
cBuf[7]=(baudrate&0xff)
Expand Down
Loading