From f60cfc02f97c35ee272463ccfb2e9ec7e835c092 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 20 Nov 2022 17:20:16 +1100 Subject: [PATCH 1/5] Ignore build folder --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d16bbbe..86fcb79 100644 --- a/.gitignore +++ b/.gitignore @@ -74,4 +74,5 @@ fabric.properties .idea/httpRequests # Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser \ No newline at end of file +.idea/caches/build_file_checksums.ser +build/ From 20c4fa016393c75aadb8aa7778eddfa0b1e1ff29 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 20 Nov 2022 17:20:46 +1100 Subject: [PATCH 2/5] Handle missing eflash loader in a nicer form Print error rather than crashing --- tools/blisp/src/cmd/write.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/blisp/src/cmd/write.c b/tools/blisp/src/cmd/write.c index 98ee249..0c734d2 100644 --- a/tools/blisp/src/cmd/write.c +++ b/tools/blisp/src/cmd/write.c @@ -252,11 +252,23 @@ void blisp_flash_firmware() { char exe_path[PATH_MAX]; char eflash_loader_path[PATH_MAX]; get_binary_folder(exe_path, PATH_MAX); // 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); - - eflash_loader_file = fopen(eflash_loader_path, "rb"); // TODO: Error handling - 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"); ret = blisp_device_load_boot_header(&device, eflash_loader_header); From c419cc0cd99fd7113bf17d6b7dfa30bed3dc26b0 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 20 Nov 2022 17:22:36 +1100 Subject: [PATCH 3/5] Markdown styling --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 343678d..a9921c7 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Tool and library for flashing their RISC-V MCUs. # Supported MCUs -- [X] `bl60x` - BL602 / BL604 -- [X] `bl70x` - BL702 / BL704 / BL706 +- [x] `bl60x` - BL602 / BL604 +- [x] `bl70x` - BL702 / BL704 / BL706 - [ ] `bl606p` - BL606P - [ ] `bl61x` - BL616 / BL618 - [ ] `bl808` - BL808 @@ -40,4 +40,3 @@ blisp --chip bl60x --reset -p /dev/ttyUSB0 name_of_firmware.bin - [ ] Another code style - [ ] Finalize API -- [ ] SDIO and JTAG support \ No newline at end of file From 8334e583b60ec3a07369b4809c32205c83e6f2d0 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 20 Nov 2022 17:22:47 +1100 Subject: [PATCH 4/5] Add note to use recursive clone --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index a9921c7..c278ae8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,17 @@ Tool and library for flashing their RISC-V MCUs. # 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: ```bash @@ -40,3 +51,4 @@ blisp --chip bl60x --reset -p /dev/ttyUSB0 name_of_firmware.bin - [ ] Another code style - [ ] Finalize API +- [ ] SDIO and JTAG support From 236690b0956604305a35858a71ded537aeb5a81f Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 20 Nov 2022 20:42:33 +1100 Subject: [PATCH 5/5] Handle failure finding current program path --- tools/blisp/src/cmd/write.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/blisp/src/cmd/write.c b/tools/blisp/src/cmd/write.c index 0c734d2..c940831 100644 --- a/tools/blisp/src/cmd/write.c +++ b/tools/blisp/src/cmd/write.c @@ -28,10 +28,14 @@ static void* cmd_write_argtable[6]; ssize_t get_binary_folder(char* buffer, uint32_t buffer_size) { #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, '/'); #else - GetModuleFileName(NULL, buffer, buffer_size); + if (GetModuleFileName(NULL, buffer, buffer_size) <= 0) { + return -1; + } char* pos = strrchr(buffer, '\\'); #endif pos[0] = '\0'; @@ -251,7 +255,11 @@ void blisp_flash_firmware() { char exe_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) { + fprintf(stderr, "Failed to find executable path to search for the " + "eflash loader\n"); + goto exit1; + } 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);