mirror of
https://github.com/pine64/blisp.git
synced 2024-12-22 06:20:12 +00:00
Merge remote-tracking branch 'upstream/feature/bl808'
This commit is contained in:
commit
d278063472
@ -9,9 +9,10 @@ option(BLISP_USE_SYSTEM_LIBRARIES "Use system-installed libraries" "${CMAKE_USE_
|
||||
option(COMPILE_TESTS "Compile the tests" OFF)
|
||||
|
||||
add_library(libblisp_obj OBJECT
|
||||
lib/blisp.c
|
||||
lib/blisp.c lib/blisp_easy.c
|
||||
lib/chip/blisp_chip_bl60x.c
|
||||
lib/chip/blisp_chip_bl70x.c lib/blisp_easy.c)
|
||||
lib/chip/blisp_chip_bl70x.c
|
||||
lib/chip/blisp_chip_bl808.c)
|
||||
|
||||
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/include/)
|
||||
|
||||
|
50
lib/blisp.c
50
lib/blisp.c
@ -216,11 +216,38 @@ blisp_return_t blisp_device_handshake(struct blisp_device* device,
|
||||
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 (device->rx_buffer[0] == 'O' && device->rx_buffer[1] == 'K') {
|
||||
return BLISP_OK;
|
||||
}
|
||||
uint32_t bytes_count = device->chip->handshake_byte_multiplier * (float)device->current_baud_rate / 10.0f;
|
||||
if (bytes_count > 600) bytes_count = 600;
|
||||
memset(handshake_buffer, 'U', bytes_count);
|
||||
|
||||
// sp_flush(serial_port, SP_BUF_BOTH);
|
||||
|
||||
for (uint8_t i = 0; i < 5; i++) {
|
||||
if (!in_ef_loader) {
|
||||
if (device->is_usb) {
|
||||
sp_blocking_write(serial_port, "BOUFFALOLAB5555RESET\0\0", 22,
|
||||
100); // TODO: Error handling
|
||||
}
|
||||
}
|
||||
ret = sp_blocking_write(serial_port, handshake_buffer, bytes_count,
|
||||
500);
|
||||
if (ret < 0) {
|
||||
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);
|
||||
if (ret >= 2) {
|
||||
for (uint8_t j = 0; j < (ret - 1); j++) {
|
||||
if (device->rx_buffer[j] == 'O' && device->rx_buffer[j + 1] == 'K') {
|
||||
return BLISP_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
blisp_dlog("Received no response from chip.");
|
||||
@ -239,14 +266,13 @@ blisp_return_t blisp_device_get_boot_info(struct blisp_device* device,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
memcpy(boot_info->boot_rom_version, &device->rx_buffer[0],
|
||||
memcpy(boot_info->boot_rom_version, &device->rx_buffer[0],
|
||||
4); // TODO: Endianess; this may break on big endian machines
|
||||
|
||||
if (device->chip->type == BLISP_CHIP_BL70X) {
|
||||
memcpy(boot_info->chip_id, &device->rx_buffer[16], 8);
|
||||
}
|
||||
// TODO: BL60X
|
||||
return BLISP_OK;
|
||||
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);
|
||||
}
|
||||
// TODO: BL60X, BL808
|
||||
return BLISP_OK;
|
||||
}
|
||||
|
||||
// TODO: Use struct instead of uint8_t*
|
||||
|
@ -1,11 +1,12 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "blisp.h"
|
||||
#include <stddef.h>
|
||||
|
||||
struct blisp_chip blisp_chip_bl808 = {
|
||||
.type = BLISP_CHIP_BL808,
|
||||
.type_str = "bl808",
|
||||
.usb_isp_available = true, // TODO: Only for BL808D :-(
|
||||
.default_xtal = "-", // ?
|
||||
.handshake_byte_multiplier = 0.003f,
|
||||
.get_eflash_loader = NULL
|
||||
.default_xtal = "-", // XXX: bfl software marks this as "Auto (0x07)"
|
||||
.handshake_byte_multiplier = 0.006f,
|
||||
.load_eflash_loader = NULL
|
||||
};
|
||||
|
@ -31,6 +31,8 @@ blisp_return_t blisp_common_init_device(struct blisp_device* device,
|
||||
chip = &blisp_chip_bl70x;
|
||||
} else if (strcmp(chip_type->sval[0], "bl60x") == 0) {
|
||||
chip = &blisp_chip_bl60x;
|
||||
} else if (strcmp(chip_type->sval[0], "bl808") == 0) {
|
||||
chip = &blisp_chip_bl808;
|
||||
} else {
|
||||
fprintf(stderr, "Chip type is invalid.\n");
|
||||
return BLISP_ERR_INVALID_CHIP_TYPE;
|
||||
|
Loading…
Reference in New Issue
Block a user