Skip to content

Commit e05d3b7

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 512768b + 26cee48 commit e05d3b7

31 files changed

+798
-90
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake .

.github/workflows/build.yml

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,31 @@ name: Build
22
on: [push, pull_request]
33

44
jobs:
5+
check-nix-flake:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: cachix/install-nix-action@v30
10+
- name: Check Nix Flake
11+
run: nix flake check --print-build-logs
12+
13+
check-nix-build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: cachix/install-nix-action@v30
18+
- name: Build package
19+
run: nix build --print-build-logs
20+
521
build-windows:
622
runs-on: windows-2022
723
defaults:
824
run:
925
shell: cmd
1026
steps:
11-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
1228
with:
13-
submodules: 'recursive'
29+
submodules: "recursive"
1430
- uses: lukka/get-cmake@latest
1531
- name: Build blisp tool
1632
run: |
@@ -19,19 +35,19 @@ jobs:
1935
cmake .. -DBLISP_BUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release
2036
cmake --build . --config Release
2137
- name: Upload results
22-
uses: actions/upload-artifact@v3
38+
uses: actions/upload-artifact@v4
2339
with:
24-
name: blips-windows-x86_64.zip
40+
name: blips-windows-x86_64
2541
path: |
2642
build/tools/blisp/Release/blisp.exe
2743
if-no-files-found: error
2844

2945
build-macos:
3046
runs-on: macos-latest
3147
steps:
32-
- uses: actions/checkout@v3
48+
- uses: actions/checkout@v4
3349
with:
34-
submodules: 'recursive'
50+
submodules: "recursive"
3551
- uses: lukka/get-cmake@latest
3652
- name: Build blisp tool
3753
run: |
@@ -40,19 +56,19 @@ jobs:
4056
cmake .. -DBLISP_BUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release
4157
cmake --build .
4258
- name: Upload results
43-
uses: actions/upload-artifact@v3
59+
uses: actions/upload-artifact@v4
4460
with:
45-
name: blips-apple-universal.zip
61+
name: blips-apple-universal
4662
path: |
4763
build/tools/blisp/blisp
4864
if-no-files-found: error
4965

5066
build-linux:
5167
runs-on: ubuntu-latest
5268
steps:
53-
- uses: actions/checkout@v3
69+
- uses: actions/checkout@v4
5470
with:
55-
submodules: 'recursive'
71+
submodules: "recursive"
5672
- uses: lukka/get-cmake@latest
5773
- name: Build blisp tool
5874
run: |
@@ -61,12 +77,12 @@ jobs:
6177
cmake .. -DBLISP_BUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release
6278
cmake --build .
6379
- name: Upload results
64-
uses: actions/upload-artifact@v3
80+
uses: actions/upload-artifact@v4
6581
with:
66-
name: blips-linux-x86_64.zip
82+
name: blips-linux-x86_64
6783
path: |
6884
build/tools/blisp/blisp
69-
if-no-files-found: error
85+
if-no-files-found: error
7086

7187
build-linux-alternative-arch:
7288
runs-on: ubuntu-latest
@@ -83,9 +99,9 @@ jobs:
8399
- arch: riscv64
84100
distro: ubuntu_latest
85101
steps:
86-
- uses: actions/checkout@v3
102+
- uses: actions/checkout@v4
87103
with:
88-
submodules: 'recursive'
104+
submodules: "recursive"
89105
- uses: uraimo/run-on-arch-action@v2
90106
name: Build artifact
91107
id: build
@@ -133,9 +149,35 @@ jobs:
133149
echo "Produced artifact at /artifacts/${artifact_name}"
134150
135151
- name: Upload results
136-
uses: actions/upload-artifact@v3
152+
uses: actions/upload-artifact@v4
137153
with:
138-
name: blisp-linux-${{ matrix.arch }}.zip
154+
name: blisp-linux-${{ matrix.arch }}
139155
path: |
140156
artifacts/blisp-*
141-
if-no-files-found: error
157+
if-no-files-found: error
158+
159+
test-linux:
160+
runs-on: ubuntu-latest
161+
steps:
162+
- uses: actions/checkout@v4
163+
with:
164+
submodules: "recursive"
165+
- uses: lukka/get-cmake@latest
166+
- name: Build blisp tool & unit tests
167+
run: |
168+
mkdir build
169+
cd build
170+
cmake .. -DBLISP_BUILD_CLI=ON -DCOMPILE_TESTS=ON
171+
cmake --build .
172+
- name: Run unit tests
173+
run: |
174+
cd build
175+
for f in $(find . -type f -executable -iname "*_test"); do
176+
echo "Running test file $f"
177+
"$f"
178+
status=$?
179+
if [ $status -ne 0 ]; then
180+
echo "Test $f failed with exit code $status"
181+
exit $status
182+
fi
183+
done

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,5 @@ fabric.properties
7777
.idea/caches/build_file_checksums.ser
7878
build/
7979

