This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/AM3358: Unable to run USB0 code from internal RAM

Part Number: AM3358

Tool/software: Code Composer Studio

Hii all,


I have to develop my own boot-loader, that will run from internal RAM.
In boot-loader application I have to implement firmware upgrade functionality as well.
for that I have to read application/firmware image from PC using USB and write it to flash.
Currently I am booting from UART0(getting binary from UART) using XMODEM interface.
My main intention is to get the application image from PC using USB and write it into FLASH.

So My current problem is I am unable to read data over USB from PC.

While debugging I found following observation

Code Sequence:

  MMUConfigAndEnable();

  IntAINTCInit();

  IntMasterIRQEnable();

USB0ModuleClkConfig();

USBInterruptEnable();


USBBufferInit((tUSBBuffer *)&g_sTxBuffer);
USBBufferInit((tUSBBuffer *)&g_sRxBuffer);

USBDBulkInit(0, (tUSBDBulkDevice *)&g_sBulkDevice);

1.Code get stuck at following function

USBDBulkInit(0, (tUSBDBulkDevice *)&g_sBulkDevice);

So please provide me solution on that as soon as possible.

Regards,

Harish

  • Hi Harish,

    Because the AM335x ROM bootloader does not support USB boot (SD/MMC, UART, NAND, and QSPI only), so you will have to implement your own boot from USB. The best way to accomplish what you need is to add the USB Bulk function into the SBL (Secondary Bootloader).

    SBL source code is at  C:\ti_am3_610\pdk_am335x_1_0_16\packages\ti\starterware\bootloader

    USB Bulk example is at C:\ti_am3_610\pdk_am335x_1_0_16\packages\ti\drv\usb\example\usb_dev\bulk

    You have to combine those two into one.

    Ming

  • Hi Ming,

    ThanksTfor your reply,

    Actually I am creating itself Secondary Booltloader and for that using TI Starterware v2.0.1.1.

    As per your suggestion we have allready merged Starterware bootloader and usb bulk example into the Secondary Bootloader. First I have checked USB bulk example in Application code(On DDR) USB is running well then USB code merged with Secondary Bootloader code but code is stuck with USBBulkInit inside Secondary bootloader.

    So Is any extra Intialization is required ?

    And Is USB stack memory configuration need to change ?

    Regards,

    Harish

  • Hi Harish,

    SBL and USB Bulk are two application programs. If you want to combine them into one, you will need adjust the link command file for the SBL to accommodate both applications.

    The other way to do it is to convert the USB Bulk application (adding your new features) into app and leave the SBL intact, so the RBL (ROM Bootloader) --> SBL --> app. This way you can focus on your new app without worrying the combine SBL and USB Bulk.

    Ming  

  • Hi Ming,

    We have allready  following RBL-----> SBL ------> App this way, Here we are boot from NAND Flash and in application code USB Bulk is used. This flow is working properly but as per our requirement USB bulk part should be add into the SBL.

    So we have add the USB bulk part into the SBL but it's stuck with USBBulkinit.

    As per our observation USBBulkInit is stuck due to the interrupt issue. For testing I have add timer overflow interrupt into the SBL code after Interrupt generated processor is not jump to timer ISR its stuck with somewhere. I thought this happen due to the Interrupt vector table is not assigned properly.

    So please suggest me how to configure Interrupt vector table properly.

  • Hi Ming,

    In our case, we are not using RTOS SDK for development of SBL as well as application.

    We are using non RTOS AM335X_StarterWare_02_00_01_01 for development of SBL and application using CCS(Code composer Studio version 8.3.)

    In application code development, for IVT(Interrupt vector table) initialization

    C:\Harish\Development tool\AM335X_StarterWare_02_00_01_01\system_config\armv7a\am335x\startup.c file is used.

    But in case of SBL, C:\ti\AM335X_StarterWare_02_00_01_01\bootloader\src\armv7a\cgt\bl_init.asm is used in which we are not able to locate IVT(Interrupt vector table) initialization file.

    bl_init.asm is provide below.

    ;******************************************************************************
    ;
    ; init.asm - Init code routines
    ;
    ;******************************************************************************
    ;******************************************************************************
    ;
    ;****************************** Global Symbols*******************************
    .global Entry
    .global start_boot
    .global __TI_auto_init

    .ref __stack
    .ref bss_start
    .ref bss_end
    .ref start_boot
    .ref main

    ;************************ Internal Definitions ******************************
    ;
    ; Define the stack sizes for different modes. The user/system mode will use
    ; the rest of the total stack size
    ;

    UND_STACK_SIZE .set 0x8
    ABT_STACK_SIZE .set 0x8
    FIQ_STACK_SIZE .set 0x8
    IRQ_STACK_SIZE .set 0x100
    SVC_STACK_SIZE .set 0x8

    ;
    ; to set the mode bits in CPSR for different modes
    ;

    MODE_USR .set 0x10
    MODE_FIQ .set 0x11
    MODE_IRQ .set 0x12
    MODE_SVC .set 0x13
    MODE_ABT .set 0x17
    MODE_UND .set 0x1B
    MODE_SYS .set 0x1F

    I_F_BIT .set 0xC0

    ;**************************** Code Seection ***********************************
    .text

    ;
    ; This code is assembled for ARM instructions
    ;
    .state32

    ;******************************************************************************
    ;
    ;******************************************************************************
    ;
    ; The reset handler sets up the stack pointers for all the modes. The FIQ and
    ; IRQ shall be disabled during this. Then, clearthe BSS sections, switch to the
    ; main() function.
    ;
    Entry:
    ;
    ; Set up the Stack for Undefined mode
    ;
    LDR r0, _stackptr ; Read the stack address
    MSR cpsr_c, #MODE_UND|I_F_BIT ; switch to undef mode
    MOV sp,r0 ; write the stack pointer
    SUB r0, r0, #UND_STACK_SIZE ; give stack space
    ;
    ; Set up the Stack for abort mode
    ;
    MSR cpsr_c, #MODE_ABT|I_F_BIT ; Change to abort mode
    MOV sp, r0 ; write the stack pointer
    SUB r0,r0, #ABT_STACK_SIZE ; give stack space
    ;
    ; Set up the Stack for FIQ mode
    ;
    MSR cpsr_c, #MODE_FIQ|I_F_BIT ; change to FIQ mode
    MOV sp,r0 ; write the stack pointer
    SUB r0,r0, #FIQ_STACK_SIZE ; give stack space
    ;
    ; Set up the Stack for IRQ mode
    ;
    MSR cpsr_c, #MODE_IRQ|I_F_BIT ; change to IRQ mode
    MOV sp,r0 ; write the stack pointer
    SUB r0,r0, #IRQ_STACK_SIZE ; give stack space
    ;
    ; Set up the Stack for SVC mode
    ;
    MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode
    MOV sp,r0 ; write the stack pointer
    SUB r0,r0, #SVC_STACK_SIZE ; give stack space
    ;
    ; Set up the Stack for USer/System mode
    ;
    MSR cpsr_c, #MODE_SYS|I_F_BIT ; change to system mode
    MOV sp,r0 ; write the stack pointer
    ;
    ; Clear the BSS section here
    ;
    Clear_Bss_Section:

    LDR r0, _bss_start ; Start address of BSS
    LDR r1, _bss_end ; End address of BSS
    SUB r1,r1,#4
    MOV r2, #0
    Loop:
    STR r2, [r0], #4 ; Clear one word in BSS
    CMP r0, r1
    BLE Loop ; Clear till BSS end

    ;
    ; Enter the start_boot function. The execution still happens in system mode
    ;
    LDR r10, _main ; Get the address of main
    MOV lr,pc ; Dummy return to main
    BX r10 ; Branch to main
    SUB pc, pc, #0x08 ; looping

    ; MSR cpsr_c, #MODE_SVC|I_F_BIT ; change to SVC mode
    ; BX lr
    ;
    ; End of the file
    ;

    _stackptr:
    .word __stack
    _bss_start:
    .word bss_start
    _bss_end:
    .word bss_end
    _main:
    .word main
    _data_auto_init:
    .word __TI_auto_init
    .end

    Is this initialization is sufficient for writing IVT(Interrupt vector table) that is required in case of interrupt functionality in SBL code.

    Regards,

    Harish

  • Hi Ming,

    I issue is resolved.

    Issue was I was using ble_Init.asm instead of init.asm.

    Inside ble_Init.asm there is Stratup.c is not linked so IVT was not assigning now I am using init.asm its worked.

    Regards,

    Harish