[CLOSED] Updating u-boot to recent version

Post Reply
doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

[CLOSED] Updating u-boot to recent version

Post by doggisbag »

Hello there, first, let me contextualize this topic.

During the course of this year, i've started to get involved in the embedded systems and linux world as a subject of practical and theoretical knowledge, having an EE education as a background. ODROID-XU has been interesting for me due its EOL state, so a lot of debugging involved.

Currently, i'm planning to build HassOS that doesn't have support for XU but it does for XU4. I know XU4 has different SoC but shares similarities as it's part of Exynos 54xx family. My XU now is running mainline kernel (5.9.1) on arch distro, and Homeassistant supervised (based on docker containers) runs quite well so the linux itself is not a drawback. My main problem is the bootloader. In the official github, the developers used buildroot LTS as tool for building the OS. They use a custom partition layout for kernel and system, and the rootfs. The problem with this is that requires modern u-boot. Compiling the kernel was a start, but the toolchain for XU u-boot is old, so new one doesn't handle and requires missing headers.

Somehow i managed to modify the buildroot odroidxu4_defconfig to compile the kernel and make use of the post-image.sh scripts to partitioning the board, but i've ommitted the step that compiles the u-boot since XU toolchain is quite old and won't let compile with kernel toolchain. So i used an already precompiled u-boot binaries from hardkernel linux u-boot tools, accomodate the scripts used for XU4 an got and built image. Sadly when i tried to boot, the boot.scr file has u-boot commands that are not supported for XU.

The script used for XU4 (boot.scr) is the following:

Code: Select all

###########################################

part start mmc ${devnum} 9 mmc_env
mmc dev ${devnum}

# Note that import is performed twice for backwards compatability.
setenv loadbootstate " \
    echo 'loading env...'; \
    mmc read ${ramdisk_addr_r} ${mmc_env} 0x20; \
    env import -c ${ramdisk_addr_r} 0x4000;"

setenv storebootstate " \
    echo 'storing env...'; \
    env export -c -s 0x4000 ${ramdisk_addr_r} BOOT_ORDER BOOT_A_LEFT BOOT_B_LEFT MACHINE_ID; \
    mmc write ${ramdisk_addr_r} ${mmc_env} 0x20;"

run loadbootstate
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B"
test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3
test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 3

# HassOS bootargs
setenv bootargs_hassos "zram.enabled=1 zram.num_devices=3 apparmor=1 security=apparmor systemd.machine_id=${MACHINE_ID} cgroup_enable=memory"

# HassOS system A/B
setenv bootargs_a "root=PARTUUID=48617373-06 rootfstype=squashfs ro rootwait"
setenv bootargs_b "root=PARTUUID=48617373-08 rootfstype=squashfs ro rootwait"

#usb start

# Load extraargs
fileenv mmc ${devnum}:1 ${ramdisk_addr_r} cmdline.txt cmdline
fatload mmc ${devnum}:1 ${fdt_addr_r} exynos5410-odroidxu.dtb
fdt addr ${fdt_addr_r}


# logical volumes get numbered after physical ones.
# 1. boot
# 2. Extended partition
# 3. Overlay
# 4. Data
# 5. KernelA
# 6. SystemA
# 7. KernelB
# 8. SystemB
# 9. BootInfo
setenv bootargs
for BOOT_SLOT in "${BOOT_ORDER}"; do
  if test "x${bootargs}" != "x"; then
    # skip remaining slots
  elif test "x${BOOT_SLOT}" = "xA"; then
    if test ${BOOT_A_LEFT} -gt 0; then
      setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
      echo "Found valid slot A, ${BOOT_A_LEFT} attempts remaining"
      setenv load_kernel "ext4load mmc ${devnum}:5 ${kernel_addr_r} zImage"
      setenv bootargs "${bootargs_hassos} ${bootargs_a} rauc.slot=A ${cmdline}"
    fi
  elif test "x${BOOT_SLOT}" = "xB"; then
    if test ${BOOT_B_LEFT} -gt 0; then
      setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
      echo "Found valid slot B, ${BOOT_B_LEFT} attempts remaining"
      setenv load_kernel "ext4load mmc ${devnum}:7 ${kernel_addr_r} zImage"
      setenv bootargs "${bootargs_hassos} ${bootargs_b} rauc.slot=B ${cmdline}"
    fi
  fi
done

if test -n "${bootargs}"; then
  run storebootstate