80-
.DS_Store
80+
.DS_Store
81+
.cache/

CMakeLists.txt

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cmake_minimum_required(VERSION 3.16)
2-
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
2+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
3+
# set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
34
project(blisp C)
45
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
56
set(CMAKE_C_STANDARD 11)
@@ -43,19 +44,18 @@ set_target_properties(libblisp_static PROPERTIES
4344
OUTPUT_NAME "blisp")
4445

4546
if(BLISP_USE_SYSTEM_LIBRARIES)
46-
find_package(PkgConfig)
47-
pkg_search_module(LIBSERIALPORT REQUIRED libserialport)
48-
target_link_libraries(libblisp PUBLIC ${LIBSERIALPORT_LIBRARIES})
49-
target_link_libraries(libblisp_static PUBLIC ${LIBSERIALPORT_LIBRARIES})
50-
target_include_directories(libblisp_obj PUBLIC ${LIBSERIALPORT_INCLUDE_DIRS})
47+
find_package(Libserialport REQUIRED)
48+
target_link_libraries(libblisp PUBLIC Libserialport::Libserialport)
49+
target_link_libraries(libblisp_static PUBLIC Libserialport::Libserialport)
50+
target_include_directories(libblisp_obj PUBLIC ${Libserialport_INCLUDE_DIRS})
5151
else()
52-
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
53-
target_sources(libblisp_obj PRIVATE
52+
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
53+
target_sources(libblisp_obj PRIVATE
5454
${CMAKE_SOURCE_DIR}/vendor/libserialport/serialport.c
5555
${CMAKE_SOURCE_DIR}/vendor/libserialport/timing.c)
5656

57-
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
58-
endif()
57+
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
58+
endif()
5959

6060
if(WIN32)
6161
target_link_libraries(libblisp PRIVATE Setupapi.lib)
@@ -93,7 +93,7 @@ else()
9393
endif()
9494

9595
include(GNUInstallDirs)
96-
install(TARGETS libblisp libblisp_static
96+
install(TARGETS libblisp libblisp_static
9797
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
9898
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
9999
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -106,5 +106,21 @@ endif()
106106

107107

108108
if(COMPILE_TESTS)
109-
add_subdirectory(tools/blisp/src/cmd/dfu/tests)
109+
# Bring in googletest & C++
110+
enable_language(CXX)
111+
enable_testing()
112+
include(FetchContent)
113+
114+
115+
FetchContent_Declare(
116+
googletest
117+
GIT_REPOSITORY https://github.com/google/googletest.git
118+
GIT_TAG v1.17.0
119+
)
120+
FetchContent_MakeAvailable(googletest)
121+
add_library(GTest::GTest INTERFACE IMPORTED)
122+
target_link_libraries(GTest::GTest INTERFACE gtest_main)
123+
124+
add_subdirectory(tools/blisp/src/file_parsers/dfu/tests)
125+
add_subdirectory(tools/blisp/src/file_parsers/hex/tests)
110126
endif(COMPILE_TESTS)

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env make -f
2+
3+
### global variables section
4+
5+
# static vars
6+
BUILD_DIR:="build"
7+
BUILD_BIN:="$(BUILD_DIR)/tools/blisp/blisp"
8+
9+
# dynamic vars
10+
FILES_CMAKE:=$(shell find . -path ./$(BUILD_DIR) -prune -false -o -type f -name '*.cmake' -o -type f -name 'CMakeLists.txt')
11+
FILES_SRC:=$(shell find . -path ./$(BUILD_DIR) -prune -false -o -type f -name '*.c' -o -type f -name '*.h')
12+
13+
### main targets section
14+
15+
# simplify build
16+
build: $(FILES_CMAKE) $(FILES_SRC) Makefile
17+
@echo "\n>>>> Generating build files in: $(BUILD_DIR) ...\n"
18+
@cmake -S . -B $(BUILD_DIR) -DBLISP_BUILD_CLI=ON
19+
@echo "\n>>>> Building...\n"
20+
@cmake --build $(BUILD_DIR)
21+
@echo "\n>>>> DONE: $(BUILD_BIN)\n"
22+
23+
# deleting output build directory with its content
24+
clean:
25+
-@rm -rf $(BUILD_DIR)/
26+
27+
# printf-like debug target
28+
vars:
29+
@echo "\n>>>> FILES_CMAKE:"
30+
@echo "$(FILES_CMAKE)" | sed 's, ,\n,g'
31+
@echo "\n>>>> FILES_SRC:"
32+
@echo "$(FILES_SRC)" | sed 's, ,\n,g'
33+
34+
.PHONY: clean vars
35+

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![GitHub release](https://img.shields.io/github/v/release/pine64/blisp?color=5791ac)](https://github.com/pine64/blisp/releases/tag/v0.0.4)
55

66
<img src="./img/Gradient-white-blue-03.png" align="left" width="60" > <br clear="left" />
7-
# BLISP
7+
# BLISP
88

99
Bouffalo Labs ISP (in-system-programming) tool & library: an open source tool to flash Bouffalo RISC-V MCUs.
1010

@@ -16,13 +16,13 @@ Bouffalo Labs ISP (in-system-programming) tool & library: an open source tool to
1616
- [x] `bl70x` - BL702 / BL704 / BL706
1717
<br>
1818

19-
## Supported Devices
20-
| System | <img width="15" src="https://cdn.simpleicons.org/Windows11/5791ac" /> Windows | <img width="15" src="https://cdn.simpleicons.org/Apple/5791ac" /> MacOS| <img width="17" src="https://cdn.simpleicons.org/Linux/5791ac" /> Linux| <img width="15" src="https://cdn.simpleicons.org/Freebsd/5791ac" /> FreeBSD |
19+
## Supported Devices
20+
| System | <img width="15" src="img/win32.png" /> Windows | <img width="15" src="https://cdn.simpleicons.org/Apple/5791ac" /> MacOS| <img width="17" src="https://cdn.simpleicons.org/Linux/5791ac" /> Linux| <img width="15" src="https://cdn.simpleicons.org/Freebsd/5791ac" /> FreeBSD |
2121
| :-----: | :------: | :------: | :------: | :------: |
2222
| Pinecil V2 |<img width="22" src="https://cdn.simpleicons.org/cachet/5791ac" />|<img width="22" src="https://cdn.simpleicons.org/cachet/5791ac" />| <img width="22" src="https://cdn.simpleicons.org/cachet/5791ac" />| <img width="22" src="https://cdn.simpleicons.org/cachet/5791ac" /> |
2323
| Pinecone |<img width="22" src="https://cdn.simpleicons.org/cachet/5791ac" />|<img width="22" src="https://cdn.simpleicons.org/cachet/5791ac" />|<img width="22" src="https://cdn.simpleicons.org/cachet/5791ac" />| <img width="22" src="https://cdn.simpleicons.org/cachet/5791ac" /> |
2424
<br>
25-
25+
2626
## How to update Pinecil V2
2727

2828
Download the newest release of [Blisp updater here](https://github.com/pine64/blisp/releases/).
@@ -94,6 +94,15 @@ Because this is done at the lowest level of serial communication, the
9494
displays aren't packet-aware or know about the chip's command set or such.
9595
This is really only useful for debugging systems-level issues withing
9696
the device or blisp itself.
97+
## Running unit tests
98+
99+
```shell
100+
mkdir build && cd build
101+
cmake -DBLISP_BUILD_CLI=ON -DCOMPILE_TESTS=ON ..
102+
cmake --build .
103+
# Find all compiled unit test files; you can now run these directly
104+
find . -type f -executable -iname "*_test" -print
105+
```
97106

98107
## Troubleshooting
99108

blisp.nix

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
lib,
3+
self,
4+
stdenv,
5+
fetchFromGitHub,
6+
argtable,
7+
cmake,
8+
libserialport,
9+
pkg-config,
10+
testers,
11+
IOKit ? null,
12+
}:
13+
14+
stdenv.mkDerivation (finalAttrs: {
15+
pname = "blisp";
16+
version = "0.0.4-unstable";
17+
src = self;
18+
19+
nativeBuildInputs = [
20+
cmake
21+
pkg-config
22+
];
23+
24+
buildInputs = [
25+
argtable
26+
libserialport
27+
] ++ lib.optional stdenv.hostPlatform.isDarwin IOKit;
28+
29+
cmakeFlags = [
30+
"-DBLISP_BUILD_CLI=ON"
31+
"-DBLISP_USE_SYSTEM_LIBRARIES=ON"
32+
];
33+
34+
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-error=implicit-function-declaration";
35+
36+
passthru.tests.version = testers.testVersion {
37+
package = finalAttrs.finalPackage;
38+
version = "v${finalAttrs.version}";
39+
};
40+
41+
meta = with lib; {
42+
description = "In-System-Programming (ISP) tool & library for Bouffalo Labs RISC-V Microcontrollers and SoCs";
43+
license = licenses.mit;
44+
mainProgram = "blisp";
45+
homepage = "https://github.com/pine64/blisp";
46+
platforms = platforms.unix;
47+
maintainers = [ maintainers.bdd ];
48+
};
49+
})

0 commit comments

Comments
 (0)