mirror of
https://github.com/pine64/blisp.git
synced 2025-04-21 09:47:19 +00:00
Fix it to work under FreeBSD
Add sp_drain() where needed. Without it FreeBSD won't pass the handshake phase. Also decreate max buffer size. Tested with Pinecil v2 and it can write and check new firmware.
This commit is contained in:
parent
7fb2cc829c
commit
6424f9ddf8
@ -17,6 +17,7 @@ Open source tool and library for flashing Bouffalo RISC-V MCUs.
|
||||
- [x] Windows
|
||||
- [x] Linux
|
||||
- [x] Apple
|
||||
- [x] FreeBSD
|
||||
|
||||
# Building
|
||||
|
||||
|
16
lib/blisp.c
16
lib/blisp.c
@ -13,6 +13,12 @@
|
||||
|
||||
#define DEBUG
|
||||
|
||||
static void drain(struct sp_port* port) {
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
sp_drain(port);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t blisp_device_init(struct blisp_device* device,
|
||||
struct blisp_chip* chip) {
|
||||
device->chip = chip;
|
||||
@ -130,9 +136,7 @@ int32_t blisp_send_command(struct blisp_device* device,
|
||||
blisp_dlog("Received error or not written all data: %d", ret);
|
||||
return BLISP_ERR_UNKNOWN;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
sp_drain(serial_port);
|
||||
#endif
|
||||
drain(serial_port);
|
||||
|
||||
return BLISP_OK;
|
||||
}
|
||||
@ -195,12 +199,12 @@ int32_t blisp_device_handshake(struct blisp_device* device, bool in_ef_loader) {
|
||||
if (!in_ef_loader) {
|
||||
if (device->is_usb) {
|
||||
sp_blocking_write(serial_port, "BOUFFALOLAB5555RESET\0\0", 22, 100);
|
||||
#ifdef __APPLE__
|
||||
sp_drain(serial_port);
|
||||
#endif
|
||||
drain(serial_port);
|
||||
}
|
||||
}
|
||||
ret = sp_blocking_write(serial_port, handshake_buffer, bytes_count, 500);
|
||||
// not sure about Apple part, but FreeBSD needs it
|
||||
drain(serial_port);
|
||||
if (ret < 0) {
|
||||
blisp_dlog("Handshake write failed, ret %d", ret);
|
||||
return BLISP_ERR_UNKNOWN;
|
||||
|
@ -331,7 +331,7 @@ int32_t blisp_easy_flash_write(struct blisp_device* device,
|
||||
uint32_t data_size,
|
||||
blisp_easy_progress_callback progress_callback) {
|
||||
int32_t ret;
|
||||
#ifdef __APPLE__
|
||||
#if defined (__APPLE__) || defined (__FreeBSD__)
|
||||
const uint16_t buffer_max_size = 372 * 1;
|
||||
#else
|
||||
const uint16_t buffer_max_size = 2052;
|
||||
|
Loading…
Reference in New Issue
Block a user