mirror of
https://github.com/pine64/blisp.git
synced 2026-09-20 11:11:31 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
236690b095 | ||
|
|
8334e583b6 | ||
|
|
c419cc0cd9 | ||
|
|
20c4fa0163 | ||
|
|
f60cfc02f9 | ||
|
|
2d7eb72e80 | ||
|
|
cae1bf0202 |
@@ -75,3 +75,4 @@ fabric.properties
|
|||||||
|
|
||||||
# Android studio 3.1+ serialized cache file
|
# Android studio 3.1+ serialized cache file
|
||||||
.idea/caches/build_file_checksums.ser
|
.idea/caches/build_file_checksums.ser
|
||||||
|
build/
|
||||||
|
|||||||
@@ -6,14 +6,25 @@ Tool and library for flashing their RISC-V MCUs.
|
|||||||
|
|
||||||
# Supported MCUs
|
# Supported MCUs
|
||||||
|
|
||||||
- [X] `bl60x` - BL602 / BL604
|
- [x] `bl60x` - BL602 / BL604
|
||||||
- [X] `bl70x` - BL702 / BL704 / BL706
|
- [x] `bl70x` - BL702 / BL704 / BL706
|
||||||
- [ ] `bl606p` - BL606P
|
- [ ] `bl606p` - BL606P
|
||||||
- [ ] `bl61x` - BL616 / BL618
|
- [ ] `bl61x` - BL616 / BL618
|
||||||
- [ ] `bl808` - BL808
|
- [ ] `bl808` - BL808
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
|
## Clone repository
|
||||||
|
|
||||||
|
If you have not cloned this repository locally; check out the git repository locally by running
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone --recursive https://github.com/pine64/blisp.git
|
||||||
|
cd blisp
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build the library and command line utility
|
||||||
|
|
||||||
For building `blisp` command line tool, use following commands:
|
For building `blisp` command line tool, use following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+2
-2
@@ -106,7 +106,7 @@ int32_t blisp_receive_response(struct blisp_device* device, bool expect_payload)
|
|||||||
// TODO: Check checksum
|
// TODO: Check checksum
|
||||||
int ret;
|
int ret;
|
||||||
struct sp_port* serial_port = device->serial_port;
|
struct sp_port* serial_port = device->serial_port;
|
||||||
ret = sp_blocking_read(serial_port, &device->rx_buffer[0], 2, 500);
|
ret = sp_blocking_read(serial_port, &device->rx_buffer[0], 2, 1000);
|
||||||
if (ret < 2) {
|
if (ret < 2) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Failed to receive response. (ret = %d)\n", ret);
|
fprintf(stderr, "Failed to receive response. (ret = %d)\n", ret);
|
||||||
@@ -166,7 +166,7 @@ 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, 1000);
|
ret = sp_blocking_read(serial_port, device->rx_buffer, 20, 50);
|
||||||
if (ret >= 2) {
|
if (ret >= 2) {
|
||||||
for (uint8_t j = 0; j < (ret - 1); j++) {
|
for (uint8_t j = 0; j < (ret - 1); j++) {
|
||||||
if (device->rx_buffer[j] == 'O' && device->rx_buffer[j + 1] == 'K') {
|
if (device->rx_buffer[j] == 'O' && device->rx_buffer[j + 1] == 'K') {
|
||||||
|
|||||||
@@ -28,10 +28,14 @@ static void* cmd_write_argtable[6];
|
|||||||
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__
|
||||||
readlink("/proc/self/exe", buffer, buffer_size); // TODO: Error handling
|
if (readlink("/proc/self/exe", buffer, buffer_size) <= 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
char* pos = strrchr(buffer, '/');
|
char* pos = strrchr(buffer, '/');
|
||||||
#else
|
#else
|
||||||
GetModuleFileName(NULL, buffer, buffer_size);
|
if (GetModuleFileName(NULL, buffer, buffer_size) <= 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
char* pos = strrchr(buffer, '\\');
|
char* pos = strrchr(buffer, '\\');
|
||||||
#endif
|
#endif
|
||||||
pos[0] = '\0';
|
pos[0] = '\0';
|
||||||
@@ -251,12 +255,28 @@ void blisp_flash_firmware() {
|
|||||||
|
|
||||||
char exe_path[PATH_MAX];
|
char exe_path[PATH_MAX];
|
||||||
char eflash_loader_path[PATH_MAX];
|
char eflash_loader_path[PATH_MAX];
|
||||||
get_binary_folder(exe_path, PATH_MAX); // TODO: Error handling
|
if (get_binary_folder(exe_path, PATH_MAX) <= 0) {
|
||||||
snprintf(eflash_loader_path, PATH_MAX, "%s/data/%s/eflash_loader_%s.bin", exe_path, device.chip->type_str, device.chip->default_eflash_loader_xtal);
|
fprintf(stderr, "Failed to find executable path to search for the "
|
||||||
|
"eflash loader\n");
|
||||||
eflash_loader_file = fopen(eflash_loader_path, "rb"); // TODO: Error handling
|
goto exit1;
|
||||||
uint8_t eflash_loader_header[176]; // TODO: Remap it to the boot header struct
|
}
|
||||||
fread(eflash_loader_header, 176, 1, eflash_loader_file); // TODO: Error handling
|
snprintf(eflash_loader_path, PATH_MAX, "%s/data/%s/eflash_loader_%s.bin",
|
||||||
|
exe_path, device.chip->type_str,
|
||||||
|
device.chip->default_eflash_loader_xtal);
|
||||||
|
printf("Loading the eflash loader file from disk\n");
|
||||||
|
eflash_loader_file
|
||||||
|
= fopen(eflash_loader_path, "rb"); // TODO: Error handling
|
||||||
|
if (eflash_loader_file == NULL) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Could not open the eflash loader file from disk.\n"
|
||||||
|
"Does \"%s\" exist?\n",
|
||||||
|
eflash_loader_path);
|
||||||
|
goto exit1;
|
||||||
|
}
|
||||||
|
uint8_t
|
||||||
|
eflash_loader_header[176]; // TODO: Remap it to the boot header struct
|
||||||
|
fread(eflash_loader_header, 176, 1,
|
||||||
|
eflash_loader_file); // TODO: Error handling
|
||||||
|
|
||||||
printf("Loading eflash_loader...\n");
|
printf("Loading eflash_loader...\n");
|
||||||
ret = blisp_device_load_boot_header(&device, eflash_loader_header);
|
ret = blisp_device_load_boot_header(&device, eflash_loader_header);
|
||||||
|
|||||||
Reference in New Issue
Block a user