else
  echo "No valid slot found, resetting tries to 3"
  setenv BOOT_A_LEFT 3
  setenv BOOT_B_LEFT 3
  run storebootstate
  reset
fi
The boot command that failed is 'part' and probably also will fail with 'ext4load' and other commands not supported by that version.

So i really want to know which would be the steps to grab the XU u-boot binaries (smdk5410) on hardkernel repository and update it to got new uboot up and running. This in terms of bootloader concepts, compiler versions, files and so on.

I've also posted on Homeassistant forum, but I think i could gather more info here with respect to u-boot.
Last edited by doggisbag on Tue Nov 17, 2020 10:08 am, edited 2 times in total.

mad_ady
Posts: 8831
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 586 times
Been thanked: 531 times
Contact:

Re: Updating u-boot to recent version

Post by mad_ady »

I didn't know HassOS has 2 kernels and a failover mechanism...
Sorry, I'm ignorant about uboot...

doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

Re: Updating u-boot to recent version

Post by doggisbag »

mad_ady wrote:I didn't know HassOS has 2 kernels and a failover mechanism...
Sorry, I'm ignorant about uboot...
Sorry, i wasn't clear enough. Homeassistant has mainly three install options. One is the hass core (based in python only), then the docker version that consists in a hypervisor virtualized echosystem with multiple docker containers (with hass core in it and additional functionalities). Both can run in several host OS that has the requirements stated in their homepage. The third one is the HassOS which is optimized for embedded systems and uses custom kernel configs depending of the target board. This is the option that i'm trying to port to XU.

My problem is that when I tried to compile both kernel and uboot, the same toolchain was used. So my mistake about not knowing more of this tool (buildroot).

Actually I think that my problem points to uboot requirements to build the partition layout that HassOS is currently using.

Enviado desde mi SM-G965F mediante Tapatalk




doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

Re: Updating u-boot to recent version

Post by doggisbag »

My current strategy is to compare the definitions between Exynos5 boards. For example, i'm looking smdk5250 that exists on hardkernel u-boot v2012.07 and compare changes in files from all board related directories, so i could understand what changes were done through last years. I've found that a lot of definitions were merged into a common file configs between Exynos5 SoCs. Moreover, there's some differences between the Exynos5410 and 5 family in terms of memory addresses to load some stuffs.

Having that on mind, i think that is possible to port the old Exynos5410 definitions to modern u-boot, but it is going to take a lot of time to inspect the complex relationship and requirements between.

I'm currently doing some diagrams to organize and trace which source and header files requires to be modded.

Nuems
Posts: 179
Joined: Thu Sep 19, 2013 3:50 am
languages_spoken: english, german
ODROIDs: xu, c1, n2
Has thanked: 4 times
Been thanked: 17 times
Contact:

Re: Updating u-boot to recent version

Post by Nuems »

I'm amazed by the effort you're putting into the XU - thanks so much!
There's one other thing I've tried - without success though: Loading (and using) MFC firmware. It might be useful to have hardware accelerated ffmpeg for (live) transcoding/streaming. If you're still into home automation, that might come in handy for webcams/video doorbells etc.

doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

Re: Updating u-boot to recent version

Post by doggisbag »

Nuems wrote:
Sat Oct 31, 2020 6:20 am
I'm amazed by the effort you're putting into the XU - thanks so much!
There's one other thing I've tried - without success though: Loading (and using) MFC firmware. It might be useful to have hardware accelerated ffmpeg for (live) transcoding/streaming. If you're still into home automation, that might come in handy for webcams/video doorbells etc.
Thanks for your words :)

Good to know about MFC. Actually when i'm using ffmpeg with two IP cameras the CPU usage raises up quickly, so i suppose that's related to calculations being done there, which instead could be done taking advance of hw accelerating capabilities. How have you done that on the XU? Maybe checking out old HK's repos and comparing with newer or still maintained (i.e. Exynos5250 or Exynos5240 based boards) could gave some insights, supposing that there's no closed source dependencies that makes that impossible.

PS: I'm still working in figuring out how to port u-boot, i'll post some updates soon if everything goes well.

mad_ady
Posts: 8831
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 586 times
Been thanked: 531 times
Contact:

Re: Updating u-boot to recent version

Post by mad_ady »

