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

cross mob
LukeCY_Wei
Level 2
Level 2
25 sign-ins First like received 10 replies posted

Hi,
    My Non-OS bootloader download Non-OS APP OK, but download FreeRTOS APP NG, and when I test this APP self reset, I found it will crash, my reset section as below, of course I have comfirm original hex and pflash data, it's match, have any advices? thanks.

BTW: If I change this APP start address from 0xa000c000 to 0xa0000020 that's self reset is OK.

App reset section:

	        uint16 endInitSafetyPassword = IfxScuWdt_getSafetyWatchdogPasswordInline();
	        __disable();
	        portENTER_CRITICAL();
	        vTaskEndScheduler();
	        IfxScuWdt_clearSafetyEndinitInline(endInitSafetyPassword);
	        MODULE_SCU.SWRSTCON.B.SWRSTREQ=1;
	        IfxScuWdt_setSafetyEndinitInline(endInitSafetyPassword);

 

Jump to App section:

   __disable();
   __asm("movh.a  a15,#@his(ApplIntJmpTable)");
   __asm("lea     a15,[a15]@los(ApplIntJmpTable)");
   __asm("ld.a    a15,[a15]");
   __asm("isync");
   __asm("ji      a15");

 

0 Likes
1 Solution
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei 
I guess you encounter a similar issue as the thread described, in which neither of core1 nor core2 runs after jumping.
BR,
Jeremy

View solution in original post

0 Likes
18 Replies
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei 
Actually, I'm still a bit confused with your question, whether you mean the Non-OS bootloader can jump to the Non-OS APP successfully, however, it fails if the APP integrates the OS.
Moreover, if the APP locates at 0xa0000020 after the self-reset happens, the bootloader still can jump to the APP successfully, but it doesn't work if the APP locates at 0xa000c000, is it right?
BR,
Jeremy

0 Likes

Hi Jeremy

    1. Yes, Non-OS APP running OK after bootloader download.

    2. The self-reset doesn't put bootloader into flash, becaue my Non-OS APP self-reset OK without bootloader in debug mode, so I do the same experiment.

Thanks.

Bootloader->Non-OS APP, OK

Bootloader->FreeRTOS APP, NG

In debug mode:

Self-reset without bootloader, Non-OS APP, 0xa0000020=OK, 0xa000c000=OK

Self-reset without bootloader, FreeRTOS APP, 0xa0000020=OK, 0xa000c000=NG

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei 
It seems a bit weird.
I was wondering if you can share the demo codes that can replicate the phenomenon you encountered.
BR,
Jeremy

0 Likes

Hi Jeremy

    I already PM related source code to you, if you have any question please let me know.

Thanks.

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei 
I've already checked your code, I find the interrupt map is LCF_INTVEC0_START begins from the END_ADDR actually, and LCF_TRAPVEC1_START and LCF_TRAPVEC2_START both beyond the END_ADDR too.
So I'd like to suggest you remodify them to assure them must be inside the range of START_ADDR and END_ADDR.

code.png
BR,
Jeremy

0 Likes

Hi Jeremy

    I modify the lsl as your suggest,  the APP still doesn't run after download, in consumer MCU forum, they discuss about interrupt vector table mapping, would you think the interrupt vector table will effect this?

BTW: After download, in debug mode, I found program count will stop in idle hook function.

Thanks.

void vApplicationIdleHook( void )
{
    OsTasks_setupTimerInterrupt(&MODULE_STM0);
    while (1)
    {
    }
}

 

//#define _StartFrom0xA0000020

#ifdef _StartFrom0xA0000020
#define LCF_INTVEC0_START   0x801F4000
#define LCF_INTVEC1_START   0x801F5000
#define LCF_INTVEC2_START   0x801F3000

#define LCF_TRAPVEC0_START  0x80000100
#define LCF_TRAPVEC1_START  0x801F6200
#define LCF_TRAPVEC2_START  0x801F6000

#else
#define START_ADDR			0xA000C000
#define END_ADDR			(START_ADDR + 160k)

#define LCF_INTVEC0_START   START_ADDR+0x6000
#define LCF_INTVEC1_START   START_ADDR+0x7000
#define LCF_INTVEC2_START   START_ADDR+0x5000

#define LCF_TRAPVEC0_START  START_ADDR+0x100
#define LCF_TRAPVEC1_START  START_ADDR+0x200
#define LCF_TRAPVEC2_START  START_ADDR+0x300
#endif

#define INTTAB0             (LCF_INTVEC0_START)
#define INTTAB1             (LCF_INTVEC1_START)
#define INTTAB2             (LCF_INTVEC2_START)

#define TRAPTAB0            (LCF_TRAPVEC0_START)
#define TRAPTAB1            (LCF_TRAPVEC1_START)
#define TRAPTAB2            (LCF_TRAPVEC2_START)

#ifdef _StartFrom0xA0000020
#define BMH_0 	0x80000000	//C000
#define RESET 	0x80000020
#define iCONST	0x80000040
#define EndAddr	0x8001FFFC
#define BMH_1 	0x80020000
#else
#define BMH_0 	0xA000C000	//C000
#define RESET 	0xA000C020
#define iCONST	0xA000C040
#define EndAddr	0xA001FFFC
#define BMH_1 	0xA0020000
#endif

 

