Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for running on Windows #3

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CMake

on: [push]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE

# No tests currently defined
#- name: Test
# working-directory: ${{github.workspace}}/build
# shell: bash
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C $BUILD_TYPE

- uses: actions/upload-artifact@v2
with:
name: usamba.exe
path: build\Release\usamba.exe


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ GRTAGS
GTAGS
*.o
*~
/.vs
/out
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.18)

project ("usamba")

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
add_link_options(-fprofile-instr-generate)

#add_compile_options(-MD)
#add_link_options(clang_rt.asan_dynamic-i386.lib)
#add_compile_options(-fsanitize=address)
endif()

set(SOURCES
"chipid.c" "chipid.h"
"comm.c" "comm.h"
"eefc.c" "eefc.h"
"utils.h"
"usamba.c"
"common_types.h")

add_executable(${PROJECT_NAME} ${SOURCES})

set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99)
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD_REQUIRED 99)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED 11)

#target_include_directories(${PROJECT_NAME} PUBLIC "${gtest_SOURCE_DIR}/include" "${gmock_SOURCE_DIR}/include" "${CMAKE_SOURCE_DIR}/network")

# get_cmake_property(_variableNames VARIABLES)
# foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()
#
27 changes: 27 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x86-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": []
}
]
}
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Micro SAM-BA
------------
============

# Description

Expand Down Expand Up @@ -40,3 +40,8 @@ for all commands:
example ``/dev/ttyACM0``.
``<start-address>`` and ``<size>`` can be specified in decimal, hexadecimal (if
prefixed by ``0x``) or octal (if prefixed by ``0``).

# Platforms
This version now also supports both Linux and Windows

[![CMake](https://github.com/Rob-McKay/micro-sam-ba/actions/workflows/cmake.yml/badge.svg)](https://github.com/Rob-McKay/micro-sam-ba/actions/workflows/cmake.yml)
7 changes: 5 additions & 2 deletions chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

static const struct _chip _chips_samx7[] = {
{ "SAME70Q21", 0xa1020e00, 0x00000002, 0x400e0c00, 0x00400000, 2048, 9 },
{ "SAME70Q21B", 0xa1020e01, 0x00000002, 0x400e0c00, 0x00400000, 2048, 9 },
{ "SAME70Q20", 0xa1020c00, 0x00000002, 0x400e0c00, 0x00400000, 1024, 9 },
{ "SAME70Q19", 0xa10d0a00, 0x00000002, 0x400e0c00, 0x00400000, 512, 9 },
{ "SAME70N21", 0xa1020e00, 0x00000001, 0x400e0c00, 0x00400000, 2048, 9 },
Expand All @@ -27,6 +28,8 @@ static const struct _chip _chips_samx7[] = {
{ "SAME70J20", 0xa1020c00, 0x00000000, 0x400e0c00, 0x00400000, 1024, 9 },
{ "SAME70J19", 0xa10d0a00, 0x00000000, 0x400e0c00, 0x00400000, 512, 9 },
{ "SAMS70Q21", 0xa1120e00, 0x00000002, 0x400e0c00, 0x00400000, 2048, 9 },
{ "SAMS70N21A", 0xa1120e00, 0x00000001, 0x400e0c00, 0x00400000, 2048, 9 },
{ "SAMS70N21B", 0xa1120e01, 0x00000001, 0x400e0c00, 0x00400000, 2048, 9 },
{ "SAMS70Q20", 0xa1120c00, 0x00000002, 0x400e0c00, 0x00400000, 1024, 9 },
{ "SAMS70Q19", 0xa11d0a00, 0x00000002, 0x400e0c00, 0x00400000, 512, 9 },
{ "SAMS70N21", 0xa1120e00, 0x00000001, 0x400e0c00, 0x00400000, 2048, 9 },
Expand Down Expand Up @@ -70,7 +73,7 @@ const struct _chip_serie* chipid_get_serie(const char* name)
return NULL;
}

bool chipid_check_serie(int fd, const struct _chip_serie* serie, const struct _chip** chip)
bool chipid_check_serie(serial_port_handle_t fd, const struct _chip_serie* serie, const struct _chip** chip)
{
// Read chip identifiers (CIDR/EXID)
uint32_t cidr, exid;
Expand All @@ -90,7 +93,7 @@ bool chipid_check_serie(int fd, const struct _chip_serie* serie, const struct _c
return false;
}

const struct _chip_serie* chipid_identity_serie(int fd, const struct _chip** chip)
const struct _chip_serie* chipid_identity_serie(serial_port_handle_t fd, const struct _chip** chip)
{
for (int i = 0; i < ARRAY_SIZE(_chip_series); i++)
if (chipid_check_serie(fd, &_chip_series[i], chip))
Expand Down
6 changes: 4 additions & 2 deletions chipid.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <stdbool.h>
#include <stdint.h>

#include "common_types.h"

struct _chip {
const char* name;
uint32_t cidr;
Expand All @@ -37,8 +39,8 @@ struct _chip_serie {

extern const struct _chip_serie* chipid_get_serie(const char* name);

extern bool chipid_check_serie(int fd, const struct _chip_serie* serie, const struct _chip** chip);
extern bool chipid_check_serie(serial_port_handle_t fd, const struct _chip_serie* serie, const struct _chip** chip);

extern const struct _chip_serie* chipid_identity_serie(int fd, const struct _chip** chip);
extern const struct _chip_serie* chipid_identity_serie(serial_port_handle_t fd, const struct _chip** chip);

#endif /* CHIPID_H_ */
Loading