How to share SDK drivers between bootloader and application?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to share SDK drivers between bootloader and application?

1,200 Views
christopher_lon
Contributor II

Using S32DS, with S32K116.

How would someone share SDK Drivers, or functions in general between boot-loader code and application code? 

Background for question:

Working on a LIN Bootloader using the SDK drivers (Lin stack, Uart, etc.) I dont want to load the driver code into the bootloader AND Application code because that would be a huge chunk of code space of duplicated code. 

From my understanding (please correct me if i'm wrong), is I would make 3 separate projects, a bootloader project, application project and driver(SDK) project. Header files from the driver project would be included in the bootloader and application project but not the .c files. Each project would be complied separately and would contain their own linker files of which obviously would not overlap. Somehow (manual merging / auto thru eclipse) for "initial release" a single binary file would be made containing bootloader, application and driver code. Subsequent releases of application code would be released independently of the other 2 projects and the application code would be bootloaded into the application sectors dedicated to the application code. 

For the drivers, how does one create a project full of just SDK Drivers, no main, no calling functions, nothing to tell the linker what functions are being used, thus where to put the code? 

Would i need to make wrapper functions for the SDKs to tell the SDK function where to go in the linker script? I guess im just really confused how to get the drivers from the SDK (which i don't want to edit any of those files for obvious change management process reasons any changes needed to the SDK would need to be via wrappers) into a specific location in flash. AND then have the bootloader call those functions, as well as the application code call those functions.  

0 Kudos
3 Replies

1,000 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

you can build your SDK driver as library and link it into Bootloader and Application - if I understand it correctly. 

pastedImage_1.png

Jiri

0 Kudos

1,000 Views
christopher_lon
Contributor II

That is the correct understanding. 

Is there an example linkerscript that i could see? 

How do i tell the linkerscript to put the library code in one spot, and then the application and bootloader know that is where to find the drivers. 

would the bootloader and application have the same linkerscript? the difference being the build know the bootloader code is the bootloader code and it goes into blah spot in the linkerscript and the application code know where to put itself? 

0 Kudos

1,000 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

um, actually this can't be solved by library. Both apps (bootloader and app)  will contain copy of Library code inside .elf.

What you are looking for is something like shared library on operating system. But this approach is not easy to do without os. In my opinion the easiest way is use your library with Boodloader app and on particular address (known also for APP) add list of pointers to functions which you like to share with App. App can read this address list from this particular address. 

Hope it helps. 

Jiri  

0 Kudos