Revision 6feb42c8
| .gitmodules | ||
|---|---|---|
| 1 |
[submodule "Host/stm32flash"] |
|
| 2 |
path = Host/Source/stm32flash |
|
| 3 |
url = https://git.code.sf.net/p/stm32flash/code |
|
| Host/Source/SerialBoot/main.c | ||
|---|---|---|
| 215 | 215 |
printf("Copyright (c) by Feaser http://www.feaser.com \n");
|
| 216 | 216 |
printf("---------------------------------------------------------------------------\n");
|
| 217 | 217 |
printf("This tool was modified for the 'Autonomous Mini Robot' - AMiRo. \n");
|
| 218 |
printf("Copyright (c) 2016..2017 Marvin Barther, Thomas Schoepping, and Stefan \n");
|
|
| 218 |
printf("Copyright (c) 2016..2018 Marvin Barther, Thomas Schoepping, and Stefan \n");
|
|
| 219 | 219 |
printf(" Herbrechtsmeier \n");
|
| 220 | 220 |
printf("This is free software; see the source for copying conditions. There is NO \n");
|
| 221 | 221 |
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
| Host/Source/stm32flash | ||
|---|---|---|
| 1 |
Subproject commit 1f934ae86babdeea47afdfae1d856d5fd5da6c53 |
|
| README.txt | ||
|---|---|---|
| 1 | 1 |
AMiRo-BLT is the bootloader and flashing toolchain for the base version of the |
| 2 |
Autonomous Mini Robot (AMiRo) [1,2]. It is based on OpenBLT developed by Feaser
|
|
| 2 |
Autonomous Mini Robot (AMiRo) [1]. It is based on OpenBLT developed by Feaser |
|
| 3 | 3 |
(see <http://feaser.com/en/openblt.php>). |
| 4 | 4 |
|
| 5 |
Copyright (C) 2016..2017 Thomas Schöpping et al.
|
|
| 5 |
Copyright (C) 2016..2018 Thomas Schöpping et al.
|
|
| 6 | 6 |
(a complete list of all authors is given below) |
| 7 | 7 |
|
| 8 | 8 |
This program is free software: you can redistribute it and/or modify |
| ... | ... | |
| 24 | 24 |
|
| 25 | 25 |
Authors: |
| 26 | 26 |
- Thomas Schöpping <tschoepp[at]cit-ec.uni-bielefeld.de> |
| 27 |
- Stefan Herbechtsmeier <sherbrec[at]cit-ec.uni-bielefeld.de>
|
|
| 27 |
- Stefan Herbrechtsmeier <sherbrec[at]cit-ec.uni-bielefeld.de>
|
|
| 28 | 28 |
- Marvin Barther |
| 29 | 29 |
|
| 30 | 30 |
References: |
| 31 |
[1] Herbrechtsmeier S., Rückert U., & Sitte J. (2012). "AMiRo - Autonomous Mini |
|
| 32 |
Robot for Research and Education". In Advances in Autonomous Mini Robots |
|
| 33 |
(pp. 101-112). Springer Berlin Heidelberg. |
|
| 34 |
[2] Schöpping T., Korthals T., Herbrechtsmeier S., & Rückert U. (2015). "AMiRo: |
|
| 35 |
A Mini Robot for Scientific Applications" In Advances in Computational |
|
| 36 |
Intelligence (pp. 199-205). Springer International Publishing. |
|
| 37 |
|
|
| 31 |
[1] S. Herbrechtsmeier, T. Korthals, T. Schopping and U. Rückert, "AMiRo: A |
|
| 32 |
modular & customizable open-source mini robot platform," 2016 20th |
|
| 33 |
International Conference on System Theory, Control and Computing (ICSTCC), |
|
| 34 |
Sinaia, 2016, pp. 687-692. |
|
| 35 |
|
|
| 38 | 36 |
|
| 39 | 37 |
|
| 40 | 38 |
################################################################################ |
| ... | ... | |
| 58 | 56 |
CONTENTS: |
| 59 | 57 |
|
| 60 | 58 |
1 Required software |
| 61 |
1.1 stm32flash |
|
| 62 |
1.2 GCC ARM Embedded Toolchain |
|
| 63 |
1.3 GNU Make |
|
| 64 |
1.4 CMake |
|
| 59 |
1.1 Git |
|
| 60 |
1.2 GNU Make |
|
| 61 |
1.3 GCC |
|
| 62 |
1.4 stm32flash |
|
| 63 |
1.5 GCC ARM Embedded Toolchain |
|
| 64 |
1.6 CMake |
|
| 65 | 65 |
2 Recommended Software |
| 66 | 66 |
3 Compiling the source code |
| 67 |
3.1 target software
|
|
| 68 |
3.2 host software
|
|
| 67 |
3.1 host software
|
|
| 68 |
3.2 target software
|
|
| 69 | 69 |
|
| 70 | 70 |
================================================================================ |
| 71 | 71 |
|
| ... | ... | |
| 80 | 80 |
to the hardware. |
| 81 | 81 |
|
| 82 | 82 |
|
| 83 |
1.1 - Git |
|
| 84 |
--------- |
|
| 85 |
|
|
| 86 |
Since all main- and subprojects are available as Git repositories, installing a |
|
| 87 |
recent version of the tool is mandatory. |
|
| 88 |
|
|
| 89 |
|
|
| 90 |
1.2 - GNU Make |
|
| 91 |
-------------- |
|
| 92 |
|
|
| 93 |
GNU Make usually comes as preinstalled tool on Ubuntu based operating systems. |
|
| 94 |
If your system is missing GNU Make, it is recommended to install it from the |
|
| 95 |
standard repositories since no special requirements (e.g. features of a very |
|
| 96 |
recent version) are required. |
|
| 97 |
|
|
| 83 | 98 |
|
| 84 |
1.1 - stm32flash |
|
| 99 |
1.3 - GCC |
|
| 100 |
--------- |
|
| 101 |
|
|
| 102 |
In order to build some required tools from source, GCC is required. It usually |
|
| 103 |
comes as preinstalled tool on Ubuntu based operating systems. If your system is |
|
| 104 |
missing GCC, it is recommended to install it from the standard repositories |
|
| 105 |
since no special requirements (e.g. features of a very recent version) are |
|
| 106 |
required. |
|
| 107 |
|
|
| 108 |
|
|
| 109 |
1.4 - stm32flash |
|
| 85 | 110 |
---------------- |
| 86 | 111 |
|
| 87 |
To build the tool from source, clone the GIT repository to a local folder on |
|
| 88 |
your machine: |
|
| 89 |
>$ git clone git://git.code.sf.net/p/stm32flash/code |
|
| 90 |
Make sure that you have selected version 0.4 or later of the tool. You can now |
|
| 91 |
build the tool simply by executing 'make'. Finally, you must make the resulting |
|
| 92 |
binary (stm32flash) globally available in your environment. You can do so by |
|
| 93 |
either copying the file to an appropriate location (e.g. /usr/local/bin/) or |
|
| 94 |
creating an according link. The tool must be available as 'stm32flash' in every |
|
| 95 |
new shell. |
|
| 112 |
This tool is required to flash the bootloader binaries to the microcontrollers. |
|
| 113 |
Since it is included in this project as a submodule, you can just run the setup |
|
| 114 |
script in the root directory: |
|
| 115 |
>$ ./setup.sh |
|
| 116 |
Follow the instructions to download the source code and compile the tool. The |
|
| 117 |
resulting binary path is ./Host/Source/stm32flash/stm32flash. Other scripts that |
|
| 118 |
require stm32flash will search for the binary at this location by default. |
|
| 96 | 119 |
|
| 120 |
The setup script does not install the tool to your system path, though, since |
|
| 121 |
this usually requires root permissions. However, stm32flash provides a Makefile |
|
| 122 |
with installation capabilities. Just Follow the instructions given in the file |
|
| 123 |
./Host/Source/stm32flash/INSTALL. |
|
| 97 | 124 |
|
| 98 |
1.2 - GCC ARM Embedded Toolchain |
|
| 125 |
|
|
| 126 |
1.5 - GCC ARM Embedded Toolchain |
|
| 99 | 127 |
-------------------------------- |
| 100 | 128 |
|
| 101 | 129 |
Various versions of the GCC for ARM embedded devices can be found at |
| 102 | 130 |
<https://launchpad.net/gcc-arm-embedded>. For installation of the compiler |
| 103 |
toolchain, please follow the instructions that can be found on the web page. |
|
| 104 |
If you have access to the AMiRo-OS project as well, it is highly recommended |
|
| 105 |
to use the setup application provided there. |
|
| 106 |
|
|
| 131 |
toolchain and managing of multiple versions, it is highly recommended to use the |
|
| 132 |
provided setup script. Alternatively you can install the compiler manually by |
|
| 133 |
following the instructions that can be found on the web page. |
|
| 107 | 134 |
|
| 108 |
1.3 - GNU Make |
|
| 109 |
-------------- |
|
| 110 |
|
|
| 111 |
GNU Make usually comes as preinstalled tool on Ubuntu based operating systems. |
|
| 112 |
If your system is missing GNU Make, it is recommended to install it from the |
|
| 113 |
standard repositories since no special requirements (e.g. features of a very |
|
| 114 |
recent version) are required. |
|
| 135 |
If you are running a 64-bit operating system, you may have to install several |
|
| 136 |
32-bit libraries in order to make the compiler work. The required packages are |
|
| 137 |
libc6, libstdc++6, and libncurses5. You can run the following shell commands to |
|
| 138 |
install the according 32-bit versions of the packages: |
|
| 139 |
>$ sudo dpkg --add-architecture i386 && sudo apt-get update |
|
| 140 |
>$ sudo apt-get install libc6:i386 libstdc++6:i386 libncurses5:i386 |
|
| 115 | 141 |
|
| 116 | 142 |
|
| 117 |
1.4 - CMake
|
|
| 143 |
1.6 - CMake
|
|
| 118 | 144 |
----------- |
| 119 | 145 |
|
| 120 | 146 |
In order to build the SerialBoot host application, CMake version 2.8 or later is |
| ... | ... | |
| 146 | 172 |
even for other modules. |
| 147 | 173 |
|
| 148 | 174 |
|
| 149 |
3.1 - target software |
|
| 175 |
3.1 - host software |
|
| 176 |
------------------- |
|
| 177 |
|
|
| 178 |
The stm32flash tool is requried to flash bootloader binaries to the MCUs. |
|
| 179 |
Instructions for builing the tool are given in chapter 1.4 of this file. |
|
| 180 |
|
|
| 181 |
The SerialBoot tool can be built by using cmake. The according CMakeLists.txt |
|
| 182 |
file can be found in the ./Host/Source/SerialBoot/ directory. To ensure |
|
| 183 |
compatibility with other software (e.g. AMiRo-OS) it is higly recommended to use |
|
| 184 |
the provided ./setup.sh script to build SerialBoot. In the end the binary path |
|
| 185 |
should be ./Host/Source/SerialBoot/build/SerialBoot, which is the default for |
|
| 186 |
any scripts and tools that use SerialBoot. |
|
| 187 |
|
|
| 188 |
|
|
| 189 |
3.2 - target software |
|
| 150 | 190 |
--------------------- |
| 151 | 191 |
|
| 152 | 192 |
In the ./Target/Demo/ directory there are three subfolders, one for each AMiRo |
| ... | ... | |
| 155 | 195 |
be compiled by executing 'make' in these directories. |
| 156 | 196 |
|
| 157 | 197 |
In order to flash the bootloader to a microcontroller, you first have to set |
| 158 |
full read and write permissions to the USB ports of your system. You can do so |
|
| 159 |
by executing the following command: |
|
| 160 |
>$ sudo echo 'KERNEL=="ttyUSB[0-9]*",NAME="tts/USB%n",SYMLINK+="%k",MODE="0666"' > /etc/udev/rules.d/50-ttyusb.rules |
|
| 198 |
full read and write permissions to the USB ports of your system. To do so, first |
|
| 199 |
create a new file by executing the following command: |
|
| 200 |
>$ sudo touch /etc/udev/rules.d/50-usb-serial.rules |
|
| 201 |
Open the file in a text editor of your choice (sudo required) and add the |
|
| 202 |
following lines: |
|
| 203 |
|
|
| 204 |
# Future Technology Devices International Ltd. - TTL-232RG |
|
| 205 |
SUBSYSTEMS=="usb", ACTION=="add", KERNEL=="ttyUSB[0-9]*", |
|
| 206 |
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666"
|
|
| 207 |
|
|
| 208 |
# Future Technology Devices International Ltd. - FT231X |
|
| 209 |
SUBSYSTEMS=="usb", ACTION=="add", KERNEL=="ttyUSB[0-9]*", |
|
| 210 |
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE="0666"
|
|
| 211 |
|
|
| 161 | 212 |
Now connect the module you want to flash directly to your system (note that |
| 162 | 213 |
indirect flashing is not possible for the bootloader itself) and run the command |
| 163 | 214 |
>$ make flash |
| 164 | 215 |
If the procedure was not successful, the following hints might help: |
| 216 |
- Did your system apply the new udev rules? |
|
| 217 |
Reboot and try again! |
|
| 165 | 218 |
- Could the makefile execute the stm32flash tool? |
| 219 |
Reinitialize the submodule and try again! |
|
| 166 | 220 |
- Are the permissions for USB ports set correctly? |
| 221 |
Check the udev rules! |
|
| 167 | 222 |
- Are there any other applications using the serial connection? |
| 223 |
Close any other applications using the serial connection! |
|
| 168 | 224 |
- Is the AMiRo module connected to your system? |
| 225 |
Use the programming cable to connect the module to your system. |
|
| 169 | 226 |
- Is the AMiRo module powered up? |
| 227 |
Keep a charger plugged in during flashing. |
|
| 170 | 228 |
|
| 171 | 229 |
ATTENTION: |
| 172 | 230 |
Never flash a bootloader to the wrong module! Doing so might cause severe errors |
| 173 | 231 |
and damage the robot. |
| 174 | 232 |
|
| 175 |
|
|
| 176 |
3.2 - host software |
|
| 177 |
------------------- |
|
| 178 |
|
|
| 179 |
The SerialBoot tool can be built by using cmake. The according CMakeLists.txt |
|
| 180 |
file can be found in the ./Host/Source/SerialBoot/ directory. To ensure |
|
| 181 |
compatibility with other software (e.g. AMiRo-OS) it is higly recommended to use |
|
| 182 |
the provided ./setup.sh script to build SerialBoot. In the end the binary path |
|
| 183 |
should be ./Host/Sotware/SerialBoot/build/SerialBoot. |
|
| 184 |
|
|
| 185 | 233 |
================================================================================ |
| 186 | 234 |
|
| Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/main.c | ||
|---|---|---|
| 170 | 170 |
|
| 171 | 171 |
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = {
|
| 172 | 172 |
.magicNumber = BL_MAGIC_NUMBER, |
| 173 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
|
|
| 173 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 1},
|
|
| 174 | 174 |
.vSSSP = {BL_VERSION_ID_SSSP, SSSP_VERSION_MAJOR, SSSP_VERSION_MINOR, 0},
|
| 175 | 175 |
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported
|
| 176 | 176 |
.cbShutdownHibernate = blCallbackShutdownHibernate, |
| Target/Demo/ARMCM3_STM32F103_LightRing_GCC/Boot/main.c | ||
|---|---|---|
| 140 | 140 |
|
| 141 | 141 |
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = {
|
| 142 | 142 |
.magicNumber = BL_MAGIC_NUMBER, |
| 143 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
|
|
| 143 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 1},
|
|
| 144 | 144 |
.vSSSP = {BL_VERSION_ID_SSSP, SSSP_VERSION_MAJOR, SSSP_VERSION_MINOR, 0},
|
| 145 | 145 |
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported
|
| 146 | 146 |
.cbShutdownHibernate = blCallbackShutdownHibernate, |
| Target/Demo/ARMCM4_STM32F405_Power_Management_GCC/Boot/main.c | ||
|---|---|---|
| 193 | 193 |
|
| 194 | 194 |
const blCallbackTable_t cbtable __attribute__ ((section ("_callback_table"))) = {
|
| 195 | 195 |
.magicNumber = BL_MAGIC_NUMBER, |
| 196 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 0},
|
|
| 196 |
.vBootloader = {BL_VERSION_ID_AMiRoBLT_Release, BL_VERSION_MAJOR, BL_VERSION_MINOR, 1},
|
|
| 197 | 197 |
.vSSSP = {BL_VERSION_ID_SSSP, SSSP_VERSION_MAJOR, SSSP_VERSION_MINOR, 0},
|
| 198 | 198 |
.vCompiler = {BL_VERSION_ID_GCC, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__}, // currently only GCC is supported
|
| 199 | 199 |
.cbShutdownHibernate = blCallbackShutdownHibernate, |
| Target/Demo/flash.mk | ||
|---|---|---|
| 1 |
STM32FLASH = stm32flash
|
|
| 1 |
STM32FLASH := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))../../Host/Source/stm32flash/stm32flash
|
|
| 2 | 2 |
ifeq ($(OS),Windows_NT) |
| 3 | 3 |
STM32FLASH_PORT ?= COM5 |
| 4 | 4 |
else |
| Target/Makefile | ||
|---|---|---|
| 1 |
################################################################################ |
|
| 2 |
# AMiRo-BLT is the bootloader and flashing toolchain for the base version of # |
|
| 3 |
# the Autonomous Mini Robot (AMiRo). It is based on OpenBLT developed by # |
|
| 4 |
# Feaser (see <http://feaser.com/en/openblt.php>). # |
|
| 5 |
# Copyright (C) 2016..2018 Thomas Schöpping et al. # |
|
| 6 |
# # |
|
| 7 |
# This program is free software: you can redistribute it and/or modify # |
|
| 8 |
# it under the terms of the GNU General Public License as published by # |
|
| 9 |
# the Free Software Foundation, either version 3 of the License, or # |
|
| 10 |
# (at your option) any later version. # |
|
| 11 |
# # |
|
| 12 |
# This program is distributed in the hope that it will be useful, # |
|
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
|
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
|
| 15 |
# GNU General Public License for more details. # |
|
| 16 |
# # |
|
| 17 |
# You should have received a copy of the GNU General Public License # |
|
| 18 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. # |
|
| 19 |
# # |
|
| 20 |
# This research/work was supported by the Cluster of Excellence Cognitive # |
|
| 21 |
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is # |
|
| 22 |
# funded by the German Research Foundation (DFG). # |
|
| 23 |
################################################################################ |
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
ROOT_PATH = .. |
|
| 28 |
DWD_PATH = $(ROOT_PATH)/Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot |
|
| 29 |
PM_PATH = $(ROOT_PATH)/Target/Demo/ARMCM4_STM32F405_Power_Management_GCC/Boot |
|
| 30 |
LR_PATH = $(ROOT_PATH)/Target/Demo/ARMCM3_STM32F103_LightRing_GCC/Boot |
|
| 31 |
|
|
| 32 |
all: |
|
| 33 |
$(MAKE) -C $(DWD_PATH) |
|
| 34 |
$(MAKE) -C $(PM_PATH) |
|
| 35 |
$(MAKE) -C $(LR_PATH) |
|
| 36 |
|
|
| 37 |
clean: |
|
| 38 |
$(MAKE) -C $(DWD_PATH) clean |
|
| 39 |
$(MAKE) -C $(PM_PATH) clean |
|
| 40 |
$(MAKE) -C $(LR_PATH) clean |
|
| 41 |
|
|
| 42 |
DiWheelDrive: |
|
| 43 |
$(MAKE) -C $(DWD_PATH) |
|
| 44 |
|
|
| 45 |
PowerManagement: |
|
| 46 |
$(MAKE) -C $(PM_PATH) |
|
| 47 |
|
|
| 48 |
LightRing: |
|
| 49 |
$(MAKE) -C $(LR_PATH) |
|
| 50 |
|
|
| 51 |
flash_DiWheelDrive: |
|
| 52 |
$(MAKE) -C $(DWD_PATH) flash |
|
| 53 |
|
|
| 54 |
flash_PowerManagement: |
|
| 55 |
$(MAKE) -C $(PM_PATH) flash |
|
| 56 |
|
|
| 57 |
flash_LightRing: |
|
| 58 |
$(MAKE) -C $(LR_PATH) flash |
|
| 59 |
|
|
| compiler/GCC/gccsetup.sh | ||
|---|---|---|
| 1 |
################################################################################ |
|
| 2 |
# AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini # |
|
| 3 |
# Robot (AMiRo) platform. # |
|
| 4 |
# Copyright (C) 2016..2018 Thomas Schöpping et al. # |
|
| 5 |
# # |
|
| 6 |
# This program is free software: you can redistribute it and/or modify # |
|
| 7 |
# it under the terms of the GNU General Public License as published by # |
|
| 8 |
# the Free Software Foundation, either version 3 of the License, or # |
|
| 9 |
# (at your option) any later version. # |
|
| 10 |
# # |
|
| 11 |
# This program is distributed in the hope that it will be useful, # |
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
|
| 14 |
# GNU General Public License for more details. # |
|
| 15 |
# # |
|
| 16 |
# You should have received a copy of the GNU General Public License # |
|
| 17 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. # |
|
| 18 |
# # |
|
| 19 |
# This research/work was supported by the Cluster of Excellence Cognitive # |
|
| 20 |
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is # |
|
| 21 |
# funded by the German Research Foundation (DFG). # |
|
| 22 |
################################################################################ |
|
| 23 |
|
|
| 24 |
#!/bin/bash |
|
| 25 |
|
|
| 26 |
################################################################################ |
|
| 27 |
# GENERIC FUNCTIONS # |
|
| 28 |
################################################################################ |
|
| 29 |
|
|
| 30 |
### print an error message ##################################################### |
|
| 31 |
# Prints a error <message> to standard output. |
|
| 32 |
#If variable 'LOG_FILE' is specified, the message is also appended to the given file. |
|
| 33 |
# |
|
| 34 |
# usage: printError <message> |
|
| 35 |
# arguments: <message> |
|
| 36 |
# Message string to print. |
|
| 37 |
# return: n/a |
|
| 38 |
# |
|
| 39 |
function printError {
|
|
| 40 |
local string="ERROR: $1" |
|
| 41 |
# if a log file is specified |
|
| 42 |
if [ -n "$LOG_FILE" ]; then |
|
| 43 |
printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE |
|
| 44 |
fi |
|
| 45 |
printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2 |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
### print a warning message #################################################### |
|
| 49 |
# Prints a warning <message> to standard output. |
|
| 50 |
#If variable 'LOG_FILE' is specified, the message is also appended to the given file. |
|
| 51 |
# |
|
| 52 |
# usage: printMessage <message> |
|
| 53 |
# arguments: <message> |
|
| 54 |
# Message string to print. |
|
| 55 |
# return: n/a |
|
| 56 |
# |
|
| 57 |
function printWarning {
|
|
| 58 |
local string="WARNING: $1" |
|
| 59 |
# if a log file is specified |
|
| 60 |
if [ -n "$LOG_FILE" ]; then |
|
| 61 |
printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE |
|
| 62 |
fi |
|
| 63 |
printf "$(tput setaf 3)>>> $string$(tput sgr 0)" |
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
### print an information message ############################################### |
|
| 67 |
# Prints an information <message> to standard output. |
|
| 68 |
#If variable 'LOG_FILE' is specified, the message is also appended to the given file. |
|
| 69 |
# |
|
| 70 |
# usage: printInfo <message> |
|
| 71 |
# arguments: <message> |
|
| 72 |
# Message string to print. |
|
| 73 |
# return: n/a |
|
| 74 |
# |
|
| 75 |
function printInfo {
|
|
| 76 |
local string="INFO: $1" |
|
| 77 |
# if a log file is specified |
|
| 78 |
if [ -n "$LOG_FILE" ]; then |
|
| 79 |
printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE |
|
| 80 |
fi |
|
| 81 |
printf "$(tput setaf 2)>>> $string$(tput sgr 0)" |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
### print a message to file #################################################### |
|
| 85 |
# Appends a <message> to a log file, specified by the variable 'LOG_FILE'. |
|
| 86 |
# |
|
| 87 |
# usage printLog <message> |
|
| 88 |
# arguments: <message> |
|
| 89 |
# Message string to print. |
|
| 90 |
# return: n/a |
|
| 91 |
# |
|
| 92 |
function printLog {
|
|
| 93 |
local string="LOG: $1" |
|
| 94 |
# if a log file is specified |
|
| 95 |
if [ -n "$LOG_FILE" ]; then |
|
| 96 |
printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE |
|
| 97 |
fi |
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
### exit the script normally ################################################### |
|
| 101 |
# Prints a delimiter and exits the script normally (returns 0). |
|
| 102 |
# |
|
| 103 |
# usage: quitScript |
|
| 104 |
# arguments: n/a |
|
| 105 |
# return: 0 |
|
| 106 |
# No error or warning occurred. |
|
| 107 |
# |
|
| 108 | ||