The default boot kernel will load the application from sector 0. The requirement is to modify the boot kernel in a way that based on a condition (for example, the assertion of a flag input); it should load one of the two applications selectively.
Refer the attached three projects(479_spi, Blink1, Blink2) and follow the below procedure to build and flash:
1. Build the modified kernel 479_spi project to generate the 479_spi.dxe file. Before build, please ensure to build in release configuration( Right click of the project > Build Configurations > Set Active > Choose Release). 479_spi.dxe is available in Release folder.
2. Build the project “Blink1” to generate Blink1.ldr for spi flash boot in ASCII format with loader options, as shown in Figure1. Ensure that it uses the modified kernel 479_spi.dxe.
3. Build the project “Blink2” to generate Blink2.ldr for spi flash boot in ASCII format with loader options, as shown in Figure2. This project may use default boot kernel as its boot kernel will not be used.
4. Use below command to flash "blink1.ldr" in offset 0x0.
cldp -proc ADSP-21479 -emu ICE-1000 -driver "C:\Analog Devices\ADSP-21479_EZKIT-Rel1.0.0\21479_EZ-Board\Examples\Device_Programmer\serial\21479_m25p16_dpia.dxe" -cmd prog -erase all -format ascii -offset 0x0 -file "Blink1.ldr"
5. Use below command to flash "blink2.ldr" in offset 0x2000. Refer Figure3.
cldp -proc ADSP-21479 -emu ICE-1000 -driver "C:\Analog Devices\ADSP-21479_EZKIT-Rel1.0.0\21479_EZ-Board\Examples\Device_Programmer\serial\21479_m25p16_dpia.dxe" -cmd prog -erase affected -format ascii -offset 0x10000 -file "Blink2.ldr"
6. After two LDR files are programmed into flash memory, Set SW4 to 1 for serial and then press the reset button or cycle power to the board.
After reset, the customized boot kernel loads and checks the status of the FLAG1 pin (connected to SW8). If the switch was pressed (FLAG0 = 1), the kernel loads application “Blink2”; otherwise, if FLAG1 = 0, it loads the application “Blink1”.