Skip to content

Commit

Permalink
debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Luphaestus committed Mar 4, 2025
1 parent fbb5fa0 commit e460f09
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
25 changes: 17 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
boards=("maestro9610" "universal9630" "maestro9820" "smdk9830" "universal9830_bringup" "phoenix9830" "c1s" "c2s" "r8s" "x1s" "y2s" "z3s" "erd3830" "universal3830")

user_mode=false
debug_mode=0
debug_mode=false
verbose_mode=0
board=""

while [[ $# -gt 0 ]]; do
Expand All @@ -13,9 +14,13 @@ while [[ $# -gt 0 ]]; do
shift
;;
-d|--debug)
debug_mode=true
shift
;;
-v|--verbose)
case "$2" in
y) debug_mode=1 ;;
n) debug_mode=-1 ;;
y) verbose_mode=1 ;;
n) verbose_mode=-1 ;;
*) echo "Invalid parameter for --debug. Use 'y' or 'n'."; exit 1 ;;
esac
shift 2
Expand All @@ -34,17 +39,19 @@ done
echo -e "\n-----------------------------------------------------------------"
echo "Board: $board"
echo "User mode: $user_mode"
echo "Debug mode: $debug_mode"
echo "Debug mode: $verbose_mode"
echo "-----------------------------------------------------------------"

if [[ " ${boards[@]} " =~ " $board " ]]; then
pushd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null
rm -rf build-$board
make_cmd="make $board"
[[ $user_mode == true ]] && make_cmd+=" user"
[[ $debug_mode == true ]] && make_cmd+=" print_debug"
make_cmd+=" -j16"
echo "Running: $make_cmd"

if [[ $debug_mode -eq -1 ]]; then
if [[ $verbose_mode -eq -1 ]]; then
$make_cmd > >(while IFS= read -r line; do printf '\r%*s\r%s' "$(tput cols)" '' "$line"; done) 2>&1 || exit 1
else
$make_cmd
Expand All @@ -56,9 +63,10 @@ elif [[ "$board" == "all" ]]; then
args=()
args+=("$b")
[[ $user_mode == true ]] && args+=("-u")
args+=("-d")
[[ $debug_mode == true ]] && args+=("-d")
args+=("-v")
debug_flag="y"
[[ $debug_mode -le 0 ]] && debug_flag="n"
[[ $verbose_mode -le 0 ]] && debug_flag="n"
args+=("$debug_flag")
"${BASH_SOURCE[0]}" ${args[@]} || exit 1
fi
Expand All @@ -70,7 +78,8 @@ else
echo ""
echo "Flags:"
echo " -u -user user mode does not enter ramdump mode when a problem occurs."
echo " -d -debug [y/N] show make output."
echo " -d -debug debug mode."
echo " -v -verbose [y/N] show make output."
echo ""
echo "Available boards:"
for board in "${boards[@]}"; do
Expand Down
5 changes: 5 additions & 0 deletions engine.mk
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ endif
ifeq ($(USER), user)
GLOBAL_DEFINES += RAMDUMP_MODE_OFF
endif

ifeq ($(PRINT_DEBUG), 1)
GLOBAL_DEFINES += PRINT_DEBUG
endif

# allow additional defines from outside the build system
ifneq ($(EXTERNAL_DEFINES),)
GLOBAL_DEFINES += $(EXTERNAL_DEFINES)
Expand Down
13 changes: 12 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ else
USER := eng
endif

ifeq ($(findstring print_debug, $(MAKECMDGOALS)), print_debug)
PRINT_DEBUG := 1
TEMP := $(filter-out print_debug, $(MAKECMDGOALS))
MAKECMDGOALS = $(TEMP)
else
PRINT_DEBUG := 0
endif

ifeq ($(MAKECMDGOALS), maestro9820)
LK_PAD_SIZE := 1048576
SB_SIGN_TYPE := 3
Expand Down Expand Up @@ -62,6 +70,7 @@ export BUILDROOT
export DEFAULT_PROJECT
export TOOLCHAIN_PREFIX
export USER
export PRINT_DEBUG

$(warning OS_INFO=$(OS_INFO))
# veneer makefile that calls into the engine with lk as the build root
Expand All @@ -78,4 +87,6 @@ $(MAKECMDGOALS): _top

user:
@echo This is user build!
.PHONY: _top user
print_debug:
@echo This is print_debug build!
.PHONY: _top user print_debug
4 changes: 3 additions & 1 deletion platform/exynos9830/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ void uart_char_out(char cData);

void platform_dputc(char c)
{
putc_fb(c);
#ifdef PRINT_DEBUG
putc_fb(c);
#endif
uart_char_out(c);
}

Expand Down

0 comments on commit e460f09

Please sign in to comment.