4 Replies Latest reply on Jun 14, 2018 6:53 AM by keng_3159731

    Bootloader/Bootloadable project pin sharing

    keng_3159731

      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.

        • 1. Re: Bootloader/Bootloadable project pin sharing
          rzzh

          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

          • 2. Re: Bootloader/Bootloadable project pin sharing
            keng_3159731

            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.

            • 3. Re: Bootloader/Bootloadable project pin sharing
              anpm

              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

              • 4. Re: Bootloader/Bootloadable project pin sharing
                keng_3159731

                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.