Compare commits

..

No commits in common. "6424f9ddf829d1b90ae311074f5e32f9a7b3ac27" and "884142932d9ce6f5a8812d5d014d4c5fb4c80103" have entirely different histories.

6 changed files with 13 additions and 26 deletions

View File

@ -17,7 +17,6 @@ Open source tool and library for flashing Bouffalo RISC-V MCUs.
- [x] Windows - [x] Windows
- [x] Linux - [x] Linux
- [x] Apple - [x] Apple
- [x] FreeBSD
# Building # Building
@ -28,7 +27,6 @@ If you have not cloned this repository locally; clone the git repository locally
```bash ```bash
git clone --recursive https://github.com/pine64/blisp.git git clone --recursive https://github.com/pine64/blisp.git
cd blisp cd blisp
git submodule update --init --recursive
``` ```
## Build the library and command line utility ## Build the library and command line utility

View File

@ -13,12 +13,6 @@
#define DEBUG #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, int32_t blisp_device_init(struct blisp_device* device,
struct blisp_chip* chip) { struct blisp_chip* chip) {
device->chip = chip; device->chip = chip;
@ -79,13 +73,13 @@ int32_t blisp_device_open(struct blisp_device* device, const char* port_name) {
sp_set_stopbits(serial_port, 1); sp_set_stopbits(serial_port, 1);
sp_set_flowcontrol(serial_port, SP_FLOWCONTROL_NONE); sp_set_flowcontrol(serial_port, SP_FLOWCONTROL_NONE);
int vid, pid; uint32_t vid, pid;
sp_get_port_usb_vid_pid(serial_port, &vid, &pid); sp_get_port_usb_vid_pid(serial_port, &vid, &pid);
device->is_usb = pid == 0xFFFF; device->is_usb = pid == 0xFFFF;
// if (device->is_usb) { // if (device->is_usb) {
// device->current_baud_rate = 2000000; // device->current_baud_rate = 2000000;
// } else { // } else {
device->current_baud_rate = 460800; device->current_baud_rate = 500000;
// } // }
#if 0 #if 0
@ -136,7 +130,9 @@ int32_t blisp_send_command(struct blisp_device* device,
blisp_dlog("Received error or not written all data: %d", ret); blisp_dlog("Received error or not written all data: %d", ret);
return BLISP_ERR_UNKNOWN; return BLISP_ERR_UNKNOWN;
} }
drain(serial_port); #ifdef __APPLE__
sp_drain(serial_port);
#endif
return BLISP_OK; return BLISP_OK;
} }
@ -199,12 +195,12 @@ int32_t blisp_device_handshake(struct blisp_device* device, bool in_ef_loader) {
if (!in_ef_loader) { if (!in_ef_loader) {
if (device->is_usb) { if (device->is_usb) {
sp_blocking_write(serial_port, "BOUFFALOLAB5555RESET\0\0", 22, 100); sp_blocking_write(serial_port, "BOUFFALOLAB5555RESET\0\0", 22, 100);
drain(serial_port); #ifdef __APPLE__
sp_drain(serial_port);
#endif
} }
} }
ret = sp_blocking_write(serial_port, handshake_buffer, bytes_count, 500); 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) { if (ret < 0) {
blisp_dlog("Handshake write failed, ret %d", ret); blisp_dlog("Handshake write failed, ret %d", ret);
return BLISP_ERR_UNKNOWN; return BLISP_ERR_UNKNOWN;

View File

@ -24,8 +24,6 @@ static int64_t blisp_easy_transport_size(struct blisp_easy_transport* transport)
return transport->data.memory.data_size; return transport->data.memory.data_size;
} else { } else {
// TODO: Implement // TODO: Implement
printf("%s() Warning: calling non-implemented function\n", __func__);
return -1;
} }
} }
@ -331,7 +329,7 @@ int32_t blisp_easy_flash_write(struct blisp_device* device,
uint32_t data_size, uint32_t data_size,
blisp_easy_progress_callback progress_callback) { blisp_easy_progress_callback progress_callback) {
int32_t ret; int32_t ret;
#if defined (__APPLE__) || defined (__FreeBSD__) #ifdef __APPLE__
const uint16_t buffer_max_size = 372 * 1; const uint16_t buffer_max_size = 372 * 1;
#else #else
const uint16_t buffer_max_size = 2052; const uint16_t buffer_max_size = 2052;

View File

@ -11,7 +11,7 @@
#include "util.h" #include "util.h"
void blisp_common_progress_callback(uint32_t current_value, uint32_t max_value) { void blisp_common_progress_callback(uint32_t current_value, uint32_t max_value) {
printf("%" PRIu32 "b / %u (%.2f%%)\n", current_value, max_value, printf("%" PRIu32 "b / %ldb (%.2f%%)\n", current_value, max_value,
(((float)current_value / (float)max_value) * 100.0f)); (((float)current_value / (float)max_value) * 100.0f));
} }

View File

@ -35,11 +35,6 @@ ssize_t util_get_binary_folder(char* buffer, uint32_t buffer_size) {
#elif defined(__APPLE__) #elif defined(__APPLE__)
util_get_executable_path(buffer, buffer_size); util_get_executable_path(buffer, buffer_size);
char* pos = strrchr(buffer, '/'); char* pos = strrchr(buffer, '/');
#elif __FreeBSD__
if (readlink("/proc/curproc/file", buffer, buffer_size) <= 0) {
return -1;
}
char* pos = strrchr(buffer, '/');
#else #else
if (GetModuleFileName(NULL, buffer, buffer_size) <= 0) { if (GetModuleFileName(NULL, buffer, buffer_size) <= 0) {
return -1; return -1;

View File

@ -4,7 +4,9 @@
#include <stdint.h> #include <stdint.h>
#if defined(_MSC_VER) #ifdef __linux__
#include <unistd.h>
#elif defined(_MSC_VER)
#include <BaseTsd.h> #include <BaseTsd.h>
typedef SSIZE_T ssize_t; typedef SSIZE_T ssize_t;
#include <windows.h> #include <windows.h>
@ -13,8 +15,6 @@ typedef SSIZE_T ssize_t;
#include <sys/syslimits.h> #include <sys/syslimits.h>
#include <assert.h> #include <assert.h>
#include <sys/types.h> #include <sys/types.h>
#else
#include <unistd.h>
#endif #endif
ssize_t util_get_binary_folder(char* buffer, uint32_t buffer_size); ssize_t util_get_binary_folder(char* buffer, uint32_t buffer_size);