Skip to content

Commit

Permalink
cli: uboot: Include PYTHONPATH in env for compiling U-Boot
Browse files Browse the repository at this point in the history
- Also group all u-boot make environment variables together for easier maintainability
- Fixes u-boot requiring `pyelftools`
- Fixes commit 04f619d
  • Loading branch information
ColorfulRhino authored and rpardini committed Jun 30, 2024
1 parent d29305a commit 792d9d9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/functions/compilation/uboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ function compile_uboot_target() {
return 0 # exit after this
fi

##########################################
# REAL COMPILATION SECTION STARTING HERE #
##########################################

# Collect make environment variables, similar to 'kernel-make.sh'
uboot_make_envs=(
"CFLAGS='${uboot_cflags}'"
"KCFLAGS='${uboot_cflags}'"
"CCACHE_BASEDIR=$(pwd)"
"PATH=${toolchain}:${toolchain2}:${PATH}"
"PYTHONPATH=\"${PYTHON3_INFO[MODULES_PATH]}:${PYTHONPATH}\"" # Insert the pip modules downloaded by Armbian into PYTHONPATH (needed e.g. for pyelftools)
)

# workaround when two compilers are needed
cross_compile="CROSS_COMPILE=\"$CCACHE $UBOOT_COMPILER\""
[[ -n $UBOOT_TOOLCHAIN2 ]] && cross_compile="ARMBIAN=foe" # empty parameter is not allowed
Expand All @@ -213,8 +226,7 @@ function compile_uboot_target() {
display_alert "${uboot_prefix}Compiling u-boot" "${version} ${target_make} with gcc '${gcc_version_main}'" "info"
declare -g if_error_detail_message="${uboot_prefix}Failed to build u-boot ${version} ${target_make}"
do_with_ccache_statistics run_host_command_logged_long_running \
"CFLAGS='${uboot_cflags}'" "KCFLAGS='${uboot_cflags}'" \
CCACHE_BASEDIR="$(pwd)" PATH="${toolchain}:${toolchain2}:${PATH}" \
"env" "-i" "${uboot_make_envs[@]}" \
unbuffer make "$target_make" "$CTHREADS" "${cross_compile}"

display_alert "${uboot_prefix}built u-boot target" "${version} in $((SECONDS - ts)) seconds" "info"
Expand Down

12 comments on commit 792d9d9

@igorpecovnik
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://paste.armbian.com/qemexoqaka

/armbian/cache/sources/u-boot-worktree/u-boot/v2022.04/./tools/binman/binman:12: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.sysconfig import get_python_lib
/armbian/cache/sources/u-boot-worktree/u-boot/v2022.04/./tools/binman/binman:12: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
from distutils.sysconfig import get_python_lib
Traceback (most recent call last):
File "/armbian/cache/sources/u-boot-worktree/u-boot/v2022.04/./tools/binman/binman", line 38, in
from binman import bintool
File "/armbian/cache/sources/u-boot-worktree/u-boot/v2022.04/tools/binman/bintool.py", line 44, in
DOWNLOAD_DESTDIR = os.path.join(os.getenv('HOME'), 'bin')
File "/usr/lib/python3.10/posixpath.py", line 76, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
make: *** [Makefile:1094: all] Error 1

probably related to this.

@rpardini
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@igorpecovnik @ColorfulRhino I just forced a rebuild of all my uboots, a few dozen, incl tinkerboard. Tinkerboard was the only one to fail. What's special about it?

@igorpecovnik
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's special about it?

It boots the device, working UMS support IIRC, ...

@rpardini
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely not what I meant.

There is some specific issue here, probably with 22.04 u-boot (using thus old binman) and newer python packages that @ColorfulRhino introduced.

@igorpecovnik
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, misunderstand it. Yes, ofc.

@rpardini
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ColorfulRhino
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing! I will investigate.

I'm building 496 (!) u-boot's to check. https://github.com/armsurvivors/armbian-release/actions/runs/9732618446/job/26858514768

Very nice 😄
It seems that only Tinkerboard and xt-q8l (?) is failing because 2022.04 uses an old binman. Khadad Vim3 seems to fail for some other unrelated (?) reason.

Maybe easiest would be to bump the uboot version on those two boards.

@rpardini
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Khadad Vim3 seems to fail for some other unrelated (?) reason

That's a lukefor userpatched thing I have, ignore it.

only Tinkerboard and xt-q8l (?) is failing because 2022.04 uses an old binman

Yeah, but maybe it's unadvertently using binman? Maybe we can bump, but maybe we can make it not-use binman if that proves too complex. (I don't have any 32-bit boards).

@ColorfulRhino
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only Tinkerboard and xt-q8l (?) is failing because 2022.04 uses an old binman

Yeah, but maybe it's unadvertently using binman? Maybe we can bump, but maybe we can make it not-use binman if that proves too complex. (I don't have any 32-bit boards).

Hmm I'm not sure why it's using binman.

The version for those two boards is defined here:

BOOTBRANCH='tag:v2022.04'
BOOTPATCHDIR='v2022.04'

I could check later if simply bumping this version and moving the patches is enough or if there's any patch conflicts, and then @paolosabatino could test since I don't have any of those boards as well.

But if you can find out the "not use binman" part, that's fine too :)

@rpardini
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check, after learning wth UBOOT_TARGET_MAP means again

@rpardini
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've a fix 🎉 will PR soon

@rpardini
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.