Skip to content

Conversation

@julek-wolfssl
Copy link
Member

  • Add new logic to libwolfboot.c for reading and updating partition states using a filesystem, enabled via WOLFBOOT_PARTITION_FILENAME.
  • Implement functions to set and get partition states (wolfBoot_update_trigger, wolfBoot_success, wolfBoot_get_partition_state)
  • Add boot_status.py and hal/library_fs.c for CLI and library access.
  • Update .gitignore and build rules for new artifacts.

Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

make clean && make lib-fs
        [CC sim] src/string.o
        [CC sim] src/image.o
        [CC sim] src/libwolfboot.o
        [CC sim] hal/hal.o
        [CC sim] src/keystore.o
        [CC sim] src/xmalloc.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/sha256.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/hash.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/memory.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/wc_port.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/wolfmath.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/logging.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/asn.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/sha512.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/ed25519.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/ge_low_mem.o
        [CC sim] /home/davidgarske/GitHub/wolfboot-alt/lib/wolfssl/wolfcrypt/src/fe_low_mem.o
        [LIB] libwolfboot.a
        [CC sim] hal/library.o
        [BIN] lib-fs
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [Makefile:207: lib-fs] Error 1

Not related, but on 32-bit targets getting these printf warnings. Can you fix these too?

In file included from hal/library.c:42:
hal/library.c: In function 'wolfBoot_start':
hal/library.c:144:25: error: format '%d' expects argument of type 'int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
  144 |         wolfBoot_printf("Failure %d: Hdr %d, Hash %d, Sig %d\n", ret,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145 |                         os_image.hdr_ok, os_image.sha_ok, os_image.signature_ok);
      |                         ~~~~~~~~~~~~~~~
      |                                 |
      |                                 uint32_t {aka long unsigned int}
include/printf.h:71:58: note: in definition of macro 'wolfBoot_printf'
   71 | #       define wolfBoot_printf(_f_, ...) fprintf(stderr, _f_, ##__VA_ARGS__)
      |                                                          ^~~
hal/library.c:144:43: note: format string is defined here
  144 |         wolfBoot_printf("Failure %d: Hdr %d, Hash %d, Sig %d\n", ret,
      |                                          ~^
      |                                           |
      |                                           int
      |                                          %ld
hal/library.c:144:25: error: format '%d' expects argument of type 'int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
  144 |         wolfBoot_printf("Failure %d: Hdr %d, Hash %d, Sig %d\n", ret,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145 |                         os_image.hdr_ok, os_image.sha_ok, os_image.signature_ok);
      |                                          ~~~~~~~~~~~~~~~
      |                                                  |
      |                                                  uint32_t {aka long unsigned int}
include/printf.h:71:58: note: in definition of macro 'wolfBoot_printf'
   71 | #       define wolfBoot_printf(_f_, ...) fprintf(stderr, _f_, ##__VA_ARGS__)
      |                                                          ^~~
hal/library.c:144:52: note: format string is defined here
  144 |         wolfBoot_printf("Failure %d: Hdr %d, Hash %d, Sig %d\n", ret,
      |                                                   ~^
      |                                                    |
      |                                                    int
      |                                                   %ld
hal/library.c:144:25: error: format '%d' expects argument of type 'int', but argument 6 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
  144 |         wolfBoot_printf("Failure %d: Hdr %d, Hash %d, Sig %d\n", ret,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145 |                         os_image.hdr_ok, os_image.sha_ok, os_image.signature_ok);
      |                                                           ~~~~~~~~~~~~~~~~~~~~~
      |                                                                   |
      |                                                                   uint32_t {aka long unsigned int}
include/printf.h:71:58: note: in definition of macro 'wolfBoot_printf'
   71 | #       define wolfBoot_printf(_f_, ...) fprintf(stderr, _f_, ##__VA_ARGS__)
      |                                                          ^~~
hal/library.c:144:60: note: format string is defined here
  144 |         wolfBoot_printf("Failure %d: Hdr %d, Hash %d, Sig %d\n", ret,
      |                                                           ~^
      |                                                            |
      |                                                            int
      |                                                           %ld
cc1: all warnings being treated as errors
make: *** [Makefile:493: hal/library.o] Error 1

@julek-wolfssl
Copy link
Member Author

Not related, but on 32-bit targets getting these printf warnings. Can you fix these too?

Added explicit casting as the types of those fields are dependent on the build configuration.

@julek-wolfssl julek-wolfssl requested a review from dgarske October 15, 2025 15:40
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

Looking really good! I will find time to test on customer hardware.

@dgarske dgarske self-requested a review October 16, 2025 19:08
julek-wolfssl and others added 7 commits October 17, 2025 10:56
- Add new logic to `libwolfboot.c` for reading and updating partition states using a filesystem, enabled via `WOLFBOOT_PARTITION_FILENAME`.
- Implement functions to set and get partition states (`wolfBoot_update_trigger`, `wolfBoot_success`, `wolfBoot_get_partition_state`)
- Add `boot_status.py` and `hal/library_fs.c` for CLI and library access.
- Update `.gitignore` and build rules for new artifacts.
- Update build rules for test-lib and lib-fs.
- Improve clean rule to remove test-lib and lib-fs binaries.
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

This needs some work and I would like to give you access to a ZCU102 with working /dev/mtd0 that you can remote into for testing. This is the .config I am using:

ARCH=AARCH64
TARGET=library_fs

SIGN?=RSA4096
HASH?=SHA3
IMAGE_HEADER_SIZE?=1024
DEBUG=1
SPMATH?=1
SPMATHALL?=0

# Required for library (libwolfboot.a)
NO_LOADER=1
USE_GCC_HEADLESS=0
CROSS_COMPILE=aarch64-linux-gnu-

# Flash Partition Filename
WOLFBOOT_PARTITION_FILENAME=\"/dev/mtd0\"
# Flash Sector Size
WOLFBOOT_SECTOR_SIZE=0x2000
# Application Partition Size
WOLFBOOT_PARTITION_SIZE=0xA000000
# Load Partition to RAM Address
WOLFBOOT_LOAD_ADDRESS?=0x18000000
# Location in Flash for wolfBoot
WOLFBOOT_ORIGIN=0x0
# Location in flash for boot partition
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x7000000
# Location in flash for update partition
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x3A00000
# Location in flash for swap
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xFFE0000

# DTS (Device Tree)
WOLFBOOT_LOAD_DTS_ADDRESS?=0x0FFF2000
WOLFBOOT_DTS_BOOT_ADDRESS?=0x7B0000
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x39B0000

This is the result when I scp the binary to the Ubuntu 20.04

root@ubuntu-focal-arm64v8:~# ls
lib-fs  libwolfboot.a
root@ubuntu-focal-arm64v8:~# ./lib-fs 
./lib-fs: /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./lib-fs)
root@ubuntu-focal-arm64v8:~# uname -a
Linux ubuntu-focal-arm64v8 5.4.0-1049-xilinx-zynqmp #53 SMP Mon May 12 17:44:51 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux
root@ubuntu-focal-arm64v8:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

@dgarske dgarske assigned julek-wolfssl and unassigned dgarske Oct 17, 2025
@dgarske
Copy link
Contributor

dgarske commented Oct 22, 2025

Closing in favor of #615

@dgarske dgarske closed this Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants