Porting Fixed Stack Bootloader Project to IAR

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

cross mob
EyGe_3183606
Level 4
Level 4
25 replies posted 10 sign-ins 10 replies posted

Hello,

We are trying to port our fixed stack bootloader project to IAR.

We have PSOC 4 with MCU CYBLE-224110-00

The instructions on porting the project to IAR are SEVERLY lacking from Cypress documenation.

In this document: https://www.cypress.com/file/198301/download  the information does not allow you to port to IAR because it just doesn't describe the entire process. I had to figure it out by myself.

I have managed to finally port the project, have it compiled and linked properly and managed to run the bootloader followed by the bootloadable on our custom board. HOWEVER, for some reason when the bootloadable runs, the code gets stuck at the very beginning when calling the function CyBle_Start().

Since the BLE stack is located in the bootloader, I added a few prints in the generated source function CyBle_Start within the bootloader project just to identify WHERE the code gets stuck. I see that it enters the function CyBle_StackInit() and doesn't continue. When the same function is invoked when the bootloader is running, it works fine.

Moreover, the exact SAME bootloadable works fine with the project runs via PSOC Creator 4.2.

Just so you understand how I ported the project to IAR (perhaps I did something wrong) here is the list of steps I made:

  1. Export the bootloader project to IAR and followed the instructions mentioned in chapter "Setting up a PSoC 4/PSoC 5LP IAR Project" under PSOC Creator's help manual.
  2. Compiled the bootloader project in IAR and made sure a hex and elf file are output from IAR.
  3. Update the bootloader component in the bootloaderable project with the paths of the elf and hex files of the bootloader mentioned above.
  4. Then exported the bootloadable project to IAR by also following the instructions in chapter "Setting up a PSoC 4/PSoC 5LP IAR Project" under PSOC Creator's help manual.
  5. Then modified the mk.bat file in the bootloader project in the following way:
    1. Changed output directory to be: set OUTPUT_DIR=%~dp0..\..\%LOADABLE_PRJ_NAME%.cydsn\Generated_Source\PSoC4\
    2. Changed compiler to be: set COMPILER=%IAR_COMPILER%
  6. Activated the mk.bat file
  7. Went to the file cm0iar.icf in \Generated_Source\PSoC4\ under the bootloadable project and add the following line:
    1. include "BootloaderSymbolsIar.icf";
  8. Compiled the bootloadable project in IAR only to discover that NOT all functions of the BLE stack that are used by the bootloadable have been "kept" by the bootloader linker. So I went back to the bootloader project and went to project-->options-->linker-->Extra Options and added the following lines:

--keep CyBle_GappStopAdvertisement

--keep CyBle_GappSetNumOfAdvPkts

--keep CyBle_GattsReadAttributeValue

--keep CyBle_EnterLPM

--keep CyBle_GetBleSsState

--keep CyBle_GapGetDevicesFromWhiteList

--keep CyBle_StoreBondingData

--keep CyBle_GapSetLocalName

--keep CyBle_GapUpdateAdvData

--keep CyBle_GapRemoveOldestDeviceFromBondedList

9. Then I compiled the bootloader again, ran the mk.bat file again and compiled the bootloadable again and then... compilation and linking was successfull!

10. I then loaded to my custom board the hex file that the IAR generated (contains both the bootloader and the bootloadable combined) and the bootloader loads fine and the BLE is initialized fine and then the bootloadable loads and gets stuck in CyBle_StackInit().

We would like to understand what can cause this and how to resolve this?

Thanks,

David

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

Please follow the steps outlined in the attached code example document to port Fixed Stack bootloader and bootloadable projects. For code example, please go to PSoC Creator, File > Code Example > BLE_OTA_FixedStack_Bootloader. 

View solution in original post

2 Replies
lock attach
Attachments are accessible only for community members.
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

Please follow the steps outlined in the attached code example document to port Fixed Stack bootloader and bootloadable projects. For code example, please go to PSoC Creator, File > Code Example > BLE_OTA_FixedStack_Bootloader. 

Thanks GeonaM.

I tried to follow the instructions you provided and indeed I had a few things missing.

Nonetheless, after implementing everything, the issue still occurs.

I think I will try this first on a "clean" example and then try to do it on my own code.

I'll keep you updated.

0 Likes