@doggisbag check out this thread, which is for xu4. The kernel components should be the same in mainline and it just needs ffmpeg v4l2m2m support: https://www.google.com/url?sa=t&source= ... VB5UG1FsEY
These users thanked the author mad_ady for the post:
doggisbag (Tue Nov 10, 2020 2:08 am)

Nuems
Posts: 179
Joined: Thu Sep 19, 2013 3:50 am
languages_spoken: english, german
ODROIDs: xu, c1, n2
Has thanked: 4 times
Been thanked: 17 times
Contact:

Re: Updating u-boot to recent version

Post by Nuems »

In the meantime, I've seen that there are MFC-related lines in the device tree files for the XU3/4-based boards. So I'd assume that some changes in that direction would be necessary. Unfortunately, my prior use of MFC-related things dates back to kernel 3.4 (no device tree, different way of firmware loading). I guess that next step would be to determine whether there are relevant differences in how MFC is implemented on these boards compared to the original XU.
These users thanked the author Nuems for the post:
doggisbag (Tue Nov 10, 2020 2:08 am)

doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

Re: Updating u-boot to recent version

Post by doggisbag »

HI! I'm still figuring out and studying the structure of u-boot and the HK's Exynos 5 boot dependencies. I've managed to compile u-boot with a few assumptions:

1. Most of the source and header files from u-boot v2012.07 from directories /board/samsung/smdk5410/, /arch/arm/cpu/armv7/exynos/, /arch/arm/include/asm/arch-exynos/ and arch/arm/cpu/armv7/s5p-common/ were merged into u-boot v2020.10 directories /arch/arm/dts, /arch/arm/mach-exynos/, /include/configs/, /configs/, /board/samsung/.

2. It should be possible to create configuration files following the structure of u-boot v2020.10 to able Exynos5410 being compiled correctly. This was the initial work of copying the directories, makefiles, Kconfig structres of Exynos5 family and matching with Exynos5410 SoC.

Having said that. The board is not able to boot right now with it. Compiler outputs two files: u-boot.bin and smdk5410-spl.bin. According to XU wiki, boot requires bl1, bl2, u-boot and tzsw blobs signed. I've used some old signed binary blobs but i think that implies a lot of compatibility issues. Don't know where smdk5410-spl.bin fits in there, but it is required also to be signed.

Now, the main problem is related with trustzone blob and checking if there's missing functions to get the board booting up. Anyways, that implies comparing files from the first assumption. Mainly comparing /board/samsung/smdk5410/ files and looking if memory addresses, registers definitions and a lot of other stuffs exists.

i've uploaded modified u-boot source code into a github repo if you want to check it out. I'm not concerned if my changes are done correctly but for now it's ok for me.

Also, there's a file that summarizes all changes done so far (as complement to diff commit).

Note: I think that i'm taking a pretty naive approach. There's a lot involved in preparing a board for booting. The main constraints relies on the DDR timings memory initialization, power sequencing and other things. So this need a lot more research.

doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

Re: Updating u-boot to recent version

Post by doggisbag »

Interesting information is obtained when comparing default configs of smdk5250.h v/s smdk5410.h in u-boot v2012.07. The comparison gives insights taking account that smdk5250 is supported at main u-boot repository and it shares common headers with rest of Exynos5. So this is another point to start digging in compatibility between SoCs.

Difference can be checked here.

The relevant definitions should be related with RAM initialization, Trustzone address, kernel address and so on. Considering both are from the same family, they should have common definitions.

In addition, here's a simple diagram that compares files and directories through u-boot versions of smdk5250 board.
Attachments
smdk5250 u-boot 2012 v_s u-boot 2020 directories and files.pdf
(291.68 KiB) Downloaded 4 times

doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

Re: Updating u-boot to recent version

Post by doggisbag »

Nuems wrote:
Wed Nov 04, 2020 10:26 pm
In the meantime, I've seen that there are MFC-related lines in the device tree files for the XU3/4-based boards. So I'd assume that some changes in that direction would be necessary. Unfortunately, my prior use of MFC-related things dates back to kernel 3.4 (no device tree, different way of firmware loading). I guess that next step would be to determine whether there are relevant differences in how MFC is implemented on these boards compared to the original XU.
As a way to keep tracked this information, i'll attach some useful links that i found through different pages (maybe this should be better if move to a separated topic):

1. Exynos_Mainline_Kernel_TODO: "Odroid XU1 (Exynos5410): add support for HDMI/Exynos DRM, MFC, GScaller, SYSMMU. In theory only clock definitions are missing to get it working (same HW as in Exynos542x SoCs).".

