Bootloader/Bootloadable project pin sharing

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I'm looking to share hardware pins between Bootloader/Bootloadable firmware.

I was able to get the BLE_OTA_FixedStack_Bootloader example project working well on my target hardware, PRoC 4 family.

Currently I'm creating my own Bootloader/Bootloadable project from scratch to make sure I understand the example project.

I would like to share the digital output pins that are defined in the Bootloader project with the Bootloadable project, as was done in the BLE_OTA_FixedStack_Bootloader example.  I defined the pin functions as "extern" in the Bootloadable project, but I get an M0120 build error, undefined reference.

For example, LED_G is a digital output defined in the Top Design of the Bootloader project.

In a Bootloadable header file

extern void LED_G_Write(uint8 value);

In Bootloadable main.c

LED_G_Write(LED_ON);

Then I get the undefined reference build error.

I feel like there's some extra magic at play to access the digital output of the Bootloader project, but I haven't found it yet.

Any suggestions would be appreciated.

0 Likes
1 Solution
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

You have to add the pin name in Symbol_list.txt file under scripts folder in Bootloader project.

For ex:

Bootloader_Service_Activation_

WakeUp_Interrupt_

Thanks & Regards,

Anjana

View solution in original post

0 Likes
4 Replies
RyanZhao
Moderator
Moderator
Moderator
250 sign-ins First question asked 750 replies posted

Hi Ken,

As per my understanding,

LED_G_Write(uint8 value) is defined in Bootloader project, correct?  But the 'extern' keyword is used in Booloadable project.

You may know that 'extern' is invalid in different projects, even though these projects are in one workspace.

If you'd like to share LED pin, you can copy and paste LED_G from Booloader project to Booloadbale project directly, and assign same pin in Bootloadble project for LED_G.

Thanks,

Ryan

0 Likes
Anonymous
Not applicable

Ryan, yes, you are correct.  The LED_G_Write(uint8 value) is defined in the Bootloader project, and the 'extern' keyword is used in a header file of the Bootloadable project.

I appreciate the suggestion to copy the LED_G pin from the Bootloader to the Bootloadable project, but I was hoping to better understand the mechanisms used to share components and APIs between projects, like what was done in the BLE_OTA_FixedStack_Bootloader example.

When you say that extern is invalid for different project, what makes it invalid?

rzzh wrote:

You may know that 'extern' is invalid in different projects, even though these projects are in one workspace.

I copied over the custom linker scripts and the mk.bat file from the BLE_OTA_FixedStack_Bootloader example, and configured the projects also as defined in the example. 

I'm using PSoC Creator 4.0 Update 1.

0 Likes
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

You have to add the pin name in Symbol_list.txt file under scripts folder in Bootloader project.

For ex:

Bootloader_Service_Activation_

WakeUp_Interrupt_

Thanks & Regards,

Anjana

0 Likes
Anonymous
Not applicable

Thank you Anjana for the helpful information.

In addition to adding the component name to the Symbol_list.txt file, you also need to use an API function from the component in the Bootloader project code in some way.  For example, in a project with a digital output component named LED_G, the LED_G_Write() API function  needs to be used in the Bootloader project code so that the LED_G_Write() function can also be available in the Bootloadable project code.

The BLE_OTA_FixedStack_Bootloader example project provides the mk.bat script and Symbol_list.txt file in the following directory.

...\BLE_OTA_FixedStack_Bootloader\BLE_OTA_FixedStack_Bootloader.cydsn\Scripts\

The component symbols in the Symbol_list.txt file are extracted from the Bootloader ELF through the mk.bat file, creating the BootloaderSymbolsGcc.ld linker script for use in the Bootloadable project.  This is how the Bootloadable project is able to utilize the exported API functions.

This process is described in the BLE_OTA_FixedStack_Bootloadable.pdf document which is part of the BLE_OTA_FixedStack_Bootloader example project, starting on page 13 in the "Custom Linker Scripts" section.  I must not have completely understood what was meant the first time reading through the document.

0 Likes