 Hello and welcome to how to create a super simple bootloader part 5 during the session We're gonna see how to share the API between the application and the bootloader code that we've been developing for the last four videos So these are the steps that are needed in order to do that So step number one is make sure that the functions are placed in the previous create a section called my memory Step number two is to have a table in a known position with all the others that are shared for the functions inside this given memory region Step number three is to create some functions to share So in this case, we're going to create three different functions all placed inside the my section which are going to be used for Blink turn on and turn off the LED Step number four is to create the API header and then step five Which is the last one for the boot side of it is to define the table at the known position From the application side, we should recreate the API structure in the main function We should also create a local table That is actually a function pointer to the others that we know the content and finally call the functions in the way That's shown right here on the highlighted part All right, so let's move into the code and see how that's deployed So the first step is on the linker script So I'm just making sure that my memory region is there and I know the starting address Then inside it. I'm going to recreate the part of the API that I'm going to share Very creative here. So I'll just use API and score shared Place it on the first position of the address of the my memory region that we just created So inside it, of course, I'll just use the common key and sure that these regions Sustained even though I may not use on the compound, which is not going to be the case But so is good to sustain the common key either way So there we have it and of course is going to be placed on my memory region So now it's time to move to the main.c file I'm going to reuse the defined locate underscore phone and copy and paste the blink and switch to Make the prototype for the functions turn off and turn on right here And go ahead and do a very simple functions to fulfill those Ends as well. So turn off and turn on functions are going to be added right here There's no special code just plain use of the hot driver Now it's time to go and create a structure So I'll just name it put loader API shared and of course I have to add the three Functions that I'm going to use with the parameters that are related to it and here I'm just creating the API which is located under the API share region Using the structure type that we just created the bootloader share API And this basically completes all the tasks that we needed to do from the bootloader side I'm going to switch to the application project starting again from the linker script And then we can again see that my memory region is already there from the previous videos so now I can move to the main.c file and Actually recreate the structure the same structure that we use the bootloader API with the same content So here's just roughly a copy and paste from the previous code that we just wrote The blink function plus the other two So now we can move into the main function and create the API Pointer function pointer and place it to the first position of my memory region that we know the content and In the main loop, I'll just use the recently created API to list all the three possibilities We can see blink turn off and turn on. I'll just go with the blink and place 200 seconds here as the parameter for that And that basically is all the modifications that we would need to do we can build the project in one very interesting thing That's gonna be shown right here on the lower corner. Is that for the application binary? We won't see anything being used on the my memory region But if we do go into the bootloader code, which is the one that was originally created for that We can see that my region does have some cold place on that And since this region of memory is shared between those two, it's actually going to be populated for both I'm still using the debug session that's sharing both ELF for the Application in bootloader and using the bootloader project as the entry point So whenever I enter input in debug mode, I'm actually loading both codes at the same time And here we can see that the message is showing that the bootloader started the application is running and again if I If I use this top button I can check where the code is running and I can even see by placing a break point that the API is properly running we can see the address in the Upright corner of the video as well And if I do spend the API structure showing that we actually managed to succeed or on our endeavor to place and Share the API between the boot and application code on the address that we wanted So even though this might not look very significant because the overall size of the functions that we share were rather small on actual Applications, this might save a lot of space a lot of flash does making the share API very Powerful that are useful on practical applications. All right, that was it for today's video. Thanks again Please check our week page for more content and also our github page. And as always have a wonderful day