Error "undefined reference to `sha1'", (photon local build).... Solution?

Error “undefined reference to `sha1’”, including sha1 in application (photon local build)… Solution?

Hi @yianmar

Does the code compile on the web builder?
I’m assuming you’re compiling your own custom application?
Have you doubled checked your code to make sure you don’t have any uses of ‘sha1’ that haven’t been initialised/declared within scope of your use?

Hi @yianmar

The problem is that the HAL layer has abstracted out your access to this code temporarily.

@mdma was gathering a list of things people would like to use from the system firmware so they can be added to the dynamic linking tables.

For now the work-around is to copy the code into your application or you could try what is called a monolithic build which the way Core firmware was built.

1 Like

Thanks. As you say the same code goes fine for core.
Could you please explain to me, in short, what “HAL layer has abstracted out” means
Thanks you all

Thanks @bko, I clearly got the wrong end of the stick here!

Hi @yianmar

I will try to explain–I am going to put two concepts, HAL and dynamic linking, into one bucket and call that HAL for this purpose:

When compiling for the Core (up to the next big change to use the HAL) all of the code, your user program and the system program, was compiled at once, every time and then downloaded to your Core. This meant that you had access to every file that was being compiled with every function, if you wanted to use it.

When compiling for the Photon, the code is split into system code and user code. System code is compiled and downloaded very infrequently and updated only on big releases. User code is compiled and downloaded every time you make a change as always. So in order for the system code to stay the same and the user code to change when you want it to, there has to be a way for the user code to call the system code at predefined points.

These predefined points are defined in the hardware-abstraction layer or HAL. The idea is that when Electron or another new hardware platform comes along, you don’t have to change much code, just the parts for that specific hardware platform in the HAL, so that’s a big benefit. There is a defined interface between the user code and the system code and only things that go through that interface need to be worked on. Plus since a user is only compiling and downloading the user part of the program, it is much faster.

But the downside is that since you are not compiling all the source code for user and system at once, you can’t access system functions unless they are specifically added to the HAL layer so your user code can link against them. As a developer, you only want things in this interface layer that people (1) want to use and (2) should use and (3) you want to keep the number of interface points small and manageable. Things you add to HAL can never go away or change either, you want to be conservative.

So I believe the plan is for @mdma to make the crypto routines accessible again eventually. For now you have the work-arounds.

1 Like

Of course I am not familiar (any more…20 years after) with things you mention.
But what I was trying to do was (and is) to use crypto routines with no intermediate use of any layer.
I do understand what for, HAL exist.

Thanks again

To use the crypto routines on the Photon, please copy the sources from communication/lib/tropicssl/include and communication/lib/tropicssl/library to your application folder. You’ll then be able to use the crypto functions.

1 Like

Already done (some days ago) and working…but it is not the right way to me too.