Skip to content

Commit

Permalink
Fix parse address failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
kendryte747 committed Nov 15, 2024
1 parent 9790250 commit 3a9375e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Build K230 Cli for Windows
run: |
rm -rf ${{ github.workspace }}/build && mkdir -p ${{ github.workspace }}/build
docker run --name llvm_mingw -v "${PWD}:/project:ro" mstorsjo/llvm-mingw /bin/bash -c 'cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/build/dist -DBUILD_WITH_MINGW=ON -DCMAKE_TOOLCHAIN_FILE=/project/src/kburn/cli/cmake/mingw-toolchain.cmake -S /project/src/kburn -B /build; cmake --build /build --config Release; cmake --install /build --prefix /build/dist'
docker run --name llvm_mingw -v "${PWD}:/project:ro" -e GIT_COMMIT=${{ env.REVISION }} mstorsjo/llvm-mingw /bin/bash -c 'cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/build/dist -DBUILD_WITH_MINGW=ON -DCMAKE_TOOLCHAIN_FILE=/project/src/kburn/cli/cmake/mingw-toolchain.cmake -S /project/src/kburn -B /build; cmake --build /build --config Release; cmake --install /build --prefix /build/dist'
docker cp llvm_mingw:/build/dist ${{ github.workspace }}/dist
docker rm llvm_mingw
ls -alh ${{ github.workspace }}/dist
Expand Down
19 changes: 14 additions & 5 deletions src/kburn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ else()
set(IS_CI FALSE)
endif()

execute_process(
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Fetch the GIT_COMMIT environment variable
set(GIT_COMMIT_ENV $ENV{GIT_COMMIT})

# Fallback in case the environment variable is not set
if(NOT GIT_COMMIT_ENV)
execute_process(
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT_ENV
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()

# Print the commit hash
message(STATUS "GIT_COMMIT = ${GIT_COMMIT_ENV}")

if(NOT DEFINED K230_FLASH_VERSION_STRING)
set(K230_FLASH_VERSION_STRING "0.0.1")
Expand Down
10 changes: 7 additions & 3 deletions src/kburn/cli/k230_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ std::istream& operator>>(std::istream& in, AddrFilePartition& value) {
in.setstate(std::ios::failbit);
return in;
}
value.address = std::stoul(token); // Convert address from string to unsigned long
value.address = std::stoul(token, nullptr, 0); // Convert address from string to unsigned long

// Parse the file path (second part)
if (!std::getline(ss, token, ',')) {
Expand All @@ -213,7 +213,7 @@ std::istream& operator>>(std::istream& in, AddrFilePartition& value) {

// Parse the partition max size (third part, optional)
if (std::getline(ss, token, ',')) {
value.partition_max_size = std::stoul(token); // Convert partition max size
value.partition_max_size = std::stoul(token, nullptr, 0); // Convert partition max size
} else {
value.partition_max_size = 0; // Default to 0 if not provided
}
Expand Down Expand Up @@ -330,7 +330,7 @@ int main(int argc, char **argv) {

if(false == read_data) {
if(0x00 == addr_filename_pairs.size()) {
printf("the following arguments are required: <address> <filename>\n");
printf("the following arguments are required: <address> <filename> [partition_max_size]\n");
goto _exit;
}

Expand Down Expand Up @@ -368,6 +368,10 @@ int main(int argc, char **argv) {
printf("Warning: Overlap detected between %s and %s.\n",
filename.c_str(), addr_filename_pairs[i + 1].file_path.c_str());
}

if(spdlog::level::level_enum::debug >= log_level) {
printf("address %u file %s length %u, next address %u\n", address, filename.c_str(), fileSize, next_address);
}
}

// Update max file offset
Expand Down

0 comments on commit 3a9375e

Please sign in to comment.