| pfls0| bmh_0       | .rodata.bmhd_0 (10773)          | 0xa000c000 |
| pfls0| reset       | .text.start (10771)             | 0xa000c020 |
| pfls0| trapvec_tc0 | .text.traptab_cpu0 (10587)      | 0xa000c100 |
| pfls0| trapvec_tc1 | .text.traptab_cpu1 (10588)      | 0xa000c200 |
| pfls0| trapvec_tc2 | .text.traptab_cpu2 (10589)      | 0xa000c300 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.001 (11444)| 0xa0012020 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.002 (12035)| 0xa0012040 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.003 (12175)| 0xa0012060 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.004 (12177)| 0xa0012080 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.005 (11772)| 0xa00120a0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.006 (11770)| 0xa00120c0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.007 (11768)| 0xa00120e0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.008 (12298)| 0xa0012100 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.009 (12383)| 0xa0012120 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.00b (12389)| 0xa0012160 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.00d (12385)| 0xa00121a0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.00e (12387)| 0xa00121c0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.00f (12391)| 0xa00121e0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.010 (12393)| 0xa0012200 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.011 (12067)| 0xa0012220 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.012 (12069)| 0xa0012240 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.013 (12071)| 0xa0012260 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.014 (12061)| 0xa0012280 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.015 (12063)| 0xa00122a0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.016 (12065)| 0xa00122c0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.01e (11728)| 0xa00123c0 |
| pfls0| int_tab_tc0 | .text.inttab0.intvec.020 (11730)| 0xa0012400 |
| pfls0| BOOT_LABEL  | .rodata._Boot_label (11652)     | 0xa001fffc |
| pfls0| bmh_1       | .rodata.bmhd_1 (10774)          | 0xa0020000 |

 

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei 
According to your testing, the bootload can jump the FreeRTOS APP if comment out the OS_Tasks_init() function in the Cpu0_Main.c, is it right?
Further, I also guess the issue is related to the interrupt vector, as I find the interrupt vector is located in the Pflash1 when checking the map file.

2023-08-01_18h13_54.png
BR,
Jeremy

0 Likes

Hi Jeremy

    Thanks for your suggest and support, and finally, I think I found root cause of RTOS@APP doesn't run. After deep trace and debug, when I disable ADC(ISR) and QSPI(DMA) related function then to use bootloader download RTOS@APP, it's work. Because my main function will refer ADC value and QSPI value, but ths ADC value always zero and QSPI always read empty data stream, if ADC and QSPI had something wrong will cause my RTOS@APP not wrok.

So I still need your suggest, I don't know why ADC and QSPI work NG, and I found this post
Bootloader and DMA , this post mean QSPI(DMA) with RTOS maybe had some problem, would you have any advise?
Thanks.

 

BTW: My ADC/QSPI function in ADC.C/ SPI.C

 

 

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei 
Thanks for your reply.
I'm a bit confused with your testing result, do you mean the application (integrate with RTOS) also fails to run in both of the below cases?
FreeRTOS APP (without bootloader), locates at 0xa0000020 or 0xa000c000

I was wondering if you can describe it in detail.

BR,
Jeremy

0 Likes

Hi Jeremy

        Test result as below table:

result.png

ADC experiment code section as below, if ADC OK, System will start when ADC_Value > ACC_Voltage, but in NG(*1) case, ADC_Value always zero effect system doesn't start, when I bypass this section then RTOS@APP run OK.

 

void MainTask(void)
{
    if(EnableSystem()==1)
    {
        //Do something
    }    
}
boolean EnableSystem(void)
{
    if(ADC_Value>ACC_Voltage)
    {
       //Start system 
       return 1;
    }
    else
    {
       //Wait ACC ON
       return 0;
    }
}

 

 

0 Likes
lock attach
Attachments are accessible only for community members.
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei ,
Thanks for your reply.
According to your testing result, the root cause is related to the malfunction of the EnableSystem(), is it right?
By the way, I didn't find this function in the demo code you shared actually.
Moreover, I share a linker file to make the application stores from the 0x80100000, and the pointer of the reset function is 0x80100020, please give it a try.
BR,
Jeremy

0 Likes

Hi Jeremy
    1. Yes, cause I optimize some code section, you can refer "multican.c"

if(ADCSampling[CHANNEL_AN27]<IGN_VOLTAGE)
    return FALSE;

    2. OK, I will try it today and feedback ASAP, Thanks!

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei ,
In my opinion, assume the ADCSampling[CHANNEL_AN27] = 0, then return, it should not affect the APP runs as a whole, as there're other tasks still running.
Meanwhile, there's potential to happen core0 and core1 to access the ADCSampling simultaneously, it should set a synchronization mechanism to avoid this.
Lastly, please confirm the value of ADCSampling[CHANNEL_AN27] whether can exceed the IGN_VOLTAGE in reality.
BR,
Jeremy

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Jeremy 
    1. Yes, other task is alive, but ADC value(IGN OFF) that disable CAN commuction, so main function doesn't work always idle.
    2. Agree, I will add sync rule to protect ADCSampling.
    3. In normal case, ADCSampling[CHANNEL_AN27] value between 2200~2400.

And bad news, I used your link file the ADC and QSPI still abnormal, attached is the map and lsl.

ADC normal case:

adc ok.png

ADC abnormal case:

adc ng.png

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei 
I guess you encounter a similar issue as the thread described, in which neither of core1 nor core2 runs after jumping.
BR,
Jeremy

0 Likes

Hi Jeremy

    I think you are correct, my app run OK now, I will do more test, if have other question, I will ask your advice.

Thanks.

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @LukeCY_Wei 

I'm glad to hear that, further, I was wondering if you can summarize the handles you did to make the App run Ok, it can help other guys who encounter a similar issue to figure it out efficiently.
BR,
Jeremy

0 Likes

Hi Jeremy

    No problem, I refer this thread then to modify my boot code of bootloader as below

1. Remove excute Core1 and Core2 section as Figure1.

2. Delete Core1 and Core2 Cstart files as Figrue1.

And run boot code in debug mode, we can see Core1 and Core2 always suspended as Figure1 too.

Thanks.

Figure1:

solution.png