Bootloader and application, Can anyone clarify couple of things

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

cross mob
ansh_2022771
Level 2
Level 2
First like received First like given

Hello Everyone,

I have been writing Over the air firmware upgrade for STM, PICS and Atmel controllers. It was  a simple process in those controllers.

Divide flash into Bootloader and application or maybe network (if you want to separate network or not).

Go to Boot loader. and then Check for an update and then reset IVC, SP & PC and then jump to application. Now that I have been working with PSOC4 BLE. I have couple of doubts and assumptions which I want to verify.

My plan to implement it:

  1. Boot loader is always empty, It checks whether an application is there If yes then jump to application otherwise look in external memory (SD card / data flash) for application image and then copy that image from external memory to PSOC's flash. Check integrity and jump to application.
  2. I am planning to update external memory (data flash or SD card) in application portion itself. If image is uploaded to external memory successfully then update the application area (flash) from bootloader.

All this seems OKAY to me based on the data gathered by me so far.

  • I will be using SPI for external memory. Also I am using same SPI for couple of other things and want to access it in application as well. SPI will be used in boot loader for reading external memory, checking integrity  & then writing the read data from external memory  to PSOC's flash. My doubts here are :
    1. Do I have to take single SPI component on both application and bootloader project ?
    2. If answer to Point 1 is true that means I have to use bootloader's SPI functions in application as well.
    3. If answer to point 1 is false that means I have to take SPI component in both bootloader and Application.
  • What does bootloader and bootloadable components do ?
  • How to devide flash for bootloader and application ?
  • Any other guidance on doing that good old stuff like "reset IVC, SP & PC" before jump to application from bootloader or is that taken care by components automatically.

Thanks for reading and I await your valuable responses.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You will need to write your own bootloader which is a bit of work, but has been done by some users before. Reason is that the current implementation expects the data coming via a fixed protocol in a hex data format. You may use as a starting point the current Bootloader component source.

You can use the same SPI for bootloader and application. When the bootloading is finished (and this includes the configuration data for the bootloadable) a reset is issued and the configuration gets set.

Bootloader component manages the interface (SPI in your case) and reads the data for the bootloadable application.

The bootloadable component simply manages the entry-point for the application so it can be called at reset.

Dividing the flash areas is mostly done automatically.

Bob    

View solution in original post

6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You will need to write your own bootloader which is a bit of work, but has been done by some users before. Reason is that the current implementation expects the data coming via a fixed protocol in a hex data format. You may use as a starting point the current Bootloader component source.

You can use the same SPI for bootloader and application. When the bootloading is finished (and this includes the configuration data for the bootloadable) a reset is issued and the configuration gets set.

Bootloader component manages the interface (SPI in your case) and reads the data for the bootloadable application.

The bootloadable component simply manages the entry-point for the application so it can be called at reset.

Dividing the flash areas is mostly done automatically.

Bob    

If the flash divide is automatic how does programmer (Miniprog3) decides

  • where to write bootloader.hex and where to write bootloadable.hex ?

Based on my understanding and requirements I will be updating firmware from application portion only.

  • Receiving data and then writing to external memory.
  • Once write successful & integrity check successful, Jump to Bootloader.
  • In the bootloader write to internal flash of PSOC. Check integrity, if all OK jump to application.

If you can see above, it's very important that I load both bootloader and bootloadable hex files on factory reset.

  • Is that possible ?
  • Also if not possible then how does developers upgrade stack of BLE if they are already communicating with BLE ?
    • Do they put BLE in bootloader ? If yes then how do they update stack ?

It all seems confusing.

0 Likes

I would suggest you to start a forum search with "BLE OTA" keywords, there are some articles/threads to read.

Bob

0 Likes

Hi Bob I was busy with some other work and was unable to look into this particular issue.

Today I started using code example of bootloader and bootloadable. In the bootloadable I placed manual placement of image at address 2000. To my surprise in the hex file of bootloadable the start address is 0000.

To be more clear - All I want is Create an application project at any location (0x00002000). Decode that generated hex file in my windows application. Once It is decoded from PC I am sending that data serialy (UART) to bootloader. Bootloader  writes this image from (0x00002000) to the flash.

0 Likes

Update - I figured out something. As we provide bootloader as dependency for bootloadable, it decodes bootloader hex file.

That also answers my another query. For first time we need not to program bootloader and application seprately. We can only program bootloadable and that will update entire flash (Bootloader and bootloadable)

I will keep posting updates here so that it helps others as well.

Another question - Now that I am sure that bootloader starts from 0000 and bootloadable (application) starts from 2000. All I want is find an API and a way to jump to bootloadable from bootloader. Is there a specific way of doing that manually.

0 Likes

Update 2 - As I said, I wanted to know how to jump properly from bootloader to Bootloadable (at a specific address 0x00002000 in our case)

Here is solution :

/* Argument 1 is your manual app address and argument 2 is app ID which is 1 in our case as bootloader's app ID is 0 */

Bootloader_SetFlashByte((uint32) 0x2000,1);

/* When you are ready to jump to application or bootloadable call this to set the run type and then do a soft reset */

Bootloader_SET_RUN_TYPE(Bootloader_SCHEDULE_BTLDB);

CySoftwareReset();

I will write a detailed post for this.