Re: Installing apps dynamically in runtime

2024-06-21 Thread Alan C. Assis
Hi Gábor,

I created a video tutorial explaining how to do that:

https://www.youtube.com/watch?v=oL6KAgkTb8M

At that time NuttX had support only for ELF executable, now it also has
support for ELF libraries (work done by WildernessLabs and improved by
Xiaomi).

About the idea of a NuttX distribution that you commented at NuttX Int.
Workshop, I investigated a little bit about package management tools that
could be used on NuttX.

Unfortunately ipkg/opkg are GPL so we cannot use it for commercial
products. There is the pkgin from NetBSD that is almost what we need, but
it uses SQLite and although we have SQLite integrated in our apps/ I think
it is too big for some low end microcontrollers.

I think we will need to implement it ourselves, looking at pkgin I see it
is not so complicated to implement and we need something simpler.

Best Regards,

Alan

On Fri, Jun 21, 2024 at 6:50 AM Gábor Kiss-Vámosi 
wrote:

> Hi,
>
> A smartwatch manufacturer company wants to dynamically add/remove apps at
> runtime on their MCU based devices . Similarly to how it works on
> smartphones.
>
> Example: The user wants to extend the smartwatch with an Alarm clock app.
> On Linux we just needed to copy the binary to the watch and it could be
> launched with any number of instances. With NuttX can we  extend the
> application which is already flashed? We can assume that all the required
> libraries (UI, communication, drivers etc) are already there and there is a
> stable ABI.
>


Re: Installing apps dynamically in runtime

2024-06-21 Thread Gregory Nutt

On 6/21/2024 9:14 AM, Xiang Xiao wrote:

but, different devices expose to the different subsets of API. e.g. some
devices mayn't enable the net subsystem at all, any application which
calls socket api will fail to load.


Right, that is a consequence of size reduction using a minimal, 
incomplete configuration for resource-limited embedded systems. POSIX 
actually specifies which APIs must be present, be we ignore this 
requirement for a smaller footprint.


You would probably have to adopt a standard, minimal configuration 
across products OR perhaps some stubs that return only ENOSYS for 
nonexistent APIs.  You might even want a common version if you want 
completely consistent, bug-for-bug behavior. Such stubs really should be 
generated automatically is a system call is configured out.  Returning 
ENOSYS if the API is not present is required by most POSIX APIs.


But this all should be doable in principle. After all, the P in POSIX 
stands for portable.




Re: Installing apps dynamically in runtime

2024-06-21 Thread Xiang Xiao
On Fri, Jun 21, 2024 at 7:44 PM Gregory Nutt  wrote:

> On 6/21/2024 3:55 AM, Xiang Xiao wrote:
> > but there is no stable ABI on NuttX, so you can't copy elf from one type
> of
> > device to another.
> Wouldn't that work if (1) the ELF module is partially linked so that it
> relies a symbol table and dynamic linking at run time so that there is
> no a priori knowledge of any address, and (2) the APIs of the ELF
> application are restricted to standard APIs that should be common in
> most releases?
> >


but, different devices expose to the different subsets of API. e.g. some
devices mayn't enable the net subsystem at all, any application which
calls socket api will fail to load.


Re: Installing apps dynamically in runtime

2024-06-21 Thread Gregory Nutt

On 6/21/2024 3:55 AM, Xiang Xiao wrote:

but there is no stable ABI on NuttX, so you can't copy elf from one type of
device to another.
Wouldn't that work if (1) the ELF module is partially linked so that it 
relies a symbol table and dynamic linking at run time so that there is 
no a priori knowledge of any address, and (2) the APIs of the ELF 
application are restricted to standard APIs that should be common in 
most releases?

  

Re: Installing apps dynamically in runtime

2024-06-21 Thread Gábor Kiss-Vámosi
Clear, thank you! We will try it out!

Xiang Xiao  ezt írta (időpont: 2024. jún. 21.,
P, 13:25):

> On Fri, Jun 21, 2024 at 6:20 PM Gábor Kiss-Vámosi 
> wrote:
>
> > It's awesome!
> >
> > but there is no stable ABI on NuttX, so you can't copy elf from one type
> of
> > > device to another.
> >
> >
> > Does it mean that the loaded apps should be self contained and not
> interact
> > with any other code on the MCU?
> >
> >
> no, elf can call functions in base image. But since the different image
> expose a different API set, you can't launch elf on other devices.
>
>
> >
> >
> > Xiang Xiao  ezt írta (időpont: 2024. jún.
> 21.,
> > P, 11:55):
> >
> > > On Fri, Jun 21, 2024 at 5:50 PM Gábor Kiss-Vámosi <
> kisvega...@gmail.com>
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > A smartwatch manufacturer company wants to dynamically add/remove
> apps
> > at
> > > > runtime on their MCU based devices . Similarly to how it works on
> > > > smartphones.
> > > >
> > > > Example: The user wants to extend the smartwatch with an Alarm clock
> > app.
> > > > On Linux we just needed to copy the binary to the watch and it could
> be
> > > > launched with any number of instances. With NuttX can we  extend the
> > > > application which is already flashed?
> > >
> > >
> > > Yes, you can load program(e.g. elf) from file system:
> > > https://nuttx.apache.org/docs/latest/components/binfmt.html
> > >
> > >
> > > > We can assume that all the required
> > > > libraries (UI, communication, drivers etc) are already there and
> there
> > > is a
> > > > stable ABI.
> > > >
> > >
> > > but there is no stable ABI on NuttX, so you can't copy elf from one
> type
> > of
> > > device to another.
> > >
> >
>


