Hi,
For the past week or so I have been trying to develop a process to make my DSP board boot itself from the Flash. I am reasonable confident that my program for writing an intel hex file to the flash works as I can see the right data from the hex file in the memory after connecting to the device in CCS.
I have been trying for quite a few days now to get a hex file that will boot when loaded into the flash. I have trawled through a number of different pdf files that all describe this process in different variations (mostly for old versions of cc) and have so far had very little success.
The DSP I am using is a C6713 and the ccs is v4.2.1.00004. The two main methods I have tried are:
1. Using CCS BIOS to specify the load and run sections separately with the following boot code in the boot section (base 0x0 and length 0x400).
FLASH_START .equ 0x90000400 ;flash start address
CODE_START .equ 0x00000400 ;start of non boot code
CODE_SIZE .equ 0x00003000 ;application code size in byte
.sect "bootload"
_boot_start:
mvkl FLASH_START,B4 ;flash start address ->B4
mvkh FLASH_START,B4
mvkl CODE_START,A4 ;apps code start address ->A4
mvkh CODE_START,A4
zero A1
_boot_loop1:
ldb *B4++,B5 ; flash read
mvkl CODE_SIZE-4,B6 ; B6 = BOOT_SIZE -1024
add 1,A1,A1 ;A1+=1,inc outer counter
|| mvkh CODE_SIZE-4,B6
cmplt A1,B6,B0
nop
stb B5,*A4++
[B0] b _boot_loop1
nop 5
mvkl .S2 _c_int00, B0
mvkh .S2 _c_int00, B0
B .S2 B0
nop 5
Then using hex6x to convert to an intel file with the following command file
C:\CCS_projects\14du\Debug\14du.out /* input COFF file */
-i
-image
-zero
-memwidth 8
-map imu_hex.map
ROMS
{
FLASH: org = 0x90000000, len = 0x10000, romwidth = 8, files = {imu.hex}
}
So if I am right doing it this way CCS should put all the sections in the write memory spaces within the out file then the hex file is compiled with any sections that need to be loaded into the flash. I am a bit unsure on which sections actually need to go in to the flash for the program to initialise. I tried different setups but maybe someone could confirm the sections that need to go to the flash for me?
2. The other method I have tried is using hex6x to specify the boot table then using the following boot code so that it reads the table from 0x90000400.
.title "Flash bootup utility for 6713 dsk"
.option D,T
.length 102
.width 140
COPY_TABLE .equ 0x90000400
.sect ".boot_load"
.global _boot
;**********************************************************************
; copy sections
;**********************************************************************
mvkl COPY_TABLE, a3 ; load table pointer
mvkh COPY_TABLE, a3
ldw *a3++, b1 ; Load entry point
copy_section_top:
ldw *a3++, b0 ; byte count
ldw *a3++, a4 ; ram start address
nop 3
[!b0] b copy_done ; have we copied all sections?
nop 5
copy_loop:
ldb *a3++,b5
sub b0,1,b0 ; decrement counter
[ b0] b copy_loop ; setup branch if not done
[!b0] b copy_section_top
zero a1
[!b0] and 3,a3,a1
stb b5,*a4++
[!b0] and -4,a3,a5 ; round address up to next multiple of 4
[ a1] add 4,a5,a3 ; round address up to next multiple of 4
;**********************************************************************
; jump to entry point
;**********************************************************************
copy_done:
b .S2 b1
nop 5
This in conjunction with the following hex6x command file
C:\CCS_projects\14du\Debug\14du.out /* input COFF file */
-i /* create intel hex image */
-image /* Create a memory image (no discontinuities) */
-zero /* reset address origin to 0 for outputfile(s)*/
-memwidth 8 /* Width of ROM/Flash memory */
-map imu_hex.map /* create a hex map file */
-boot /* create a boot table for all initialized sects*/
-bootorg 0x90000400 /* address of the boot/copy-table */
-bootsection .boot_load 0x90000000 /* section containing our asm boot routine */
ROMS
{
FLASH: org = 90000000h, len = 0x10000,romwidth = 8, files = {imu.hex}
}
I have also tried many variations between the two including inserting the following code before the boot code to set up the EMIF correctly for my application.
;EMIF Register Addresses
EMIF_GCTL .equ 0x01800000 ;EMIF global control
EMIF_CE1 .equ 0x01800004 ;address of EMIF CE1 control reg.
EMIF_CE0 .equ 0x01800008 ;EMIF CE0control
EMIF_CE2 .equ 0x01800010 ;EMIF CE2control
EMIF_CE3 .equ 0x01800014 ;EMIF CE3control
EMIF_SDRAMCTL .equ 0x01800018 ;EMIF SDRAM control
EMIF_SDRAMTIM .equ 0x0180001c ;EMIF SDRAM timer
EMIF_SDRAMEXT .equ 0x01800020 ;EMIF SDRAM extension
; EMIF Register Values for 6713 DSK
EMIF_GCTL_V .equ 0x00000078 ;
EMIF_CE0_V .equ 0xffffbf93 ;EMIF CE0 SDRAM -
EMIF_CE1_V .equ 0xffffff03 ;EMIF CE1 Flash 8-
EMIF_CE2_V .equ 0x22a28a22 ;EMIF CE2 Daughtercard 32-bit async
EMIF_CE3_V .equ 0x22a28a22 ;EMIF CE3 Daughtercard 32-bit async
EMIF_SDRAMCTL_V .equ 0x5748f000 ;EMIF SDRAM control
EMIF_SDRAMTIM_V .equ 0x005DC5DC ;SDRAM timing (refresh)
EMIF_SDRAMEXT_V .equ 0x000a8529 ;SDRAM extended control
;**********************************************************************
;* CONFIGURE EMIF
;**********************************************************************
;****************************************************************
; *EMIF_GCTL = EMIF_GCTL_V;
;****************************************************************
mvkl EMIF_GCTL,A4
|| mvkl EMIF_GCTL_V,B4
mvkh EMIF_GCTL,A4
|| mvkh EMIF_GCTL_V,B4
stw B4,*A4
I have also tried having a vector table at 0x0 and the boot code at 0x200.
I tried to see what was happening by loading the symbol file in debug but in the following code it goes as far as the nop 3 the loops back to myloop, repeatedly.
;**********************************************************************
;* Debug Loop - Comment out B for Normal Operation
;**********************************************************************
zero B1
_myloop: [!B1] B _myloop
nop 5
_myloopend: nop
;**********************************************************************
;* Copy code sections
;**********************************************************************
mvkl COPY_TABLE, a3 ; load table pointer
mvkh COPY_TABLE, a3
ldw *a3++, b1 ; Load entry point
copy_section_top:
ldw *a3++, b0 ; byte count
ldw *a3++, a4 ; ram start address
nop 3
[!b0] b copy_done ; have we copied all sections?
nop 5
It also went in strange loops that didn’t match up with the symbols when I tired it in other configurations. If anybody can offer any clarity on the best way to create a bootable .hex file from ccsv4 and help me along my way I would be very grateful.
Sorry for the long post with so many sections of code but hopefully it can help somebody see where I am going wrong.
Regards
Sean