Skip to content

Conversation

zdebanos
Copy link
Contributor

This commit marks the end of my GSoC 2025 project in the NuttX section.

Currently creating as a draft pull request.
I have agreed with Pavel Pisa to separate the library's dependancy named ulut from the shv-libs4c repository (located currently here https://github.com/silicon-heaven/shv-libs4c/tree/master/submodule). This will require more time for me. Also, I have discussed with Karel Koci from Elektroline a.s. about the posibilities of the exports of external libraries - something that I somehow solved in this commit: #3154.
In the end we have agreed that this should be considered as "hacking the whole Makefile system" and I should rather come up with a better solution, and thus I'm postponing it. Since I require the export for the GSoC, I'd be glad to leave it here as draft until I solve all the issues already mentioned.

I am about to add documentation into the nuttx repo, too.

Summary

Please look into the commit's verbose message :-).

Impact

Adds the Silicon Heaven protocol implementation. A framework designed to register your callbacks into your application. The callbacks are organized into nodes and the nodes can form a tree structure.

Testing

The testing was done on my custom samv7 board. In nuttx:
tools/configure.sh myboard/myconfig - configuration OK
make - downloads the shv-libs4c repo from github, and compiles OK

DISCLAIMER: in my GSoC, I was using make export. But with the solution used here (https://github.com/zdebanos/pysimCoder/tree/shv-refactor) I succesfully compiled against automatically generated source code in pysimCoder.

@cederom cederom moved this to In Progress in Apache NuttX GSoC Aug 31, 2025
@cederom cederom changed the title Add Silicon Heaven protocol adaptation into NuttX and SHV examples [GSoC2025] Add Silicon Heaven protocol adaptation into NuttX and SHV examples Aug 31, 2025
@zdebanos zdebanos force-pushed the gsoc2025-shv-libs4c-final branch 2 times, most recently from ad61dea to 12f3c4f Compare September 1, 2025 00:35
@zdebanos zdebanos force-pushed the gsoc2025-shv-libs4c-final branch 5 times, most recently from b657b39 to a6ede5f Compare September 2, 2025 13:35
@zdebanos
Copy link
Contributor Author

zdebanos commented Sep 2, 2025

I came across an issue, which must be fixed: locally, I was running against pyshv==0.7.3 (implementation of Silicon Heaven API in python) but when I added requirements and changed the imports to match with pyshv==0.10.0, it stopped working, probably by using a bad function of some sort. I'll have to look deeper into that.

All i know is that the script worked with the previous version, the target device functionality has not changed.

@simbit18
Copy link
Contributor

simbit18 commented Sep 2, 2025

would reformat /home/runner/work/nuttx-apps/nuttx-apps/apps/examples/shv-nxboot-updater/update-script/gui.py

Oh no! 💥 💔 💥
1 file would be reformatted.

black check failed, run following command to update the style:
  $ black <src>

@zdebanos
Copy link
Contributor Author

zdebanos commented Sep 2, 2025

@simbit18 I know about that, I'm working on a different fix and I'm gonna fix the linter error too.

@zdebanos
Copy link
Contributor Author

zdebanos commented Sep 2, 2025

I also need to address the shv-libs4c correct version. I've got two options I can implement:

  1. download a correct .zip from github releases
  2. clone a "specific hash" commit and compile against it

I'm in favor with the second option. That means I'll have to specify the commit hash inside the Makefile.

Currently, I'm running against master as it's still draft and I'm fixing last errors. Then I'll specify the correct version.

@zdebanos zdebanos force-pushed the gsoc2025-shv-libs4c-final branch from a6ede5f to 39ec06f Compare September 2, 2025 16:31
@michallenc
Copy link
Contributor

I also need to address the shv-libs4c correct version. I've got two options I can implement:

1. download a correct .zip from github releases

2. clone a "specific hash" commit and compile against it

I'm in favor with the second option. That means I'll have to specify the commit hash inside the Makefile.

Currently, I'm running against master as it's still draft and I'm fixing last errors. Then I'll specify the correct version.

I am also for the second option. The commit hash can even be a configurable option in Kconfig to easily allow the change of a version per project.

@zdebanos zdebanos force-pushed the gsoc2025-shv-libs4c-final branch 4 times, most recently from 7fd3ae8 to 2657996 Compare September 13, 2025 01:29
@zdebanos
Copy link
Contributor Author

zdebanos commented Sep 13, 2025

Thanks to Pavel Pisa, the Makefile system adjusts better to the build system used in the shv-libs4c library. As discussed in the heading, we have also successfully separated the ulut dependancy from the shv-libs4c library and now it's an external dependancy.

Currently, ulut is placed in neutilts/libulut. We can't think of a better place to put this library, as it is a collection of data structures (containers) written in the C language, and as it is a direct dependency of SHV, we put it parallel to libshvc. We should probably put this somewhere else but now we are keeping it here.

Also I suppose the export of the library should be done outside of this PR as a separate commit. I have found out we can use an EXTOBJS variable to handle the job better (only for .o files, not a solution to .h files).

I have also changed the apps a bit, now the mandatory arguments are position independent.

Also the pipeline is failing due to a typo. But I do not think it's a typo the pipeline should fail at since it is used in a macro in the Makefile. But I'll consult this with Pavel Pisa.

@zdebanos zdebanos force-pushed the gsoc2025-shv-libs4c-final branch from 2657996 to 2912530 Compare September 13, 2025 08:38
@zdebanos zdebanos force-pushed the gsoc2025-shv-libs4c-final branch 2 times, most recently from 02eed11 to 3bac145 Compare September 13, 2025 09:55
@zdebanos zdebanos marked this pull request as ready for review September 13, 2025 22:42
@zdebanos
Copy link
Contributor Author

I have unmarked this commit as draft since we have agreed upon a stable solution. The only thing that needs to be done is the documention, I'm working on it right now.

$(SHVOBJS) : shv-build-library

$(SHVDIR):
$(call CLONE, https://github.com/silicon-heaven/shv-libs4c, $(SHVDIR), )
Copy link
Contributor

Choose a reason for hiding this comment

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

should we skip the clone if user already git clone manually like other 3rd party project?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure what is the best option. If the repository is already cloned then there should be mechanism how to keep it at the correct version matching given NuttX version/commit.

I have implemented next script for integration into pysimCoder

https://github.com/zdebanos/pysimCoder/blob/gsoc-2025-shv-refactor/ExtLibs/extlib-fetch.sh

It keeps the local branch, if the repository is clean it switches it to the specified library version by reset. If there is only small local change which does not clash with switch to newly required commit, it informs user and switches. If there are conflicting changes it fails. If there is another branch and state is clean it switches and it is user's task to move changes.

I am not sure what is preferred and typical for NuttX

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the current solution is better - you get the correct version that Is supported by the library (i.e. what we think works the best). Your approach would in my opinion overcomplicate things.

Copy link
Member

@raiden00pl raiden00pl Sep 17, 2025

Choose a reason for hiding this comment

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

I also think we should use a similar approach as in other 3rd party projects to be consistent in the project: download the archive and unpack it.
Example here:

$(NIMBLE_TAR):
$(Q) curl -L $(NIMBLE_URL) -o $(NIMBLE_TAR)
$(NIMBLE_UNPACKDIR): $(NIMBLE_TAR)
$(Q) tar zxf $(NIMBLE_TAR)
$(Q) mv mynewt-nimble-$(CONFIG_NIMBLE_REF) $(NIMBLE_UNPACKDIR)
$(Q) touch $(NIMBLE_UNPACKDIR)
# Download and unpack tarball if no git repo found
ifeq ($(wildcard $(NIMBLE_UNPACKDIR)/.git),)
context:: $(NIMBLE_UNPACKDIR)
distclean::
$(call DELFILE,$(NIMBLE_TAR))
$(call DELDIR,$(NIMBLE_UNPACKDIR))
endif

By default, if the user only wants to use a 3rd party project, the code will always be downloaded from a verified hash.
But skipping the package download when a git repository exists makes the work of developers working on a given 3rd party project much easier.
Maintaining the correct version of code when a user uses their own git repo is not a problem. The user has to clone the repository to the correct location, and if they do so, we can assume they're doing it consciously and intentionally.

Another thing is that the user may want to use custom 3rd party package with custom patches. With the current solution this is impossible.

Copy link
Contributor

Choose a reason for hiding this comment

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

In a perfect world we would like to have all external dependencies listed somewhere, fetch before build, and then build. This is important for testing automation in order to provide all dependencies prior build is executed where malicious scripts can be executed. But this is another story of the future :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've agreed with @ppisa that the solution with tar.gz is possible but as we do not have any release yet, we will use the commit hash instead as an identifier. We also both think a hash identifier is a more reasonable solution.

I'll try to submit a solution as fast as I can.

$(ULUTOBJS) : ulut-build-library

$(ULUTDIR):
$(call CLONE, https://git.code.sf.net/p/ulan/ulut.git, $(ULUTDIR), )
Copy link
Contributor

Choose a reason for hiding this comment

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

should we skip the clone if user already git clone manually like other 3rd party project

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto

@zdebanos zdebanos force-pushed the gsoc2025-shv-libs4c-final branch 4 times, most recently from 566328c to 02a7762 Compare September 18, 2025 17:07
…xamples

This commit marks the end of my GSoC 2025 project in the NuttX section.
All changes:

- Silicon Heaven protocol (SHV) implementation:
  The library is cloned from github.com/silicon-heaven/shv-libs4c
  and compiled here. The library has out-of-the-box support
  for NuttX and possibly all posix systems.
  The library is compiled with CONFIG_SHV_LIBS4C_PLATFORM define
  set to "nuttx". The library's dependancy is Pavel Pisa's ULUT
  and originates from Michal Lenc's GSoC.

- examples/shv-nxboot-updater:
  An example which constructs a SHV tree with which you can perform
  firmware updates using a SHV "file node". The file node wraps
  around NXBoot's update partition.
  The application also allows for NXBoot confirmation of the images.
  This application is to be meant used as a "background service",
  started before any apps, possibly using rcS. The tree is allocated
  as GAVL (see below).

- examples/shv-test:
  An example which constructs a SHV tree and gives the user
  the ability to choose which type of construction should be used,
  either:
    - GAVL:       dynamic SHV tree allocation encapsulated within
                  an AVL tree.
    - GSA:        dynamic SHV tree allocation encapsulated within
                  a continuous array with binary search
    - GSA_STATIC: SHV tree is defined as static const, this means
                  all the data structures are placed in .rodata.
		  Extremely beneficial for embedded systems,
		  as .rodata is located in flash and embedded
		  systems usually have more flash than sram,
		  thus reducing sram usage. The downside is that
		  the definitions are rather tedious, but can
		  be automated in case of some code generation
		  (like in pysimCoder).
		  All of it is places in a continuous array with
		  binary search.

Signed-off-by: Stepan Pressl <[email protected]>
@zdebanos zdebanos force-pushed the gsoc2025-shv-libs4c-final branch from 02a7762 to e0543e7 Compare September 18, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

7 participants