Other Parts Discussed in Thread: UNIFLASH
Hi, Currently I am trying to implement a bootloader to TI-RTOS's code. However, I can not find any example other than notROTS examples. So I follow the given example and some of the threads' answers to work on it.
During the implementation, I was testing the code with the BSL-scripter in the command line and I have no luck. So I think I should just debug using the CCS debug mode, which I had successfully make have it running. I started to debug and then upload script_1.txt to the board and restart the debug. The program works fine, it can trigger the jumptobootloade mode from BIOS_exit. However, this one is not working for the BSL-scripter still. So I come up with a different method. I generate a .txt file from the program and try to upload it through Uniflash. This method can upload the program and have it working only if I select the erase configuration to Erase and download necessary segments only. This result makes me think I question my code, it that anything that is erasing the main memory when I run the BSL-scripter. However, I can not find anything that is causing it. Please help if anyone has any ideas.
I am testing the BSL with the buttonled TI-RTOS example and following are some of my steps for the change
1. .cmd file :
a. FLASH (RX) : origin = 0x00004000, length = 0x000FC000
b. SECTIONS
{
.intvecs: > APP_BASE
.text : > FLASH
.const : > FLASH
.rodata : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
.vtable : > 0x20000000
2. .cfg file
m3Hwi.resetVectorAddress = 0x4000;/* App base */
3. main application:
a. add Jumptobootloader function
void JumpToBootLoader(void);
void JumpToBootLoader(void)
{
/* We must make sure we turn off SysTick and its interrupt before entering
* the boot loader! */
MAP_SysTickIntDisable();
MAP_SysTickDisable();
/* Disable all processor interrupts. Instead of disabling them one at a
* time, a direct write to NVIC is done to disable all peripheral
* interrupts. */
NVIC->ICER[0] = 0xffffffff;
NVIC->ICER[1] = 0xffffffff;
NVIC->ICER[2] = 0xffffffff;
NVIC->ICER[3] = 0xffffffff;
// Load the stack pointer from the bootloader's vector
// __set_MSP( *((volatile uint32_t*)0x00 ));
/* Return control to the boot loader. This is a call to the SVC handler
* in the boot loader. */
(*((void (*)(void)) (*(uint32_t*) 0x2c)))();
}
2. add function RTOS exit (line 126 at main_tirtos.c)
int main(void)
{
pthread_t thread;
pthread_attr_t attrs;
struct sched_param priParam;
int retc;
Board_init();
/* Initialize the attributes structure with default values */
pthread_attr_init(&attrs);
/* Set priority, detach state, and stack size attributes */
priParam.sched_priority = 1;
retc = pthread_attr_setschedparam(&attrs, &priParam);
retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
if (retc != 0) {
/* failed to set attributes */
while (1) {}
}
retc = pthread_create(&thread, &attrs, mainThread, NULL);
if (retc != 0) {
/* pthread_create() failed */
while (1) {}
}
System_atexit(JumpToBootLoader);
BIOS_start();
return (0);
}
4. RTOS.c
at BIOS_exit(1); to triggle (line 146 at buttonled.c)
if(Button_EV_CLICKED == (events & Button_EV_CLICKED))
{
bStats.clicked++;
bStats.lastpressedduration =
Button_getLastPressedDuration(handle);
/* Put event in ring buffer for printing */
RingBuf_put(&ringObj, events);
if(LED_STATE_BLINKING == LED_getState(led))
{
LED_stopBlinking(led);
LED_setOff(led);
}
else
{
LED_toggle(led);
BIOS_exit(1);
}
}
Thank you so much