Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

[BUILD] Ccoffee Enhancements #148

Open
wants to merge 2 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
14 changes: 12 additions & 2 deletions AvrDataTypes/build/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#**
#* Ccoffee Build tool, manual build, alpha-v1.
#*
#* @author pavl_g.
#*#
#!/bin/sh

canonical_link=`readlink -f ${0}`
build_dir=`dirname $canonical_link`

echo "Ccoffee Script starts"
echo "---------------------------------------------"
source compile.sh
source upload.sh
source "${build_dir}/compile.sh"
source "${build_dir}/upload.sh"
echo "---------------------------------------------"
echo "Ccoffee Script finishes"
38 changes: 29 additions & 9 deletions AvrDataTypes/build/compile.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
source variables.sh
export LC_ALL=C
#**
#* Ccoffee Build tool, manual build, alpha-v1.
#*
#* @author pavl_g.
#*#
#!/bin/sh

# export all locales as "en_US.UTF-8" for the gcc compiler
export LC_ALL="en_US.UTF-8"

canonical_link=`readlink -f ${0}`
build_dir=`dirname $canonical_link`

source "${build_dir}/variables.sh"

function compile() {
# attrs : dir to compile & sharedLib name
nativeSources=`find ${project}'/main' -name '*.c' -o -name '*.cxx' -o -name '*.cpp' -o -name '*.h' -o -name '*.c++'`
native_sources=`find ${project}'/main' -name '*.c' -o -name '*.cxx' -o -name '*.cpp' -o -name '*.h' -o -name '*.c++'`

sudo ${AVR_HOME}'/bin/avr-g++' \
-mmcu=${CHIP} ${nativeSources} \
sudo ${avr_home}'/bin/avr-g++' \
-mmcu=${CHIP} ${native_sources} \
-O2 \
-I${AVR_HOME}'/avr/include' \
-I${avr_home}'/avr/include' \
-I${project}'/main/include' \
-o ${output}

return $?
}

function convertToHex() {
${AVR_HOME}'/bin/avr-objcopy' -O ihex ${output} ${output}'.hex'
${avr_home}'/bin/avr-objcopy' -O ihex ${output} ${output}'.hex'
return $?
}

echo -e "${WHITE_C} --MajorTask@Compile : Compiling the project"

echo -e ${RESET_Cs}

if [[ ! `compile` -eq 0 ]]; then
compile

if [[ ! $? -eq 0 ]]; then
echo -e "${RED_C} --MajorTask@Compile : Failed compiling sources, exits with errno500."
exit 500
else
Expand All @@ -31,10 +47,14 @@ fi
echo -e ${RESET_Cs}

echo -e "${WHITE_C} --MajorTask@Hexing : Creating Hex file"
if [[ ! `convertToHex` -eq 0 ]]; then

convertToHex

if [[ ! $? -eq 0 ]]; then
echo -e "${RED_C} --MajorTask@Hexing : Failed to create hex file, exits with errno600."
exit 600
else
echo -e "${GREEN_C} --MajorTask@Hexing : Hex file created successfully."
fi

echo -e ${RESET_Cs}
40 changes: 33 additions & 7 deletions AvrDataTypes/build/readPort.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
PORT='/dev/ttyUSB0'
BAUD_RATE='57600'
#**
#* Ccoffee Build tool, manual build, alpha-v1.
#*
#* @author pavl_g.
#*#
#!/bin/sh

echo "\n"
canonical_link=`readlink -f ${0}`
build_dir=`dirname $canonical_link`

echo "Started reading PORT [$PORT] to terminate hold [CTRL+A+D]\n"
source "${build_dir}/variables.sh"

adjustBaudRate() {
function prepare() {
sudo apt-get install screen
}

function adjustBaudRate() {
stty -F $1 $2
}

readPort() {
screen "$1" "$BAUD_RATE"
function holdStill() {
for ((i = 0; i < 4; i++))
do
sleep 2
printf "....."
done
printf "\n"
}

function readPort() {
screen -R "READ-PORT" -U "$1" "$BAUD_RATE"
}

printf "Preparing the [screen] util\n"

prepare

adjustBaudRate "$PORT" "$BAUD_RATE"

printf "Started reading PORT [$PORT] to terminate hold [CTRL+A+D]\n"

holdStill

readPort "$PORT"
20 changes: 18 additions & 2 deletions AvrDataTypes/build/upload.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
source variables.sh
#**
#* Ccoffee Build tool, manual build, alpha-v1.
#*
#* @author pavl_g.
#*#
#!/bin/sh

canonical_link=`readlink -f ${0}`
build_dir=`dirname $canonical_link`

source "${build_dir}/variables.sh"

function prepare() {
sudo stty -F ${PORT} ${BAUD_RATE}
Expand All @@ -8,12 +18,18 @@ function upload() {
sudo avrdude -c ${PROGRAMMER} -b${BAUD_RATE} -P${PORT} -p${CHIP_ALIAS} -F -U flash:w:${output}'.hex'
return $?
}

prepare

echo -e "${WHITE_C} --MajorTask@UploadingCode : Uploading Hex file"
if [[ ! `upload` -eq 0 ]]; then

upload

if [[ ! $? -eq 0 ]]; then
echo -e "${RED_C} --MajorTask@UploadingCode : Failed to upload hex file, exits with errno700."
exit 700
else
echo -e "${GREEN_C} --MajorTask@UploadingCode : Task finished."
fi

echo -e ${RESET_Cs}
17 changes: 8 additions & 9 deletions AvrDataTypes/build/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@
#*
#* @author pavl_g.
#*#
#!/bin/sh

canonical_link=`readlink -f ${0}`
build_dir=`dirname $canonical_link`

# define work directory
# 1) print the current working directory to a string value
pwd=`pwd`
# cut the working directory from its end by a one '/' delimiter
project="${pwd%/*}"
project="${build_dir%/*}"
# cut the working directory from its end by a one '/' delimiter again
rootProject="${project%/*}"
# pass the value of the dire

clibName=('libAvrDataTypes')
object_file=('hello-avr-types.elf')
# AVR-DUDE properties
BAUD_RATE='57600'
PORT='/dev/ttyUSB0'
CHIP='atmega328p'
CHIP_ALIAS='m328'
PROGRAMMER='arduino'
# Common Variables contain colors
source ${rootProject}'/CommonVariables.sh'
source ${rootProject}'/AVR__HOME.sh'
output=${project}'/output/'${clibName}
source ${rootProject}'/common-variables.sh'
source ${rootProject}'/avr-home.sh'
output=${project}'/output/'${object_file}
2 changes: 1 addition & 1 deletion AvrDataTypes/main/lib/SerialCounter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

void SerialCounter::Counter::start(volatile uint8_t& PORT) {
volatile uint8_t CLK = 0x00;
while(HIGH) {
while (HIGH) {
_delay_ms(DELAY/2);
PORT = HIGH << (++CLK % UINT8_MAX);
_delay_ms(DELAY/2);
Expand Down
Binary file added AvrDataTypes/output/hello-avr-types.elf
Binary file not shown.
Loading