Re: Installing apps dynamically in runtime

2024-06-21 Thread Xiang Xiao
On Fri, Jun 21, 2024 at 6:20 PM Gábor Kiss-Vámosi 
wrote:

> It's awesome!
>
> but there is no stable ABI on NuttX, so you can't copy elf from one type of
> > device to another.
>
>
> Does it mean that the loaded apps should be self contained and not interact
> with any other code on the MCU?
>
>
no, elf can call functions in base image. But since the different image
expose a different API set, you can't launch elf on other devices.


>
>
> Xiang Xiao  ezt írta (időpont: 2024. jún. 21.,
> P, 11:55):
>
> > On Fri, Jun 21, 2024 at 5:50 PM Gábor Kiss-Vámosi 
> > wrote:
> >
> > > Hi,
> > >
> > > A smartwatch manufacturer company wants to dynamically add/remove apps
> at
> > > runtime on their MCU based devices . Similarly to how it works on
> > > smartphones.
> > >
> > > Example: The user wants to extend the smartwatch with an Alarm clock
> app.
> > > On Linux we just needed to copy the binary to the watch and it could be
> > > launched with any number of instances. With NuttX can we  extend the
> > > application which is already flashed?
> >
> >
> > Yes, you can load program(e.g. elf) from file system:
> > https://nuttx.apache.org/docs/latest/components/binfmt.html
> >
> >
> > > We can assume that all the required
> > > libraries (UI, communication, drivers etc) are already there and there
> > is a
> > > stable ABI.
> > >
> >
> > but there is no stable ABI on NuttX, so you can't copy elf from one type
> of
> > device to another.
> >
>


Re: Installing apps dynamically in runtime

2024-06-21 Thread Gábor Kiss-Vámosi
It's awesome!

but there is no stable ABI on NuttX, so you can't copy elf from one type of
> device to another.


Does it mean that the loaded apps should be self contained and not interact
with any other code on the MCU?



Xiang Xiao  ezt írta (időpont: 2024. jún. 21.,
P, 11:55):

> On Fri, Jun 21, 2024 at 5:50 PM Gábor Kiss-Vámosi 
> wrote:
>
> > Hi,
> >
> > A smartwatch manufacturer company wants to dynamically add/remove apps at
> > runtime on their MCU based devices . Similarly to how it works on
> > smartphones.
> >
> > Example: The user wants to extend the smartwatch with an Alarm clock app.
> > On Linux we just needed to copy the binary to the watch and it could be
> > launched with any number of instances. With NuttX can we  extend the
> > application which is already flashed?
>
>
> Yes, you can load program(e.g. elf) from file system:
> https://nuttx.apache.org/docs/latest/components/binfmt.html
>
>
> > We can assume that all the required
> > libraries (UI, communication, drivers etc) are already there and there
> is a
> > stable ABI.
> >
>
> but there is no stable ABI on NuttX, so you can't copy elf from one type of
> device to another.
>


Re: Installing apps dynamically in runtime

2024-06-21 Thread Xiang Xiao
On Fri, Jun 21, 2024 at 5:50 PM Gábor Kiss-Vámosi 
wrote:

> Hi,
>
> A smartwatch manufacturer company wants to dynamically add/remove apps at
> runtime on their MCU based devices . Similarly to how it works on
> smartphones.
>
> Example: The user wants to extend the smartwatch with an Alarm clock app.
> On Linux we just needed to copy the binary to the watch and it could be
> launched with any number of instances. With NuttX can we  extend the
> application which is already flashed?


Yes, you can load program(e.g. elf) from file system:
https://nuttx.apache.org/docs/latest/components/binfmt.html


> We can assume that all the required
> libraries (UI, communication, drivers etc) are already there and there is a
> stable ABI.
>

but there is no stable ABI on NuttX, so you can't copy elf from one type of
device to another.


Installing apps dynamically in runtime

2024-06-21 Thread Gábor Kiss-Vámosi
Hi,

A smartwatch manufacturer company wants to dynamically add/remove apps at
runtime on their MCU based devices . Similarly to how it works on
smartphones.

Example: The user wants to extend the smartwatch with an Alarm clock app.
On Linux we just needed to copy the binary to the watch and it could be
launched with any number of instances. With NuttX can we  extend the
application which is already flashed? We can assume that all the required
libraries (UI, communication, drivers etc) are already there and there is a
stable ABI.