mirror of
https://github.com/pine64/blisp.git
synced 2026-09-20 02:51:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4609916981 | ||
|
|
6de3af46aa | ||
|
|
6c0c857474 | ||
|
|
a4489c7cce | ||
|
|
8bb6d2a82d | ||
|
|
717d693d0b | ||
|
|
115f1df0b3 | ||
|
|
dd2801d6e9 | ||
|
|
807c21bbef | ||
|
|
e789cdf809 |
@@ -49,6 +49,9 @@ elseif(UNIX AND NOT APPLE)
|
|||||||
${CMAKE_SOURCE_DIR}/vendor/libserialport/linux_termios.c)
|
${CMAKE_SOURCE_DIR}/vendor/libserialport/linux_termios.c)
|
||||||
target_compile_definitions(libblisp_obj PRIVATE
|
target_compile_definitions(libblisp_obj PRIVATE
|
||||||
LIBSERIALPORT_ATBUILD
|
LIBSERIALPORT_ATBUILD
|
||||||
|
HAVE_TERMIOS2_SPEED
|
||||||
|
HAVE_STRUCT_TERMIOS2
|
||||||
|
HAVE_DECL_BOTHER
|
||||||
"SP_API=__attribute__((visibility(\"default\")))"
|
"SP_API=__attribute__((visibility(\"default\")))"
|
||||||
"SP_PRIV=__attribute__((visibility(\"hidden\")))")
|
"SP_PRIV=__attribute__((visibility(\"hidden\")))")
|
||||||
write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.")
|
write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.")
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Marek Kraus <gamelaster@outlook.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Bouffalo Labs ISP tool & library
|
# Bouffalo Labs ISP tool & library
|
||||||
|
|
||||||
Tool and library for flashing their RISC-V MCUs.
|
Open source tool and library for flashing Bouffalo RISC-V MCUs.
|
||||||
|
|
||||||
**NOTE:** Library API and `blisp` tool cli arguments are not stable yet.
|
**NOTE:** Library API and `blisp` tool cli arguments are not stable yet.
|
||||||
|
|
||||||
@@ -12,6 +12,9 @@ Tool and library for flashing their RISC-V MCUs.
|
|||||||
- [ ] `bl61x` - BL616 / BL618
|
- [ ] `bl61x` - BL616 / BL618
|
||||||
- [ ] `bl808` - BL808
|
- [ ] `bl808` - BL808
|
||||||
|
|
||||||
|
# Supported Devices
|
||||||
|
- [X] [Pinecil V2](https://wiki.pine64.org/wiki/Pinecil)
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
## Clone repository
|
## Clone repository
|
||||||
@@ -38,7 +41,7 @@ cmake --build .
|
|||||||
For BL70X, BL61X, BL808 and BL606P, connected via USB, you can use following command, which will auto-detect serial port:
|
For BL70X, BL61X, BL808 and BL606P, connected via USB, you can use following command, which will auto-detect serial port:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
blisp --chip bl70x --reset name_of_firmware.bin
|
blisp write --chip bl70x --reset name_of_firmware.bin
|
||||||
```
|
```
|
||||||
|
|
||||||
For BL60X, you need to specify also the serial port path:
|
For BL60X, you need to specify also the serial port path:
|
||||||
@@ -47,6 +50,92 @@ For BL60X, you need to specify also the serial port path:
|
|||||||
blisp --chip bl60x --reset -p /dev/ttyUSB0 name_of_firmware.bin
|
blisp --chip bl60x --reset -p /dev/ttyUSB0 name_of_firmware.bin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Updating Pinecil V2: How to build BLISP Flasher
|
||||||
|
|
||||||
|
_Note: This has been tested on x86-64. The build process also works on aarch64 and armv7._
|
||||||
|
|
||||||
|
## Linux Steps
|
||||||
|
|
||||||
|
⛔ Do not use the Pinecil DC barrel jack while updating firmware or you may destroy your PC. ⛔
|
||||||
|
|
||||||
|
1. **Linux set-up**
|
||||||
|
```
|
||||||
|
git clone --recursive https://github.com/pine64/blisp.git
|
||||||
|
cd blisp
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake -DBLISP_BUILD_CLI=ON ..
|
||||||
|
cmake --build .
|
||||||
|
mkdir tools/blisp/data
|
||||||
|
mkdir -p tools/blisp/data/bl70x
|
||||||
|
```
|
||||||
|
Note: the blisp command will now be in build/tools/blisp/ folder and could later be run with flags as ` ./tools/blisp/blisp` unless you cd into that folder.
|
||||||
|
|
||||||
|
2. Get and cp or mv eflash_loader_32m.bin to bl70x folder
|
||||||
|
```
|
||||||
|
/build/tools/blisp/data/bl70x/eflash_loader_32m.bin
|
||||||
|
```
|
||||||
|
a. Download [eflash*32m.bin here](https://github.com/River-b/blisp/tree/master/eflash).
|
||||||
|
b. Move eflash*32m.bin to the build/tools/data/bl70x folder
|
||||||
|
b. Move eflash*32m.bin to the folder build/tools/data/bl70x
|
||||||
|
c. If it is a Zip, then unzip & move it.
|
||||||
|
```
|
||||||
|
unzip eflash_loader_32m.zip -d tools/blisp/data/bl70x/
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Get V2 firmware** from Github Ralim's IronOS
|
||||||
|
|
||||||
|
a. Download the newest stable [firmware release here](https://github.com/Ralim/IronOS).
|
||||||
|
|
||||||
|
b. Or download the Beta firmware [IronOS here](https://github.com/Ralim/IronOS/actions/runs/3545583488)
|
||||||
|
Scroll to the very bottom of the page and download **Pinecilv2**. This link is to [beta that has BLE and also works for EPR chargers](https://github.com/Ralim/IronOS/actions/runs/3545583488)
|
||||||
|
|
||||||
|
d. Extract **Pinecilv2.zip** and select a single language file (English = ```Pinecilv2_EN.bin```).
|
||||||
|
|
||||||
|
e. Move the Pinecilv2_EN.bin (or selected language) into the same folder as the blisp command.
|
||||||
|
```
|
||||||
|
build/tools/blisp/Pinecilv2_EN.bin
|
||||||
|
```
|
||||||
|
can delete all the rest of the Pinecilv2**.zip as it is not needed.
|
||||||
|
|
||||||
|
4. Connect Pinecil to PC/laptop: long hold [`-`] , then connect cable. Can release the [-] after about 15-20second. V2 screen should be Empty/black, if not, then repeat connection, or find another cable/port. Pinecil connects as a serial COM port.
|
||||||
|
|
||||||
|
5. If this fails, see [troubleshooting below](https://github.com/River-b/blisp/blob/master/README.md#troubleshooting).
|
||||||
|
|
||||||
|
6. If you are in the folder `blisp/build/tools/blisp/` then execute
|
||||||
|
```
|
||||||
|
sudo ./blisp write -c bl70x --reset Pinecilv2_EN.bin
|
||||||
|
```
|
||||||
|
Note: if a different language was selected, replace `Pinecilv2_**.bin` above with the chosen file name.
|
||||||
|
|
||||||
|
7. Almost done: unplug from the PC and restart V2. Hold down the minus `(-)` button to see the new version number.
|
||||||
|
|
||||||
|
8. Before making menu changes, it is recommended to first [Restore Settings to Default](https://github.com/Ralim/IronOS/blob/dev/Documentation/GettingStarted.md#settings-menu).
|
||||||
|
Simply go to Advanced settings > Restore default settings, confirm using the `(+)` button. This sets all menu items to defaults, keeps the same firmware version, and does not affect any Boot-up logo art if applicable. Setting defaults first avoids unexpected behavior due to some changes in upgrades.
|
||||||
|
|
||||||
|
9. Congradulations, and [Stay Fluxey, my friends!](https://www.reddit.com/r/PINE64official/comments/xk9vxu/most_interesting_man_in_the_world_i_dont_always/?utm_source=share&utm_medium=web2x&context=3)
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
1. If the Pinecil V2 fails to connect to the PC, check the `dmesg` command output.
|
||||||
|
|
||||||
|
a. try different cable: usb-C to C is recommended over Usb-A, especially if you are having issues.
|
||||||
|
|
||||||
|
b. don't use a USB hub, directly connect to the USB port on the PC or laptop.
|
||||||
|
|
||||||
|
c. try different Usb ports (usb-c recommended). Sometimes the rear ports on a PC are better because they are directly connected to the motherboard.
|
||||||
|
|
||||||
|
d. try a different PC/laptop
|
||||||
|
|
||||||
|
2. It is important to hold down the `(-)` minus button _before_ plugging in the Usb-c cable, and do not release the button for another 15-20 seconds. Try to hold it a little longer before releasing if your computer is slow and it is not working. In rare circumstances on fussy USB ports, keep holding the `(-)` for the entire update.
|
||||||
|
|
||||||
|
3. If all of this fails, then join one of the [Live Community Chat channels linked](https://wiki.pine64.org/wiki/Pinecil#Community_links) in the Pinecil Wiki as volunteers there might be able to help.
|
||||||
|
|
||||||
|
4. Open a an new issue ticket in this Github/Blisp flasher at https://github.com/pine64/blisp/issues
|
||||||
|
|
||||||
|
5. See [Pinecil Wiki](https://wiki.pine64.org/wiki/Pinecil) for hardware information.
|
||||||
|
|
||||||
|
6. See [Github Ralim's IronOS](https://ralim.github.io/IronOS/#getting-started) for firmware/software information. This is only the Flasher that loads the firmware; all Pinecil firmware documents and menu instructions are in IronOS.
|
||||||
|
|
||||||
|
|
||||||
# To Do
|
# To Do
|
||||||
|
|
||||||
- [ ] Another code style
|
- [ ] Another code style
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#ifndef _LIBBLISP_H
|
#ifndef _LIBBLISP_H
|
||||||
#define _LIBBLISP_H
|
#define _LIBBLISP_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#ifndef _BLISP_CHIP_H
|
#ifndef _BLISP_CHIP_H
|
||||||
#define _BLISP_CHIP_H
|
#define _BLISP_CHIP_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#ifndef _BLISP_UTIL_H
|
#ifndef _BLISP_UTIL_H
|
||||||
#define _BLISP_UTIL_H
|
#define _BLISP_UTIL_H
|
||||||
|
|
||||||
|
|||||||
+31
-9
@@ -1,9 +1,15 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#include <blisp.h>
|
#include <blisp.h>
|
||||||
|
#include <blisp_util.h>
|
||||||
#include <libserialport.h>
|
#include <libserialport.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <blisp_util.h>
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <linux/serial.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
@@ -69,7 +75,20 @@ int32_t blisp_device_open(struct blisp_device* device, const char* port_name)
|
|||||||
// } else {
|
// } else {
|
||||||
device->current_baud_rate = 500000;
|
device->current_baud_rate = 500000;
|
||||||
// }
|
// }
|
||||||
sp_set_baudrate(serial_port, device->current_baud_rate);
|
|
||||||
|
#if 0
|
||||||
|
int fd;
|
||||||
|
sp_get_port_handle(serial_port, &fd);
|
||||||
|
struct serial_struct serial;
|
||||||
|
ioctl(fd, TIOCGSERIAL, &serial);
|
||||||
|
// serial.flags &= ~(ASYNC_LOW_LATENCY);
|
||||||
|
serial.flags |= ASYNC_LOW_LATENCY;
|
||||||
|
ioctl(fd, TIOCSSERIAL, &serial);
|
||||||
|
#endif
|
||||||
|
ret = sp_set_baudrate(serial_port, device->current_baud_rate);
|
||||||
|
if (ret != SP_OK) {
|
||||||
|
return -1; // TODO: Handle this
|
||||||
|
}
|
||||||
device->serial_port = serial_port;
|
device->serial_port = serial_port;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -146,14 +165,13 @@ blisp_device_handshake(struct blisp_device* device, bool in_ef_loader) {
|
|||||||
sp_set_dtr(serial_port, SP_DTR_OFF);
|
sp_set_dtr(serial_port, SP_DTR_OFF);
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
sp_set_rts(serial_port, SP_RTS_OFF);
|
sp_set_rts(serial_port, SP_RTS_OFF);
|
||||||
|
sleep_ms(50); // Wait a bit so BootROM can init
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t bytes_count = device->chip->handshake_byte_multiplier * (float)device->current_baud_rate / 10.0f;
|
uint32_t bytes_count = device->chip->handshake_byte_multiplier * (float)device->current_baud_rate / 10.0f;
|
||||||
if (bytes_count > 600) bytes_count = 600;
|
if (bytes_count > 600) bytes_count = 600;
|
||||||
memset(handshake_buffer, 'U', bytes_count);
|
memset(handshake_buffer, 'U', bytes_count);
|
||||||
|
|
||||||
// sp_flush(serial_port, SP_BUF_BOTH);
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 5; i++) {
|
for (uint8_t i = 0; i < 5; i++) {
|
||||||
if (!in_ef_loader) {
|
if (!in_ef_loader) {
|
||||||
if (device->is_usb) {
|
if (device->is_usb) {
|
||||||
@@ -166,12 +184,16 @@ blisp_device_handshake(struct blisp_device* device, bool in_ef_loader) {
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = sp_blocking_read(serial_port, device->rx_buffer, 20, 50);
|
|
||||||
|
if (!in_ef_loader && !device->is_usb) {
|
||||||
|
sp_drain(serial_port); // Wait for write to send all data
|
||||||
|
sp_flush(serial_port, SP_BUF_INPUT); // Flush garbage out of RX
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = sp_blocking_read(serial_port, device->rx_buffer, 2, 50);
|
||||||
if (ret >= 2) {
|
if (ret >= 2) {
|
||||||
for (uint8_t j = 0; j < (ret - 1); j++) {
|
if (device->rx_buffer[0] == 'O' && device->rx_buffer[1] == 'K') {
|
||||||
if (device->rx_buffer[j] == 'O' && device->rx_buffer[j + 1] == 'K') {
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#include "blisp.h"
|
#include "blisp.h"
|
||||||
|
|
||||||
struct blisp_chip blisp_chip_bl60x = {
|
struct blisp_chip blisp_chip_bl60x = {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#include "blisp.h"
|
#include "blisp.h"
|
||||||
|
|
||||||
struct blisp_chip blisp_chip_bl70x = {
|
struct blisp_chip blisp_chip_bl70x = {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#ifndef BLISP_CMD_H
|
#ifndef BLISP_CMD_H
|
||||||
#define BLISP_CMD_H
|
#define BLISP_CMD_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#include "../cmd.h"
|
#include "../cmd.h"
|
||||||
#include "argtable3.h"
|
#include "argtable3.h"
|
||||||
#include <blisp.h>
|
#include <blisp.h>
|
||||||
@@ -25,6 +26,29 @@ static struct arg_lit* reset;
|
|||||||
static struct arg_end* end;
|
static struct arg_end* end;
|
||||||
static void* cmd_write_argtable[6];
|
static void* cmd_write_argtable[6];
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// Ugh. This stuff is just so messy without C++17 or Qt...
|
||||||
|
// These are not thread safe, but it doesn't place the responsibility
|
||||||
|
// to free an allocated buffer on the caller.nn
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static void get_executable_path(char* buffer_out, uint32_t max_size) {
|
||||||
|
assert (max_size >= PATH_MAX); // n.b. 1024 on MacOS. 4K on most Linux.
|
||||||
|
|
||||||
|
char raw_path_name[PATH_MAX]; // $HOME/../../var/tmp/x
|
||||||
|
char real_path_name[PATH_MAX]; // /var/tmp/x
|
||||||
|
uint32_t raw_path_size = sizeof(raw_path_name);
|
||||||
|
|
||||||
|
if(!_NSGetExecutablePath(raw_path_name, &raw_path_size)) {
|
||||||
|
realpath(raw_path_name, real_path_name);
|
||||||
|
}
|
||||||
|
// *real_path_name is appropriately sized and null terminated.
|
||||||
|
strcpy(buffer_out, real_path_name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
get_binary_folder(char* buffer, uint32_t buffer_size) {
|
get_binary_folder(char* buffer, uint32_t buffer_size) {
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@@ -32,6 +56,9 @@ get_binary_folder(char* buffer, uint32_t buffer_size) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
char* pos = strrchr(buffer, '/');
|
char* pos = strrchr(buffer, '/');
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
get_executable_path(buffer, buffer_size);
|
||||||
|
char* pos = strrchr(buffer, '/');
|
||||||
#else
|
#else
|
||||||
if (GetModuleFileName(NULL, buffer, buffer_size) <= 0) {
|
if (GetModuleFileName(NULL, buffer, buffer_size) <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#include "argtable3.h"
|
#include "argtable3.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user