mirror of
https://github.com/pine64/blisp.git
synced 2025-05-18 05:57:12 +00:00
Initial support for BL808
Not working yet
This commit is contained in:
parent
cae1bf0202
commit
738626e67e
@ -8,7 +8,8 @@ option(BLISP_BUILD_CLI "Build CLI Tool" OFF)
|
|||||||
add_library(libblisp_obj OBJECT
|
add_library(libblisp_obj OBJECT
|
||||||
lib/blisp.c
|
lib/blisp.c
|
||||||
lib/chip/blisp_chip_bl60x.c
|
lib/chip/blisp_chip_bl60x.c
|
||||||
lib/chip/blisp_chip_bl70x.c)
|
lib/chip/blisp_chip_bl70x.c
|
||||||
|
lib/chip/blisp_chip_bl808.c)
|
||||||
|
|
||||||
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/include/)
|
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/include/)
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
enum blisp_chip_type {
|
enum blisp_chip_type {
|
||||||
BLISP_CHIP_BL60X,
|
BLISP_CHIP_BL60X,
|
||||||
BLISP_CHIP_BL70X
|
BLISP_CHIP_BL70X,
|
||||||
|
BLISP_CHIP_BL808
|
||||||
};
|
};
|
||||||
|
|
||||||
struct blisp_chip { // TODO: Move elsewhere?
|
struct blisp_chip { // TODO: Move elsewhere?
|
||||||
@ -19,5 +20,6 @@ struct blisp_chip { // TODO: Move elsewhere?
|
|||||||
|
|
||||||
extern struct blisp_chip blisp_chip_bl60x;
|
extern struct blisp_chip blisp_chip_bl60x;
|
||||||
extern struct blisp_chip blisp_chip_bl70x;
|
extern struct blisp_chip blisp_chip_bl70x;
|
||||||
|
extern struct blisp_chip blisp_chip_bl808;
|
||||||
|
|
||||||
#endif
|
#endif
|
12
lib/blisp.c
12
lib/blisp.c
@ -158,7 +158,7 @@ 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,
|
sp_blocking_write(serial_port, "BOUFFALOLAB5555RESET\0\0", 22,
|
||||||
100);
|
100); // TODO: Error handling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = sp_blocking_write(serial_port, handshake_buffer, bytes_count,
|
ret = sp_blocking_write(serial_port, handshake_buffer, bytes_count,
|
||||||
@ -166,6 +166,12 @@ blisp_device_handshake(struct blisp_device* device, bool in_ef_loader) {
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (device->chip->type == BLISP_CHIP_BL808) {
|
||||||
|
sleep_ms(300);
|
||||||
|
const uint8_t second_handshake[] = { 0x50, 0x00, 0x08, 0x00, 0x38, 0xF0, 0x00, 0x20, 0x00, 0x00, 0x00, 0x18 };
|
||||||
|
sp_blocking_write(serial_port, second_handshake, sizeof(second_handshake), 300); // TODO: Error handling
|
||||||
|
}
|
||||||
ret = sp_blocking_read(serial_port, device->rx_buffer, 20, 50);
|
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++) {
|
||||||
@ -189,10 +195,10 @@ int32_t blisp_device_get_boot_info(struct blisp_device* device, struct blisp_boo
|
|||||||
if (ret < 0) return ret;
|
if (ret < 0) return ret;
|
||||||
|
|
||||||
memcpy(boot_info->boot_rom_version, &device->rx_buffer[0], 4); // TODO: Endianess
|
memcpy(boot_info->boot_rom_version, &device->rx_buffer[0], 4); // TODO: Endianess
|
||||||
if (device->chip->type == BLISP_CHIP_BL70X) {
|
if (device->chip->type == BLISP_CHIP_BL70X || device->chip->type == BLISP_CHIP_BL808) { // TODO: This is only 70X related
|
||||||
memcpy(boot_info->chip_id, &device->rx_buffer[16], 8);
|
memcpy(boot_info->chip_id, &device->rx_buffer[16], 8);
|
||||||
}
|
}
|
||||||
// TODO: BL60X
|
// TODO: BL60X, BL808
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
lib/chip/blisp_chip_bl808.c
Normal file
8
lib/chip/blisp_chip_bl808.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "blisp.h"
|
||||||
|
|
||||||
|
struct blisp_chip blisp_chip_bl808 = {
|
||||||
|
.type = BLISP_CHIP_BL808,
|
||||||
|
.type_str = "bl808",
|
||||||
|
.usb_isp_available = true,
|
||||||
|
.handshake_byte_multiplier = 0.006f,
|
||||||
|
};
|
@ -196,6 +196,8 @@ void blisp_flash_firmware() {
|
|||||||
chip = &blisp_chip_bl70x;
|
chip = &blisp_chip_bl70x;
|
||||||
} else if (strcmp(chip_type->sval[0], "bl60x") == 0) {
|
} else if (strcmp(chip_type->sval[0], "bl60x") == 0) {
|
||||||
chip = &blisp_chip_bl60x;
|
chip = &blisp_chip_bl60x;
|
||||||
|
} else if (strcmp(chip_type->sval[0], "bl808") == 0) {
|
||||||
|
chip = &blisp_chip_bl808;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Chip type is invalid.\n");
|
fprintf(stderr, "Chip type is invalid.\n");
|
||||||
return;
|
return;
|
||||||
@ -249,6 +251,11 @@ void blisp_flash_firmware() {
|
|||||||
boot_info.chip_id[6],
|
boot_info.chip_id[6],
|
||||||
boot_info.chip_id[7]);
|
boot_info.chip_id[7]);
|
||||||
|
|
||||||
|
if (device.chip->type == BLISP_CHIP_BL808) {
|
||||||
|
// Since eflash_loader is not needed in BL808, we can jump to flashing.
|
||||||
|
goto eflash_loader; // TODO: Rework
|
||||||
|
}
|
||||||
|
|
||||||
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
|
get_binary_folder(exe_path, PATH_MAX); // TODO: Error handling
|
||||||
@ -325,7 +332,13 @@ void blisp_flash_firmware() {
|
|||||||
}
|
}
|
||||||
printf(" OK\n");
|
printf(" OK\n");
|
||||||
|
|
||||||
eflash_loader:;
|
eflash_loader:
|
||||||
|
if (device.chip->type == BLISP_CHIP_BL808) {
|
||||||
|
// Setting CLK configuration
|
||||||
|
// Setting Flash Config
|
||||||
|
// Setting Flash Parameter
|
||||||
|
}
|
||||||
|
|
||||||
FILE* firmware_file = fopen(binary_to_write->filename[0], "rb");
|
FILE* firmware_file = fopen(binary_to_write->filename[0], "rb");
|
||||||
if (firmware_file == NULL) {
|
if (firmware_file == NULL) {
|
||||||
fprintf(stderr,"Failed to open firmware file \"%s\".\n", binary_to_write->filename[0]);
|
fprintf(stderr,"Failed to open firmware file \"%s\".\n", binary_to_write->filename[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user