From ea8f277b358a0fdaae049c00cfe8c67a73c68020 Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Fri, 10 Jun 2011 10:48:25 -0400 Subject: Updated changes for GA RC1 --- boot_loader/IBL_buildibl | 15 +- boot_loader/examples/emac/Ethernet_boot/README | 18 - .../examples/emac/Ethernet_boot/pcsendpkt.c | 177 ------ .../examples/emac/Ethernet_boot/pcsendpkt.exe | Bin 111616 -> 0 bytes boot_loader/examples/emac/Ethernet_boot/simple.eth | 87 --- boot_loader/examples/emac/Utilities/b2ccs.c | 164 ----- boot_loader/examples/emac/Utilities/b2ccs.exe | Bin 32768 -> 0 bytes boot_loader/examples/emac/Utilities/b2i2c.c | 226 ------- boot_loader/examples/emac/Utilities/b2i2c.exe | Bin 32768 -> 0 bytes boot_loader/examples/emac/Utilities/bconvert64x.c | 668 -------------------- .../examples/emac/Utilities/bconvert64x.exe | Bin 36864 -> 0 bytes boot_loader/examples/emac/Utilities/bootpacket.c | 478 -------------- boot_loader/examples/emac/Utilities/bootpacket.exe | Bin 40960 -> 0 bytes boot_loader/examples/emac/Utilities/bootpacket.h | 77 --- boot_loader/examples/emac/Utilities/build-msvc.bat | 12 - boot_loader/examples/emac/Utilities/mergebtbl.c | 127 ---- boot_loader/examples/emac/Utilities/mergebtbl.exe | Bin 32768 -> 0 bytes boot_loader/examples/emac/Utilities/myparser.c | 157 ----- boot_loader/examples/emac/Utilities/myparser.exe | Bin 36864 -> 0 bytes boot_loader/examples/emac/simple/makefile | 45 -- boot_loader/examples/emac/simple/simple.btbl | 10 - boot_loader/examples/emac/simple/simple.cmd | 41 -- boot_loader/examples/emac/simple/simple.le.btbl | 8 - boot_loader/examples/emac/simple/simple.map | 95 --- boot_loader/examples/emac/simple/simple.obj | Bin 1460 -> 0 bytes boot_loader/examples/emac/simple/simple.out | Bin 1820 -> 0 bytes boot_loader/examples/emac/simple/simple.rmd | 15 - boot_loader/examples/emac/simple/simple.s | 64 -- .../examples/ethernet/Ethernet_boot/pcsendpkt.c | 209 ++++++ .../examples/ethernet/Ethernet_boot/pcsendpkt.exe | Bin 0 -> 111616 bytes .../examples/ethernet/Ethernet_boot/simple.eth | 87 +++ .../examples/ethernet/Utilities/bconvert64x.c | 701 +++++++++++++++++++++ .../examples/ethernet/Utilities/bconvert64x.exe | Bin 0 -> 36864 bytes .../examples/ethernet/Utilities/bootpacket.c | 509 +++++++++++++++ .../examples/ethernet/Utilities/bootpacket.exe | Bin 0 -> 40960 bytes .../examples/ethernet/Utilities/bootpacket.h | 110 ++++ boot_loader/examples/ethernet/docs/README.txt | 62 ++ boot_loader/examples/ethernet/simple/makefile | 45 ++ boot_loader/examples/ethernet/simple/simple.bat | 4 + boot_loader/examples/ethernet/simple/simple.cmd | 41 ++ boot_loader/examples/ethernet/simple/simple.rmd | 15 + boot_loader/examples/ethernet/simple/simple.s | 96 +++ boot_loader/examples/i2c/emac/docs/README.txt | 54 -- .../examples/i2c/emac/evmc6670l/.ccsproject | 10 - boot_loader/examples/i2c/emac/evmc6670l/.cproject | 82 --- boot_loader/examples/i2c/emac/evmc6670l/.project | 96 --- .../i2c/emac/evmc6670l/i2c_boot_emac_example.cmd | 77 --- boot_loader/examples/i2c/emac/evmc6670l/macros.ini | 1 - .../examples/i2c/emac/evmc6678l/.ccsproject | 10 - boot_loader/examples/i2c/emac/evmc6678l/.cproject | 84 --- boot_loader/examples/i2c/emac/evmc6678l/.project | 96 --- .../i2c/emac/evmc6678l/i2c_boot_emac_example.cmd | 77 --- boot_loader/examples/i2c/emac/evmc6678l/macros.ini | 1 - .../examples/i2c/emac/src/i2c_boot_emac_example.c | 113 ---- boot_loader/examples/i2c/nand/docs/README.txt | 13 +- boot_loader/examples/i2c/nor/docs/README.txt | 13 +- boot_loader/examples/i2c/tftp/docs/README.txt | 59 ++ .../examples/i2c/tftp/evmc6670l/.ccsproject | 10 + boot_loader/examples/i2c/tftp/evmc6670l/.cproject | 81 +++ boot_loader/examples/i2c/tftp/evmc6670l/.project | 96 +++ .../i2c/tftp/evmc6670l/i2c_boot_tftp_example.cmd | 77 +++ boot_loader/examples/i2c/tftp/evmc6670l/macros.ini | 1 + .../examples/i2c/tftp/evmc6678l/.ccsproject | 10 + boot_loader/examples/i2c/tftp/evmc6678l/.cproject | 83 +++ boot_loader/examples/i2c/tftp/evmc6678l/.project | 96 +++ .../i2c/tftp/evmc6678l/i2c_boot_tftp_example.cmd | 77 +++ boot_loader/examples/i2c/tftp/evmc6678l/macros.ini | 1 + .../examples/i2c/tftp/src/i2c_boot_tftp_example.c | 113 ++++ boot_loader/tools_install.bat | 3 + 69 files changed, 2619 insertions(+), 3178 deletions(-) delete mode 100644 boot_loader/examples/emac/Ethernet_boot/README delete mode 100644 boot_loader/examples/emac/Ethernet_boot/pcsendpkt.c delete mode 100644 boot_loader/examples/emac/Ethernet_boot/pcsendpkt.exe delete mode 100644 boot_loader/examples/emac/Ethernet_boot/simple.eth delete mode 100644 boot_loader/examples/emac/Utilities/b2ccs.c delete mode 100644 boot_loader/examples/emac/Utilities/b2ccs.exe delete mode 100644 boot_loader/examples/emac/Utilities/b2i2c.c delete mode 100644 boot_loader/examples/emac/Utilities/b2i2c.exe delete mode 100644 boot_loader/examples/emac/Utilities/bconvert64x.c delete mode 100644 boot_loader/examples/emac/Utilities/bconvert64x.exe delete mode 100644 boot_loader/examples/emac/Utilities/bootpacket.c delete mode 100644 boot_loader/examples/emac/Utilities/bootpacket.exe delete mode 100644 boot_loader/examples/emac/Utilities/bootpacket.h delete mode 100644 boot_loader/examples/emac/Utilities/build-msvc.bat delete mode 100644 boot_loader/examples/emac/Utilities/mergebtbl.c delete mode 100644 boot_loader/examples/emac/Utilities/mergebtbl.exe delete mode 100644 boot_loader/examples/emac/Utilities/myparser.c delete mode 100644 boot_loader/examples/emac/Utilities/myparser.exe delete mode 100644 boot_loader/examples/emac/simple/makefile delete mode 100644 boot_loader/examples/emac/simple/simple.btbl delete mode 100644 boot_loader/examples/emac/simple/simple.cmd delete mode 100644 boot_loader/examples/emac/simple/simple.le.btbl delete mode 100644 boot_loader/examples/emac/simple/simple.map delete mode 100644 boot_loader/examples/emac/simple/simple.obj delete mode 100644 boot_loader/examples/emac/simple/simple.out delete mode 100644 boot_loader/examples/emac/simple/simple.rmd delete mode 100644 boot_loader/examples/emac/simple/simple.s create mode 100644 boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c create mode 100644 boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe create mode 100644 boot_loader/examples/ethernet/Ethernet_boot/simple.eth create mode 100644 boot_loader/examples/ethernet/Utilities/bconvert64x.c create mode 100644 boot_loader/examples/ethernet/Utilities/bconvert64x.exe create mode 100644 boot_loader/examples/ethernet/Utilities/bootpacket.c create mode 100644 boot_loader/examples/ethernet/Utilities/bootpacket.exe create mode 100644 boot_loader/examples/ethernet/Utilities/bootpacket.h create mode 100644 boot_loader/examples/ethernet/docs/README.txt create mode 100644 boot_loader/examples/ethernet/simple/makefile create mode 100644 boot_loader/examples/ethernet/simple/simple.bat create mode 100644 boot_loader/examples/ethernet/simple/simple.cmd create mode 100644 boot_loader/examples/ethernet/simple/simple.rmd create mode 100644 boot_loader/examples/ethernet/simple/simple.s delete mode 100644 boot_loader/examples/i2c/emac/docs/README.txt delete mode 100644 boot_loader/examples/i2c/emac/evmc6670l/.ccsproject delete mode 100644 boot_loader/examples/i2c/emac/evmc6670l/.cproject delete mode 100644 boot_loader/examples/i2c/emac/evmc6670l/.project delete mode 100644 boot_loader/examples/i2c/emac/evmc6670l/i2c_boot_emac_example.cmd delete mode 100644 boot_loader/examples/i2c/emac/evmc6670l/macros.ini delete mode 100644 boot_loader/examples/i2c/emac/evmc6678l/.ccsproject delete mode 100644 boot_loader/examples/i2c/emac/evmc6678l/.cproject delete mode 100644 boot_loader/examples/i2c/emac/evmc6678l/.project delete mode 100644 boot_loader/examples/i2c/emac/evmc6678l/i2c_boot_emac_example.cmd delete mode 100644 boot_loader/examples/i2c/emac/evmc6678l/macros.ini delete mode 100644 boot_loader/examples/i2c/emac/src/i2c_boot_emac_example.c create mode 100644 boot_loader/examples/i2c/tftp/docs/README.txt create mode 100644 boot_loader/examples/i2c/tftp/evmc6670l/.ccsproject create mode 100644 boot_loader/examples/i2c/tftp/evmc6670l/.cproject create mode 100644 boot_loader/examples/i2c/tftp/evmc6670l/.project create mode 100644 boot_loader/examples/i2c/tftp/evmc6670l/i2c_boot_tftp_example.cmd create mode 100644 boot_loader/examples/i2c/tftp/evmc6670l/macros.ini create mode 100644 boot_loader/examples/i2c/tftp/evmc6678l/.ccsproject create mode 100644 boot_loader/examples/i2c/tftp/evmc6678l/.cproject create mode 100644 boot_loader/examples/i2c/tftp/evmc6678l/.project create mode 100644 boot_loader/examples/i2c/tftp/evmc6678l/i2c_boot_tftp_example.cmd create mode 100644 boot_loader/examples/i2c/tftp/evmc6678l/macros.ini create mode 100644 boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c (limited to 'boot_loader') diff --git a/boot_loader/IBL_buildibl b/boot_loader/IBL_buildibl index 4d06619..c6cfa13 100644 --- a/boot_loader/IBL_buildibl +++ b/boot_loader/IBL_buildibl @@ -1,7 +1,20 @@ cd ibl/src/make source setupenvMsys.sh -make evm_c667x_i2c ENDIAN=little I2C_BUS_ADDR=0x51 +make evm_c6678_i2c ENDIAN=little I2C_BUS_ADDR=0x51 +cp -f ibl_c66x/i2crom.dat ../../../i2crom_0x51_c6678_le.dat +cp -f ../util/i2cConfig/i2cparam_c66x_le.out ../../../i2cparam_0x51_c6678_le_0x500.out +make clean + +make evm_c6670_i2c ENDIAN=little I2C_BUS_ADDR=0x51 +cp -f ibl_c66x/i2crom.dat ../../../i2crom_0x51_c6670_le.dat +cp -f ../util/i2cConfig/i2cparam_c66x_le.out ../../../i2cparam_0x51_c6670_le_0x500.out +make clean + +mv -f ../../../i2crom_0x51_c6678_le.dat bin/i2crom_0x51_c6678_le.dat +mv -f ../../../i2crom_0x51_c6670_le.dat bin/i2crom_0x51_c6670_le.dat +mv -f ../../../i2cparam_0x51_c6678_le_0x500.out bin/i2cparam_0x51_c6678_le_0x500.out +mv -f ../../../i2cparam_0x51_c6670_le_0x500.out bin/i2cparam_0x51_c6670_le_0x500.out cd ../../../ diff --git a/boot_loader/examples/emac/Ethernet_boot/README b/boot_loader/examples/emac/Ethernet_boot/README deleted file mode 100644 index acd5b86..0000000 --- a/boot_loader/examples/emac/Ethernet_boot/README +++ /dev/null @@ -1,18 +0,0 @@ -/****** Steps to send the image from the Host to the target DSP. ***********/ - -1. Boot the target the DSP in Ethernet boot mode. - -2. Once the DSP boots up, it transmits BOOTP packet at regular interval which will have the MAC id of the DSP. - -3. Create a image of the simple code in the simple folder using the "make simple.eth". - -4. The resulting simple.eth file is the desired image. - -5. Add an ARP entry for the DSP mac address associating with an IP local to the host. For example if the host PC's -IP is 192.168.1.1, then add an ARP entry with the DSP's MAC address associated with IP address 192.168.1.2. - -5. Use the pcsendpkt.exe to send the image to the DSP using the associated IP address. For example -pcsendpkt.exe simple.eth 192.168.1.2 - -6. In order to compile the pcsendpkt.c file please compile with -lwsock32 option for using windows socket. - diff --git a/boot_loader/examples/emac/Ethernet_boot/pcsendpkt.c b/boot_loader/examples/emac/Ethernet_boot/pcsendpkt.c deleted file mode 100644 index 587ca2f..0000000 --- a/boot_loader/examples/emac/Ethernet_boot/pcsendpkt.c +++ /dev/null @@ -1,177 +0,0 @@ -#include -#include -#include -#include - -#define UDP_LOW 42 -#define UDP_HIGH 1504 // Note: Windows FRAGMENTS higher UDP sizes - -#define SRCPORT 1234 -#define DSTPORT 9 - -#define DELAY 60000 - -/* convert ascii to decimal number */ -int toNum(unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return(c - '0'); - - else if ((c >= 'A') && (c <= 'F')) - return(c -'A' + 10); - - else if ((c >= 'a') && (c <= 'f')) - return(c - 'a' + 10); - - return(-1); -} - - -int main( int argc, char *argv[] ) -{ - WORD wVersionRequested; - WSADATA wsaData; - SOCKET s; - struct sockaddr_in sin; - unsigned char *pBuf = 0; - int tmp1,tmp2,tmp3,tmp4; - time_t ts,tn; - FILE *strin; - char iline[132]; - int i,j,length; - int packetno; - - if( (argc != 3) || - sscanf(argv[2],"%03d.%03d.%03d.%03d",&tmp1,&tmp2,&tmp3,&tmp4)!=4 || - (tmp1 < 0 || tmp1 > 255 || tmp2 < 0 || tmp2 > 255 || - tmp3 < 0 || tmp3 > 255 || tmp4 < 0 || tmp4 > 255) ) - { - printf("\nUsage: %s packetfile ipaddress\n",argv[0]); - exit(-1); - } - - tmp1 |= tmp2 << 8; - tmp1 |= tmp3 << 16; - tmp1 |= tmp4 << 24; - - strin = fopen (argv[1], "r"); - if (strin == NULL) { - printf ("could not open input file %s\n", argv[1]); - exit(-1); - } - - /* Skip the first two lines */ - fgets (iline, 131, strin); - fgets (iline, 131, strin); - - wVersionRequested = MAKEWORD(1, 1); - tmp2 = WSAStartup(wVersionRequested, &wsaData); - if (tmp2 != 0) - { - printf("\r\nUnable to initialize WinSock for host info"); - exit(0); - } - - s = socket( AF_INET, SOCK_DGRAM, 0 ); - if( s < 0 ) - { - printf("failed connect (%d)\n",WSAGetLastError()); - goto end; - } - - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = 0; - sin.sin_port = htons(SRCPORT); - - if ( bind( s, (struct sockaddr *)&sin, sizeof(sin) ) < 0 ) - { - printf("failed bind (%d)\n",WSAGetLastError()); - goto end; - } - - /* Allocate a working buffer */ - if( !(pBuf = malloc( 2000 )) ) - { - printf("failed packetno buffer allocation\n"); - goto end; - } - - sin.sin_addr.s_addr = tmp1; - sin.sin_port = htons(DSTPORT); - - ts = time(0); - - packetno = 0; - - printf("\nSending packets to %d.%d.%d.%d\n", - tmp1&255, (tmp1>>8)&255, (tmp1>>16)&255, (tmp1>>24)&255 ); - - while(1) - { - /* get length in bytes */ - if(fgets(iline, 131, strin)==NULL) break; - length = toNum(iline[2])<<12 | toNum(iline[3])<<8 | toNum(iline[4])<<4 | toNum(iline[5]); - if(length == 0) break; - else if(length < UDP_LOW || length > UDP_HIGH) { - printf("Invalid length = %d\n",length); - goto end; - } - - /* skip the next 21 lines, 14 mac + 20 IP + 8 UDP = 42 bytes = 21 lines */ - for(i=0; i<21; i++) { - if(fgets(iline,131,strin)==NULL) break; - } - - length -= 42; - if(length < 0) { - printf("Invalid length = %d\n",length); - goto end; - } - - /* copy the payload: magicno + seq no + boot table */ - for(i=0,j=0; i< length/2; i++) { - if(fgets(iline, 131, strin)==NULL) break; - - *(pBuf+j) = toNum(iline[2])<<4 | toNum(iline[3]); - j++; - *(pBuf+j) = toNum(iline[4])<<4 | toNum(iline[5]); - j++; - } - - /* send out the packet */ - if( sendto( s, pBuf, length, 0, (struct sockaddr *)&sin, sizeof(sin) ) < 0 ) - { - printf("send failed (%d)\n",WSAGetLastError()); - break; - } - - /* packet number */ - packetno++; - printf("Packet %d sent\n",packetno); - - /* add delay between packets */ - for(i=0; i= 0 ) - closesocket( s ); - - WSACleanup(); -} - diff --git a/boot_loader/examples/emac/Ethernet_boot/pcsendpkt.exe b/boot_loader/examples/emac/Ethernet_boot/pcsendpkt.exe deleted file mode 100644 index 4e7173d..0000000 Binary files a/boot_loader/examples/emac/Ethernet_boot/pcsendpkt.exe and /dev/null differ diff --git a/boot_loader/examples/emac/Ethernet_boot/simple.eth b/boot_loader/examples/emac/Ethernet_boot/simple.eth deleted file mode 100644 index fcbbb2c..0000000 --- a/boot_loader/examples/emac/Ethernet_boot/simple.eth +++ /dev/null @@ -1,87 +0,0 @@ -1651 1 890000 1 56 -0x0000 -0x00A2 -0x0008 -0x7433 -0x2630 -0x000D -0x5676 -0x2F1A -0x0800 -0x4500 -0x0094 -0x4567 -0x0000 -0x1011 -0x58CC -0x9EDA -0x674E -0x9EDA -0x6723 -0x0000 -0x0009 -0x0080 -0x0ED8 -0x544B -0x0100 -0x0081 -0x0000 -0x0000 -0x0040 -0x0081 -0x0000 -0x0099 -0xA228 -0x0088 -0x9168 -0x0101 -0x00A8 -0x0100 -0x40E8 -0x0108 -0x0226 -0x0181 -0x0828 -0x0180 -0x40E8 -0x018C -0x3626 -0x020C -0x0226 -0x0001 -0xA120 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0000 -0x0004 -0x0081 -0x0100 -0x1234 -0xABCD -0x0000 -0x0001 -0x0081 -0x0201 -0x1200 -0x0000 -0x0000 -0x0002 -0x0081 -0x0210 -0x1234 -0x0000 -0x0000 -0x0000 -0xEA00 -0x0000 -0x0000 diff --git a/boot_loader/examples/emac/Utilities/b2ccs.c b/boot_loader/examples/emac/Utilities/b2ccs.c deleted file mode 100644 index 61018be..0000000 --- a/boot_loader/examples/emac/Utilities/b2ccs.c +++ /dev/null @@ -1,164 +0,0 @@ -/* Convert a hex b file into a ccs data file */ - -#include -#include - - -int asciiByte (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (1); - - if ((c >= 'A') && (c <= 'F')) - return (1); - - return (0); -} - -int toNum (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (c - '0'); - - return (c - 'A' + 10); - -} - - -void stripLine (FILE *s) -{ - char iline[132]; - - fgets (iline, 131, s); - -} - -/* Read a .b file. */ -unsigned long readBFile (FILE *s, unsigned char *data, unsigned long maxSize) -{ - unsigned char x, y; - unsigned long byteCount = 0; - - /* Strip the 1st two lines */ - stripLine (s); - stripLine (s); - - for (;;) { - - /* read the 1st ascii char */ - do { - x = fgetc (s); - if (x == (unsigned char)EOF) - return (byteCount); - - } while (!asciiByte(x)); - - /* Read the next ascii char */ - y = fgetc (s); - if (y == (unsigned char)EOF) - return (byteCount); - if (asciiByte(y)) - data[byteCount++] = (toNum(x) << 4) | toNum (y); - - if (byteCount >= maxSize) { - fprintf (stderr, "Max input array size exceeded\n"); - return (-1); - } - } -} - - -unsigned dwordConvert (unsigned char *data, unsigned long idx, unsigned long iMax) -{ - unsigned value; - unsigned char c[4]; - int i; - - c[0] = c[1] = c[2] = c[3] = 0; - - for (i = 0; i < 4; i++) { - if (idx >= iMax) - break; - c[i] = data[idx++]; - } - - value = c[3] | (c[2] << 8) | (c[1] << 16) | (c[0] << 24); - - return (value); - -} - - - -#define SIZE (1024 * 1024 * 2) /* max array size 2MB */ - -int main (int argc, char *argv[]) -{ - FILE *strin; - FILE *strout; - - unsigned char *dataSet1; - - unsigned char block[128]; - unsigned blockSize; - - unsigned long pIn; - unsigned long pOut; - - unsigned long inSize; - unsigned long i; - - /* Arg check */ - if (argc != 3) { - fprintf (stderr, "usage: %s infile outfile\n", argv[0]); - return (-1); - } - - /* Open the input file */ - strin = fopen (argv[1], "r"); - if (strin == NULL) { - fprintf (stderr, "%s: Could not open file %s for reading\n", argv[0], argv[1]); - return (-1); - } - - /* Allocate the two data set memories */ - dataSet1 = malloc (SIZE * sizeof (unsigned char)); - if (dataSet1 == NULL) { - fprintf (stderr, "%s: Malloc failure\n", argv[0]); - return (-1); - } - - /* Read the data into the byte stream */ - if ((inSize = readBFile (strin, dataSet1, SIZE)) < 0) - return (inSize); - fclose (strin); - - strout = fopen (argv[2], "w"); - if (strout == NULL) { - fprintf (stderr, "%s error: Could not open output file %s\n", argv[0], argv[2]); - free (dataSet1); - return (-1); - } - - /* Write the CCS header */ - fprintf (strout, "1651 1 10000 1 %x\n", (inSize + 3) / 4); - - /* Write out each 32 bit line. */ - for (i = 0; i < inSize; i += 4) - fprintf (strout, "0x%08x\n", dwordConvert (dataSet1, i, inSize)); - - free (dataSet1); - fclose (strout); - - - return (0); - -} - - - - - - - - diff --git a/boot_loader/examples/emac/Utilities/b2ccs.exe b/boot_loader/examples/emac/Utilities/b2ccs.exe deleted file mode 100644 index b11083e..0000000 Binary files a/boot_loader/examples/emac/Utilities/b2ccs.exe and /dev/null differ diff --git a/boot_loader/examples/emac/Utilities/b2i2c.c b/boot_loader/examples/emac/Utilities/b2i2c.c deleted file mode 100644 index 54e2a95..0000000 --- a/boot_loader/examples/emac/Utilities/b2i2c.c +++ /dev/null @@ -1,226 +0,0 @@ -/* Create an ascii hex i2c data file */ - -#include -#include - -unsigned onesComplementAdd (unsigned value1, unsigned value2) -{ - unsigned result; - - result = (unsigned)value1 + (unsigned)value2; - - result = (result >> 16) + (result & 0xFFFF); /* add in carry */ - result += (result >> 16); /* maybe one more */ - result = (result & 0xffff); - return (unsigned)result; - -} /* end of beth_ones_complement_add() */ - - -int asciiByte (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (1); - - if ((c >= 'A') && (c <= 'F')) - return (1); - - return (0); -} - -int toNum (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (c - '0'); - - return (c - 'A' + 10); - -} - - -void stripLine (FILE *s) -{ - char iline[132]; - - fgets (iline, 131, s); - -} - -/* Read a .b file. */ -unsigned long readBFile (FILE *s, unsigned char *data, unsigned long maxSize) -{ - unsigned char x, y; - unsigned long byteCount = 0; - - /* Strip the 1st two lines */ - stripLine (s); - stripLine (s); - - for (;;) { - - /* read the 1st ascii char */ - do { - x = fgetc (s); - if (x == (unsigned char)EOF) - return (byteCount); - - } while (!asciiByte(x)); - - /* Read the next ascii char */ - y = fgetc (s); - if (y == (unsigned char)EOF) - return (byteCount); - if (asciiByte(y)) - data[byteCount++] = (toNum(x) << 4) | toNum (y); - - if (byteCount >= maxSize) { - fprintf (stderr, "Max input array size exceeded\n"); - return (-1); - } - } -} - - -int copyBlock (unsigned char *source, unsigned long idx, unsigned long maxSize, - unsigned char *dest, unsigned long count) -{ - unsigned long i; - - for (i = 0; i < count; i++) { - if (idx >= maxSize) - break; - - dest[i] = source[idx++]; - } - - return (i); - -} - -void blockCheckSum (unsigned char *block, unsigned long blockSize) -{ - unsigned checksum = 0; - unsigned value; - unsigned long i; - - if (blockSize & 0x0001) { - fprintf (stderr, "program requires an even blocksize\n"); - exit (-1); - } - - for (i = 0; i < blockSize; i += 2) { - value = (block[i] << 8) | block[i+1]; - checksum = onesComplementAdd (checksum, value); - } - - /* Put the checksum into the block starting at byte 2. Use big endian */ - checksum = ~checksum; - block[3] = checksum & 0xff; - block[2] = (checksum >> 8) & 0xff; - -} - -#define SIZE (1024 * 1024 * 2) /* max array size 2MB */ - -int main (int argc, char *argv[]) -{ - FILE *strin; - FILE *strout; - - unsigned char *dataSet1; - unsigned char *dataSet2; - - unsigned char block[128]; - unsigned blockSize; - - unsigned long pIn; - unsigned long pOut; - - unsigned long inSize; - unsigned long i; - - /* Arg check */ - if (argc != 3) { - fprintf (stderr, "usage: %s infile outfile\n", argv[0]); - return (-1); - } - - /* Open the input file */ - strin = fopen (argv[1], "r"); - if (strin == NULL) { - fprintf (stderr, "%s: Could not open file %s for reading\n", argv[0], argv[1]); - return (-1); - } - - /* Allocate the two data set memories */ - dataSet1 = malloc (SIZE * sizeof (unsigned char)); - dataSet2 = malloc (SIZE * sizeof (unsigned char)); - if ((dataSet1 == NULL) || (dataSet2 == NULL)) { - fprintf (stderr, "%s: Malloc failure\n", argv[0]); - return (-1); - } - - /* Read the data into the byte stream */ - if ((inSize = readBFile (strin, dataSet1, SIZE)) < 0) - return (inSize); - fclose (strin); - - /* Perform the i2c block formatting. The block size will be fixed at 128 bytes, - * 2 bytes of length, 2 bytes checksum, 124 bytes of data. */ - pIn = 0; - pOut = 0; - - do { - - /* Copy the block, leave 4 bytes at the top */ - blockSize = copyBlock (dataSet1, pIn, inSize, &block[4], 124); - pIn += blockSize; /* advance to next data in source */ - - if (blockSize) { - blockSize += 4; /* Add room for the header - big endian */ - block[1] = blockSize & 0xff; - block[0] = (blockSize >> 8) & 0xff; - block[2] = block[3] = 0; - - /* Checksum the block */ - blockCheckSum (block, blockSize); - - /* Copy the results to the destination block */ - if ((pOut + blockSize) >= SIZE) { - fprintf (stderr, "%s: destination array size exceeded\n", argv[0]); - return (-1); - } - for (i = 0; i < blockSize; i++) - dataSet2[pOut++] = block[i]; - } - - } while (blockSize == 128); - - - /* Copy the resulting data set into the output file in ccs format */ - strout = fopen (argv[2], "w"); - if (strout == NULL) { - fprintf (stderr, "%s: Could not open %s for writing\n", argv[0], argv[2]); - return (-1); - } - - - /* Write the two line header */ - fprintf (strout, "%c\n$A000000\n", (unsigned char)2); - - /* Write out the data */ - for (i = 0; i < pOut; i++) { - if ( ((i+1)%24) ) - fprintf (strout, "%02X ", dataSet2[i]); - else - fprintf (strout, "%02X\n", dataSet2[i]); - } - - /* Write the close character */ - fprintf (strout, "\n%c", (unsigned char)3); - - fclose (strout); - - return (0); - -} diff --git a/boot_loader/examples/emac/Utilities/b2i2c.exe b/boot_loader/examples/emac/Utilities/b2i2c.exe deleted file mode 100644 index a1d1822..0000000 Binary files a/boot_loader/examples/emac/Utilities/b2i2c.exe and /dev/null differ diff --git a/boot_loader/examples/emac/Utilities/bconvert64x.c b/boot_loader/examples/emac/Utilities/bconvert64x.c deleted file mode 100644 index 98b0dfd..0000000 --- a/boot_loader/examples/emac/Utilities/bconvert64x.c +++ /dev/null @@ -1,668 +0,0 @@ -/************************************************************************************ - * FILE PURPOSE: Convert a hex6x boot table file into the format required - * by the c6x chip boot loader. - ************************************************************************************ - * FILE NAME: bconvert.c - * - * DESCRIPTION: Converts a boot table. The boot table format is: - * - * /--------------------------------------------------------\ - * | 32 bit entry point address | - * +--------------------------------------------------------+ - * | 32 bit section byte count | \ - * +--------------------------------------------------------+ \ - * | 32 bit section byte start address | \ - * +-------------+-------------+-------------+--------------+ repeat each section - * | Data byte | Data byte | Data byte | Data byte | / - * +-------------+-------------+-------------+--------------+ / - * | Data byte | Data byte | Data byte | Data byte | / - * +-------------+-------------+-------------+--------------+ - * | 32 bit zero byte count (end of boot table) | - * \--------------------------------------------------------/ - * - * - * The C6x boot loader expects all 32 bit values to be in big endian - * (most significant byte arrives first). Data bytes are also arranged to be 32 bit - * big endian represented. - * - * This program handles conversion of data values that are in sections that are - * not multiples of 4 bytes. For example, a program compiled in big endian format - * with a 1 byte section will have the following table entry (address 0x22222222), value - * 0x33 - * - * 00 00 00 01 22 22 22 22 33 00 00 00 - * - * The same file compiled with little endian mode will have the entry - * - * 00 00 00 01 22 22 22 22 00 00 00 33 - * - * - * Since the boot loader has no idea what endianness the code was compiled for, this - * program performs an endian conversion on any section that does not have a length - * that is a multiple of 4 bytes, if the little endian option is specified. Nothing - * is changed for the big endian mode. - * - * Invokation: - * - * bconvert -be|-le [input_file] [output_file] - * - ***************************************************************************************/ - -#include "stdio.h" -#include "malloc.h" -#include "string.h" - -/* Global variable storing the invokation name */ -char *invok; - -/* Error values */ -enum { - ERR_PARSE_TOO_MANY_ARGS = 1000, - ERR_PARSE_NO_ENDIAN, - ERR_PARSE_INPUT_OPEN_FAIL, - ERR_PARSE_OUTPUT_OPEN_FAIL, - ERR_READ_BFILE_INITIAL_MALLOC_FAIL, - ERR_READ_BFILE_REALLOC_FAIL, - ERR_VALUE32_SIZE_ERR, - ERR_VALUE16_SIZE_ERR, - ERR_DATA32_SIZE_ERR, - ERR_REG32_PARSE_ERROR, - ERR_DATA32_REMAIN_ERR -}; - -enum { - LITTLE, - BIG -}; - -/************************************************************************************ - * FUNTION PURPOSE: Send an error string - ************************************************************************************ - * DESCRIPTION: Prints an error to stderr - ************************************************************************************/ -void showErr (int errflag) -{ - char *s; - - switch (errflag) { - case ERR_PARSE_TOO_MANY_ARGS: - s = "Parse error: too many args specified"; - break; - - case ERR_PARSE_NO_ENDIAN: - s = "Parse error: no endian mode specified"; - break; - - case ERR_PARSE_INPUT_OPEN_FAIL: - s = "File error: failed to open specified input file"; - break; - - case ERR_PARSE_OUTPUT_OPEN_FAIL: - s = "File error: Failed to open specified output file"; - break; - - case ERR_READ_BFILE_INITIAL_MALLOC_FAIL: - s = "Memory error: Initial malloc call failed"; - break; - - case ERR_READ_BFILE_REALLOC_FAIL: - s = "Memory error: Subsequent realloc call failed"; - break; - - case ERR_VALUE32_SIZE_ERR: - s = "Data format error: End of data on 32 bit value read"; - break; - - case ERR_VALUE16_SIZE_ERR: - s = "Data format error: End of data on 16 bit value read"; - break; - - case ERR_REG32_PARSE_ERROR: - s = "Parse error: error parsing after reg32 arg"; - break; - - case ERR_DATA32_REMAIN_ERR: - s = "Parse error: A remainder size greater then four was found"; - break; - - default: - s = "Unspecified error"; - break; - - } - - fprintf (stderr, "%s: %s\n", invok, s); - -} /* showErr */ - - -/************************************************************************************* - * FUNCTION PURPOSE: Check if a string is prefixed with "0x". - ************************************************************************************* - * DESCRIPTION: Returns non-zero if the string begins with "0x" - *************************************************************************************/ -int isChex (char *s) -{ - if ((s[0] == '0') && (s[1] == 'x')) - return (1); - - return (0); - -} /* isChex */ - - - -/************************************************************************************* - * FUNCTION PURPOSE: Parse the input parameters - ************************************************************************************* - * DESCRIPTION: Checks for required args, opens source and destination streams. - *************************************************************************************/ -int parseit (int argc, char *argv[], FILE **fin, FILE **fout, int *endian) -{ - int inspec = 0; - int outspec = 0; - int espec = 0; - int c = 1; - - char *iname; - char *oname; - - *endian = -1; - - /* Store the invokation name */ - invok = argv[0]; - - while (c < argc) { - - /* -be | -le */ - if (!espec) { - if (!strcmp (argv[c], "-be")) { - *endian = BIG; - espec = 1; - c += 1; - continue; - } else if (!strcmp (argv[c], "-le")) { - *endian = LITTLE; - espec = 1; - c += 1; - continue; - } - } - - - /* input file */ - if (!inspec) { - inspec = 1; - iname = argv[c]; - c += 1; - continue; - } - - /* output file */ - if (!outspec) { - outspec = 1; - oname = argv[c]; - c += 1; - continue; - } - - /* Don't know what to do with the arg */ - return (ERR_PARSE_TOO_MANY_ARGS); - - } - - - /* Make sure endian is known */ - if (!espec) - return (ERR_PARSE_NO_ENDIAN); - - /* Open input file if not stdin */ - if (inspec) { - *fin = fopen (iname, "r"); - if (*fin == NULL) - return (ERR_PARSE_INPUT_OPEN_FAIL); - } - - /* Open output file if not stdin */ - if (outspec) { - *fout = fopen (oname, "w"); - if (*fout == NULL) - return (ERR_PARSE_OUTPUT_OPEN_FAIL); - } - - return (0); - -} /* parseit */ - - - -/*************************************************************************************** - * FUNCTION PURPOSE: Check if data is ascii - *************************************************************************************** - * DESCRIPTION: Returns 1 if a byte is 0-9, a-f, 0 otherwise - ***************************************************************************************/ -int asciiByte (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (1); - - if ((c >= 'A') && (c <= 'F')) - return (1); - - return (0); -} /* asciiByte */ - -/************************************************************************************** - * FUNCTION PURPOSE: Returns the binary equivalent of an ascii byte - ************************************************************************************** - * DESCRIPTION: Conversion from ascii to binary - **************************************************************************************/ -int toNum (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (c - '0'); - - return (c - 'A' + 10); - -} /* toNum */ - - -/********************************************************************************** - * FUNCTION PURPOSE: Read a line from a file, toss it - ********************************************************************************** - * DESCRIPTION: Reads a line, including the newline character, and throws it away. - **********************************************************************************/ -void stripLine (FILE *s) -{ - char iline[132]; - - fgets (iline, 131, s); - -} /* stripLine */ - -/************************************************************************************ - * FILE PURPOSE: Read the hex55 data file - ************************************************************************************ - * DESCRIPTION: Reads the input data file. Strips the first two lines, reads - * the byte stream. - ************************************************************************************/ -#define MALLOC_BLOCK_SIZE 512000 -unsigned char *readBFile (FILE *fin, unsigned *n, int *errcode) -{ - unsigned char *d; - unsigned allocSize; - unsigned m; - unsigned char x, y; - - /* Create a block of data */ - allocSize = MALLOC_BLOCK_SIZE; - d = malloc (allocSize * sizeof (unsigned char)); - if (d == NULL) { - *errcode = ERR_READ_BFILE_INITIAL_MALLOC_FAIL; - if (fin != stdin) - fclose (fin); - return (NULL); - } - - /* Strip the 1st two lines */ - stripLine (fin); - stripLine (fin); - - *errcode = 0; - m = 0; - - for (;;) { - - /* Read the 1st ascii char */ - do { - x = fgetc (fin); - if (x == (unsigned char)EOF) { - *errcode = 0; - *n = m; - if (fin != stdin) - fclose (fin); - return (d); - } - } while (!asciiByte(x)); - - /* Read the next ascii char */ - y = fgetc(fin); - if (y == (unsigned char)EOF) { - *errcode = 0; - *n = m; - if (fin != stdin) - fclose (fin); - return (d); - } - - /* Convert the two characters into a byte */ - if (asciiByte(y)) - d[m++] = (toNum(x) << 4) | toNum(y); - - /* Verify memory bounds */ - if (m >= allocSize) { - allocSize += MALLOC_BLOCK_SIZE; - d= realloc (d, allocSize); - if (d== NULL) { - *errcode = ERR_READ_BFILE_REALLOC_FAIL; - if (fin != stdin) - fclose (fin); - return (NULL); - } - } - - } /* end for */ - -} /* readBFile */ - -/************************************************************************************** - * FUNCTION PURPOSE: converts four bytes into an unsigned value - ************************************************************************************** - * DESCRIPTION: Converts bytes to a value - **************************************************************************************/ -unsigned value32bitAdd (int endian, unsigned char *data, unsigned n, unsigned *p, int *errflag, unsigned add) -{ - unsigned v; - unsigned w; - unsigned q; - - /* Verify that there are 4 values still in the character array */ - if ((*p + 4) > n) { - *errflag = ERR_VALUE32_SIZE_ERR; - return (0); - } - - /* Store the original pointer */ - q = w = *p; - - v = (unsigned)data[w+0] << 24 | - (unsigned)data[w+1] << 16 | - (unsigned)data[w+2] << 8 | - (unsigned)data[w+3] << 0 ; - - *errflag = 0; - - /* Add any additional value */ - v = v + add; - - /* Write the data back in big endian format */ - data[q+0] = (v >> 24) & 0xff; - data[q+1] = (v >> 16) & 0xff; - data[q+2] = (v >> 8) & 0xff; - data[q+3] = (v >> 0) & 0xff; - - *p = q+4; - return (v); - -} /* value32bitAdd */ - -/************************************************************************************** - * FUNCTION PURPOSE: converts four bytes into an unsigned value - ************************************************************************************** - * DESCRIPTION: Converts bytes to a value, depending on the endian configuration. - **************************************************************************************/ -unsigned value32bit (int endian, unsigned char *data, unsigned n, unsigned *p, int *errflag) -{ - return (value32bitAdd (endian, data, n, p, errflag, 0)); - -} /* value32bit */ - - - - -/********************************************************************************* - * FUNCTION PURPOSE: Convert up to four bytes to big endian - ********************************************************************************* - * DESCRIPTION: Data bytes are converted. - *********************************************************************************/ -#define SWAP(x,y,z) (z)=(x);(x)=(y);(y)=(z) -void data32bit (int endian, unsigned char *data, unsigned n, unsigned *p, unsigned m, int *errflag) -{ - - /* Calculate the number of bytes to convert, limited to four bytes */ - if (m > 4) - m = 4; - - /* return an error if there are not enough values in the array */ - if ((*p + m) >= n) { - *errflag = ERR_DATA32_SIZE_ERR; - return; - } - - /* Clear the error flag */ - *errflag = 0; - - - /* The data is always already in big endian, there is nothing to do but advance the pointer */ - *p += m; - -} /* data32bit */ - -void remain32bit (int endian, unsigned char *data, unsigned n, unsigned *p, unsigned m, int *errflag) -{ - unsigned w; - unsigned char h; - - /* return an error if the size is greater then or equal to 4 */ - if (m >= 4) { - *errflag = ERR_DATA32_REMAIN_ERR; - return; - } - - /* return an error if there are not enough values in the array */ - if ((*p + m) >= n) { - *errflag = ERR_DATA32_SIZE_ERR; - return; - } - - w = *p; - - /* Only swap if endianness is little */ - if (endian == LITTLE) { - /* Swap the next four bytes */ - SWAP(data[w+0], data[w+3], h); - SWAP(data[w+1], data[w+2], h); - } - - /* Update the full four elements */ - *p = *p + 4; - - -} /* remain32bit */ - - -/********************************************************************************* - * FUNCTION PURPOSE: Convert 2 bytes into an unsigned value - ********************************************************************************* - * DESCRIPTION: Converts the next two bytes into an unsigned value based on - * the endian configuration. - *********************************************************************************/ -unsigned value16bit (int endian, unsigned char *data, unsigned n, unsigned *p, int *errflag) -{ - unsigned v; - unsigned q; - - /* Verify that there are 4 values still in the character array */ - if ((*p + 2) > n) { - *errflag = ERR_VALUE16_SIZE_ERR; - return (0); - } - - /* Store the original pointer */ - q = *p; - - /* convert based on endianness. For little endain the 16 bit words are actually - * big endian, but the bytes in those words are not */ - if (endian == BIG) { - v = data[(*p)++] << 8 | - data[(*p)++] << 0 ; - - } else { - v = data[(*p)++] << 0 | - data[(*p)++] << 8 ; - } - - *errflag = 0; - - /* Write the data back in big endian format */ - data[q++] = (v >> 8) & 0xff; - data[q++] = (v >> 0) & 0xff; - - return (v); - -} /* value16bit */ - -/************************************************************************************** - * FUNCTION PURPOSE: Writes a 16 bit value into the array - ************************************************************************************** - * DESCRIPTION: Writes a big endian 16 bit value, increments the array pointer. - **************************************************************************************/ -void write16bit (unsigned value, unsigned char *data, unsigned *p) -{ - data[(*p)++] = (value >> 8) & 0xff; - data[(*p)++] = (value >> 0) & 0xff; - -} /* write16bit */ - - -/************************************************************************************* - * FUNCTION PURPOSE: Write the output file - ************************************************************************************* - * DESCRIPTION: Writes the resulting output. - *************************************************************************************/ -void writeBFile (FILE *fout, unsigned char *data, unsigned n) -{ - unsigned i; - - /* Write the two line header */ - fprintf (fout, "%c\n$A000000\n", (unsigned char)2); - - for (i = 0; i < n; i++) { - if ( ((i+1)%24) ) - fprintf (fout, "%02X ", data[i]); - else - fprintf (fout, "%02X\n", data[i]); - } - - /* Write the close character */ - fprintf (fout, "\n%c", (unsigned char)3); - - if (fout != stdout) - fclose (fout); - -} /* writeBFile */ - - -/************************************************************************************** - * FUNCTION PURPOSE: Main - ************************************************************************************** - * DESCRIPTION: Provides the top level program flow. - **************************************************************************************/ -int main (int argc, char *argv[]) -{ - FILE *fin; /* input stream */ - FILE *fout; /* output stream */ - - unsigned char *data; /* The data set */ - unsigned n; /* Data set size */ - unsigned p; /* Data index */ - unsigned v; /* Data value */ - unsigned n32; /* Number of bytes that form complete 32 bit values */ - unsigned r32; /* Number of bytes remaining (0-3) */ - - int endian; /* Endian */ - int errflag; /* error indicator */ - int i, j; /* loop var */ - int origRegs; /* original reg count */ - int shift; /* data shift amount */ - - - /* Parse the input */ - if (errflag = parseit (argc, argv, &fin, &fout, &endian)) { - showErr (errflag); - return (-1); - } - - /* Read the raw data file */ - data = readBFile (fin, &n, &errflag); - if (data == NULL) { - showErr (errflag); - return(-1); - } - - /* Parse the sections */ - p = 0; - - /* The entry point */ - v = value32bit (endian, data, n, &p, &errflag); - if (errflag) { - showErr (errflag); - return(-1); - } - - - /* The sections */ - do { - - /* Get the section byte count */ - v = value32bit (endian, data, n, &p, &errflag); - if (errflag) { - showErr (errflag); - return(-1); - } - - if (v) { - /* Convert the start address (adjusts the array index) */ - value32bit (endian, data, n, &p, &errflag); - if (errflag) { - showErr (errflag); - return(-1); - } - } - - /* Determine how many bytes form complete 32 bit fields, and how many are left over */ - n32 = v & 0xfffffffc; - r32 = v & 0x00000003; - - /* Convert the data to big endian format */ - for (i = 0; i < n32; i += 4) { - data32bit (endian, data, n, &p, v-i, &errflag); - if (errflag) { - showErr (errflag); - return (-1); - } - } - - /* Convert any remaining bytes. */ - if (r32) { - remain32bit (endian, data, n, &p, r32, &errflag); - if (errflag) { - showErr (errflag); - return (-1); - } - } - - } while (v); - - /* Write out the data file */ - writeBFile (fout, data, n); - - /* Return resources */ - free (data); - - return (0); - -} - - - - - - - - - - - - - diff --git a/boot_loader/examples/emac/Utilities/bconvert64x.exe b/boot_loader/examples/emac/Utilities/bconvert64x.exe deleted file mode 100644 index f17b5f7..0000000 Binary files a/boot_loader/examples/emac/Utilities/bconvert64x.exe and /dev/null differ diff --git a/boot_loader/examples/emac/Utilities/bootpacket.c b/boot_loader/examples/emac/Utilities/bootpacket.c deleted file mode 100644 index e11d4f5..0000000 --- a/boot_loader/examples/emac/Utilities/bootpacket.c +++ /dev/null @@ -1,478 +0,0 @@ -/* Convert a boot table to Ethernet boot format */ -/* A simple utility program written by D.Zhou */ -/* Version: 0.3 */ -/* Last modified on: June 14,2006 */ - - -#include -#include -#include -#include "bootpacket.h" - -unsigned int line=0; - - - -void writeheader(FILE *s, INT16* pdata) -{ - int i; - - for (i = 0; i < TOTAL_HEADER_LEN/2; i++) - fprintf (s, "0x%04X\n",(unsigned short int)(*pdata++)); -} - - -void writeboottable(FILE *s, INT16* pdata, int size) -{ - int i; - - for (i = 0; i < size; i++) - fprintf (s, "0x%04X\n",(unsigned short int)(*pdata++)); -} - - -void stripLine (FILE *s) -{ - char iline[132]; - - fgets (iline, 131, s); - -} - - -int asciiByte (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (1); - - if ((c >= 'A') && (c <= 'F')) - return (1); - - return (0); -} - - -int toNum (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (c - '0'); - - return (c - 'A' + 10); - -} - -int toNumMAC (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return(c - '0'); - - else if ((c >= 'A') && (c <= 'F')) - return(c -'A' + 10); - - else if ((c >= 'a') && (c <= 'f')) - return(c - 'a' + 10); - - else if(c == ':') - return(100); - - return(200); -} - - - -/* Read the file size in bytes*/ -int getFileSize (FILE *s) -{ - unsigned char x, y; - unsigned int byteCount = 0; - - /* Strip the 1st two lines */ - stripLine (s); - stripLine (s); - - for (;;) { - - /* read the 1st ascii char */ - do { - x = fgetc (s); - if (x == (unsigned char)EOF) - return (byteCount); - - } while (!asciiByte(x)); - - /* Read the next ascii char */ - y = fgetc (s); - if (y == (unsigned char)EOF) - return (byteCount); - if (asciiByte(y)) - byteCount++; - } -} - - - -int getDataIn(FILE *s, int size_bytes, unsigned short int *output) -{ - int i; - unsigned char x, y; - unsigned char c[2]; - - for(i= 0; i< size_bytes/2; i++) { - c[0] = 0; - c[1] = 0; - - /* read the 1st ascii char */ - do { - x = fgetc (s); - if (x == (unsigned char)EOF) { - printf("file parsing error\n"); - return(-1); - } - } while (!asciiByte(x)); - - - /* Read the next ascii char */ - y = fgetc (s); - if (y == (unsigned char)EOF) { - printf("file parsing error\n"); - return(-1); - } - - if (asciiByte(y)) { - c[0] = (toNum(x) << 4) | toNum (y); - } - - do { - x = fgetc (s); - if (x == (unsigned char)EOF) { - printf("file parsing error\n"); - return(-1); - } - } while (!asciiByte(x)); - - - /* Read the next ascii char */ - y = fgetc (s); - if (y == (unsigned char)EOF) { - printf("file parsing error\n"); - return(-1); - } - - if (asciiByte(y)) { - c[1] = (toNum(x) << 4) | toNum (y); - } - - *output++ = (c[0] << 8) | c[1] ; - line++; - } - return(0); -} - - - -UINT16 bootmiscOnesComplementAdd (UINT16 value1, UINT16 value2) -{ - UINT32 result; - - result = (UINT32)value1 + (UINT32)value2; - - result = (result >> 16) + (result & 0xFFFF); /* add in carry */ - result += (result >> 16); /* maybe one more */ - return (UINT16)result; -} - - - -/* Description: Calculate an Internet style one's complement checksum */ - UINT16 bootmiscOnesComplementChksum (UINT16 base, UINT16 *p_data, UINT16 len) -{ - UINT16 chksum = base; - - while (len > 0) - { - chksum = bootmiscOnesComplementAdd(chksum,*p_data); - p_data++; - len--; - } - return ((unsigned short) ~chksum); -} - - - -/* - Input file format: boot table in big endian format - - Output file format: - - 1st line: CCS data format - 2nd line: 0x0000 - 3rd line: length of first packet in bytes, length counts not include itself - ....... - first packet - ....... - - 0xEA00 - 0x0000 - length of the second packet in bytes, length counts not include itself - ....... - second packet - ....... - - - 0xEA00 - 0x0000 - length of the other packet in bytes, length counts not include itself - ....... - other packets - ....... - - 0xEA00 - 0X0000 - 0X0000: end of the file -*/ - -struct BootPacket data; - - -void main (int argc, char *argv[]) -{ - UINT32 j; - UINT32 inSize; - UINT32 counter; - UINT16 UDPchecksum; - FILE *strin, *strout; - UINT32 temp; - unsigned int MACaddr[6]; - - /* Arg check */ - if (argc <3 || argc> 5) { - fprintf (stderr, "usage: %s infile outfile\n\n", argv[0]); - fprintf (stderr, "To generates the same result as bt-pkt.exe\n"); - fprintf (stderr, "usage: %s infile outfile btpkt\n\n", argv[0]); - fprintf (stderr, "To use your own MAC address\n"); - fprintf (stderr, "usage: %s infile outfile dstMAC srcMAC\n", argv[0]); - return; - } - - strin = fopen(argv[1],"rb"); - if(strin == NULL){ - fprintf (stderr, "%s: Could not open file %s for reading\n", argv[0], argv[1]); - return; - } - - /* Get the file size of data file */ - inSize = getFileSize (strin); - printf("File size = %d bytes.\n",inSize); - fclose (strin); - strin = fopen(argv[1],"rb"); - /* Strip the 1st two lines */ - stripLine (strin); - stripLine (strin); - - strout = fopen(argv[2],"w"); - if(strout == NULL) { - fprintf (stderr, "%s error: Could not open output file %s\n", argv[0], argv[2]); - return; - } - - - // MAC header, 14 bytes - if(argc == 5) { - - /* get destination MAC address */ - if((sscanf(argv[3],"%02x-%02x-%02x-%02x-%02x-%02x",&MACaddr[0],&MACaddr[1], \ - &MACaddr[2],&MACaddr[3],&MACaddr[4],&MACaddr[5])!=6) || \ - (MACaddr[0] < 0 || MACaddr[0] > 255 || \ - MACaddr[1] < 0 || MACaddr[1] > 255 || \ - MACaddr[2] < 0 || MACaddr[2] > 255 || \ - MACaddr[3] < 0 || MACaddr[3] > 255 || \ - MACaddr[4] < 0 || MACaddr[4] > 255 || \ - MACaddr[5] < 0 || MACaddr[5] > 255) ) { - - printf("Error in dstMAC address\n"); - fclose(strin); - fclose(strout); - return; - } - - data.dstMAC_H = (unsigned short)(MACaddr[0]<<8 | MACaddr[1]); - data.dstMAC_M = (unsigned short)(MACaddr[2]<<8 | MACaddr[3]); - data.dstMAC_L = (unsigned short)(MACaddr[4]<<8 | MACaddr[5]); - - /* get source MAC address */ - if((sscanf(argv[4],"%02x-%02x-%02x-%02x-%02x-%02x",&MACaddr[0],&MACaddr[1], \ - &MACaddr[2],&MACaddr[3],&MACaddr[4],&MACaddr[5])!=6) || \ - (MACaddr[0] < 0 || MACaddr[0] > 255 || \ - MACaddr[1] < 0 || MACaddr[1] > 255 || \ - MACaddr[2] < 0 || MACaddr[2] > 255 || \ - MACaddr[3] < 0 || MACaddr[3] > 255 || \ - MACaddr[4] < 0 || MACaddr[4] > 255 || \ - MACaddr[5] < 0 || MACaddr[5] > 255) ) { - - printf("Error in srcMAC address\n"); - fclose(strin); - fclose(strout); - return; - } - - data.srcMAC_H = (unsigned short)(MACaddr[0]<<8 | MACaddr[1]); - data.srcMAC_M = (unsigned short)(MACaddr[2]<<8 | MACaddr[3]); - data.srcMAC_L = (unsigned short)(MACaddr[4]<<8 | MACaddr[5]); - - } else { /* use default MAC address */ - data.dstMAC_H = (unsigned short)DST_MAC_H; - data.dstMAC_M = (unsigned short)DST_MAC_M; - data.dstMAC_L = (unsigned short)DST_MAC_L; - data.srcMAC_H = (unsigned short)SRC_MAC_H; - data.srcMAC_M = (unsigned short)SRC_MAC_M; - data.srcMAC_L = (unsigned short)SRC_MAC_L; - } - data.EtherType = ETHER_TYPE_IP; - - // IP header, 20 bytes - data.VerTOS = 0x4500; - data.IPlength = 0x0000; - data.ID = 0x4567; - data.FlagsFrag = 0x0000; - data.TTLProtocol = 0x1000 | IP_TYPE_UDP; - data.IPchecksum = 0x0000; - data.srcIPAddr_H = (unsigned short)SRC_IP_ADDR_H; - data.srcIPAddr_L = (unsigned short)SRC_IP_ADDR_L; - data.dstIPAddr_H = (unsigned short)DST_IP_ADDR_H; - data.dstIPAddr_L = (unsigned short)DST_IP_ADDR_L; - - // UDP header, 8 bytes - if(argc != 4) { - data.srcPort = (unsigned short)UDP_SRC_PORT; - } else { - data.srcPort = (unsigned short)UDP_SRC_PORT_BTPKT; - } - data.dstPort = (unsigned short)UDP_DST_PORT; - data.UDPlength = 0x0000; - data.UDPchecksum = 0x0000; - - // Payload header, 4 bytes - data.MagicNo = MAGICNO; - data.SeqNo = 0x100; - - memset(&data.BootTable,0, sizeof(data.BootTable)); - - counter = inSize / MAX_BOOTTBL_LEN; // calculate how many packets - - // If there is only one packet - if(counter <=1) { - data.UDPlength = UDP_HEADER_LEN + BOOTTBL_HEADER_LEN + inSize; - - data.IPlength = data.UDPlength + IP_HEADER_LEN; - data.IPchecksum=bootmiscOnesComplementChksum(0,&data.VerTOS,IP_HEADER_LEN/2); - - if(getDataIn(strin, inSize, data.BootTable)!=0) { - fclose(strin); - fclose(strout); - return; - } - - UDPchecksum = bootmiscOnesComplementAdd(IP_TYPE_UDP, data.UDPlength); - data.UDPchecksum=bootmiscOnesComplementChksum(UDPchecksum, &data.srcIPAddr_H,\ - (UINT16)((4+4+UDP_HEADER_LEN+BOOTTBL_HEADER_LEN+inSize)/2)); - - temp = BGN_BYTE_LEN+TOTAL_HEADER_LEN+inSize+END_BYTE_LEN; - - if(argc != 4) { - fprintf(strout,"1651 1 890000 1 %x\n",temp/2); // CCS format - } else { - fprintf(strout,"1651 1 10000 1 %x\n",temp/2); // CCS format - } - - fprintf (strout, "0x%04X\n",0x0000); - fprintf (strout, "0x%04X\n",TOTAL_HEADER_LEN+inSize); /* length in bytes */ - - writeheader(strout, &data.dstMAC_H); - - writeboottable(strout,&data.BootTable[0],inSize/2); - - fprintf (strout, "0x%04X\n",(unsigned short)(SYMBOL)); - fprintf (strout, "0x%04X\n",0x0000); - fprintf (strout, "0x%04X\n",0x0000); - - } else { // If there are many packets - - temp = BGN_BYTE_LEN + (counter+1)*(TOTAL_HEADER_LEN + END_BYTE_LEN) + inSize; - - if(argc != 4) { - fprintf(strout,"1651 1 890000 1 %x\n",temp/2); // CCS format - } else { - fprintf(strout,"1651 1 10000 1 %x\n",temp/2); // CCS format - } - - fprintf (strout, "0x%04X\n",0x0000); - fprintf (strout, "0x%04X\n",TOTAL_HEADER_LEN+MAX_BOOTTBL_LEN); /* length in bytes */ - - data.UDPlength = UDP_HEADER_LEN + BOOTTBL_HEADER_LEN + MAX_BOOTTBL_LEN; - data.IPlength = data.UDPlength + IP_HEADER_LEN; - UDPchecksum = bootmiscOnesComplementAdd(IP_TYPE_UDP, data.UDPlength); - - for(j=0; j= 0x200) { - data.SeqNo = 0x100; - } - - data.IPchecksum = 0x0000; - data.UDPchecksum = 0x0000; - - } - - // For the last packet - temp = counter*MAX_BOOTTBL_LEN; - counter = inSize - temp; // how many bytes remained - fprintf (strout,"0x%04X\n",TOTAL_HEADER_LEN+counter); - - data.UDPlength = UDP_HEADER_LEN + BOOTTBL_HEADER_LEN + counter; - - data.IPlength = data.UDPlength + IP_HEADER_LEN; - data.IPchecksum = bootmiscOnesComplementChksum(0,&data.VerTOS,IP_HEADER_LEN/2); - - if(getDataIn(strin, counter, data.BootTable)!=0) { - fclose(strin); - fclose(strout); - return; - } - - UDPchecksum = bootmiscOnesComplementAdd(IP_TYPE_UDP, data.UDPlength); - data.UDPchecksum=bootmiscOnesComplementChksum(UDPchecksum, &data.srcIPAddr_H,\ - (UINT16)((4+4+UDP_HEADER_LEN+BOOTTBL_HEADER_LEN+counter)/2)); - writeheader(strout, &data.dstMAC_H); - writeboottable(strout,&data.BootTable[0],counter/2); - - fprintf (strout, "0x%04X\n",(unsigned short)(SYMBOL)); - fprintf (strout, "0x%04X\n",0x0000); - fprintf (strout, "0x%04X\n",0x0000); - } - - fclose(strin); - fclose(strout); -} diff --git a/boot_loader/examples/emac/Utilities/bootpacket.exe b/boot_loader/examples/emac/Utilities/bootpacket.exe deleted file mode 100644 index cc11e0e..0000000 Binary files a/boot_loader/examples/emac/Utilities/bootpacket.exe and /dev/null differ diff --git a/boot_loader/examples/emac/Utilities/bootpacket.h b/boot_loader/examples/emac/Utilities/bootpacket.h deleted file mode 100644 index 9d298de..0000000 --- a/boot_loader/examples/emac/Utilities/bootpacket.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef bootpacket -#define bootpacket - -typedef short int INT16; -typedef int INT32; -typedef unsigned short int UINT16; -typedef unsigned int UINT32; - -#define DST_MAC_H 0x0008 -#define DST_MAC_M 0x7433 -#define DST_MAC_L 0x2630 - -#define SRC_MAC_H 0x000D -#define SRC_MAC_M 0x5676 -#define SRC_MAC_L 0x2F1A - -#define SRC_IP_ADDR_H 0x9EDA -#define SRC_IP_ADDR_L 0x674E -#define DST_IP_ADDR_H 0x9EDA -#define DST_IP_ADDR_L 0x6723 - -#define UDP_SRC_PORT 0x0 -#define UDP_SRC_PORT_BTPKT 0xBEEF /* Bill's bt-pkt.exe use this value */ -#define UDP_DST_PORT 0x9 - -#define ETHER_TYPE_IP 0x800 -#define IP_TYPE_UDP 0x11 - -#define MAGICNO 0x544B - -/* Actual packets has 14 +20 + 8 + 244 = 42 + 244 = 286 bytes */ - -#define MAC_HEADER_LEN 14 -#define IP_HEADER_LEN 20 -#define UDP_HEADER_LEN 8 -#define BOOTTBL_HEADER_LEN 4 -#define TOTAL_HEADER_LEN 46 /* 14 + 20 + 8 + 4 = 46 bytes */ - -#define MAX_PAYLOAD_LEN 244 -//#define MAX_PAYLOAD_LEN 1176 -#define MAX_BOOTTBL_LEN (MAX_PAYLOAD_LEN - BOOTTBL_HEADER_LEN) /* 240 bytes */ - -#define SYMBOL 0xEA00 -#define BGN_BYTE_LEN 0x04 /* ex: 0x0000, 0x00A2 */ -#define END_BYTE_LEN 0x06 /* ex: EA00, 0000, 0000 */ - - -struct BootPacket { - INT16 dstMAC_H; /* MAC */ - INT16 dstMAC_M; - INT16 dstMAC_L; - INT16 srcMAC_H; - INT16 srcMAC_M; - INT16 srcMAC_L; - INT16 EtherType; - INT16 VerTOS; /* IP */ - UINT16 IPlength; - INT16 ID; - INT16 FlagsFrag; - INT16 TTLProtocol; - UINT16 IPchecksum; - INT16 srcIPAddr_H; - INT16 srcIPAddr_L; - INT16 dstIPAddr_H; - INT16 dstIPAddr_L; - INT16 srcPort; /* UDP */ - INT16 dstPort; - UINT16 UDPlength; - UINT16 UDPchecksum; - INT16 MagicNo; /* Payload */ - INT16 SeqNo; - INT16 BootTable[MAX_BOOTTBL_LEN/2]; -}; - - - -#endif \ No newline at end of file diff --git a/boot_loader/examples/emac/Utilities/build-msvc.bat b/boot_loader/examples/emac/Utilities/build-msvc.bat deleted file mode 100644 index 99e3c83..0000000 --- a/boot_loader/examples/emac/Utilities/build-msvc.bat +++ /dev/null @@ -1,12 +0,0 @@ -;local -set MSVCROOT=c:\progtool\msvc60\ -set PATH=%MSVCROOT%\vc98\bin;%MSVCROOT%\common\msdev98\bin;%PATH% -set INCLUDE=%MSVCROOT%\vc98\include -set LIB=%MSVCROOT%\vc98\lib - -cl b2ccs.c -cl b2i2c.c -cl bconvert64x.c -cl bootpacket.c -cl mergebtbl.c -cl myparser.c diff --git a/boot_loader/examples/emac/Utilities/mergebtbl.c b/boot_loader/examples/emac/Utilities/mergebtbl.c deleted file mode 100644 index c237f23..0000000 --- a/boot_loader/examples/emac/Utilities/mergebtbl.c +++ /dev/null @@ -1,127 +0,0 @@ -/************************************************************************************** - * FILE PURPOSE: Merge multiple boot tables into one boot table - ************************************************************************************** - * FILE NAME: mergebtbl.c - * - * Usage: mergebtbl inputfile1 inputfile2 ... outputfile - * Note: may not support single line boot table(hardly possible) - * - **************************************************************************************/ -#include -#include - - -int asciiByte (unsigned char c) -{ - if ((c >= '0') && (c <= '9')) - return (1); - - if ((c >= 'A') && (c <= 'F')) - return (1); - - return (0); -} - - -int main (int argc, char *argv[]) -{ - FILE *strin; - FILE *strout; - int i,j,k; - int line; - int start; - - char iline[132]; - char iline2nd[132]; - - /* Verify the number of args */ - if (argc < 3) { - printf ("usage: %s inpfile[1] ... infile[n] outfile\n", argv[0]); - return (-1); - } - - strout = fopen (argv[argc-1], "w"); - if (strout == NULL) { - printf ("could not open file %s to write\n",argv[argc-1]); - return (-1); - } - - fputs("first line\n",strout); - fputs("second line\n",strout); - - for(i=1; i10)) { - for(k=0;k -#include - - -/*************************************************************************************** - * FUNCTION PURPOSE: The main program - *************************************************************************************** - * DESCRIPTION: Performs the conversion from ccs format to qt format - ***************************************************************************************/ -int main (int argc, char *argv[]) -{ - FILE *strin1; - FILE *strin2; - FILE *strout; - - int a,b,c,d,n1,n; - int i, table; - int num_tables; - int table_size; - int rem_lines; - long int temp; - - char iline[132]; - char iline2[132]; - - /* Verify the number of args */ - if (argc != 4) { - printf ("usage: %s input.ccs input.txt output.ccs\n", argv[0]); - return (-1); - } - - /* Open all the files */ - strin1 = fopen (argv[1], "r"); - if (strin1 == NULL) { - printf ("could not open input file %s\n", argv[1]); - return (-1); - } - - strin2 = fopen (argv[2], "r"); - if (strin2 == NULL) { - printf ("could not open input file %s\n", argv[2]); - return (-1); - } - - strout = fopen (argv[3], "w"); - if (strout == NULL) { - printf ("could not open file %s to write\n",argv[3]); - return (-1); - } - - /* Read the header */ - fgets (iline, 132, strin1); - sscanf (iline, "%x %x %x %x %x", &a, &b, &c, &d, &n1); - - /* read the first config line - get number of tables in the file */ - fgets(iline,132,strin2); - sscanf (iline, "%x", &num_tables); - - if (num_tables == 0) - { - printf("Error in I2C configure file, num tables = 0.\n"); - return(-1); - } - printf("Reading %d tables from I2C configure file\n", num_tables); - - n = n1 + (32 * num_tables) + 2; - - /* Write the CCS header */ - fprintf (strout, "1651 1 10890000 1 %x\n", n); - fprintf (strout, "0x%08x\n",n*4-8); - fprintf (strout, "0x%08x\n",0); - - - /* Prime the loop: read the table size from the first line */ - if (fgets(iline,132,strin2)==NULL) - { - fclose(strin1); - fclose(strin2); - fclose(strout); - printf("Error in I2C configure file\n"); - return(-1); - } - - for (table = 0; table < num_tables; table++) - { - strncpy(iline2, iline, 6); //get the first 16 bits (0xffff) - iline2[6] = 0; //make sure it's null terminated - sscanf (iline2, "%x", &table_size); - fprintf(strout, "%s", iline); - - printf(" Table %d size %d\n", table+1, table_size); - - /* There must be table_size / 4 lines in the file. */ - for (i = 1; i < (table_size / 4); i++) - { - if (fgets(iline,132,strin2)==NULL) - { - fclose(strin1); - fclose(strin2); - fclose(strout); - printf("Error in I2C configure file\n"); - return(-1); - } - - fprintf (strout, "%s",iline); - } - - rem_lines = (128 - table_size) / 4; - - /* Read remaining lines, or encounter the next header early. */ - for (i = 0; i < rem_lines; i++) - { - if (fgets(iline,132,strin2)==NULL) break; - - strncpy(iline2, iline, 10); //get just the hex number - iline2[10] = 0; //make sure it's null terminated - sscanf (iline2, "%x", &temp); - if (temp != 0) break; - fprintf (strout, "%s",iline); - } - - if (i < rem_lines) //encountered next header early, add remaining lines - { - rem_lines -= i; - - for (i = 0; i < rem_lines; i++) - fprintf (strout, "0x%08x\n",0); - } - else if (table < (num_tables - 1)) - { - fgets(iline,132,strin2); //read the next header - } - } - - fclose(strin2); - - for (i=0; i < n1; i++) - { - fgets(iline,132,strin1); - fprintf (strout, "%s",iline); - } - - fclose(strin1); - fclose(strout); - - return (0); -} diff --git a/boot_loader/examples/emac/Utilities/myparser.exe b/boot_loader/examples/emac/Utilities/myparser.exe deleted file mode 100644 index 3c1839c..0000000 Binary files a/boot_loader/examples/emac/Utilities/myparser.exe and /dev/null differ diff --git a/boot_loader/examples/emac/simple/makefile b/boot_loader/examples/emac/simple/makefile deleted file mode 100644 index 136d6bd..0000000 --- a/boot_loader/examples/emac/simple/makefile +++ /dev/null @@ -1,45 +0,0 @@ -#************************************************************************** -#* FILE PURPOSE: Build the simple test program -#************************************************************************** -#* FILE NAME: makefile -#* -#* DESCRIPTION: Builds the following: -#* -#* simple_him.out - little endian himalaya mapped program. -#* simple.le.btbl - Simple program in boot table format. -#* simple.eth - Simple Program in ETH format. -#* -#*************************************************************************** - -AOPTS_LE= -g -c -k -mi200 -ml3 -pm -mv6400 -AOPTS_BE= -me $(AOPTS_LE) - -all: simple.eth - -simple.eth: simple.out - hex6x simple.rmd - ../Utilities/bconvert64x -le simple.btbl simple.le.btbl - ../Utilities/bootpacket simple.le.btbl simple.eth - cp simple.eth ../Ethernet_boot/simple.eth - rm simple.eth - -simple.out: simple.obj simple.cmd - cl6x -z simple.cmd -o simple.out -m simple.map - -simple.obj: simple.s - cl6x $(AOPTS_LE) simple.s - -clean: - rm simple.obj - rm simple.out - rm simple.btbl - rm simple.le.btbl - rm simple.map - - - - - - - - diff --git a/boot_loader/examples/emac/simple/simple.btbl b/boot_loader/examples/emac/simple/simple.btbl deleted file mode 100644 index eb67ebb..0000000 --- a/boot_loader/examples/emac/simple/simple.btbl +++ /dev/null @@ -1,10 +0,0 @@ - -$A0400, -00 81 00 00 00 00 00 40 00 81 00 00 00 99 A2 28 00 88 91 68 01 01 00 A8 -01 00 40 E8 01 08 02 26 01 81 08 28 01 80 40 E8 01 8C 36 26 02 0C 02 26 -00 01 A1 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 -00 00 00 04 00 81 01 00 12 34 AB CD -00 00 00 01 00 81 02 01 00 00 00 12 -00 00 00 02 00 81 02 10 00 00 34 12 00 00 00 00 - \ No newline at end of file diff --git a/boot_loader/examples/emac/simple/simple.cmd b/boot_loader/examples/emac/simple/simple.cmd deleted file mode 100644 index 6b7cf3d..0000000 --- a/boot_loader/examples/emac/simple/simple.cmd +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * FILE PURPOSE: The Himalaya linker command file for program simple - *************************************************************************** - * FILE NAME: simple_him.cmd - * - * DESCRIPTION: Maps the program simple into the Himalaya memory space - * - ***************************************************************************/ - -/* Object file */ -simple.obj - -/* Linker options */ --c --a - -MEMORY -{ - PAGE 0: - - TEXT : origin = 0x810000, length = 0x0040 - DATA : origin = 0x810100, length = 0x0004 - BYTE1 : origin = 0x810201, length = 0x0001 - BYTE2 : origin = 0x810210, length = 0x0002 - -} - -SECTIONS -{ - .text > TEXT PAGE 0 - .data > DATA PAGE 0 - .byte1 > BYTE1 PAGE 0 - .byte2 > BYTE2 PAGE 0 -} - - - - - - - diff --git a/boot_loader/examples/emac/simple/simple.le.btbl b/boot_loader/examples/emac/simple/simple.le.btbl deleted file mode 100644 index c528049..0000000 --- a/boot_loader/examples/emac/simple/simple.le.btbl +++ /dev/null @@ -1,8 +0,0 @@ - -$A000000 -00 81 00 00 00 00 00 40 00 81 00 00 00 99 A2 28 00 88 91 68 01 01 00 A8 -01 00 40 E8 01 08 02 26 01 81 08 28 01 80 40 E8 01 8C 36 26 02 0C 02 26 -00 01 A1 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 04 00 81 01 00 12 34 AB CD 00 00 00 01 00 81 02 01 -12 00 00 00 00 00 00 02 00 81 02 10 12 34 00 00 00 00 00 00 - \ No newline at end of file diff --git a/boot_loader/examples/emac/simple/simple.map b/boot_loader/examples/emac/simple/simple.map deleted file mode 100644 index fbfc4f9..0000000 --- a/boot_loader/examples/emac/simple/simple.map +++ /dev/null @@ -1,95 +0,0 @@ -****************************************************************************** - TMS320C6x Linker PC v7.2.0 -****************************************************************************** ->> Linked Mon May 02 11:08:25 2011 - -OUTPUT FILE NAME: -ENTRY POINT SYMBOL: "_c_int00" address: 00810000 - - -MEMORY CONFIGURATION - - name origin length used unused attr fill ----------------------- -------- --------- -------- -------- ---- -------- - TEXT 00810000 00000040 00000040 00000000 RWIX - DATA 00810100 00000004 00000004 00000000 RWIX - BYTE1 00810201 00000001 00000001 00000000 RWIX - BYTE2 00810210 00000002 00000002 00000000 RWIX - - -SECTION ALLOCATION MAP - - output attributes/ -section page origin length input sections --------- ---- ---------- ---------- ---------------- -.text 0 00810000 00000040 - 00810000 00000040 simple.obj (.text) - -.data 0 00810100 00000004 - 00810100 00000004 simple.obj (.data) - -.byte1 0 00810201 00000001 - 00810201 00000001 simple.obj (.byte1) - -.byte2 0 00810210 00000002 - 00810210 00000002 simple.obj (.byte2) - - -GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name - -address name --------- ---- -00000000 $bss -00810100 .data -00810000 .text -ffffffff ___TI_pprof_out_hndl -ffffffff ___TI_prof_data_size -ffffffff ___TI_prof_data_start -ffffffff ___binit__ -ffffffff ___c_args__ -ffffffff ___cinit__ -00810100 ___data__ -00810104 ___edata__ -00810040 ___etext__ -ffffffff ___pinit__ -00810000 ___text__ -00810000 _c_int00 -ffffffff binit -00810201 byte1 -00810210 byte2 -ffffffff cinit -00810104 edata -00810040 etext -ffffffff pinit -00810100 someData - - -GLOBAL SYMBOLS: SORTED BY Symbol Address - -address name --------- ---- -00000000 $bss -00810000 .text -00810000 ___text__ -00810000 _c_int00 -00810040 ___etext__ -00810040 etext -00810100 .data -00810100 ___data__ -00810100 someData -00810104 ___edata__ -00810104 edata -00810201 byte1 -00810210 byte2 -ffffffff ___TI_pprof_out_hndl -ffffffff ___TI_prof_data_size -ffffffff ___TI_prof_data_start -ffffffff ___binit__ -ffffffff ___c_args__ -ffffffff ___cinit__ -ffffffff ___pinit__ -ffffffff binit -ffffffff cinit -ffffffff pinit - -[23 symbols] diff --git a/boot_loader/examples/emac/simple/simple.obj b/boot_loader/examples/emac/simple/simple.obj deleted file mode 100644 index 59de594..0000000 Binary files a/boot_loader/examples/emac/simple/simple.obj and /dev/null differ diff --git a/boot_loader/examples/emac/simple/simple.out b/boot_loader/examples/emac/simple/simple.out deleted file mode 100644 index 54460bc..0000000 Binary files a/boot_loader/examples/emac/simple/simple.out and /dev/null differ diff --git a/boot_loader/examples/emac/simple/simple.rmd b/boot_loader/examples/emac/simple/simple.rmd deleted file mode 100644 index 7b0bf5c..0000000 --- a/boot_loader/examples/emac/simple/simple.rmd +++ /dev/null @@ -1,15 +0,0 @@ -simple.out --a --boot --e _c_int00 --order L - -ROMS -{ - ROM1: org = 0x0400, length = 0x0080, memwidth = 32, romwidth = 32 - files = { simple.btbl } - -} - - - \ No newline at end of file diff --git a/boot_loader/examples/emac/simple/simple.s b/boot_loader/examples/emac/simple/simple.s deleted file mode 100644 index 1e233a1..0000000 --- a/boot_loader/examples/emac/simple/simple.s +++ /dev/null @@ -1,64 +0,0 @@ -;**************************************************************************** -;* FILE PURPOSE: Code a simple endian independent example -;**************************************************************************** -;* FILE NAME: Simple.s -;* -;* DESCRIPTION: This program is part of the Himalaya I2C boot test plan. -;* It is a simple program that defines two initialized -;* sections, text and data, and performs a simple -;* execution with a self check on the results in register a0. -;* -;* The code is also designed to be relocatable, so it will -;* function in the himsim program running on the DM642. -;* -;***************************************************************************** - -;***************************************************************************** -;* Initialized data -;***************************************************************************** - .data - .def someData -someData .word 01234ABCDh - - .def byte1 - .sect ".byte1" -byte1: .byte 0x12 - - .def byte2 - .sect ".byte2" -byte2: .byte 0x12, 0x34 - -;***************************************************************************** -;* code -;***************************************************************************** - .text - .def _c_int00 - -myConst .equ 011223344h - -_c_int00: - - MVKL.S1 myConst, A1 - MVKH.S1 myConst, A1 - - MVKL.S1 byte1, A2 - MVKH.S1 byte1, A2 - LDB.D1 *A2, B2 - - MVKL.S1 byte2, A3 - MVKH.S1 byte2, A3 - LDB.D1 *A3++, B3 - LDB.D1 *A3, B4 - - -etrap: - - BNOP.S1 etrap, 5 - - - - - - - - diff --git a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c new file mode 100644 index 0000000..c3c07fd --- /dev/null +++ b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c @@ -0,0 +1,209 @@ +/****************************************************************************** + * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ +#include +#include +#include +#include + +#define UDP_LOW 42 +#define UDP_HIGH 1504 // Note: Windows FRAGMENTS higher UDP sizes + +#define SRCPORT 1234 +#define DSTPORT 9 + +#define DELAY 60000 + +/* convert ascii to decimal number */ +int toNum(unsigned char c) +{ + if ((c >= '0') && (c <= '9')) + return(c - '0'); + + else if ((c >= 'A') && (c <= 'F')) + return(c -'A' + 10); + + else if ((c >= 'a') && (c <= 'f')) + return(c - 'a' + 10); + + return(-1); +} + + +int main( int argc, char *argv[] ) +{ + WORD wVersionRequested; + WSADATA wsaData; + SOCKET s; + struct sockaddr_in sin; + unsigned char *pBuf = 0; + int tmp1,tmp2,tmp3,tmp4; + time_t ts,tn; + FILE *strin; + char iline[132]; + int i,j,length; + int packetno; + + if( (argc != 3) || + sscanf(argv[2],"%03d.%03d.%03d.%03d",&tmp1,&tmp2,&tmp3,&tmp4)!=4 || + (tmp1 < 0 || tmp1 > 255 || tmp2 < 0 || tmp2 > 255 || + tmp3 < 0 || tmp3 > 255 || tmp4 < 0 || tmp4 > 255) ) + { + printf("\nUsage: %s packetfile ipaddress\n",argv[0]); + exit(-1); + } + + tmp1 |= tmp2 << 8; + tmp1 |= tmp3 << 16; + tmp1 |= tmp4 << 24; + + strin = fopen (argv[1], "r"); + if (strin == NULL) { + printf ("could not open input file %s\n", argv[1]); + exit(-1); + } + + /* Skip the first two lines */ + fgets (iline, 131, strin); + fgets (iline, 131, strin); + + wVersionRequested = MAKEWORD(1, 1); + tmp2 = WSAStartup(wVersionRequested, &wsaData); + if (tmp2 != 0) + { + printf("\r\nUnable to initialize WinSock for host info"); + exit(0); + } + + s = socket( AF_INET, SOCK_DGRAM, 0 ); + if( s < 0 ) + { + printf("failed connect (%d)\n",WSAGetLastError()); + goto end; + } + + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = 0; + sin.sin_port = htons(SRCPORT); + + if ( bind( s, (struct sockaddr *)&sin, sizeof(sin) ) < 0 ) + { + printf("failed bind (%d)\n",WSAGetLastError()); + goto end; + } + + /* Allocate a working buffer */ + if( !(pBuf = malloc( 2000 )) ) + { + printf("failed packetno buffer allocation\n"); + goto end; + } + + sin.sin_addr.s_addr = tmp1; + sin.sin_port = htons(DSTPORT); + + ts = time(0); + + packetno = 0; + + printf("\nSending packets to %d.%d.%d.%d\n", + tmp1&255, (tmp1>>8)&255, (tmp1>>16)&255, (tmp1>>24)&255 ); + + while(1) + { + /* get length in bytes */ + if(fgets(iline, 131, strin)==NULL) break; + length = toNum(iline[2])<<12 | toNum(iline[3])<<8 | toNum(iline[4])<<4 | toNum(iline[5]); + if(length == 0) break; + else if(length < UDP_LOW || length > UDP_HIGH) { + printf("Invalid length = %d\n",length); + goto end; + } + + /* skip the next 21 lines, 14 mac + 20 IP + 8 UDP = 42 bytes = 21 lines */ + for(i=0; i<21; i++) { + if(fgets(iline,131,strin)==NULL) break; + } + + length -= 42; + if(length < 0) { + printf("Invalid length = %d\n",length); + goto end; + } + + /* copy the payload: magicno + seq no + boot table */ + for(i=0,j=0; i< length/2; i++) { + if(fgets(iline, 131, strin)==NULL) break; + + *(pBuf+j) = toNum(iline[2])<<4 | toNum(iline[3]); + j++; + *(pBuf+j) = toNum(iline[4])<<4 | toNum(iline[5]); + j++; + } + + /* send out the packet */ + if( sendto( s, pBuf, length, 0, (struct sockaddr *)&sin, sizeof(sin) ) < 0 ) + { + printf("send failed (%d)\n",WSAGetLastError()); + break; + } + + /* packet number */ + packetno++; + printf("Packet %d sent\n",packetno); + + /* add delay between packets */ + for(i=0; i= 0 ) + closesocket( s ); + + WSACleanup(); +} + diff --git a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe new file mode 100644 index 0000000..4e7173d Binary files /dev/null and b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe differ diff --git a/boot_loader/examples/ethernet/Ethernet_boot/simple.eth b/boot_loader/examples/ethernet/Ethernet_boot/simple.eth new file mode 100644 index 0000000..fcbbb2c --- /dev/null +++ b/boot_loader/examples/ethernet/Ethernet_boot/simple.eth @@ -0,0 +1,87 @@ +1651 1 890000 1 56 +0x0000 +0x00A2 +0x0008 +0x7433 +0x2630 +0x000D +0x5676 +0x2F1A +0x0800 +0x4500 +0x0094 +0x4567 +0x0000 +0x1011 +0x58CC +0x9EDA +0x674E +0x9EDA +0x6723 +0x0000 +0x0009 +0x0080 +0x0ED8 +0x544B +0x0100 +0x0081 +0x0000 +0x0000 +0x0040 +0x0081 +0x0000 +0x0099 +0xA228 +0x0088 +0x9168 +0x0101 +0x00A8 +0x0100 +0x40E8 +0x0108 +0x0226 +0x0181 +0x0828 +0x0180 +0x40E8 +0x018C +0x3626 +0x020C +0x0226 +0x0001 +0xA120 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0000 +0x0004 +0x0081 +0x0100 +0x1234 +0xABCD +0x0000 +0x0001 +0x0081 +0x0201 +0x1200 +0x0000 +0x0000 +0x0002 +0x0081 +0x0210 +0x1234 +0x0000 +0x0000 +0x0000 +0xEA00 +0x0000 +0x0000 diff --git a/boot_loader/examples/ethernet/Utilities/bconvert64x.c b/boot_loader/examples/ethernet/Utilities/bconvert64x.c new file mode 100644 index 0000000..c6b1b27 --- /dev/null +++ b/boot_loader/examples/ethernet/Utilities/bconvert64x.c @@ -0,0 +1,701 @@ +/****************************************************************************** + * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +/************************************************************************************ + * FILE PURPOSE: Convert a hex6x boot table file into the format required + * by the c6x chip boot loader. + ************************************************************************************ + * FILE NAME: bconvert.c + * + * DESCRIPTION: Converts a boot table. The boot table format is: + * + * /--------------------------------------------------------\ + * | 32 bit entry point address | + * +--------------------------------------------------------+ + * | 32 bit section byte count | \ + * +--------------------------------------------------------+ \ + * | 32 bit section byte start address | \ + * +-------------+-------------+-------------+--------------+ repeat each section + * | Data byte | Data byte | Data byte | Data byte | / + * +-------------+-------------+-------------+--------------+ / + * | Data byte | Data byte | Data byte | Data byte | / + * +-------------+-------------+-------------+--------------+ + * | 32 bit zero byte count (end of boot table) | + * \--------------------------------------------------------/ + * + * + * The C6x boot loader expects all 32 bit values to be in big endian + * (most significant byte arrives first). Data bytes are also arranged to be 32 bit + * big endian represented. + * + * This program handles conversion of data values that are in sections that are + * not multiples of 4 bytes. For example, a program compiled in big endian format + * with a 1 byte section will have the following table entry (address 0x22222222), value + * 0x33 + * + * 00 00 00 01 22 22 22 22 33 00 00 00 + * + * The same file compiled with little endian mode will have the entry + * + * 00 00 00 01 22 22 22 22 00 00 00 33 + * + * + * Since the boot loader has no idea what endianness the code was compiled for, this + * program performs an endian conversion on any section that does not have a length + * that is a multiple of 4 bytes, if the little endian option is specified. Nothing + * is changed for the big endian mode. + * + * Invokation: + * + * bconvert -be|-le [input_file] [output_file] + * + ***************************************************************************************/ + +#include "stdio.h" +#include "malloc.h" +#include "string.h" + +/* Global variable storing the invokation name */ +char *invok; + +/* Error values */ +enum { + ERR_PARSE_TOO_MANY_ARGS = 1000, + ERR_PARSE_NO_ENDIAN, + ERR_PARSE_INPUT_OPEN_FAIL, + ERR_PARSE_OUTPUT_OPEN_FAIL, + ERR_READ_BFILE_INITIAL_MALLOC_FAIL, + ERR_READ_BFILE_REALLOC_FAIL, + ERR_VALUE32_SIZE_ERR, + ERR_VALUE16_SIZE_ERR, + ERR_DATA32_SIZE_ERR, + ERR_REG32_PARSE_ERROR, + ERR_DATA32_REMAIN_ERR +}; + +enum { + LITTLE, + BIG +}; + +/************************************************************************************ + * FUNTION PURPOSE: Send an error string + ************************************************************************************ + * DESCRIPTION: Prints an error to stderr + ************************************************************************************/ +void showErr (int errflag) +{ + char *s; + + switch (errflag) { + case ERR_PARSE_TOO_MANY_ARGS: + s = "Parse error: too many args specified"; + break; + + case ERR_PARSE_NO_ENDIAN: + s = "Parse error: no endian mode specified"; + break; + + case ERR_PARSE_INPUT_OPEN_FAIL: + s = "File error: failed to open specified input file"; + break; + + case ERR_PARSE_OUTPUT_OPEN_FAIL: + s = "File error: Failed to open specified output file"; + break; + + case ERR_READ_BFILE_INITIAL_MALLOC_FAIL: + s = "Memory error: Initial malloc call failed"; + break; + + case ERR_READ_BFILE_REALLOC_FAIL: + s = "Memory error: Subsequent realloc call failed"; + break; + + case ERR_VALUE32_SIZE_ERR: + s = "Data format error: End of data on 32 bit value read"; + break; + + case ERR_VALUE16_SIZE_ERR: + s = "Data format error: End of data on 16 bit value read"; + break; + + case ERR_REG32_PARSE_ERROR: + s = "Parse error: error parsing after reg32 arg"; + break; + + case ERR_DATA32_REMAIN_ERR: + s = "Parse error: A remainder size greater then four was found"; + break; + + default: + s = "Unspecified error"; + break; + + } + + fprintf (stderr, "%s: %s\n", invok, s); + +} /* showErr */ + + +/************************************************************************************* + * FUNCTION PURPOSE: Check if a string is prefixed with "0x". + ************************************************************************************* + * DESCRIPTION: Returns non-zero if the string begins with "0x" + *************************************************************************************/ +int isChex (char *s) +{ + if ((s[0] == '0') && (s[1] == 'x')) + return (1); + + return (0); + +} /* isChex */ + + + +/************************************************************************************* + * FUNCTION PURPOSE: Parse the input parameters + ************************************************************************************* + * DESCRIPTION: Checks for required args, opens source and destination streams. + *************************************************************************************/ +int parseit (int argc, char *argv[], FILE **fin, FILE **fout, int *endian) +{ + int inspec = 0; + int outspec = 0; + int espec = 0; + int c = 1; + + char *iname; + char *oname; + + *endian = -1; + + /* Store the invokation name */ + invok = argv[0]; + + while (c < argc) { + + /* -be | -le */ + if (!espec) { + if (!strcmp (argv[c], "-be")) { + *endian = BIG; + espec = 1; + c += 1; + continue; + } else if (!strcmp (argv[c], "-le")) { + *endian = LITTLE; + espec = 1; + c += 1; + continue; + } + } + + + /* input file */ + if (!inspec) { + inspec = 1; + iname = argv[c]; + c += 1; + continue; + } + + /* output file */ + if (!outspec) { + outspec = 1; + oname = argv[c]; + c += 1; + continue; + } + + /* Don't know what to do with the arg */ + return (ERR_PARSE_TOO_MANY_ARGS); + + } + + + /* Make sure endian is known */ + if (!espec) + return (ERR_PARSE_NO_ENDIAN); + + /* Open input file if not stdin */ + if (inspec) { + *fin = fopen (iname, "r"); + if (*fin == NULL) + return (ERR_PARSE_INPUT_OPEN_FAIL); + } + + /* Open output file if not stdin */ + if (outspec) { + *fout = fopen (oname, "w"); + if (*fout == NULL) + return (ERR_PARSE_OUTPUT_OPEN_FAIL); + } + + return (0); + +} /* parseit */ + + + +/*************************************************************************************** + * FUNCTION PURPOSE: Check if data is ascii + *************************************************************************************** + * DESCRIPTION: Returns 1 if a byte is 0-9, a-f, 0 otherwise + ***************************************************************************************/ +int asciiByte (unsigned char c) +{ + if ((c >= '0') && (c <= '9')) + return (1); + + if ((c >= 'A') && (c <= 'F')) + return (1); + + return (0); +} /* asciiByte */ + +/************************************************************************************** + * FUNCTION PURPOSE: Returns the binary equivalent of an ascii byte + ************************************************************************************** + * DESCRIPTION: Conversion from ascii to binary + **************************************************************************************/ +int toNum (unsigned char c) +{ + if ((c >= '0') && (c <= '9')) + return (c - '0'); + + return (c - 'A' + 10); + +} /* toNum */ + + +/********************************************************************************** + * FUNCTION PURPOSE: Read a line from a file, toss it + ********************************************************************************** + * DESCRIPTION: Reads a line, including the newline character, and throws it away. + **********************************************************************************/ +void stripLine (FILE *s) +{ + char iline[132]; + + fgets (iline, 131, s); + +} /* stripLine */ + +/************************************************************************************ + * FILE PURPOSE: Read the hex55 data file + ************************************************************************************ + * DESCRIPTION: Reads the input data file. Strips the first two lines, reads + * the byte stream. + ************************************************************************************/ +#define MALLOC_BLOCK_SIZE 512000 +unsigned char *readBFile (FILE *fin, unsigned *n, int *errcode) +{ + unsigned char *d; + unsigned allocSize; + unsigned m; + unsigned char x, y; + + /* Create a block of data */ + allocSize = MALLOC_BLOCK_SIZE; + d = malloc (allocSize * sizeof (unsigned char)); + if (d == NULL) { + *errcode = ERR_READ_BFILE_INITIAL_MALLOC_FAIL; + if (fin != stdin) + fclose (fin); + return (NULL); + } + + /* Strip the 1st two lines */ + stripLine (fin); + stripLine (fin); + + *errcode = 0; + m = 0; + + for (;;) { + + /* Read the 1st ascii char */ + do { + x = fgetc (fin); + if (x == (unsigned char)EOF) { + *errcode = 0; + *n = m; + if (fin != stdin) + fclose (fin); + return (d); + } + } while (!asciiByte(x)); + + /* Read the next ascii char */ + y = fgetc(fin); + if (y == (unsigned char)EOF) { + *errcode = 0; + *n = m; + if (fin != stdin) + fclose (fin); + return (d); + } + + /* Convert the two characters into a byte */ + if (asciiByte(y)) + d[m++] = (toNum(x) << 4) | toNum(y); + + /* Verify memory bounds */ + if (m >= allocSize) { + allocSize += MALLOC_BLOCK_SIZE; + d= realloc (d, allocSize); + if (d== NULL) { + *errcode = ERR_READ_BFILE_REALLOC_FAIL; + if (fin != stdin) + fclose (fin); + return (NULL); + } + } + + } /* end for */ + +} /* readBFile */ + +/************************************************************************************** + * FUNCTION PURPOSE: converts four bytes into an unsigned value + ************************************************************************************** + * DESCRIPTION: Converts bytes to a value + **************************************************************************************/ +unsigned value32bitAdd (int endian, unsigned char *data, unsigned n, unsigned *p, int *errflag, unsigned add) +{ + unsigned v; + unsigned w; + unsigned q; + + /* Verify that there are 4 values still in the character array */ + if ((*p + 4) > n) { + *errflag = ERR_VALUE32_SIZE_ERR; + return (0); + } + + /* Store the original pointer */ + q = w = *p; + + v = (unsigned)data[w+0] << 24 | + (unsigned)data[w+1] << 16 | + (unsigned)data[w+2] << 8 | + (unsigned)data[w+3] << 0 ; + + *errflag = 0; + + /* Add any additional value */ + v = v + add; + + /* Write the data back in big endian format */ + data[q+0] = (v >> 24) & 0xff; + data[q+1] = (v >> 16) & 0xff; + data[q+2] = (v >> 8) & 0xff; + data[q+3] = (v >> 0) & 0xff; + + *p = q+4; + return (v); + +} /* value32bitAdd */ + +/************************************************************************************** + * FUNCTION PURPOSE: converts four bytes into an unsigned value + ************************************************************************************** + * DESCRIPTION: Converts bytes to a value, depending on the endian configuration. + **************************************************************************************/ +unsigned value32bit (int endian, unsigned char *data, unsigned n, unsigned *p, int *errflag) +{ + return (value32bitAdd (endian, data, n, p, errflag, 0)); + +} /* value32bit */ + + + + +/********************************************************************************* + * FUNCTION PURPOSE: Convert up to four bytes to big endian + ********************************************************************************* + * DESCRIPTION: Data bytes are converted. + *********************************************************************************/ +#define SWAP(x,y,z) (z)=(x);(x)=(y);(y)=(z) +void data32bit (int endian, unsigned char *data, unsigned n, unsigned *p, unsigned m, int *errflag) +{ + + /* Calculate the number of bytes to convert, limited to four bytes */ + if (m > 4) + m = 4; + + /* return an error if there are not enough values in the array */ + if ((*p + m) >= n) { + *errflag = ERR_DATA32_SIZE_ERR; + return; + } + + /* Clear the error flag */ + *errflag = 0; + + + /* The data is always already in big endian, there is nothing to do but advance the pointer */ + *p += m; + +} /* data32bit */ + +void remain32bit (int endian, unsigned char *data, unsigned n, unsigned *p, unsigned m, int *errflag) +{ + unsigned w; + unsigned char h; + + /* return an error if the size is greater then or equal to 4 */ + if (m >= 4) { + *errflag = ERR_DATA32_REMAIN_ERR; + return; + } + + /* return an error if there are not enough values in the array */ + if ((*p + m) >= n) { + *errflag = ERR_DATA32_SIZE_ERR; + return; + } + + w = *p; + + /* Only swap if endianness is little */ + if (endian == LITTLE) { + /* Swap the next four bytes */ + SWAP(data[w+0], data[w+3], h); + SWAP(data[w+1], data[w+2], h); + } + + /* Update the full four elements */ + *p = *p + 4; + + +} /* remain32bit */ + + +/********************************************************************************* + * FUNCTION PURPOSE: Convert 2 bytes into an unsigned value + ********************************************************************************* + * DESCRIPTION: Converts the next two bytes into an unsigned value based on + * the endian configuration. + *********************************************************************************/ +unsigned value16bit (int endian, unsigned char *data, unsigned n, unsigned *p, int *errflag) +{ + unsigned v; + unsigned q; + + /* Verify that there are 4 values still in the character array */ + if ((*p + 2) > n) { + *errflag = ERR_VALUE16_SIZE_ERR; + return (0); + } + + /* Store the original pointer */ + q = *p; + + /* convert based on endianness. For little endain the 16 bit words are actually + * big endian, but the bytes in those words are not */ + if (endian == BIG) { + v = data[(*p)++] << 8 | + data[(*p)++] << 0 ; + + } else { + v = data[(*p)++] << 0 | + data[(*p)++] << 8 ; + } + + *errflag = 0; + + /* Write the data back in big endian format */ + data[q++] = (v >> 8) & 0xff; + data[q++] = (v >> 0) & 0xff; + + return (v); + +} /* value16bit */ + +/************************************************************************************** + * FUNCTION PURPOSE: Writes a 16 bit value into the array + ************************************************************************************** + * DESCRIPTION: Writes a big endian 16 bit value, increments the array pointer. + **************************************************************************************/ +void write16bit (unsigned value, unsigned char *data, unsigned *p) +{ + data[(*p)++] = (value >> 8) & 0xff; + data[(*p)++] = (value >> 0) & 0xff; + +} /* write16bit */ + + +/************************************************************************************* + * FUNCTION PURPOSE: Write the output file + ************************************************************************************* + * DESCRIPTION: Writes the resulting output. + *************************************************************************************/ +void writeBFile (FILE *fout, unsigned char *data, unsigned n) +{ + unsigned i; + + /* Write the two line header */ + fprintf (fout, "%c\n$A000000\n", (unsigned char)2); + + for (i = 0; i < n; i++) { + if ( ((i+1)%24) ) + fprintf (fout, "%02X ", data[i]); + else + fprintf (fout, "%02X\n", data[i]); + } + + /* Write the close character */ + fprintf (fout, "\n%c", (unsigned char)3); + + if (fout != stdout) + fclose (fout); + +} /* writeBFile */ + + +/************************************************************************************** + * FUNCTION PURPOSE: Main + ************************************************************************************** + * DESCRIPTION: Provides the top level program flow. + **************************************************************************************/ +int main (int argc, char *argv[]) +{ + FILE *fin; /* input stream */ + FILE *fout; /* output stream */ + + unsigned char *data; /* The data set */ + unsigned n; /* Data set size */ + unsigned p; /* Data index */ + unsigned v; /* Data value */ + unsigned n32; /* Number of bytes that form complete 32 bit values */ + unsigned r32; /* Number of bytes remaining (0-3) */ + + int endian; /* Endian */ + int errflag; /* error indicator */ + int i, j; /* loop var */ + int origRegs; /* original reg count */ + int shift; /* data shift amount */ + + + /* Parse the input */ + if (errflag = parseit (argc, argv, &fin, &fout, &endian)) { + showErr (errflag); + return (-1); + } + + /* Read the raw data file */ + data = readBFile (fin, &n, &errflag); + if (data == NULL) { + showErr (errflag); + return(-1); + } + + /* Parse the sections */ + p = 0; + + /* The entry point */ + v = value32bit (endian, data, n, &p, &errflag); + if (errflag) { + showErr (errflag); + return(-1); + } + + + /* The sections */ + do { + + /* Get the section byte count */ + v = value32bit (endian, data, n, &p, &errflag); + if (errflag) { + showErr (errflag); + return(-1); + } + + if (v) { + /* Convert the start address (adjusts the array index) */ + value32bit (endian, data, n, &p, &errflag); + if (errflag) { + showErr (errflag); + return(-1); + } + } + + /* Determine how many bytes form complete 32 bit fields, and how many are left over */ + n32 = v & 0xfffffffc; + r32 = v & 0x00000003; + + /* Convert the data to big endian format */ + for (i = 0; i < n32; i += 4) { + data32bit (endian, data, n, &p, v-i, &errflag); + if (errflag) { + showErr (errflag); + return (-1); + } + } + + /* Convert any remaining bytes. */ + if (r32) { + remain32bit (endian, data, n, &p, r32, &errflag); + if (errflag) { + showErr (errflag); + return (-1); + } + } + + } while (v); + + /* Write out the data file */ + writeBFile (fout, data, n); + + /* Return resources */ + free (data); + + return (0); + +} + + + + + + + + + + + + + diff --git a/boot_loader/examples/ethernet/Utilities/bconvert64x.exe b/boot_loader/examples/ethernet/Utilities/bconvert64x.exe new file mode 100644 index 0000000..f17b5f7 Binary files /dev/null and b/boot_loader/examples/ethernet/Utilities/bconvert64x.exe differ diff --git a/boot_loader/examples/ethernet/Utilities/bootpacket.c b/boot_loader/examples/ethernet/Utilities/bootpacket.c new file mode 100644 index 0000000..6beb46d --- /dev/null +++ b/boot_loader/examples/ethernet/Utilities/bootpacket.c @@ -0,0 +1,509 @@ +/****************************************************************************** + * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +/* A simple utility program to convert a boot table to Ethernet boot format */ +/* Version: 0.3 */ + + +#include +#include +#include +#include "bootpacket.h" + +unsigned int line=0; + + + +void writeheader(FILE *s, INT16* pdata) +{ + int i; + + for (i = 0; i < TOTAL_HEADER_LEN/2; i++) + fprintf (s, "0x%04X\n",(unsigned short int)(*pdata++)); +} + + +void writeboottable(FILE *s, INT16* pdata, int size) +{ + int i; + + for (i = 0; i < size; i++) + fprintf (s, "0x%04X\n",(unsigned short int)(*pdata++)); +} + + +void stripLine (FILE *s) +{ + char iline[132]; + + fgets (iline, 131, s); + +} + + +int asciiByte (unsigned char c) +{ + if ((c >= '0') && (c <= '9')) + return (1); + + if ((c >= 'A') && (c <= 'F')) + return (1); + + return (0); +} + + +int toNum (unsigned char c) +{ + if ((c >= '0') && (c <= '9')) + return (c - '0'); + + return (c - 'A' + 10); + +} + +int toNumMAC (unsigned char c) +{ + if ((c >= '0') && (c <= '9')) + return(c - '0'); + + else if ((c >= 'A') && (c <= 'F')) + return(c -'A' + 10); + + else if ((c >= 'a') && (c <= 'f')) + return(c - 'a' + 10); + + else if(c == ':') + return(100); + + return(200); +} + + + +/* Read the file size in bytes*/ +int getFileSize (FILE *s) +{ + unsigned char x, y; + unsigned int byteCount = 0; + + /* Strip the 1st two lines */ + stripLine (s); + stripLine (s); + + for (;;) { + + /* read the 1st ascii char */ + do { + x = fgetc (s); + if (x == (unsigned char)EOF) + return (byteCount); + + } while (!asciiByte(x)); + + /* Read the next ascii char */ + y = fgetc (s); + if (y == (unsigned char)EOF) + return (byteCount); + if (asciiByte(y)) + byteCount++; + } +} + + + +int getDataIn(FILE *s, int size_bytes, unsigned short int *output) +{ + int i; + unsigned char x, y; + unsigned char c[2]; + + for(i= 0; i< size_bytes/2; i++) { + c[0] = 0; + c[1] = 0; + + /* read the 1st ascii char */ + do { + x = fgetc (s); + if (x == (unsigned char)EOF) { + printf("file parsing error\n"); + return(-1); + } + } while (!asciiByte(x)); + + + /* Read the next ascii char */ + y = fgetc (s); + if (y == (unsigned char)EOF) { + printf("file parsing error\n"); + return(-1); + } + + if (asciiByte(y)) { + c[0] = (toNum(x) << 4) | toNum (y); + } + + do { + x = fgetc (s); + if (x == (unsigned char)EOF) { + printf("file parsing error\n"); + return(-1); + } + } while (!asciiByte(x)); + + + /* Read the next ascii char */ + y = fgetc (s); + if (y == (unsigned char)EOF) { + printf("file parsing error\n"); + return(-1); + } + + if (asciiByte(y)) { + c[1] = (toNum(x) << 4) | toNum (y); + } + + *output++ = (c[0] << 8) | c[1] ; + line++; + } + return(0); +} + + + +UINT16 bootmiscOnesComplementAdd (UINT16 value1, UINT16 value2) +{ + UINT32 result; + + result = (UINT32)value1 + (UINT32)value2; + + result = (result >> 16) + (result & 0xFFFF); /* add in carry */ + result += (result >> 16); /* maybe one more */ + return (UINT16)result; +} + + + +/* Description: Calculate an Internet style one's complement checksum */ + UINT16 bootmiscOnesComplementChksum (UINT16 base, UINT16 *p_data, UINT16 len) +{ + UINT16 chksum = base; + + while (len > 0) + { + chksum = bootmiscOnesComplementAdd(chksum,*p_data); + p_data++; + len--; + } + return ((unsigned short) ~chksum); +} + + + +/* + Input file format: boot table in big endian format + + Output file format: + + 1st line: CCS data format + 2nd line: 0x0000 + 3rd line: length of first packet in bytes, length counts not include itself + ....... + first packet + ....... + + 0xEA00 + 0x0000 + length of the second packet in bytes, length counts not include itself + ....... + second packet + ....... + + + 0xEA00 + 0x0000 + length of the other packet in bytes, length counts not include itself + ....... + other packets + ....... + + 0xEA00 + 0X0000 + 0X0000: end of the file +*/ + +struct BootPacket data; + + +void main (int argc, char *argv[]) +{ + UINT32 j; + UINT32 inSize; + UINT32 counter; + UINT16 UDPchecksum; + FILE *strin, *strout; + UINT32 temp; + unsigned int MACaddr[6]; + + /* Arg check */ + if (argc <3 || argc> 5) { + fprintf (stderr, "usage: %s infile outfile\n\n", argv[0]); + fprintf (stderr, "To generates the same result as bt-pkt.exe\n"); + fprintf (stderr, "usage: %s infile outfile btpkt\n\n", argv[0]); + fprintf (stderr, "To use your own MAC address\n"); + fprintf (stderr, "usage: %s infile outfile dstMAC srcMAC\n", argv[0]); + return; + } + + strin = fopen(argv[1],"rb"); + if(strin == NULL){ + fprintf (stderr, "%s: Could not open file %s for reading\n", argv[0], argv[1]); + return; + } + + /* Get the file size of data file */ + inSize = getFileSize (strin); + printf("File size = %d bytes.\n",inSize); + fclose (strin); + strin = fopen(argv[1],"rb"); + /* Strip the 1st two lines */ + stripLine (strin); + stripLine (strin); + + strout = fopen(argv[2],"w"); + if(strout == NULL) { + fprintf (stderr, "%s error: Could not open output file %s\n", argv[0], argv[2]); + return; + } + + + // MAC header, 14 bytes + if(argc == 5) { + + /* get destination MAC address */ + if((sscanf(argv[3],"%02x-%02x-%02x-%02x-%02x-%02x",&MACaddr[0],&MACaddr[1], \ + &MACaddr[2],&MACaddr[3],&MACaddr[4],&MACaddr[5])!=6) || \ + (MACaddr[0] < 0 || MACaddr[0] > 255 || \ + MACaddr[1] < 0 || MACaddr[1] > 255 || \ + MACaddr[2] < 0 || MACaddr[2] > 255 || \ + MACaddr[3] < 0 || MACaddr[3] > 255 || \ + MACaddr[4] < 0 || MACaddr[4] > 255 || \ + MACaddr[5] < 0 || MACaddr[5] > 255) ) { + + printf("Error in dstMAC address\n"); + fclose(strin); + fclose(strout); + return; + } + + data.dstMAC_H = (unsigned short)(MACaddr[0]<<8 | MACaddr[1]); + data.dstMAC_M = (unsigned short)(MACaddr[2]<<8 | MACaddr[3]); + data.dstMAC_L = (unsigned short)(MACaddr[4]<<8 | MACaddr[5]); + + /* get source MAC address */ + if((sscanf(argv[4],"%02x-%02x-%02x-%02x-%02x-%02x",&MACaddr[0],&MACaddr[1], \ + &MACaddr[2],&MACaddr[3],&MACaddr[4],&MACaddr[5])!=6) || \ + (MACaddr[0] < 0 || MACaddr[0] > 255 || \ + MACaddr[1] < 0 || MACaddr[1] > 255 || \ + MACaddr[2] < 0 || MACaddr[2] > 255 || \ + MACaddr[3] < 0 || MACaddr[3] > 255 || \ + MACaddr[4] < 0 || MACaddr[4] > 255 || \ + MACaddr[5] < 0 || MACaddr[5] > 255) ) { + + printf("Error in srcMAC address\n"); + fclose(strin); + fclose(strout); + return; + } + + data.srcMAC_H = (unsigned short)(MACaddr[0]<<8 | MACaddr[1]); + data.srcMAC_M = (unsigned short)(MACaddr[2]<<8 | MACaddr[3]); + data.srcMAC_L = (unsigned short)(MACaddr[4]<<8 | MACaddr[5]); + + } else { /* use default MAC address */ + data.dstMAC_H = (unsigned short)DST_MAC_H; + data.dstMAC_M = (unsigned short)DST_MAC_M; + data.dstMAC_L = (unsigned short)DST_MAC_L; + data.srcMAC_H = (unsigned short)SRC_MAC_H; + data.srcMAC_M = (unsigned short)SRC_MAC_M; + data.srcMAC_L = (unsigned short)SRC_MAC_L; + } + data.EtherType = ETHER_TYPE_IP; + + // IP header, 20 bytes + data.VerTOS = 0x4500; + data.IPlength = 0x0000; + data.ID = 0x4567; + data.FlagsFrag = 0x0000; + data.TTLProtocol = 0x1000 | IP_TYPE_UDP; + data.IPchecksum = 0x0000; + data.srcIPAddr_H = (unsigned short)SRC_IP_ADDR_H; + data.srcIPAddr_L = (unsigned short)SRC_IP_ADDR_L; + data.dstIPAddr_H = (unsigned short)DST_IP_ADDR_H; + data.dstIPAddr_L = (unsigned short)DST_IP_ADDR_L; + + // UDP header, 8 bytes + if(argc != 4) { + data.srcPort = (unsigned short)UDP_SRC_PORT; + } else { + data.srcPort = (unsigned short)UDP_SRC_PORT_BTPKT; + } + data.dstPort = (unsigned short)UDP_DST_PORT; + data.UDPlength = 0x0000; + data.UDPchecksum = 0x0000; + + // Payload header, 4 bytes + data.MagicNo = MAGICNO; + data.SeqNo = 0x100; + + memset(&data.BootTable,0, sizeof(data.BootTable)); + + counter = inSize / MAX_BOOTTBL_LEN; // calculate how many packets + + // If there is only one packet + if(counter <=1) { + data.UDPlength = UDP_HEADER_LEN + BOOTTBL_HEADER_LEN + inSize; + + data.IPlength = data.UDPlength + IP_HEADER_LEN; + data.IPchecksum=bootmiscOnesComplementChksum(0,&data.VerTOS,IP_HEADER_LEN/2); + + if(getDataIn(strin, inSize, data.BootTable)!=0) { + fclose(strin); + fclose(strout); + return; + } + + UDPchecksum = bootmiscOnesComplementAdd(IP_TYPE_UDP, data.UDPlength); + data.UDPchecksum=bootmiscOnesComplementChksum(UDPchecksum, &data.srcIPAddr_H,\ + (UINT16)((4+4+UDP_HEADER_LEN+BOOTTBL_HEADER_LEN+inSize)/2)); + + temp = BGN_BYTE_LEN+TOTAL_HEADER_LEN+inSize+END_BYTE_LEN; + + if(argc != 4) { + fprintf(strout,"1651 1 890000 1 %x\n",temp/2); // CCS format + } else { + fprintf(strout,"1651 1 10000 1 %x\n",temp/2); // CCS format + } + + fprintf (strout, "0x%04X\n",0x0000); + fprintf (strout, "0x%04X\n",TOTAL_HEADER_LEN+inSize); /* length in bytes */ + + writeheader(strout, &data.dstMAC_H); + + writeboottable(strout,&data.BootTable[0],inSize/2); + + fprintf (strout, "0x%04X\n",(unsigned short)(SYMBOL)); + fprintf (strout, "0x%04X\n",0x0000); + fprintf (strout, "0x%04X\n",0x0000); + + } else { // If there are many packets + + temp = BGN_BYTE_LEN + (counter+1)*(TOTAL_HEADER_LEN + END_BYTE_LEN) + inSize; + + if(argc != 4) { + fprintf(strout,"1651 1 890000 1 %x\n",temp/2); // CCS format + } else { + fprintf(strout,"1651 1 10000 1 %x\n",temp/2); // CCS format + } + + fprintf (strout, "0x%04X\n",0x0000); + fprintf (strout, "0x%04X\n",TOTAL_HEADER_LEN+MAX_BOOTTBL_LEN); /* length in bytes */ + + data.UDPlength = UDP_HEADER_LEN + BOOTTBL_HEADER_LEN + MAX_BOOTTBL_LEN; + data.IPlength = data.UDPlength + IP_HEADER_LEN; + UDPchecksum = bootmiscOnesComplementAdd(IP_TYPE_UDP, data.UDPlength); + + for(j=0; j= 0x200) { + data.SeqNo = 0x100; + } + + data.IPchecksum = 0x0000; + data.UDPchecksum = 0x0000; + + } + + // For the last packet + temp = counter*MAX_BOOTTBL_LEN; + counter = inSize - temp; // how many bytes remained + fprintf (strout,"0x%04X\n",TOTAL_HEADER_LEN+counter); + + data.UDPlength = UDP_HEADER_LEN + BOOTTBL_HEADER_LEN + counter; + + data.IPlength = data.UDPlength + IP_HEADER_LEN; + data.IPchecksum = bootmiscOnesComplementChksum(0,&data.VerTOS,IP_HEADER_LEN/2); + + if(getDataIn(strin, counter, data.BootTable)!=0) { + fclose(strin); + fclose(strout); + return; + } + + UDPchecksum = bootmiscOnesComplementAdd(IP_TYPE_UDP, data.UDPlength); + data.UDPchecksum=bootmiscOnesComplementChksum(UDPchecksum, &data.srcIPAddr_H,\ + (UINT16)((4+4+UDP_HEADER_LEN+BOOTTBL_HEADER_LEN+counter)/2)); + writeheader(strout, &data.dstMAC_H); + writeboottable(strout,&data.BootTable[0],counter/2); + + fprintf (strout, "0x%04X\n",(unsigned short)(SYMBOL)); + fprintf (strout, "0x%04X\n",0x0000); + fprintf (strout, "0x%04X\n",0x0000); + } + + fclose(strin); + fclose(strout); +} diff --git a/boot_loader/examples/ethernet/Utilities/bootpacket.exe b/boot_loader/examples/ethernet/Utilities/bootpacket.exe new file mode 100644 index 0000000..cc11e0e Binary files /dev/null and b/boot_loader/examples/ethernet/Utilities/bootpacket.exe differ diff --git a/boot_loader/examples/ethernet/Utilities/bootpacket.h b/boot_loader/examples/ethernet/Utilities/bootpacket.h new file mode 100644 index 0000000..a31a2df --- /dev/null +++ b/boot_loader/examples/ethernet/Utilities/bootpacket.h @@ -0,0 +1,110 @@ +/****************************************************************************** + * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +#ifndef bootpacket +#define bootpacket + +typedef short int INT16; +typedef int INT32; +typedef unsigned short int UINT16; +typedef unsigned int UINT32; + +#define DST_MAC_H 0x0008 +#define DST_MAC_M 0x7433 +#define DST_MAC_L 0x2630 + +#define SRC_MAC_H 0x000D +#define SRC_MAC_M 0x5676 +#define SRC_MAC_L 0x2F1A + +#define SRC_IP_ADDR_H 0x9EDA +#define SRC_IP_ADDR_L 0x674E +#define DST_IP_ADDR_H 0x9EDA +#define DST_IP_ADDR_L 0x6723 + +#define UDP_SRC_PORT 0x0 +#define UDP_SRC_PORT_BTPKT 0xBEEF /* Bill's bt-pkt.exe use this value */ +#define UDP_DST_PORT 0x9 + +#define ETHER_TYPE_IP 0x800 +#define IP_TYPE_UDP 0x11 + +#define MAGICNO 0x544B + +/* Actual packets has 14 +20 + 8 + 244 = 42 + 244 = 286 bytes */ + +#define MAC_HEADER_LEN 14 +#define IP_HEADER_LEN 20 +#define UDP_HEADER_LEN 8 +#define BOOTTBL_HEADER_LEN 4 +#define TOTAL_HEADER_LEN 46 /* 14 + 20 + 8 + 4 = 46 bytes */ + +#define MAX_PAYLOAD_LEN 244 +//#define MAX_PAYLOAD_LEN 1176 +#define MAX_BOOTTBL_LEN (MAX_PAYLOAD_LEN - BOOTTBL_HEADER_LEN) /* 240 bytes */ + +#define SYMBOL 0xEA00 +#define BGN_BYTE_LEN 0x04 /* ex: 0x0000, 0x00A2 */ +#define END_BYTE_LEN 0x06 /* ex: EA00, 0000, 0000 */ + + +struct BootPacket { + INT16 dstMAC_H; /* MAC */ + INT16 dstMAC_M; + INT16 dstMAC_L; + INT16 srcMAC_H; + INT16 srcMAC_M; + INT16 srcMAC_L; + INT16 EtherType; + INT16 VerTOS; /* IP */ + UINT16 IPlength; + INT16 ID; + INT16 FlagsFrag; + INT16 TTLProtocol; + UINT16 IPchecksum; + INT16 srcIPAddr_H; + INT16 srcIPAddr_L; + INT16 dstIPAddr_H; + INT16 dstIPAddr_L; + INT16 srcPort; /* UDP */ + INT16 dstPort; + UINT16 UDPlength; + UINT16 UDPchecksum; + INT16 MagicNo; /* Payload */ + INT16 SeqNo; + INT16 BootTable[MAX_BOOTTBL_LEN/2]; +}; + + + +#endif \ No newline at end of file diff --git a/boot_loader/examples/ethernet/docs/README.txt b/boot_loader/examples/ethernet/docs/README.txt new file mode 100644 index 0000000..d0f0a85 --- /dev/null +++ b/boot_loader/examples/ethernet/docs/README.txt @@ -0,0 +1,62 @@ +ROM Ethernet boot example + +A simple example demonstrating ROM Ethernet boot. + + +Directory structure: + +docs - directory contains the README.txt +simple - directory contains the batch/make file to build the simple example +Utilities - directory contains the utilities to convert the hex6x boot table file + to the Ethernet boot format data file: + + bconvert64x.exe - Convert a hex6x boot table file into the format required + by the c6x chip boot loader. + bootpacket.exe - Convert a boot table to Ethernet boot format + + +Steps to build the example: + +1. Run "simple.bat" under "tools\boot_loader\examples\ethernet\simple\". This will build the simple.out and use + hex6x.exe (delivered in CG tools package) to convert the .out to a boot table file, and then use the + bconvert64x.exe/bootpacket.exe to convert the hex6x boot table file to the Ethernet boot format data file, + simple.eth. + + +Steps to send the simple.eth from the Host to the target DSP + +1. Boot the target DSP in ROM Ethernet boot mode. + + The DIP switch setting for C6678 EVM is: + SW3(pin1, pin2, pin3, pin4): off, on, off, on + SW4(pin1, pin2, pin3, pin4): on, on, on, off + SW5(pin1, pin2, pin3, pin4): on, on, off, off + SW6(pin1, pin2, pin3, pin4): off, on, on, on + + The DIP switch setting for C6670 EVM is: + SW3(pin1, pin2, pin3, pin4): off, on, off, on + SW4(pin1, pin2, pin3, pin4): on, on, on, off + SW5(pin1, pin2, pin3, pin4): on, off, on, off + SW6(pin1, pin2, pin3, pin4): off, off, on, on + +2. Once the DSP boots up, it transmits BOOTP packet at regular interval which will have the MAC ID of the DSP. + +3. Add an ARP entry for the DSP MAC address associating with an IP local to the host. For example if the host PC's + IP is 192.168.1.1, then add an ARP entry with the DSP's MAC address associated with IP address 192.168.1.2. + +4. Use the pcsendpkt.exe to send the image to the DSP using the associated IP address. For example + pcsendpkt.exe simple.eth 192.168.1.2 + +5. Use CCS to connect the EVM, and check that A1 register is set to 0x11223344, that confirms the simple program + is received and booted by the ROM boot loader. + +Notes: +1. In order to compile the pcsendpkt.c file please compile with -lwsock32 option for using windows socket. +2. Please refer to the C66x DSP Bootloader User's Guide (http://www.ti.com/litv/pdf/sprugy5) for more details. +3. Please refer to C6678L/C6670L EVM boot mode dip switch settings: +http://processors.wiki.ti.com/index.php/TMDXEVM6678L_EVM_Hardware_Setup#Boot_Mode_Dip_Switch_Settings +http://processors.wiki.ti.com/index.php/TMDXEVM6670L_EVM_Hardware_Setup#Boot_Mode_Dip_Switch_Settings + +and User's Guide for more details: +http://processors.wiki.ti.com/index.php/BIOS_MCSDK_2.0_User_Guide + diff --git a/boot_loader/examples/ethernet/simple/makefile b/boot_loader/examples/ethernet/simple/makefile new file mode 100644 index 0000000..949de97 --- /dev/null +++ b/boot_loader/examples/ethernet/simple/makefile @@ -0,0 +1,45 @@ +#************************************************************************** +#* FILE PURPOSE: Build the simple test program +#************************************************************************** +#* FILE NAME: makefile +#* +#* DESCRIPTION: Builds the following: +#* +#* simple.out - little endian mapped program. +#* simple.le.btbl - Simple program in boot table format. +#* simple.eth - Simple Program in ETH format. +#* +#*************************************************************************** + +AOPTS_LE= -g -c -k -mi200 -ml3 -pm -mv6400 +AOPTS_BE= -me $(AOPTS_LE) + +all: simple.eth + +simple.eth: simple.out + hex6x simple.rmd + ../Utilities/bconvert64x -le simple.btbl simple.le.btbl + ../Utilities/bootpacket simple.le.btbl simple.eth + cp simple.eth ../Ethernet_boot/simple.eth + rm simple.eth + +simple.out: simple.obj simple.cmd + cl6x -z simple.cmd -o simple.out -m simple.map + +simple.obj: simple.s + cl6x $(AOPTS_LE) simple.s + +clean: + rm simple.obj + rm simple.out + rm simple.btbl + rm simple.le.btbl + rm simple.map + + + + + + + + diff --git a/boot_loader/examples/ethernet/simple/simple.bat b/boot_loader/examples/ethernet/simple/simple.bat new file mode 100644 index 0000000..b48983a --- /dev/null +++ b/boot_loader/examples/ethernet/simple/simple.bat @@ -0,0 +1,4 @@ +set PATH=%PATH%;"C:\Program Files\Texas Instruments\ccsv5\tools\compiler\c6000\bin"; +make simple.eth + + diff --git a/boot_loader/examples/ethernet/simple/simple.cmd b/boot_loader/examples/ethernet/simple/simple.cmd new file mode 100644 index 0000000..4589593 --- /dev/null +++ b/boot_loader/examples/ethernet/simple/simple.cmd @@ -0,0 +1,41 @@ +/*************************************************************************** + * FILE PURPOSE: The linker command file for program simple + *************************************************************************** + * FILE NAME: simple_him.cmd + * + * DESCRIPTION: Maps the program simple into the memory space + * + ***************************************************************************/ + +/* Object file */ +simple.obj + +/* Linker options */ +-c +-a + +MEMORY +{ + PAGE 0: + + TEXT : origin = 0x810000, length = 0x0040 + DATA : origin = 0x810100, length = 0x0004 + BYTE1 : origin = 0x810201, length = 0x0001 + BYTE2 : origin = 0x810210, length = 0x0002 + +} + +SECTIONS +{ + .text > TEXT PAGE 0 + .data > DATA PAGE 0 + .byte1 > BYTE1 PAGE 0 + .byte2 > BYTE2 PAGE 0 +} + + + + + + + diff --git a/boot_loader/examples/ethernet/simple/simple.rmd b/boot_loader/examples/ethernet/simple/simple.rmd new file mode 100644 index 0000000..7b0bf5c --- /dev/null +++ b/boot_loader/examples/ethernet/simple/simple.rmd @@ -0,0 +1,15 @@ +simple.out +-a +-boot +-e _c_int00 +-order L + +ROMS +{ + ROM1: org = 0x0400, length = 0x0080, memwidth = 32, romwidth = 32 + files = { simple.btbl } + +} + + + \ No newline at end of file diff --git a/boot_loader/examples/ethernet/simple/simple.s b/boot_loader/examples/ethernet/simple/simple.s new file mode 100644 index 0000000..4501452 --- /dev/null +++ b/boot_loader/examples/ethernet/simple/simple.s @@ -0,0 +1,96 @@ +;/****************************************************************************** +; * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com +; * +; * Redistribution and use in source and binary forms, with or without +; * modification, are permitted provided that the following conditions +; * are met: +; * +; * Redistributions of source code must retain the above copyright +; * notice, this list of conditions and the following disclaimer. +; * +; * Redistributions in binary form must reproduce the above copyright +; * notice, this list of conditions and the following disclaimer in the +; * documentation and/or other materials provided with the +; * distribution. +; * +; * Neither the name of Texas Instruments Incorporated nor the names of +; * its contributors may be used to endorse or promote products derived +; * from this software without specific prior written permission. +; * +; * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +; * +; *****************************************************************************/ + +;**************************************************************************** +;* FILE PURPOSE: A simple endian independent example +;**************************************************************************** +;* FILE NAME: Simple.s +;* +;* DESCRIPTION: A simple program that defines two initialized +;* sections, text and data, and performs the following simple +;* executions: +;* 1. store a constant (011223344h) to register A1 +;* 2. store the data in byte1 section (0x12) to registerB2. +;* 3. store the data in byte21 section (0x12, 034) to register B3, B4. +;* +;***************************************************************************** + +;***************************************************************************** +;* Initialized data +;***************************************************************************** + .data + .def someData +someData .word 01234ABCDh + + .def byte1 + .sect ".byte1" +byte1: .byte 0x12 + + .def byte2 + .sect ".byte2" +byte2: .byte 0x12, 0x34 + +;***************************************************************************** +;* code +;***************************************************************************** + .text + .def _c_int00 + +myConst .equ 011223344h + +_c_int00: + + MVKL.S1 myConst, A1 + MVKH.S1 myConst, A1 + + MVKL.S1 byte1, A2 + MVKH.S1 byte1, A2 + LDB.D1 *A2, B2 + + MVKL.S1 byte2, A3 + MVKH.S1 byte2, A3 + LDB.D1 *A3++, B3 + LDB.D1 *A3, B4 + + +etrap: + + BNOP.S1 etrap, 5 + + + + + + + + diff --git a/boot_loader/examples/i2c/emac/docs/README.txt b/boot_loader/examples/i2c/emac/docs/README.txt deleted file mode 100644 index dda194d..0000000 --- a/boot_loader/examples/i2c/emac/docs/README.txt +++ /dev/null @@ -1,54 +0,0 @@ -EMAC boot over I2C example - -A simple Hello World example demonstrating EMAC boot over I2C. - -Steps to build the example: - -1. Import the i2cemacboot CCS project from tools\boot_loader\examples\i2c\emac\evmc66xxl directory. (in CCSv5, - Project->Import Existing CCS/CCE Eclipse Projects) - -2. Clean the i2cemacboot project and re-build the project, after build is completed, i2cemacboot_evm66xxl.out and - i2cemacboot_evm66xxl.map will be generated under tools\boot_loader\examples\i2c\emac\evmc66xxl\bin directory. - -Steps to run i2cemacboot in CCSv5: - -1. Be sure to set the boot mode dip switch to no boot/EMIF16 boot mode on the EVM. - -2. Load the program tools\boot_loader\examples\i2c\emac\evmc66xxl\bin\i2cemacboot_evm66xxl.out to CCS. - -3. Connect the 3-pin RS-232 cable from the EVM to the serial port of the PC, and start Hyper Terminal. - -4. Create a new connection with the Baud rate set to 115200 bps, Data bits 8, Parity none, Stop bits 1 and - Flow control none. Be sure the COM port # is set correctly. - -5. Run the program in CCS, i2cemacboot will send the hello world booting info to both the CCS console and the - Hyper Terminal. - -Steps to boot i2cemacboot from EMAC: - -1. Be sure IBL is programmed to I2C EEPROM bus address 81 (0x51), if IBL is not programmed, refer to - tools\boot_loader\ibl\doc\README.txt on how to program the IBL to EEPROM. - -2. By default, IBL will boot a BBLOB image from EMAC, to run this example, we need to change the - EMAC boot image format to ELF: - a. In setConfig_c66xx_main() of tools\boot_loader\ibl\src\util\i2cConfig\i2cConfig.gel, - replace - ibl.bootModes[2].u.ethBoot.bootFormat = ibl_BOOT_FORMAT_BBLOB; - with - ibl.bootModes[2].u.ethBoot.bootFormat = ibl_BOOT_FORMAT_ELF; - b. Re-program the boot configuration table, refer to tools\boot_loader\ibl\doc\README.txt on how to program - the boot configuration table to EEPROM. - -3. Start a TFTP server (you can download a free, open source application from http://tftpd32.jounin.net) and copy - tools\boot_loader\examples\i2c\emac\evmc66xxl\bin\i2cemacboot_evm66xxl.out to the TFTP base directory, rename - i2cemacboot_evm66xxl.out to app.out. - -4. Set the IP address of the PC that is running the TFTP server to 192.168.2.101, since by default IBL will set the EVM - IP address to 192.168.2.100 and the TFTP server IP address to 192.168.2.101. - -5. Set the boot dip switches to I2C master mode, bus address 81 (0x51) and boot parameter index to be 4. - -6. Be sure the EVM and the PC are connected in the same subnet of a local network, after POR, IBL will download the - boot image from TFTP server and boot from it. - -Please refer to User's Guide (http://processors.wiki.ti.com/index.php/BIOS_MCSDK_2.0_User_Guide) for more details. diff --git a/boot_loader/examples/i2c/emac/evmc6670l/.ccsproject b/boot_loader/examples/i2c/emac/evmc6670l/.ccsproject deleted file mode 100644 index 79d3116..0000000 --- a/boot_loader/examples/i2c/emac/evmc6670l/.ccsproject +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/boot_loader/examples/i2c/emac/evmc6670l/.cproject b/boot_loader/examples/i2c/emac/evmc6670l/.cproject deleted file mode 100644 index b056636..0000000 --- a/boot_loader/examples/i2c/emac/evmc6670l/.cproject +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/boot_loader/examples/i2c/emac/evmc6670l/.project b/boot_loader/examples/i2c/emac/evmc6670l/.project deleted file mode 100644 index 459c24e..0000000 --- a/boot_loader/examples/i2c/emac/evmc6670l/.project +++ /dev/null @@ -1,96 +0,0 @@ - - - i2cemacboot_evmc6670l - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - -k - - - org.eclipse.cdt.make.core.buildCommand - ${CCS_INSTALL_ROOT}/utils/gmake/gmake - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/i2cemacboot/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - true - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.rtsc.xdctools.buildDefinitions.XDC.xdcNature - com.ti.ccstudio.managedbuild.core.ccsNature - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - README.txt - 1 - TI_MCSDK_I2CEXAMPLES_DIR/emac/docs/README.txt - - - src - 2 - TI_MCSDK_I2CEXAMPLES_DIR/emac/src - - - diff --git a/boot_loader/examples/i2c/emac/evmc6670l/i2c_boot_emac_example.cmd b/boot_loader/examples/i2c/emac/evmc6670l/i2c_boot_emac_example.cmd deleted file mode 100644 index cab1993..0000000 --- a/boot_loader/examples/i2c/emac/evmc6670l/i2c_boot_emac_example.cmd +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -/* - * Linker command file - * - */ - --c --heap 0x40000 --stack 0x8000 - -/* Memory Map 1 - the default */ -MEMORY -{ - L1PSRAM (RWX) : org = 0x0E00000, len = 0x7FFF - L1DSRAM (RWX) : org = 0x0F00000, len = 0x7FFF - - L2SRAM (RWX) : org = 0x0820000, len = 0xe0000 - MSMCSRAM (RWX) : org = 0xc000000, len = 0x200000 - DDR3 (RWX) : org = 0x80000000,len = 0x10000000 -} - -SECTIONS -{ - .csl_vect > L2SRAM - .cppi > L2SRAM - .linkram > L2SRAM - .mac_buffer > L2SRAM - platform_lib > L2SRAM - .text > L2SRAM - GROUP (NEAR_DP) - { - .neardata - .rodata - .bss - } load > L2SRAM - .stack > L2SRAM - .cinit > L2SRAM - .cio > L2SRAM - .const > L2SRAM - .data > L2SRAM - .switch > L2SRAM - .sysmem > L2SRAM - .far > L2SRAM - .testMem > L2SRAM - .fardata > L2SRAM -} diff --git a/boot_loader/examples/i2c/emac/evmc6670l/macros.ini b/boot_loader/examples/i2c/emac/evmc6670l/macros.ini deleted file mode 100644 index f4e4f7b..0000000 --- a/boot_loader/examples/i2c/emac/evmc6670l/macros.ini +++ /dev/null @@ -1 +0,0 @@ -TI_MCSDK_I2CEXAMPLES_DIR="../../../../ diff --git a/boot_loader/examples/i2c/emac/evmc6678l/.ccsproject b/boot_loader/examples/i2c/emac/evmc6678l/.ccsproject deleted file mode 100644 index 79d3116..0000000 --- a/boot_loader/examples/i2c/emac/evmc6678l/.ccsproject +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/boot_loader/examples/i2c/emac/evmc6678l/.cproject b/boot_loader/examples/i2c/emac/evmc6678l/.cproject deleted file mode 100644 index da96a73..0000000 --- a/boot_loader/examples/i2c/emac/evmc6678l/.cproject +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/boot_loader/examples/i2c/emac/evmc6678l/.project b/boot_loader/examples/i2c/emac/evmc6678l/.project deleted file mode 100644 index e1f5627..0000000 --- a/boot_loader/examples/i2c/emac/evmc6678l/.project +++ /dev/null @@ -1,96 +0,0 @@ - - - i2cemacboot_evmc6678l - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - -k - - - org.eclipse.cdt.make.core.buildCommand - ${CCS_INSTALL_ROOT}/utils/gmake/gmake - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/i2cemacboot/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - true - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.rtsc.xdctools.buildDefinitions.XDC.xdcNature - com.ti.ccstudio.managedbuild.core.ccsNature - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - README.txt - 1 - TI_MCSDK_I2CEXAMPLES_DIR/emac/docs/README.txt - - - src - 2 - TI_MCSDK_I2CEXAMPLES_DIR/emac/src - - - diff --git a/boot_loader/examples/i2c/emac/evmc6678l/i2c_boot_emac_example.cmd b/boot_loader/examples/i2c/emac/evmc6678l/i2c_boot_emac_example.cmd deleted file mode 100644 index cab1993..0000000 --- a/boot_loader/examples/i2c/emac/evmc6678l/i2c_boot_emac_example.cmd +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -/* - * Linker command file - * - */ - --c --heap 0x40000 --stack 0x8000 - -/* Memory Map 1 - the default */ -MEMORY -{ - L1PSRAM (RWX) : org = 0x0E00000, len = 0x7FFF - L1DSRAM (RWX) : org = 0x0F00000, len = 0x7FFF - - L2SRAM (RWX) : org = 0x0820000, len = 0xe0000 - MSMCSRAM (RWX) : org = 0xc000000, len = 0x200000 - DDR3 (RWX) : org = 0x80000000,len = 0x10000000 -} - -SECTIONS -{ - .csl_vect > L2SRAM - .cppi > L2SRAM - .linkram > L2SRAM - .mac_buffer > L2SRAM - platform_lib > L2SRAM - .text > L2SRAM - GROUP (NEAR_DP) - { - .neardata - .rodata - .bss - } load > L2SRAM - .stack > L2SRAM - .cinit > L2SRAM - .cio > L2SRAM - .const > L2SRAM - .data > L2SRAM - .switch > L2SRAM - .sysmem > L2SRAM - .far > L2SRAM - .testMem > L2SRAM - .fardata > L2SRAM -} diff --git a/boot_loader/examples/i2c/emac/evmc6678l/macros.ini b/boot_loader/examples/i2c/emac/evmc6678l/macros.ini deleted file mode 100644 index f4e4f7b..0000000 --- a/boot_loader/examples/i2c/emac/evmc6678l/macros.ini +++ /dev/null @@ -1 +0,0 @@ -TI_MCSDK_I2CEXAMPLES_DIR="../../../../ diff --git a/boot_loader/examples/i2c/emac/src/i2c_boot_emac_example.c b/boot_loader/examples/i2c/emac/src/i2c_boot_emac_example.c deleted file mode 100644 index 55e447c..0000000 --- a/boot_loader/examples/i2c/emac/src/i2c_boot_emac_example.c +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Texas Instruments Incorporated emac the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ - -/************************************************************************************** - * FILE PURPOSE: EMAC Boot Over I2C Example - ************************************************************************************** - * FILE NAME: i2c_boot_emac_example.c - * - * DESCRIPTION: A simple hello world example demonstrating EMAC boot over I2C. - * - ***************************************************************************************/ -#include -#include -#include -#include "platform.h" - -#define BOOT_UART_BAUDRATE 115200 - -/* i2c_boot_emac_example version */ -char version[] = "01.00.00.00"; - -/****************************************************************************** - * Function: print_platform_errno - ******************************************************************************/ -void -print_platform_errno -( - void -) -{ - printf ("Returned platform error number is %d\n", platform_errno); -} - -/****************************************************************************** - * Function: write_uart - ******************************************************************************/ -void -write_uart -( - char* msg -) -{ - uint32_t i; - uint32_t msg_len = strlen(msg); - - /* Write the message to the UART */ - for (i = 0; i < msg_len; i++) - { - platform_uart_write(msg[i]); - } -} - - -/****************************************************************************** - * Function: main - ******************************************************************************/ -void main () -{ - platform_init_flags init_flags; - platform_init_config init_config; - char version_msg[] = "\r\n\r\nEMAC Boot Over I2C Example Version "; - char boot_msg[] = "\r\n\r\nBooting Hello World image from EMAC via IBL over I2C 0x51 ..."; - - printf("%s%s\n\n", version_msg, version); - - /* Initialize main Platform lib */ - memset(&init_config, 0, sizeof(platform_init_config)); - memset(&init_flags, 1, sizeof(platform_init_flags)); - if (platform_init(&init_flags, &init_config) != Platform_EOK) - { - printf ("Platform init failed!\n"); - print_platform_errno(); - return; - } - platform_uart_init(); - platform_uart_set_baudrate(BOOT_UART_BAUDRATE); - - write_uart(version_msg); - write_uart(version); - - printf("%s", boot_msg); - write_uart(boot_msg); -} diff --git a/boot_loader/examples/i2c/nand/docs/README.txt b/boot_loader/examples/i2c/nand/docs/README.txt index 6930c19..fe9eab9 100644 --- a/boot_loader/examples/i2c/nand/docs/README.txt +++ b/boot_loader/examples/i2c/nand/docs/README.txt @@ -26,12 +26,12 @@ Steps to run i2cnandboot in CCSv5: Steps to program i2cnandboot to NAND: -1. Be sure IBL is programmed to I2C EEPROM bus address 81 (0x51), if IBL is not programmed, refer to +1. Be sure IBL is programmed to I2C EEPROM bus address 0x51, if IBL is not programmed, refer to tools\boot_loader\ibl\doc\README.txt on how to program the IBL to EEPROM. 2. By default, IBL will boot a BBLOB image (Linux kernel) from NAND, to run this example, we need to change the NAND boot image format to ELF: - a. In setConfig_c66xx_main() of tools\boot_loader\ibl\src\util\i2cConfig\i2cConfig.gel, + a. In setConfig_c66xx_main() of tools\boot_loader\ibl\src\make\bin\i2cConfig.gel, replace ibl.bootModes[1].u.nandBoot.bootFormat = ibl_BOOT_FORMAT_BBLOB; with @@ -44,8 +44,13 @@ Steps to program i2cnandboot to NAND: the app.bin to NAND flash. 4. Once the programming is completed successfully, set the boot dip switches to I2C master mode, - bus address 81 (0x51) and boot parameter index to be 2. + bus address 0x51 and boot parameter index to be 2. 5. After POR, IBL will boot the hello world image from NAND. -Please refer to User's Guide (http://processors.wiki.ti.com/index.php/BIOS_MCSDK_2.0_User_Guide) for more details. +Please refer to C6678L/C6670L EVM boot mode dip switch settings: +http://processors.wiki.ti.com/index.php/TMDXEVM6678L_EVM_Hardware_Setup#Boot_Mode_Dip_Switch_Settings +http://processors.wiki.ti.com/index.php/TMDXEVM6670L_EVM_Hardware_Setup#Boot_Mode_Dip_Switch_Settings + +and User's Guide for more details: +http://processors.wiki.ti.com/index.php/BIOS_MCSDK_2.0_User_Guide diff --git a/boot_loader/examples/i2c/nor/docs/README.txt b/boot_loader/examples/i2c/nor/docs/README.txt index dd4d846..b6119ed 100644 --- a/boot_loader/examples/i2c/nor/docs/README.txt +++ b/boot_loader/examples/i2c/nor/docs/README.txt @@ -27,7 +27,7 @@ Steps to run i2cnorboot in CCSv5: Steps to program i2cnorboot to NOR: -1. Be sure IBL and boot configuration table are programmed to I2C EEPROM bus address 81 (0x51), if IBL and/or +1. Be sure IBL and boot configuration table are programmed to I2C EEPROM bus address 0x51, if IBL and/or boot configuration table are not programmed, refer to tools\boot_loader\ibl\doc\README.txt on how to program the IBL and boot configuration table to EEPROM. @@ -36,8 +36,15 @@ Steps to program i2cnorboot to NOR: the app.bin to NOR flash. 3. Once the programming is completed successfully, set the boot dip switches to I2C master mode, - bus address 81 (0x51) and boot parameter index to be 0. + bus address 0x51 and boot parameter index to be 0. 4. After POR, IBL will boot the hello world image from NOR. -Please refer to User's Guide (http://processors.wiki.ti.com/index.php/BIOS_MCSDK_2.0_User_Guide) for more details. +Please refer to C6678L/C6670L EVM boot mode dip switch settings: +http://processors.wiki.ti.com/index.php/TMDXEVM6678L_EVM_Hardware_Setup#Boot_Mode_Dip_Switch_Settings +http://processors.wiki.ti.com/index.php/TMDXEVM6670L_EVM_Hardware_Setup#Boot_Mode_Dip_Switch_Settings + +and User's Guide for more details: +http://processors.wiki.ti.com/index.php/BIOS_MCSDK_2.0_User_Guide + + diff --git a/boot_loader/examples/i2c/tftp/docs/README.txt b/boot_loader/examples/i2c/tftp/docs/README.txt new file mode 100644 index 0000000..d2799aa --- /dev/null +++ b/boot_loader/examples/i2c/tftp/docs/README.txt @@ -0,0 +1,59 @@ +TFTP boot over I2C example + +A simple Hello World example demonstrating TFTP boot over I2C. + +Steps to build the example: + +1. Import the i2ctftpboot CCS project from tools\boot_loader\examples\i2c\tftp\evmc66xxl directory. (in CCSv5, + Project->Import Existing CCS/CCE Eclipse Projects) + +2. Clean the i2ctftpboot project and re-build the project, after build is completed, i2ctftpboot_evm66xxl.out and + i2ctftpboot_evm66xxl.map will be generated under tools\boot_loader\examples\i2c\tftp\evmc66xxl\bin directory. + +Steps to run i2ctftpboot in CCSv5: + +1. Be sure to set the boot mode dip switch to no boot/EMIF16 boot mode on the EVM. + +2. Load the program tools\boot_loader\examples\i2c\tftp\evmc66xxl\bin\i2ctftpboot_evm66xxl.out to CCS. + +3. Connect the 3-pin RS-232 cable from the EVM to the serial port of the PC, and start Hyper Terminal. + +4. Create a new connection with the Baud rate set to 115200 bps, Data bits 8, Parity none, Stop bits 1 and + Flow control none. Be sure the COM port # is set correctly. + +5. Run the program in CCS, i2ctftpboot will send the hello world booting info to both the CCS console and the + Hyper Terminal. + +Steps to boot i2ctftpboot from TFTP: + +1. Be sure IBL is programmed to I2C EEPROM bus address 81 (0x51), if IBL is not programmed, refer to + tools\boot_loader\ibl\doc\README.txt on how to program the IBL to EEPROM. + +2. By default, IBL will boot a BBLOB image from TFTP, to run this example, we need to change the + TFTP boot image format to ELF: + a. In setConfig_c66xx_main() of tools\boot_loader\ibl\src\make\bin\i2cConfig.gel, + replace + ibl.bootModes[2].u.ethBoot.bootFormat = ibl_BOOT_FORMAT_BBLOB; + with + ibl.bootModes[2].u.ethBoot.bootFormat = ibl_BOOT_FORMAT_ELF; + b. Re-program the boot configuration table, refer to tools\boot_loader\ibl\doc\README.txt on how to program + the boot configuration table to EEPROM. + +3. Start a TFTP server (you can download a free, open source application from http://tftpd32.jounin.net) and copy + tools\boot_loader\examples\i2c\tftp\evmc66xxl\bin\i2ctftpboot_evm66xxl.out to the TFTP base directory, rename + i2ctftpboot_evm66xxl.out to app.out. + +4. Set the IP address of the PC that is running the TFTP server to 192.168.2.101, since by default IBL will set the EVM + IP address to 192.168.2.100 and the TFTP server IP address to 192.168.2.101. + +5. Set the boot dip switches to I2C master mode, bus address 0x51 and boot parameter index to be 4. + +6. Be sure the EVM and the PC are connected in the same subnet of a local network, after POR, IBL will download the + boot image from TFTP server and boot from it. + +Please refer to C6678L/C6670L EVM boot mode dip switch settings: +http://processors.wiki.ti.com/index.php/TMDXEVM6678L_EVM_Hardware_Setup#Boot_Mode_Dip_Switch_Settings +http://processors.wiki.ti.com/index.php/TMDXEVM6670L_EVM_Hardware_Setup#Boot_Mode_Dip_Switch_Settings + +and User's Guide for more details: +http://processors.wiki.ti.com/index.php/BIOS_MCSDK_2.0_User_Guide diff --git a/boot_loader/examples/i2c/tftp/evmc6670l/.ccsproject b/boot_loader/examples/i2c/tftp/evmc6670l/.ccsproject new file mode 100644 index 0000000..79d3116 --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6670l/.ccsproject @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/boot_loader/examples/i2c/tftp/evmc6670l/.cproject b/boot_loader/examples/i2c/tftp/evmc6670l/.cproject new file mode 100644 index 0000000..03a9e17 --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6670l/.cproject @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/boot_loader/examples/i2c/tftp/evmc6670l/.project b/boot_loader/examples/i2c/tftp/evmc6670l/.project new file mode 100644 index 0000000..a8fbd18 --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6670l/.project @@ -0,0 +1,96 @@ + + + i2ctftpboot_evmc6670l + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + -k + + + org.eclipse.cdt.make.core.buildCommand + ${CCS_INSTALL_ROOT}/utils/gmake/gmake + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/i2ctftpboot/Debug} + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + true + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.rtsc.xdctools.buildDefinitions.XDC.xdcNature + com.ti.ccstudio.managedbuild.core.ccsNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + README.txt + 1 + TI_MCSDK_I2CEXAMPLES_DIR/tftp/docs/README.txt + + + src + 2 + TI_MCSDK_I2CEXAMPLES_DIR/tftp/src + + + diff --git a/boot_loader/examples/i2c/tftp/evmc6670l/i2c_boot_tftp_example.cmd b/boot_loader/examples/i2c/tftp/evmc6670l/i2c_boot_tftp_example.cmd new file mode 100644 index 0000000..cab1993 --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6670l/i2c_boot_tftp_example.cmd @@ -0,0 +1,77 @@ +/****************************************************************************** + * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ +/* + * Linker command file + * + */ + +-c +-heap 0x40000 +-stack 0x8000 + +/* Memory Map 1 - the default */ +MEMORY +{ + L1PSRAM (RWX) : org = 0x0E00000, len = 0x7FFF + L1DSRAM (RWX) : org = 0x0F00000, len = 0x7FFF + + L2SRAM (RWX) : org = 0x0820000, len = 0xe0000 + MSMCSRAM (RWX) : org = 0xc000000, len = 0x200000 + DDR3 (RWX) : org = 0x80000000,len = 0x10000000 +} + +SECTIONS +{ + .csl_vect > L2SRAM + .cppi > L2SRAM + .linkram > L2SRAM + .mac_buffer > L2SRAM + platform_lib > L2SRAM + .text > L2SRAM + GROUP (NEAR_DP) + { + .neardata + .rodata + .bss + } load > L2SRAM + .stack > L2SRAM + .cinit > L2SRAM + .cio > L2SRAM + .const > L2SRAM + .data > L2SRAM + .switch > L2SRAM + .sysmem > L2SRAM + .far > L2SRAM + .testMem > L2SRAM + .fardata > L2SRAM +} diff --git a/boot_loader/examples/i2c/tftp/evmc6670l/macros.ini b/boot_loader/examples/i2c/tftp/evmc6670l/macros.ini new file mode 100644 index 0000000..f4e4f7b --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6670l/macros.ini @@ -0,0 +1 @@ +TI_MCSDK_I2CEXAMPLES_DIR="../../../../ diff --git a/boot_loader/examples/i2c/tftp/evmc6678l/.ccsproject b/boot_loader/examples/i2c/tftp/evmc6678l/.ccsproject new file mode 100644 index 0000000..79d3116 --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6678l/.ccsproject @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/boot_loader/examples/i2c/tftp/evmc6678l/.cproject b/boot_loader/examples/i2c/tftp/evmc6678l/.cproject new file mode 100644 index 0000000..4d71d4c --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6678l/.cproject @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/boot_loader/examples/i2c/tftp/evmc6678l/.project b/boot_loader/examples/i2c/tftp/evmc6678l/.project new file mode 100644 index 0000000..bf80801 --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6678l/.project @@ -0,0 +1,96 @@ + + + i2ctftpboot_evmc6678l + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + -k + + + org.eclipse.cdt.make.core.buildCommand + ${CCS_INSTALL_ROOT}/utils/gmake/gmake + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/i2ctftpboot/Debug} + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + true + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.rtsc.xdctools.buildDefinitions.XDC.xdcNature + com.ti.ccstudio.managedbuild.core.ccsNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + README.txt + 1 + TI_MCSDK_I2CEXAMPLES_DIR/tftp/docs/README.txt + + + src + 2 + TI_MCSDK_I2CEXAMPLES_DIR/tftp/src + + + diff --git a/boot_loader/examples/i2c/tftp/evmc6678l/i2c_boot_tftp_example.cmd b/boot_loader/examples/i2c/tftp/evmc6678l/i2c_boot_tftp_example.cmd new file mode 100644 index 0000000..cab1993 --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6678l/i2c_boot_tftp_example.cmd @@ -0,0 +1,77 @@ +/****************************************************************************** + * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ +/* + * Linker command file + * + */ + +-c +-heap 0x40000 +-stack 0x8000 + +/* Memory Map 1 - the default */ +MEMORY +{ + L1PSRAM (RWX) : org = 0x0E00000, len = 0x7FFF + L1DSRAM (RWX) : org = 0x0F00000, len = 0x7FFF + + L2SRAM (RWX) : org = 0x0820000, len = 0xe0000 + MSMCSRAM (RWX) : org = 0xc000000, len = 0x200000 + DDR3 (RWX) : org = 0x80000000,len = 0x10000000 +} + +SECTIONS +{ + .csl_vect > L2SRAM + .cppi > L2SRAM + .linkram > L2SRAM + .mac_buffer > L2SRAM + platform_lib > L2SRAM + .text > L2SRAM + GROUP (NEAR_DP) + { + .neardata + .rodata + .bss + } load > L2SRAM + .stack > L2SRAM + .cinit > L2SRAM + .cio > L2SRAM + .const > L2SRAM + .data > L2SRAM + .switch > L2SRAM + .sysmem > L2SRAM + .far > L2SRAM + .testMem > L2SRAM + .fardata > L2SRAM +} diff --git a/boot_loader/examples/i2c/tftp/evmc6678l/macros.ini b/boot_loader/examples/i2c/tftp/evmc6678l/macros.ini new file mode 100644 index 0000000..f4e4f7b --- /dev/null +++ b/boot_loader/examples/i2c/tftp/evmc6678l/macros.ini @@ -0,0 +1 @@ +TI_MCSDK_I2CEXAMPLES_DIR="../../../../ diff --git a/boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c b/boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c new file mode 100644 index 0000000..55e447c --- /dev/null +++ b/boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c @@ -0,0 +1,113 @@ +/****************************************************************************** + * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated emac the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +/************************************************************************************** + * FILE PURPOSE: EMAC Boot Over I2C Example + ************************************************************************************** + * FILE NAME: i2c_boot_emac_example.c + * + * DESCRIPTION: A simple hello world example demonstrating EMAC boot over I2C. + * + ***************************************************************************************/ +#include +#include +#include +#include "platform.h" + +#define BOOT_UART_BAUDRATE 115200 + +/* i2c_boot_emac_example version */ +char version[] = "01.00.00.00"; + +/****************************************************************************** + * Function: print_platform_errno + ******************************************************************************/ +void +print_platform_errno +( + void +) +{ + printf ("Returned platform error number is %d\n", platform_errno); +} + +/****************************************************************************** + * Function: write_uart + ******************************************************************************/ +void +write_uart +( + char* msg +) +{ + uint32_t i; + uint32_t msg_len = strlen(msg); + + /* Write the message to the UART */ + for (i = 0; i < msg_len; i++) + { + platform_uart_write(msg[i]); + } +} + + +/****************************************************************************** + * Function: main + ******************************************************************************/ +void main () +{ + platform_init_flags init_flags; + platform_init_config init_config; + char version_msg[] = "\r\n\r\nEMAC Boot Over I2C Example Version "; + char boot_msg[] = "\r\n\r\nBooting Hello World image from EMAC via IBL over I2C 0x51 ..."; + + printf("%s%s\n\n", version_msg, version); + + /* Initialize main Platform lib */ + memset(&init_config, 0, sizeof(platform_init_config)); + memset(&init_flags, 1, sizeof(platform_init_flags)); + if (platform_init(&init_flags, &init_config) != Platform_EOK) + { + printf ("Platform init failed!\n"); + print_platform_errno(); + return; + } + platform_uart_init(); + platform_uart_set_baudrate(BOOT_UART_BAUDRATE); + + write_uart(version_msg); + write_uart(version); + + printf("%s", boot_msg); + write_uart(boot_msg); +} diff --git a/boot_loader/tools_install.bat b/boot_loader/tools_install.bat index c3aef59..0c6d54c 100644 --- a/boot_loader/tools_install.bat +++ b/boot_loader/tools_install.bat @@ -1,5 +1,8 @@ mv -f MAD_UG.doc mad-utils\MAD_UG.doc +rm -f examples\srio\docs\readme.doc + +rm -f -r ..\factory_images -- cgit v1.2.3-54-g00ecf