Hi All,
I am working on small and fast secondary bootloader. From this reason I decided to use file system functions located in ROM (fs_Open(), fs_GetFileInfo(), fs_Read()) instead standard file systems functions from SimpleLink NWP. This approach allows save some boot time because it it not required started NWP. Also bootloader is smaller because is not necessary link SimpleLink driver library. My idea is based on fast boot mode from "application_bootloader" in SDK 1.2.0 and file filesystem.h in this example.
Unfortunately calling file system functions from ROM not work properly. I am not able find reason of the issue. Calling of fs_Open() function always return -11 (=file not found). My file "/sys/mcuimg1.bin" is properly saved in flash filesystem and with sl_FsOpen() works properly. From my point of view it looks like that filename was not properly pass into ROM function call. Unfortunately I don't know how this fix. Any advice will be highly appreciated.
Actually same issue was discussed at this thread (https://e2e.ti.com/support/wireless_connectivity/simplelink_wifi_cc31xx_cc32xx/f/968/p/498670/1807110). There is verified answer, unfortunately it not answers what is root case of problem.
My minimal code of bootloader for CCS is here:
#include "hw_ints.h"
#include "hw_types.h"
#include "fs.h"
#include "hw_memmap.h"
#include "rom.h"
#include "rom_map.h"
#include "prcm.h"
#include "interrupt.h"
#include "filesystem.h"
// vector table
#if defined(ccs) || defined(gcc)
extern void (* const g_pfnVectors[])(void);
#endif
// application entry point
#define APP_OFFSET 0x20020000
// application image file name
static unsigned char file[] = "/sys/mcuimg1.bin";
//
// Run firmware image from RAM address
//
void runFirmwareImage(unsigned long);
__asm(" .sect \".text:runFirmwareImage\"\n"
" .clink\n"
" .thumbfunc runFirmwareImage\n"
" .thumb\n"
"runFirmwareImage:\n"
" ldr sp,[r0]\n"
" add r0,r0,#4\n"
" ldr r1,[r0]\n"
" bx r1");
//
// Load fimrware image from file into RAM
//
int loadFirmwareImage(void) {
long handle;
SlFsFileInfo2_t pFsFileInfo2;
Token_t token = 0;
// open file for read - used ROM function fs_Open()
if ((handle = fs_Open(1, file, _FS_MODE_OPEN_READ, &token)) <= 0) return handle;
// get file length - used ROM function fs_GetFileInfo()
if (fs_GetFileInfo(1, file, &token, &pFsFileInfo2) < 0) return 2;
// load application image into RAM - used ROM function fs_Read()
if (fs_Read(handle, 0, (char *)APP_OFFSET, pFsFileInfo2.Size) < 0) return 3;
return 0;
}
//
// Main
//
int main() {
int retVal;
// init hardware
MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
IntMasterEnable();
IntEnable(FAULT_SYSTICK);
PRCMCC3200MCUInit();
// load image into RAM (always return -11)
retVal = loadFirmwareImage();
// execute image from RAM
if (retVal == 0) runFirmwareImage(APP_OFFSET);
while(1) {}
}
Bootloader linker file:
#define RAM_BASE 0x20004000
/* System memory map */
MEMORY
{
/* Application uses internal RAM for program and data */
SRAM_CODE (RWX) : origin = 0x20004000, length = 0x8000
SRAM_DATA (RWX) : origin = 0x20000000, length = 0x4000
}
/* Section allocation in memory */
SECTIONS
{
.intvecs: > RAM_BASE
.init_array : > SRAM_CODE
.vtable : > SRAM_CODE
.text : > SRAM_CODE
.const : > SRAM_CODE
.cinit : > SRAM_CODE
.pinit : > SRAM_CODE
.data : > SRAM_DATA
.bss : > SRAM_DATA
.sysmem : > SRAM_DATA
.stack : > SRAM_DATA(HIGH)
}
Whole CSS 6.1.3 project:
Regards,
Jan