2. Kernel mailing with some MFCs device tree definition in XU4 at exynos5420.dtsi file.

3. Linux kernel documentation =https://www.kernel.org/doc/Documentati ... ice driver. Relevant to say that Exynos5410 should use mfc-v6 assuming is compatible as it is from Exynos5 family.

Work of defining the nodes and it's related pins for irqs, clocks and memory address could be done with help of the schematic and source headers files.

doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

Re: Updating u-boot to recent version

Post by doggisbag »

doggisbag wrote:
Wed Nov 11, 2020 8:00 am
Nuems wrote:
Wed Nov 04, 2020 10:26 pm
In the meantime, I've seen that there are MFC-related lines in the device tree files for the XU3/4-based boards. So I'd assume that some changes in that direction would be necessary. Unfortunately, my prior use of MFC-related things dates back to kernel 3.4 (no device tree, different way of firmware loading). I guess that next step would be to determine whether there are relevant differences in how MFC is implemented on these boards compared to the original XU.
As a way to keep tracked this information, i'll attach some useful links that i found through different pages (maybe this should be better if move to a separated topic):

1. Exynos_Mainline_Kernel_TODO: "Odroid XU1 (Exynos5410): add support for HDMI/Exynos DRM, MFC, GScaller, SYSMMU. In theory only clock definitions are missing to get it working (same HW as in Exynos542x SoCs).".

2. Kernel mailing with some MFCs device tree definition in XU4 at exynos5420.dtsi file.

3. Linux kernel documentation =https://www.kernel.org/doc/Documentati ... ice driver. Relevant to say that Exynos5410 should use mfc-v6 assuming is compatible as it is from Exynos5 family.

Work of defining the nodes and it's related pins for irqs, clocks and memory address could be done with help of the schematic and source headers files.
EXYNOS5410 MFC SUPPORT EFFORTS

According to mainline kernel mailing:

"Odroid XU1 (Exynos5410): add support for HDMI/Exynos DRM, MFC, GScaller, SYSMMU. In theory only clock definitions are missing to get it working (same HW as in Exynos542x SoCs). ".

Assumptions:

- As exynos5420.h clock dt-bindings shares a lot of identical clock definitions with exynos5410.h, it could be naively assumed that MFC and others shares the same numbering.
- As limited knowledge about the subject, i'm assuming that all definitions that has mfc name on it should be enough to support codec.

Work done:

- Ported device tree mfc related definitions from exynos5420.dtsi into exynos5410.dtsi.
- Added MFC clock definitions from /dt-bindings/exynos5420.h to /dt-bindings/exynos5410.h.

Results at 11/11/2020:

- With both changes done, dmesg outputs the following:

[ 8.096826] s5p-secss 10830000.sss: s5p-sss driver registered
[ 8.203181] s5p-mfc 11000000.codec: deferred probe timeout, ignoring dependency
[ 8.221893] s5p-mfc 11000000.codec: preallocated 8 MiB buffer for the firmware and context buffers
[ 8.237064] s5p_mfc_init_pm:42: Failed to get clock: mfc
[ 8.241360] s5p-mfc 11000000.codec: failed to get mfc clock source
[ 8.249042] s5p-mfc: probe of 11000000.codec failed with error -2

Considering that there's mfc related definitions on clk-exynos5420.c, then the error are probably caused by missing definitions at /drivers/clk/samsung/clk-exynos5410.c, which in fact, they're missing.

Work TODO:

- Port all mfc related definitions from exynos5420.c or exynos5250.c to exynos5410.c and test. Probably it is required to recompile kernel (for now that info is out of my sight).
- Strategy to port some specific definition will be done inspecting the odroidxu3.4y HK's linux branch, where there is all Exynos5410 MFC's sources files that worked when XU's was supported.

doggisbag
Posts: 31
Joined: Wed Nov 20, 2019 7:46 am
languages_spoken: english, spanish
ODROIDs: 2x Odroid-XU
Has thanked: 23 times
Been thanked: 8 times
Contact:

Re: Updating u-boot to recent version

Post by doggisbag »

Sadly, u-boot update to XU will not be possible due that Exynos5410 Samsung signing servers for spl.bin are not available for HK (and possibly samsung discarded too). So main efforts are to Linux kernel support only.

Post Reply

Return to “General Chat”

Who is online

Users browsing this forum: No registered users and 0 guests