Skip to content
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.h linguist-language=C
49 changes: 9 additions & 40 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
{
"env": {
"loaderDefaultIncludePaths": [
"${workspaceFolder}/include",
"${workspaceFolder}/scripts/opt/cross/lib/gcc/arm-none-eabi/8.2.0/include",
"${workspaceFolder}/scripts/opt/cross/lib/gcc/aarch64-none-elf/8.2.0/include"
],
"loaderDefaultBrowsePaths": [
"${workspaceFolder}/src",
"${workspaceFolder}/include",
"${workspaceFolder}/scripts/opt/cross/lib/gcc/arm-none-eabi/8.2.0/include",
"${workspaceFolder}/scripts/opt/cross/lib/gcc/aarch64-none-elf/8.2.0/include"
]
},
"configurations": [
{
"name": "Mac",
"includePath": [
"${loaderDefaultIncludePaths}"
"${workspaceFolder}/include"
],
"defines": [],
"intelliSenseMode": "${default}",
"browse": {
"path": [
"${loaderDefaultBrowsePaths}"
"${workspaceFolder}/src",
"${workspaceFolder}/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"macFrameworkPath": [],
"macFrameworkPath": [
"/System/Library/Frameworks"
],
"forcedInclude": [
"${workspaceFolder}/build/include/config.h"
],
Expand All @@ -36,35 +26,14 @@
{
"name": "Linux",
"includePath": [
"${loaderDefaultIncludePaths}"
"${workspaceFolder}/include"
],
"defines": [],
"intelliSenseMode": "${default}",
"browse": {
"path": [
"${loaderDefaultBrowsePaths}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"forcedInclude": [
"${workspaceFolder}/build/include/config.h"
],
"cStandard": "c11"
},
{
"name": "Win32",
"includePath": [
"${loaderDefaultIncludePaths}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "${default}",
"browse": {
"path": [
"${loaderDefaultBrowsePaths}"
"${workspaceFolder}/src",
"${workspaceFolder}/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Authors of bolthur-serial-communicator

Christian Freitag [email protected]
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xxxx-xx-xx Christian Freitag <[email protected]>
File renamed without changes.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

ACLOCAL_AMFLAGS = -I m4
ACLOCAL_AMFLAGS = -I build-aux/m4

SUBDIRS = src
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEWS - List of noteworthy changes between releases of bolthur-serial-communicator
Empty file added README
Empty file.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# bolthur serial communicator [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE) [![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](./.github/CODE_OF_CONDUCT.md) [![Contribution Guide](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](./.github/CONTRIBUTING.md) ![version](https://img.shields.io/badge/version-none-blue.svg?maxAge=2592000)

bolthur serial communicator project.
_Copyright (C) 2019 bolthur project_
_Copyright (C) 2019 - 2020 bolthur project_

## About

Small tool waiting for response from serial bootloader to send kernel to device.
Small tool waiting for response from serial bootloader to send kernel and optional initrd to device.
5 changes: 5 additions & 0 deletions build-aux/m4/flag.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

AC_DEFUN([BOLTHUR_SERIAL_COMMUNICATOR_SET_FLAG], [
# compile flags
CFLAGS="${CFLAGS} -Wall -Wextra -Werror -Wpedantic -Wconversion -O2"
])
42 changes: 42 additions & 0 deletions build-aux/m4/host.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

AC_DEFUN([BOLTHUR_SERIAL_COMMUNICATOR_SET_HOST], [
# define templates
AH_TEMPLATE([LINUX], [Linux build define])
AH_TEMPLATE([WINDOWS], [Windows build define])
AH_TEMPLATE([OSX], [Mac build define])

# bunch of flags
build_linux=no
build_windows=no
build_mac=no

# detect the target system
case "${host_os}" in
linux*)
CFLAGS="${CFLAGS} -std=c18"
build_linux=yes
;;
darwin*)
CFLAGS="${CFLAGS} -std=c17"
build_mac=yes
;;
cygwin*|mingw*)
CFLAGS="${CFLAGS} -std=c18"
build_windows=yes
;;
*)
AC_MSG_ERROR(["OS $host_os is not supported"])
;;
esac

# set host defines
if test "x$build_linux" = xyes; then
AC_DEFINE([LINUX], [1])
fi
if test "x$build_windows" = xyes; then
AC_DEFINE([WINDOWS], [1])
fi
if test "x$build_mac" = xyes; then
AC_DEFINE([OSX], [1])
fi
])
27 changes: 7 additions & 20 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@

AC_PREREQ(2.57)
AC_INIT([bolthur-serial-communicator], [0.1], [https://github.com/bolthur/serial-communicator/issues], [bolthur-serial-communicator], [https://github.com/bolthur/serial-communicator])
AC_COPYRIGHT([Copyright (C) 2019 bolthur project])
AC_COPYRIGHT([Copyright (C) 2019 - 2020 bolthur project])

AC_CONFIG_AUX_DIR([config])
AC_CONFIG_AUX_DIR([build-aux/config])
AC_CONFIG_MACRO_DIR([build-aux/m4])

AC_CANONICAL_HOST
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign 1.7])
AM_INIT_AUTOMAKE()
AC_CONFIG_HEADERS([include/config.h])

AM_SILENT_RULES([yes])

AC_LANG([C])

# compile flags
CFLAGS="${CFLAGS} -Wall -Wextra -Werror -Wpedantic -Wconversion -O2"

# Detect the target system
case "${host_os}" in
linux*)
CFLAGS="${CFLAGS} -std=c18"
;;
darwin*)
CFLAGS="${CFLAGS} -std=c17"
;;
*)
AC_MSG_ERROR(["OS $host_os is not supported"])
;;
esac
# Set flag and host
BOLTHUR_SERIAL_COMMUNICATOR_SET_FLAG
BOLTHUR_SERIAL_COMMUNICATOR_SET_HOST

# conftest
AC_LANG_CONFTEST([AC_LANG_SOURCE([[const char hw[] = "Hello, World\r\n";]])])
Expand Down
21 changes: 19 additions & 2 deletions include/endian_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* Copyright (C) 2019 bolthur project.
* Copyright (C) 2019 - 2020 bolthur project.
*
* This file is part of bolthur/serial-communicator.
*
Expand All @@ -20,7 +20,7 @@

#if !defined( ENDIAN_WRAPPER_H )
#define ENDIAN_WRAPPER_H
#if defined( __APPLE__ )
#if defined( OSX )
#include <libkern/OSByteOrder.h>

#define htobe16(x) OSSwapHostToBigInt16(x)
Expand All @@ -37,6 +37,23 @@
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
#elif defined( WINDOWS )
#include <windows.h>

#define htobe16(x) __builtin_bswap16(x)
#define htole16(x) (x)
#define be16toh(x) __builtin_bswap16(x)
#define le16toh(x) (x)

#define htobe32(x) __builtin_bswap32(x)
#define htole32(x) (x)
#define be32toh(x) __builtin_bswap32(x)
#define le32toh(x) (x)

#define htobe64(x) __builtin_bswap64(x)
#define htole64(x) (x)
#define be64toh(x) __builtin_bswap64(x)
#define le64toh(x) (x)
#else
#define __USE_MISC
#include <endian.h>
Expand Down
29 changes: 29 additions & 0 deletions include/initrd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

/**
* Copyright (C) 2019 - 2020 bolthur project.
*
* This file is part of bolthur/serial-communicator.
*
* bolthur/serial-communicator is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* bolthur/serial-communicator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bolthur/serial-communicator. If not, see <http://www.gnu.org/licenses/>.
*/

#if !defined( INITRD_H )
#define INITRD_H

#include <stdint.h>

extern void initrd_load( const char*, const char*, uint8_t**, uint32_t*, uint32_t* );
extern void initrd_rpi_prepare( uint32_t*, uint32_t* );

#endif
6 changes: 3 additions & 3 deletions include/kernel.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* Copyright (C) 2019 bolthur project.
* Copyright (C) 2019 - 2020 bolthur project.
*
* This file is part of bolthur/serial-communicator.
*
Expand All @@ -23,7 +23,7 @@

#include <stdint.h>

extern void kernel_load( const char*, const char*, uint8_t**, uint32_t* );
extern void kernel_rpi_prepare( uint32_t* file_length );
extern void kernel_load( const char*, const char*, uint8_t**, uint32_t*, uint32_t* );
extern void kernel_rpi_prepare( uint32_t*, uint32_t* );

#endif
13 changes: 10 additions & 3 deletions include/serial.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* Copyright (C) 2019 bolthur project.
* Copyright (C) 2019 - 2020 bolthur project.
*
* This file is part of bolthur/serial-communicator.
*
Expand All @@ -25,8 +25,15 @@
#include <stdlib.h>
#include <stdio.h>

#define INVALID_HANDLE -1
typedef int serial_handle_t;
#if defined( WINDOWS )
#include <windows.h>
typedef HANDLE serial_handle_t;
#define INVALID_HANDLE INVALID_HANDLE_VALUE
#else
typedef int serial_handle_t;
#define INVALID_HANDLE -1
#endif


serial_handle_t serial_open( const char* );
void serial_close( serial_handle_t );
Expand Down
27 changes: 27 additions & 0 deletions include/type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

/**
* Copyright (C) 2019 - 2020 bolthur project.
*
* This file is part of bolthur/serial-communicator.
*
* bolthur/serial-communicator is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* bolthur/serial-communicator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bolthur/serial-communicator. If not, see <http://www.gnu.org/licenses/>.
*/

#if !defined( TYPE_H )
#define TYPE_H

#define TYPE_KERNEL 1
#define TYPE_INITRD 2

#endif
4 changes: 3 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ AM_CFLAGS = -imacros $(top_builddir)/include/config.h -I$(top_srcdir)/include

bin_PROGRAMS = bolthur-communicator
bolthur_communicator_SOURCES = \
vendor/rpi/kernel.c \
platform/rpi/initrd.c \
platform/rpi/kernel.c \
initrd.c \
kernel.c \
main.c \
serial.c
Loading