You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
| 2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
| 2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
| 2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
| 2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
| 2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
| 2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
| 2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
| 2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
| 2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
| 2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
| 2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
| 2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
| 2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
| 2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
| 2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
| 2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(54) |
Sep
(47) |
Oct
(15) |
Nov
(42) |
Dec
|
|
From: <oh...@ma...> - 2009-01-05 10:32:27
|
Author: oharboe
Date: 2009-01-05 10:32:23 +0100 (Mon, 05 Jan 2009)
New Revision: 1301
Modified:
trunk/src/flash/pic32mx.c
trunk/src/flash/pic32mx.h
trunk/src/target/mips32_pracc.c
trunk/src/target/mips32_pracc.h
Log:
John McCarthy <jg...@ma...> pic32mx flash fixups and speedups
Modified: trunk/src/flash/pic32mx.c
===================================================================
--- trunk/src/flash/pic32mx.c 2009-01-05 09:26:25 UTC (rev 1300)
+++ trunk/src/flash/pic32mx.c 2009-01-05 09:32:23 UTC (rev 1301)
@@ -71,6 +71,8 @@
int pic32mx_erase(struct flash_bank_s *bank, int first, int last);
int pic32mx_protect(struct flash_bank_s *bank, int set, int first, int last);
int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
+int pic32mx_write_row(struct flash_bank_s *bank, u32 address, u32 srcaddr);
+int pic32mx_write_word(struct flash_bank_s *bank, u32 address, u32 word);
int pic32mx_probe(struct flash_bank_s *bank);
int pic32mx_auto_probe(struct flash_bank_s *bank);
int pic32mx_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
@@ -189,7 +191,6 @@
int pic32mx_protect_check(struct flash_bank_s *bank)
{
target_t *target = bank->target;
- pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
u32 devcfg0;
int s;
@@ -233,9 +234,9 @@
return ERROR_TARGET_NOT_HALTED;
}
-#if 0
if ((first == 0) && (last == (bank->num_sectors - 1)) && (bank->base == PIC32MX_KSEG0_PGM_FLASH || bank->base == PIC32MX_KSEG1_PGM_FLASH))
{
+ LOG_DEBUG("Erasing entire program flash");
status = pic32mx_nvm_exec(bank, NVMCON_OP_PFM_ERASE, 50);
if( status & NVMCON_NVMERR )
return ERROR_FLASH_OPERATION_FAILED;
@@ -243,11 +244,13 @@
return ERROR_FLASH_OPERATION_FAILED;
return ERROR_OK;
}
-#endif
for (i = first; i <= last; i++)
{
- target_write_u32(target, PIC32MX_NVMADDR, bank->base + bank->sectors[i].offset);
+ if(bank->base >= PIC32MX_KSEG1_PGM_FLASH)
+ target_write_u32(target, PIC32MX_NVMADDR, KS1Virt2Phys(bank->base + bank->sectors[i].offset));
+ else
+ target_write_u32(target, PIC32MX_NVMADDR, KS0Virt2Phys(bank->base + bank->sectors[i].offset));
status = pic32mx_nvm_exec(bank, NVMCON_OP_PAGE_ERASE, 10);
@@ -354,15 +357,14 @@
int pic32mx_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
{
- pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
target_t *target = bank->target;
- u32 buffer_size = 8192;
+ u32 buffer_size = 512;
working_area_t *source;
u32 address = bank->base + offset;
- reg_param_t reg_params[4];
+ int retval = ERROR_OK;
#if 0
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
armv7m_algorithm_t armv7m_info;
- int retval = ERROR_OK;
u8 pic32mx_flash_write_code[] = {
/* write: */
@@ -395,40 +397,34 @@
if ((retval=target_write_buffer(target, pic32mx_info->write_algorithm->address, sizeof(pic32mx_flash_write_code), pic32mx_flash_write_code))!=ERROR_OK)
return retval;
+#endif
/* memory buffer */
- while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK)
+ if (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK)
{
- buffer_size /= 2;
- if (buffer_size <= 256)
- {
- /* if we already allocated the writing code, but failed to get a buffer, free the algorithm */
- if (pic32mx_info->write_algorithm)
- target_free_working_area(target, pic32mx_info->write_algorithm);
+#if 0
+ /* if we already allocated the writing code, but failed to get a buffer, free the algorithm */
+ if (pic32mx_info->write_algorithm)
+ target_free_working_area(target, pic32mx_info->write_algorithm);
+#endif
- LOG_WARNING("no large enough working area available, can't do block memory writes");
- return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
- }
- };
+ LOG_WARNING("no large enough working area available, can't do block memory writes");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
- armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
- armv7m_info.core_mode = ARMV7M_MODE_ANY;
-
- init_reg_param(®_params[0], "r0", 32, PARAM_OUT);
- init_reg_param(®_params[1], "r1", 32, PARAM_OUT);
- init_reg_param(®_params[2], "r2", 32, PARAM_OUT);
- init_reg_param(®_params[3], "r3", 32, PARAM_IN);
-
- while (count > 0)
+ while (count >= buffer_size/4)
{
- u32 thisrun_count = (count > (buffer_size / 2)) ? (buffer_size / 2) : count;
+ u32 status;
- if ((retval = target_write_buffer(target, source->address, thisrun_count * 2, buffer))!=ERROR_OK)
+ if ((retval = target_write_buffer(target, source->address, buffer_size, buffer))!=ERROR_OK) {
+ LOG_ERROR("Failed to write row buffer (%d words) to RAM", buffer_size/4);
break;
+ }
+#if 0
buf_set_u32(reg_params[0].value, 0, 32, source->address);
buf_set_u32(reg_params[1].value, 0, 32, address);
- buf_set_u32(reg_params[2].value, 0, 32, thisrun_count);
+ buf_set_u32(reg_params[2].value, 0, 32, buffer_size/4);
if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, pic32mx_info->write_algorithm->address, \
pic32mx_info->write_algorithm->address + (sizeof(pic32mx_flash_write_code) - 10), 10000, &armv7m_info)) != ERROR_OK)
@@ -443,39 +439,86 @@
retval = ERROR_FLASH_OPERATION_FAILED;
break;
}
+#endif
+ status = pic32mx_write_row(bank, address, source->address);
+ if( status & NVMCON_NVMERR ) {
+ LOG_ERROR("Flash write error NVMERR (status=0x%08x)", status);
+ retval = ERROR_FLASH_OPERATION_FAILED;
+ break;
+ }
+ if( status & NVMCON_LVDERR ) {
+ LOG_ERROR("Flash write error LVDERR (status=0x%08x)", status);
+ retval = ERROR_FLASH_OPERATION_FAILED;
+ break;
+ }
- buffer += thisrun_count * 2;
- address += thisrun_count * 2;
- count -= thisrun_count;
+ buffer += buffer_size;
+ address += buffer_size;
+ count -= buffer_size/4;
}
target_free_working_area(target, source);
- target_free_working_area(target, pic32mx_info->write_algorithm);
- destroy_reg_param(®_params[0]);
- destroy_reg_param(®_params[1]);
- destroy_reg_param(®_params[2]);
- destroy_reg_param(®_params[3]);
+ while(count > 0)
+ {
+ u32 status;
+ status = pic32mx_write_word(bank, address, *(u32*)buffer);
+ if( status & NVMCON_NVMERR ) {
+ LOG_ERROR("Flash write error NVMERR (status=0x%08x)", status);
+ retval = ERROR_FLASH_OPERATION_FAILED;
+ break;
+ }
+ if( status & NVMCON_LVDERR ) {
+ LOG_ERROR("Flash write error LVDERR (status=0x%08x)", status);
+ retval = ERROR_FLASH_OPERATION_FAILED;
+ break;
+ }
+
+ buffer += 4;
+ address += 4;
+ count--;
+ }
+
return retval;
-#else
- return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
-#endif
}
int pic32mx_write_word(struct flash_bank_s *bank, u32 address, u32 word)
{
target_t *target = bank->target;
- target_write_u32(target, PIC32MX_NVMADDR, address);
+ if(bank->base >= PIC32MX_KSEG1_PGM_FLASH)
+ target_write_u32(target, PIC32MX_NVMADDR, KS1Virt2Phys(address));
+ else
+ target_write_u32(target, PIC32MX_NVMADDR, KS0Virt2Phys(address));
target_write_u32(target, PIC32MX_NVMDATA, word);
return pic32mx_nvm_exec(bank, NVMCON_OP_WORD_PROG, 5);
}
+/*
+ * Write a 128 word (512 byte) row to flash address from RAM srcaddr.
+ */
+int pic32mx_write_row(struct flash_bank_s *bank, u32 address, u32 srcaddr)
+{
+ target_t *target = bank->target;
+
+ LOG_DEBUG("addr: 0x%08x srcaddr: 0x%08x", address, srcaddr);
+
+ if(address >= PIC32MX_KSEG1_PGM_FLASH)
+ target_write_u32(target, PIC32MX_NVMADDR, KS1Virt2Phys(address));
+ else
+ target_write_u32(target, PIC32MX_NVMADDR, KS0Virt2Phys(address));
+ if(srcaddr >= PIC32MX_KSEG1_RAM)
+ target_write_u32(target, PIC32MX_NVMSRCADDR, KS1Virt2Phys(srcaddr));
+ else
+ target_write_u32(target, PIC32MX_NVMSRCADDR, KS0Virt2Phys(srcaddr));
+
+ return pic32mx_nvm_exec(bank, NVMCON_OP_ROW_PROG, 100);
+}
+
int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
{
- target_t *target = bank->target;
u32 words_remaining = (count / 4);
u32 bytes_remaining = (count & 0x00000003);
u32 address = bank->base + offset;
@@ -862,7 +905,6 @@
{
flash_bank_t *bank;
u32 address, value;
- int i;
int status, res;
if (argc != 3)
Modified: trunk/src/flash/pic32mx.h
===================================================================
--- trunk/src/flash/pic32mx.h 2009-01-05 09:26:25 UTC (rev 1300)
+++ trunk/src/flash/pic32mx.h 2009-01-05 09:32:23 UTC (rev 1301)
@@ -42,22 +42,31 @@
/* pic32mx memory locations */
#define PIC32MX_KUSEG_PGM_FLASH 0x7D000000
-#define PIC32MX_KUSEG_RAM 0x7F000000
+#define PIC32MX_KUSEG_RAM 0x7F000000
-#define PIC32MX_KSEG0_RAM 0x80000000
+#define PIC32MX_KSEG0_RAM 0x80000000
#define PIC32MX_KSEG0_PGM_FLASH 0x9D000000
#define PIC32MX_KSEG0_BOOT_FLASH 0x9FC00000
-#define PIC32MX_KSEG1_RAM 0xA0000000
+#define PIC32MX_KSEG1_RAM 0xA0000000
#define PIC32MX_KSEG1_PGM_FLASH 0xBD000000
#define PIC32MX_KSEG1_PERIPHERAL 0xBF800000
#define PIC32MX_KSEG1_BOOT_FLASH 0xBFC00000
-#define PIC32MX_PHYS_RAM 0x00000000
+#define PIC32MX_PHYS_RAM 0x00000000
#define PIC32MX_PHYS_PGM_FLASH 0x1D000000
#define PIC32MX_PHYS_PERIPHERALS 0x1F800000
#define PIC32MX_PHYS_BOOT_FLASH 0x1FC00000
+/*
+ * Translate Virtual and Physical addresses.
+ * Note: These macros only work for KSEG0/KSEG1 addresses.
+ */
+#define KS1Virt2Phys(vaddr) ((vaddr)-0xA0000000)
+#define Phys2KS1Virt(paddr) ((paddr)+0xA0000000)
+#define KS0Virt2Phys(vaddr) ((vaddr)-0x80000000)
+#define Phys2KS0Virt(paddr) ((paddr)+0x80000000)
+
/* pic32mx configuration register locations */
#define PIC32MX_DEVCFG0 0xBFC02FFC
@@ -77,11 +86,11 @@
#define NVMCON_NVMERR (1<<13)
#define NVMCON_LVDERR (1<<12)
#define NVMCON_LVDSTAT (1<<11)
-#define NVMCON_OP_PFM_ERASE 0x5
+#define NVMCON_OP_PFM_ERASE 0x5
#define NVMCON_OP_PAGE_ERASE 0x4
-#define NVMCON_OP_ROW_PROG 0x3
-#define NVMCON_OP_WORD_PROG 0x1
-#define NVMCON_OP_NOP 0x0
+#define NVMCON_OP_ROW_PROG 0x3
+#define NVMCON_OP_WORD_PROG 0x1
+#define NVMCON_OP_NOP 0x0
#define PIC32MX_NVMKEY 0xBF80F410
#define PIC32MX_NVMADDR 0xBF80F420
Modified: trunk/src/target/mips32_pracc.c
===================================================================
--- trunk/src/target/mips32_pracc.c 2009-01-05 09:26:25 UTC (rev 1300)
+++ trunk/src/target/mips32_pracc.c 2009-01-05 09:32:23 UTC (rev 1301)
@@ -218,7 +218,10 @@
case 2:
return mips32_pracc_read_mem16(ejtag_info, addr, count, (u16*)buf);
case 4:
- return mips32_pracc_read_mem32(ejtag_info, addr, count, (u32*)buf);
+ if(count==1)
+ return mips32_pracc_read_u32(ejtag_info, addr, (u32*)buf);
+ else
+ return mips32_pracc_read_mem32(ejtag_info, addr, count, (u32*)buf);
}
return ERROR_OK;
@@ -247,8 +250,8 @@
MIPS32_BEQ(0,10,9), /* beq 0, $10, end */
MIPS32_NOP,
- MIPS32_LW(12,0,9), /* lw $12,0($9), Load $12 with the word @mem[$9] */
- MIPS32_SW(12,0,11), /* sw $12,0($11) */
+ MIPS32_LW(8,0,9), /* lw $8,0($9), Load $8 with the word @mem[$9] */
+ MIPS32_SW(8,0,11), /* sw $8,0($11) */
MIPS32_ADDI(10,10,NEG16(1)), /* $10-- */
MIPS32_ADDI(9,9,4), /* $1+=4 */
@@ -298,6 +301,47 @@
return retval;
}
+int mips32_pracc_read_u32(mips_ejtag_t *ejtag_info, u32 addr, u32 *buf)
+{
+ u32 code[] = {
+ /* start: */
+ MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
+ MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
+ MIPS32_ORI(15,15,LOWER16(MIPS32_PRACC_STACK)),
+ MIPS32_SW(8,0,15), /* sw $8,($15) */
+ MIPS32_SW(9,0,15), /* sw $9,($15) */
+
+ MIPS32_LUI(8,UPPER16(MIPS32_PRACC_PARAM_IN)), /* $8 = MIPS32_PRACC_PARAM_IN */
+ MIPS32_ORI(8,8,LOWER16(MIPS32_PRACC_PARAM_IN)),
+ MIPS32_LW(8,0,8), /* $8=mem[$8]; read addr */
+ MIPS32_LUI(9,UPPER16(MIPS32_PRACC_PARAM_OUT)), /* $9=MIPS32_PRACC_PARAM_OUT */
+ MIPS32_ORI(9,9,LOWER16(MIPS32_PRACC_PARAM_OUT)),
+
+ MIPS32_LW(8,0,8), /* lw $8,0($8), Load $8 with the word @mem[$8] */
+ MIPS32_SW(8,0,9), /* sw $8,0($9) */
+
+ MIPS32_LW(9,0,15), /* lw $9,($15) */
+ MIPS32_LW(8,0,15), /* lw $8,($15) */
+ MIPS32_MFC0(15,31,0), /* move COP0 DeSave to $15 */
+ MIPS32_NOP,
+ MIPS32_B(NEG16(17)), /* b start */
+ MIPS32_NOP,
+ };
+
+ int retval = ERROR_OK;
+ u32 param_in[1];
+
+ param_in[0] = addr;
+
+ if ((retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code,
+ sizeof(param_in)/sizeof(param_in[0]), param_in, sizeof(u32), buf, 1)) != ERROR_OK)
+ {
+ return retval;
+ }
+
+ return retval;
+}
+
int mips32_pracc_read_mem16(mips_ejtag_t *ejtag_info, u32 addr, int count, u16 *buf)
{
u32 code[] = {
@@ -321,8 +365,8 @@
MIPS32_BEQ(0,10,9), /* beq 0, $10, end */
MIPS32_NOP,
- MIPS32_LHU(12,0,9), /* lw $12,0($9), Load $12 with the halfword @mem[$9] */
- MIPS32_SW(12,0,11), /* sw $12,0($11) */
+ MIPS32_LHU(8,0,9), /* lw $8,0($9), Load $8 with the halfword @mem[$9] */
+ MIPS32_SW(8,0,11), /* sw $8,0($11) */
MIPS32_ADDI(10,10,NEG16(1)), /* $10-- */
MIPS32_ADDI(9,9,2), /* $9+=2 */
@@ -400,8 +444,8 @@
MIPS32_BEQ(0,10,9), /* beq 0, $10, end */
MIPS32_NOP,
- MIPS32_LBU(12,0,9), /* lw $12,0($9), Load t4 with the byte @mem[t1] */
- MIPS32_SW(12,0,11), /* sw $12,0($11) */
+ MIPS32_LBU(8,0,9), /* lw $8,0($9), Load t4 with the byte @mem[t1] */
+ MIPS32_SW(8,0,11), /* sw $8,0($11) */
MIPS32_ADDI(10,10,NEG16(1)), /* $10-- */
MIPS32_ADDI(9,9,1), /* $9+=1 */
@@ -465,7 +509,10 @@
case 2:
return mips32_pracc_write_mem16(ejtag_info, addr, count,(u16*)buf);
case 4:
- return mips32_pracc_write_mem32(ejtag_info, addr, count, (u32*)buf);
+ if(count==1)
+ return mips32_pracc_write_u32(ejtag_info, addr, (u32*)buf);
+ else
+ return mips32_pracc_write_mem32(ejtag_info, addr, count, (u32*)buf);
}
return ERROR_OK;
@@ -526,6 +573,42 @@
return ERROR_OK;
}
+int mips32_pracc_write_u32(mips_ejtag_t *ejtag_info, u32 addr, u32 *buf)
+{
+ u32 code[] = {
+ /* start: */
+ MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
+ MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
+ MIPS32_ORI(15,15,LOWER16(MIPS32_PRACC_STACK)),
+ MIPS32_SW(8,0,15), /* sw $8,($15) */
+ MIPS32_SW(9,0,15), /* sw $9,($15) */
+
+ MIPS32_LUI(8,UPPER16((MIPS32_PRACC_PARAM_IN+4))), /* $8 = MIPS32_PRACC_PARAM_IN+4 */
+ MIPS32_ORI(8,8,LOWER16((MIPS32_PRACC_PARAM_IN+4))),
+ MIPS32_LW(9,NEG16(4),8), /* Load write addr to $9 */
+
+ MIPS32_LW(8,0,8), /* lw $8,0($8), Load $8 with the word @mem[$8] */
+ MIPS32_SW(8,0,9), /* sw $8,0($9) */
+
+ MIPS32_LW(9,0,15), /* lw $9,($15) */
+ MIPS32_LW(8,0,15), /* lw $8,($15) */
+ MIPS32_MFC0(15,31,0), /* move COP0 DeSave to $15 */
+ MIPS32_NOP,
+ MIPS32_B(NEG16(15)), /* b start */
+ MIPS32_NOP,
+ };
+
+ /* TODO remove array */
+ u32 param_in[1+1];
+ param_in[0] = addr;
+ param_in[1] = *buf;
+
+ mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ sizeof(param_in)/sizeof(param_in[0]),param_in, 0, NULL, 1);
+
+ return ERROR_OK;
+}
+
int mips32_pracc_write_mem16(mips_ejtag_t *ejtag_info, u32 addr, int count, u16 *buf)
{
u32 code[] = {
Modified: trunk/src/target/mips32_pracc.h
===================================================================
--- trunk/src/target/mips32_pracc.h 2009-01-05 09:26:25 UTC (rev 1300)
+++ trunk/src/target/mips32_pracc.h 2009-01-05 09:32:23 UTC (rev 1301)
@@ -42,10 +42,12 @@
extern int mips32_pracc_read_mem8(mips_ejtag_t *ejtag_info, u32 addr, int count, u8 *buf);
extern int mips32_pracc_read_mem16(mips_ejtag_t *ejtag_info, u32 addr, int count, u16 *buf);
extern int mips32_pracc_read_mem32(mips_ejtag_t *ejtag_info, u32 addr, int count, u32 *buf);
+extern int mips32_pracc_read_u32(mips_ejtag_t *ejtag_info, u32 addr, u32 *buf);
extern int mips32_pracc_write_mem8(mips_ejtag_t *ejtag_info, u32 addr, int count, u8 *buf);
extern int mips32_pracc_write_mem16(mips_ejtag_t *ejtag_info, u32 addr, int count, u16 *buf);
extern int mips32_pracc_write_mem32(mips_ejtag_t *ejtag_info, u32 addr, int count, u32 *buf);
+extern int mips32_pracc_write_u32(mips_ejtag_t *ejtag_info, u32 addr, u32 *buf);
extern int mips32_pracc_read_regs(mips_ejtag_t *ejtag_info, u32 *regs);
extern int mips32_pracc_write_regs(mips_ejtag_t *ejtag_info, u32 *regs);
|
|
From: <oh...@ma...> - 2009-01-05 10:26:26
|
Author: oharboe
Date: 2009-01-05 10:26:25 +0100 (Mon, 05 Jan 2009)
New Revision: 1300
Modified:
trunk/src/jtag/ft2232.c
Log:
John McCarthy <jg...@ma...> formatting fix of debug output
Modified: trunk/src/jtag/ft2232.c
===================================================================
--- trunk/src/jtag/ft2232.c 2009-01-05 09:25:23 UTC (rev 1299)
+++ trunk/src/jtag/ft2232.c 2009-01-05 09:26:25 UTC (rev 1300)
@@ -442,7 +442,7 @@
timeval_subtract(&d_inter2, &inter2, &start);
timeval_subtract(&d_end, &end, &start);
- LOG_INFO("inter: %i.%i, inter2: %i.%i end: %i.%i", d_inter.tv_sec, d_inter.tv_usec, d_inter2.tv_sec, d_inter2.tv_usec, d_end.tv_sec, d_end.tv_usec);
+ LOG_INFO("inter: %i.%06i, inter2: %i.%06i end: %i.%06i", d_inter.tv_sec, d_inter.tv_usec, d_inter2.tv_sec, d_inter2.tv_usec, d_end.tv_sec, d_end.tv_usec);
#endif
|
|
From: <oh...@ma...> - 2009-01-05 10:25:28
|
Author: oharboe
Date: 2009-01-05 10:25:23 +0100 (Mon, 05 Jan 2009)
New Revision: 1299
Added:
trunk/src/target/board/x300t.cfg
trunk/src/target/interface/parport_dlc5.cfg
trunk/src/target/target/smp8634.cfg
Log:
Andi <ope...@gm...> basic support for the MIPS based SMP8634 SoC.
Added: trunk/src/target/board/x300t.cfg
===================================================================
--- trunk/src/target/board/x300t.cfg 2009-01-04 08:51:48 UTC (rev 1298)
+++ trunk/src/target/board/x300t.cfg 2009-01-05 09:25:23 UTC (rev 1299)
@@ -0,0 +1,17 @@
+# This is for the T-Home X300T / X301T IPTV box,
+# which are based on IPTV reference designs from Kiss/Cisco KMM-32**
+#
+# It has Sigma Designs SMP8634 chip.
+source [find target/smp8634.cfg]
+
+$_TARGETNAME configure -event reset-init { x300t_init }
+
+# 1MB CFI capable flash
+# flash bank <driver> <base> <size> <chip_width> <bus_width>
+flash bank cfi 0xac000000 0x100000 2 2 0
+
+proc x300t_init { } {
+ # Setup SDRAM config and flash mapping
+ # map flash to CPU address space REG_BASE_cpu_block+CPU_remap4
+ mww 0x6f010 0x48000000
+}
Added: trunk/src/target/interface/parport_dlc5.cfg
===================================================================
--- trunk/src/target/interface/parport_dlc5.cfg 2009-01-04 08:51:48 UTC (rev 1298)
+++ trunk/src/target/interface/parport_dlc5.cfg 2009-01-05 09:25:23 UTC (rev 1299)
@@ -0,0 +1,7 @@
+telnet_port 4444
+gdb_port 2001
+
+interface parport
+parport_port /dev/parport0
+parport_cable dlc5
+jtag_speed 0
Added: trunk/src/target/target/smp8634.cfg
===================================================================
--- trunk/src/target/target/smp8634.cfg 2009-01-04 08:51:48 UTC (rev 1298)
+++ trunk/src/target/target/smp8634.cfg 2009-01-05 09:25:23 UTC (rev 1299)
@@ -0,0 +1,32 @@
+# script for Sigma Designs SMP8634 (eventually even SMP8635)
+
+if { [info exists CHIPNAME] } {
+ set _CHIPNAME $CHIPNAME
+} else {
+ set _CHIPNAME smp8634
+}
+
+if { [info exists ENDIAN] } {
+ set _ENDIAN $ENDIAN
+} else {
+ set _ENDIAN little
+}
+
+if { [info exists CPUTAPID ] } {
+ set _CPUTAPID $CPUTAPID
+} else {
+ # force an error till we get a good number
+ set _CPUTAPID 0x08630001
+}
+
+jtag_nsrst_delay 100
+jtag_ntrst_delay 100
+
+reset_config trst_and_srst separate
+
+# jtag scan chain
+# format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
+jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1
+
+set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
+target create $_TARGETNAME mips_m4k -endian $_ENDIAN -variant
|
|
From: <oh...@ma...> - 2009-01-04 09:51:50
|
Author: oharboe Date: 2009-01-04 09:51:48 +0100 (Sun, 04 Jan 2009) New Revision: 1298 Modified: trunk/src/target/board/pic-p32mx.cfg Log: eol-style native Modified: trunk/src/target/board/pic-p32mx.cfg =================================================================== --- trunk/src/target/board/pic-p32mx.cfg 2009-01-03 08:56:52 UTC (rev 1297) +++ trunk/src/target/board/pic-p32mx.cfg 2009-01-04 08:51:48 UTC (rev 1298) @@ -1,8 +1,8 @@ -# The Olimex PIC-P32MX has a PIC32MX - -set CPUTAPID 0x40916053 -source [find target/pic32mx.cfg] - -init -flash probe 0 -flash probe 1 +# The Olimex PIC-P32MX has a PIC32MX + +set CPUTAPID 0x40916053 +source [find target/pic32mx.cfg] + +init +flash probe 0 +flash probe 1 Property changes on: trunk/src/target/board/pic-p32mx.cfg ___________________________________________________________________ Name: svn:eol-style + native |
|
From: <oh...@ma...> - 2009-01-03 09:56:55
|
Author: oharboe
Date: 2009-01-03 09:56:52 +0100 (Sat, 03 Jan 2009)
New Revision: 1297
Modified:
trunk/src/flash/pic32mx.c
trunk/src/flash/pic32mx.h
Log:
eol-style native
Modified: trunk/src/flash/pic32mx.c
===================================================================
--- trunk/src/flash/pic32mx.c 2009-01-02 23:58:16 UTC (rev 1296)
+++ trunk/src/flash/pic32mx.c 2009-01-03 08:56:52 UTC (rev 1297)
@@ -1,902 +1,902 @@
-/***************************************************************************
- * Copyright (C) 2005 by Dominic Rath *
- * Dom...@gm... *
- * *
- * Copyright (C) 2008 by Spencer Oliver *
- * sp...@sp... *
- * *
- * Copyright (C) 2008 by John McCarthy *
- * jg...@ma... *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "replacements.h"
-
-#include "pic32mx.h"
-#include "flash.h"
-#include "target.h"
-#include "log.h"
-#include "mips32.h"
-#include "algorithm.h"
-#include "binarybuffer.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-static
-struct pic32mx_devs_s {
- u8 devid;
- char *name;
- u32 pfm_size;
-} pic32mx_devs[] = {
- { 0x78, "460F512L USB", 512 },
- { 0x74, "460F256L USB", 256 },
- { 0x6D, "440F128L USB", 128 },
- { 0x56, "440F512H USB", 512 },
- { 0x52, "440F256H USB", 256 },
- { 0x4D, "440F128H USB", 128 },
- { 0x42, "420F032H USB", 32 },
- { 0x38, "360F512L", 512 },
- { 0x34, "360F256L", 256 },
- { 0x2D, "340F128L", 128 },
- { 0x2A, "320F128L", 128 },
- { 0x16, "340F512H", 512 },
- { 0x12, "340F256H", 256 },
- { 0x0D, "340F128H", 128 },
- { 0x0A, "320F128H", 128 },
- { 0x06, "320F064H", 64 },
- { 0x02, "320F032H", 32 },
- { 0x00, NULL, 0 }
-};
-
-int pic32mx_register_commands(struct command_context_s *cmd_ctx);
-int pic32mx_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
-int pic32mx_erase(struct flash_bank_s *bank, int first, int last);
-int pic32mx_protect(struct flash_bank_s *bank, int set, int first, int last);
-int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
-int pic32mx_probe(struct flash_bank_s *bank);
-int pic32mx_auto_probe(struct flash_bank_s *bank);
-int pic32mx_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-int pic32mx_protect_check(struct flash_bank_s *bank);
-int pic32mx_info(struct flash_bank_s *bank, char *buf, int buf_size);
-
-#if 0
-int pic32mx_handle_lock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-int pic32mx_handle_unlock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-#endif
-int pic32mx_handle_chip_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-int pic32mx_handle_pgm_word_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-int pic32mx_chip_erase(struct flash_bank_s *bank);
-
-flash_driver_t pic32mx_flash =
-{
- .name = "pic32mx",
- .register_commands = pic32mx_register_commands,
- .flash_bank_command = pic32mx_flash_bank_command,
- .erase = pic32mx_erase,
- .protect = pic32mx_protect,
- .write = pic32mx_write,
- .probe = pic32mx_probe,
- .auto_probe = pic32mx_auto_probe,
- .erase_check = default_flash_mem_blank_check,
- .protect_check = pic32mx_protect_check,
- .info = pic32mx_info
-};
-
-int pic32mx_register_commands(struct command_context_s *cmd_ctx)
-{
- command_t *pic32mx_cmd = register_command(cmd_ctx, NULL, "pic32mx", NULL, COMMAND_ANY, "pic32mx flash specific commands");
-
-#if 0
- register_command(cmd_ctx, pic32mx_cmd, "lock", pic32mx_handle_lock_command, COMMAND_EXEC,
- "lock device");
- register_command(cmd_ctx, pic32mx_cmd, "unlock", pic32mx_handle_unlock_command, COMMAND_EXEC,
- "unlock protected device");
-#endif
- register_command(cmd_ctx, pic32mx_cmd, "chip_erase", pic32mx_handle_chip_erase_command, COMMAND_EXEC,
- "erase device");
- register_command(cmd_ctx, pic32mx_cmd, "pgm_word", pic32mx_handle_pgm_word_command, COMMAND_EXEC,
- "program a word");
- return ERROR_OK;
-}
-
-/* flash bank pic32mx <base> <size> 0 0 <target#>
- */
-int pic32mx_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
-{
- pic32mx_flash_bank_t *pic32mx_info;
-
- if (argc < 6)
- {
- LOG_WARNING("incomplete flash_bank pic32mx configuration");
- return ERROR_FLASH_BANK_INVALID;
- }
-
- pic32mx_info = malloc(sizeof(pic32mx_flash_bank_t));
- bank->driver_priv = pic32mx_info;
-
- pic32mx_info->write_algorithm = NULL;
- pic32mx_info->probed = 0;
-
- return ERROR_OK;
-}
-
-u32 pic32mx_get_flash_status(flash_bank_t *bank)
-{
- target_t *target = bank->target;
- u32 status;
-
- target_read_u32(target, PIC32MX_NVMCON, &status);
-
- return status;
-}
-
-u32 pic32mx_wait_status_busy(flash_bank_t *bank, int timeout)
-{
- u32 status;
-
- /* wait for busy to clear */
- while (((status = pic32mx_get_flash_status(bank)) & NVMCON_NVMWR) && (timeout-- > 0))
- {
- LOG_DEBUG("status: 0x%x", status);
- alive_sleep(1);
- }
- if(timeout <= 0)
- LOG_DEBUG("timeout: status: 0x%x", status);
-
- return status;
-}
-
-int pic32mx_nvm_exec(struct flash_bank_s *bank, u32 op, u32 timeout)
-{
- target_t *target = bank->target;
- u32 status;
-
- target_write_u32(target, PIC32MX_NVMCON, NVMCON_NVMWREN|op);
-
- /* unlock flash registers */
- target_write_u32(target, PIC32MX_NVMKEY, NVMKEY1);
- target_write_u32(target, PIC32MX_NVMKEY, NVMKEY2);
-
- /* start operation */
- target_write_u32(target, PIC32MX_NVMCONSET, NVMCON_NVMWR);
-
- status = pic32mx_wait_status_busy(bank, timeout);
-
- /* lock flash registers */
- target_write_u32(target, PIC32MX_NVMCONCLR, NVMCON_NVMWREN);
-
- return status;
-}
-
-int pic32mx_protect_check(struct flash_bank_s *bank)
-{
- target_t *target = bank->target;
- pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
-
- u32 devcfg0;
- int s;
- int num_pages;
-
- if (target->state != TARGET_HALTED)
- {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
- target_read_u32(target, PIC32MX_DEVCFG0, &devcfg0);
- if((devcfg0 & (1<<28)) == 0) /* code protect bit */
- num_pages = 0xffff; /* All pages protected */
- else if(bank->base == PIC32MX_KSEG1_BOOT_FLASH)
- {
- if(devcfg0 & (1<<24))
- num_pages = 0; /* All pages unprotected */
- else
- num_pages = 0xffff; /* All pages protected */
- }
- else /* pgm flash */
- num_pages = (~devcfg0 >> 12) & 0xff;
- for (s = 0; s < bank->num_sectors && s < num_pages; s++)
- bank->sectors[s].is_protected = 1;
- for (; s < bank->num_sectors; s++)
- bank->sectors[s].is_protected = 0;
-
- return ERROR_OK;
-}
-
-int pic32mx_erase(struct flash_bank_s *bank, int first, int last)
-{
- target_t *target = bank->target;
- int i;
- u32 status;
-
- if (bank->target->state != TARGET_HALTED)
- {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
-#if 0
- if ((first == 0) && (last == (bank->num_sectors - 1)) && (bank->base == PIC32MX_KSEG0_PGM_FLASH || bank->base == PIC32MX_KSEG1_PGM_FLASH))
- {
- status = pic32mx_nvm_exec(bank, NVMCON_OP_PFM_ERASE, 50);
- if( status & NVMCON_NVMERR )
- return ERROR_FLASH_OPERATION_FAILED;
- if( status & NVMCON_LVDERR )
- return ERROR_FLASH_OPERATION_FAILED;
- return ERROR_OK;
- }
-#endif
-
- for (i = first; i <= last; i++)
- {
- target_write_u32(target, PIC32MX_NVMADDR, bank->base + bank->sectors[i].offset);
-
- status = pic32mx_nvm_exec(bank, NVMCON_OP_PAGE_ERASE, 10);
-
- if( status & NVMCON_NVMERR )
- return ERROR_FLASH_OPERATION_FAILED;
- if( status & NVMCON_LVDERR )
- return ERROR_FLASH_OPERATION_FAILED;
- bank->sectors[i].is_erased = 1;
- }
-
- return ERROR_OK;
-}
-
-int pic32mx_protect(struct flash_bank_s *bank, int set, int first, int last)
-{
- pic32mx_flash_bank_t *pic32mx_info = NULL;
- target_t *target = bank->target;
- u16 prot_reg[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
- int i, reg, bit;
- int status;
- u32 protection;
-
- pic32mx_info = bank->driver_priv;
-
- if (target->state != TARGET_HALTED)
- {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
-#if 0
- if ((first && (first % pic32mx_info->ppage_size)) || ((last + 1) && (last + 1) % pic32mx_info->ppage_size))
- {
- LOG_WARNING("sector start/end incorrect - stm32 has %dK sector protection", pic32mx_info->ppage_size);
- return ERROR_FLASH_SECTOR_INVALID;
- }
-
- /* medium density - each bit refers to a 4bank protection
- * high density - each bit refers to a 2bank protection */
- target_read_u32(target, PIC32MX_FLASH_WRPR, &protection);
-
- prot_reg[0] = (u16)protection;
- prot_reg[1] = (u16)(protection >> 8);
- prot_reg[2] = (u16)(protection >> 16);
- prot_reg[3] = (u16)(protection >> 24);
-
- if (pic32mx_info->ppage_size == 2)
- {
- /* high density flash */
-
- /* bit 7 controls sector 62 - 255 protection */
- if (last > 61)
- {
- if (set)
- prot_reg[3] &= ~(1 << 7);
- else
- prot_reg[3] |= (1 << 7);
- }
-
- if (first > 61)
- first = 62;
- if (last > 61)
- last = 61;
-
- for (i = first; i <= last; i++)
- {
- reg = (i / pic32mx_info->ppage_size) / 8;
- bit = (i / pic32mx_info->ppage_size) - (reg * 8);
-
- if( set )
- prot_reg[reg] &= ~(1 << bit);
- else
- prot_reg[reg] |= (1 << bit);
- }
- }
- else
- {
- /* medium density flash */
- for (i = first; i <= last; i++)
- {
- reg = (i / pic32mx_info->ppage_size) / 8;
- bit = (i / pic32mx_info->ppage_size) - (reg * 8);
-
- if( set )
- prot_reg[reg] &= ~(1 << bit);
- else
- prot_reg[reg] |= (1 << bit);
- }
- }
-
- if ((status = pic32mx_erase_options(bank)) != ERROR_OK)
- return status;
-
- pic32mx_info->option_bytes.protection[0] = prot_reg[0];
- pic32mx_info->option_bytes.protection[1] = prot_reg[1];
- pic32mx_info->option_bytes.protection[2] = prot_reg[2];
- pic32mx_info->option_bytes.protection[3] = prot_reg[3];
-
- return pic32mx_write_options(bank);
-#else
- return ERROR_OK;
-#endif
-}
-
-int pic32mx_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
-{
- pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
- target_t *target = bank->target;
- u32 buffer_size = 8192;
- working_area_t *source;
- u32 address = bank->base + offset;
- reg_param_t reg_params[4];
-#if 0
- armv7m_algorithm_t armv7m_info;
- int retval = ERROR_OK;
-
- u8 pic32mx_flash_write_code[] = {
- /* write: */
- 0xDF, 0xF8, 0x24, 0x40, /* ldr r4, PIC32MX_FLASH_CR */
- 0x09, 0x4D, /* ldr r5, PIC32MX_FLASH_SR */
- 0x4F, 0xF0, 0x01, 0x03, /* mov r3, #1 */
- 0x23, 0x60, /* str r3, [r4, #0] */
- 0x30, 0xF8, 0x02, 0x3B, /* ldrh r3, [r0], #2 */
- 0x21, 0xF8, 0x02, 0x3B, /* strh r3, [r1], #2 */
- /* busy: */
- 0x2B, 0x68, /* ldr r3, [r5, #0] */
- 0x13, 0xF0, 0x01, 0x0F, /* tst r3, #0x01 */
- 0xFB, 0xD0, /* beq busy */
- 0x13, 0xF0, 0x14, 0x0F, /* tst r3, #0x14 */
- 0x01, 0xD1, /* bne exit */
- 0x01, 0x3A, /* subs r2, r2, #1 */
- 0xED, 0xD1, /* bne write */
- /* exit: */
- 0xFE, 0xE7, /* b exit */
- 0x10, 0x20, 0x02, 0x40, /* PIC32MX_FLASH_CR: .word 0x40022010 */
- 0x0C, 0x20, 0x02, 0x40 /* PIC32MX_FLASH_SR: .word 0x4002200C */
- };
-
- /* flash write code */
- if (target_alloc_working_area(target, sizeof(pic32mx_flash_write_code), &pic32mx_info->write_algorithm) != ERROR_OK)
- {
- LOG_WARNING("no working area available, can't do block memory writes");
- return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
- };
-
- if ((retval=target_write_buffer(target, pic32mx_info->write_algorithm->address, sizeof(pic32mx_flash_write_code), pic32mx_flash_write_code))!=ERROR_OK)
- return retval;
-
- /* memory buffer */
- while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK)
- {
- buffer_size /= 2;
- if (buffer_size <= 256)
- {
- /* if we already allocated the writing code, but failed to get a buffer, free the algorithm */
- if (pic32mx_info->write_algorithm)
- target_free_working_area(target, pic32mx_info->write_algorithm);
-
- LOG_WARNING("no large enough working area available, can't do block memory writes");
- return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
- }
- };
-
- armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
- armv7m_info.core_mode = ARMV7M_MODE_ANY;
-
- init_reg_param(®_params[0], "r0", 32, PARAM_OUT);
- init_reg_param(®_params[1], "r1", 32, PARAM_OUT);
- init_reg_param(®_params[2], "r2", 32, PARAM_OUT);
- init_reg_param(®_params[3], "r3", 32, PARAM_IN);
-
- while (count > 0)
- {
- u32 thisrun_count = (count > (buffer_size / 2)) ? (buffer_size / 2) : count;
-
- if ((retval = target_write_buffer(target, source->address, thisrun_count * 2, buffer))!=ERROR_OK)
- break;
-
- buf_set_u32(reg_params[0].value, 0, 32, source->address);
- buf_set_u32(reg_params[1].value, 0, 32, address);
- buf_set_u32(reg_params[2].value, 0, 32, thisrun_count);
-
- if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, pic32mx_info->write_algorithm->address, \
- pic32mx_info->write_algorithm->address + (sizeof(pic32mx_flash_write_code) - 10), 10000, &armv7m_info)) != ERROR_OK)
- {
- LOG_ERROR("error executing pic32mx flash write algorithm");
- retval = ERROR_FLASH_OPERATION_FAILED;
- break;
- }
-
- if (buf_get_u32(reg_params[3].value, 0, 32) & 0x14)
- {
- retval = ERROR_FLASH_OPERATION_FAILED;
- break;
- }
-
- buffer += thisrun_count * 2;
- address += thisrun_count * 2;
- count -= thisrun_count;
- }
-
- target_free_working_area(target, source);
- target_free_working_area(target, pic32mx_info->write_algorithm);
-
- destroy_reg_param(®_params[0]);
- destroy_reg_param(®_params[1]);
- destroy_reg_param(®_params[2]);
- destroy_reg_param(®_params[3]);
-
- return retval;
-#else
- return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
-#endif
-}
-
-int pic32mx_write_word(struct flash_bank_s *bank, u32 address, u32 word)
-{
- target_t *target = bank->target;
-
- target_write_u32(target, PIC32MX_NVMADDR, address);
- target_write_u32(target, PIC32MX_NVMDATA, word);
-
- return pic32mx_nvm_exec(bank, NVMCON_OP_WORD_PROG, 5);
-}
-
-int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
-{
- target_t *target = bank->target;
- u32 words_remaining = (count / 4);
- u32 bytes_remaining = (count & 0x00000003);
- u32 address = bank->base + offset;
- u32 bytes_written = 0;
- u32 status;
- u32 retval;
-
- if (bank->target->state != TARGET_HALTED)
- {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
- if (offset & 0x3)
- {
- LOG_WARNING("offset 0x%x breaks required 4-byte alignment", offset);
- return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
- }
-
- /* multiple words (4-byte) to be programmed? */
- if (words_remaining > 0)
- {
- /* try using a block write */
- if ((retval = pic32mx_write_block(bank, buffer, offset, words_remaining)) != ERROR_OK)
- {
- if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
- {
- /* if block write failed (no sufficient working area),
- * we use normal (slow) single dword accesses */
- LOG_WARNING("couldn't use block writes, falling back to single memory accesses");
- }
- else if (retval == ERROR_FLASH_OPERATION_FAILED)
- {
- LOG_ERROR("flash writing failed with error code: 0x%x", retval);
- return ERROR_FLASH_OPERATION_FAILED;
- }
- }
- else
- {
- buffer += words_remaining * 4;
- address += words_remaining * 4;
- words_remaining = 0;
- }
- }
-
- while (words_remaining > 0)
- {
- status = pic32mx_write_word(bank, address, *(u32*)(buffer + bytes_written));
-
- if( status & NVMCON_NVMERR )
- return ERROR_FLASH_OPERATION_FAILED;
- if( status & NVMCON_LVDERR )
- return ERROR_FLASH_OPERATION_FAILED;
-
- bytes_written += 4;
- words_remaining--;
- address += 4;
- }
-
- if (bytes_remaining)
- {
- u8 last_word[4] = {0xff, 0xff, 0xff, 0xff};
- int i = 0;
-
- while(bytes_remaining > 0)
- {
- /* Assumes little endian */
- last_word[i++] = *(buffer + bytes_written);
- bytes_remaining--;
- bytes_written++;
- }
-
- status = pic32mx_write_word(bank, address, *(u32*)last_word);
-
- if( status & NVMCON_NVMERR )
- return ERROR_FLASH_OPERATION_FAILED;
- if( status & NVMCON_LVDERR )
- return ERROR_FLASH_OPERATION_FAILED;
- }
-
- return ERROR_OK;
-}
-
-int pic32mx_probe(struct flash_bank_s *bank)
-{
- target_t *target = bank->target;
- pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
- mips32_common_t *mips32 = target->arch_info;
- mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
- int i;
- u16 num_pages;
- u32 device_id;
- int page_size;
-
- pic32mx_info->probed = 0;
-
- device_id = ejtag_info->idcode;
- LOG_INFO( "device id = 0x%08x (manuf 0x%03x dev 0x%02x, ver 0x%03x)", device_id, (device_id>>1)&0x7ff, (device_id>>12)&0xff, (device_id>>20)&0xfff );
-
- if(((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
- LOG_WARNING( "Cannot identify target as a PIC32MX family." );
- return ERROR_FLASH_OPERATION_FAILED;
- }
-
- page_size = 4096;
- if(bank->base == PIC32MX_KSEG1_BOOT_FLASH || bank->base == 1) {
- /* 0xBFC00000: Boot flash size fixed at 12k */
- num_pages = 12;
- } else {
- /* 0xBD000000: Program flash size varies with device */
- for(i=0; pic32mx_devs[i].name != NULL; i++)
- if(pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
- num_pages = pic32mx_devs[i].pfm_size;
- break;
- }
- if(pic32mx_devs[i].name == NULL) {
- LOG_WARNING( "Cannot identify target as a PIC32MX family." );
- return ERROR_FLASH_OPERATION_FAILED;
- }
- }
-
-#if 0
- if (bank->target->state != TARGET_HALTED)
- {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
- /* get flash size from target */
- if (target_read_u16(target, 0x1FFFF7E0, &num_pages) != ERROR_OK)
- {
- /* failed reading flash size, default to max target family */
- num_pages = 0xffff;
- }
-#endif
-
- LOG_INFO( "flash size = %dkbytes", num_pages );
-
- /* calculate numbers of pages */
- num_pages /= (page_size / 1024);
-
- if(bank->base == 0) bank->base = PIC32MX_KSEG1_PGM_FLASH;
- if(bank->base == 1) bank->base = PIC32MX_KSEG1_BOOT_FLASH;
- bank->size = (num_pages * page_size);
- bank->num_sectors = num_pages;
- bank->chip_width = 4;
- bank->bus_width = 4;
- bank->sectors = malloc(sizeof(flash_sector_t) * num_pages);
-
- for (i = 0; i < num_pages; i++)
- {
- bank->sectors[i].offset = i * page_size;
- bank->sectors[i].size = page_size;
- bank->sectors[i].is_erased = -1;
- bank->sectors[i].is_protected = 1;
- }
-
- pic32mx_info->probed = 1;
-
- return ERROR_OK;
-}
-
-int pic32mx_auto_probe(struct flash_bank_s *bank)
-{
- pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
- if (pic32mx_info->probed)
- return ERROR_OK;
- return pic32mx_probe(bank);
-}
-
-int pic32mx_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- return ERROR_OK;
-}
-
-int pic32mx_info(struct flash_bank_s *bank, char *buf, int buf_size)
-{
- target_t *target = bank->target;
- mips32_common_t *mips32 = target->arch_info;
- mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
- u32 device_id;
- int printed, i;
-
- device_id = ejtag_info->idcode;
-
- if(((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
- snprintf(buf, buf_size, "Cannot identify target as a PIC32MX family (manufacturer 0x%03d != 0x%03d)\n", (device_id>>1)&0x7ff, PIC32MX_MANUF_ID);
- return ERROR_FLASH_OPERATION_FAILED;
- }
- for(i=0; pic32mx_devs[i].name != NULL; i++)
- if(pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
- printed = snprintf(buf, buf_size, "PIC32MX%s", pic32mx_devs[i].name);
- break;
- }
- if(pic32mx_devs[i].name == NULL) {
- snprintf(buf, buf_size, "Cannot identify target as a PIC32MX family\n");
- return ERROR_FLASH_OPERATION_FAILED;
- }
- buf += printed;
- buf_size -= printed;
- printed = snprintf(buf, buf_size, " Ver: 0x%03x", (device_id>>20)&0xfff);
-
- return ERROR_OK;
-}
-
-#if 0
-int pic32mx_handle_lock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- flash_bank_t *bank;
- target_t *target = NULL;
- pic32mx_flash_bank_t *pic32mx_info = NULL;
-
- if (argc < 1)
- {
- command_print(cmd_ctx, "pic32mx lock <bank>");
- return ERROR_OK;
- }
-
- bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
- if (!bank)
- {
- command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
- return ERROR_OK;
- }
-
- pic32mx_info = bank->driver_priv;
-
- target = bank->target;
-
- if (target->state != TARGET_HALTED)
- {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
- if (pic32mx_erase_options(bank) != ERROR_OK)
- {
- command_print(cmd_ctx, "pic32mx failed to erase options");
- return ERROR_OK;
- }
-
- /* set readout protection */
- pic32mx_info->option_bytes.RDP = 0;
-
- if (pic32mx_write_options(bank) != ERROR_OK)
- {
- command_print(cmd_ctx, "pic32mx failed to lock device");
- return ERROR_OK;
- }
-
- command_print(cmd_ctx, "pic32mx locked");
-
- return ERROR_OK;
-}
-
-int pic32mx_handle_unlock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- flash_bank_t *bank;
- target_t *target = NULL;
- pic32mx_flash_bank_t *pic32mx_info = NULL;
-
- if (argc < 1)
- {
- command_print(cmd_ctx, "pic32mx unlock <bank>");
- return ERROR_OK;
- }
-
- bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
- if (!bank)
- {
- command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
- return ERROR_OK;
- }
-
- pic32mx_info = bank->driver_priv;
-
- target = bank->target;
-
- if (target->state != TARGET_HALTED)
- {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
- if (pic32mx_erase_options(bank) != ERROR_OK)
- {
- command_print(cmd_ctx, "pic32mx failed to unlock device");
- return ERROR_OK;
- }
-
- if (pic32mx_write_options(bank) != ERROR_OK)
- {
- command_print(cmd_ctx, "pic32mx failed to lock device");
- return ERROR_OK;
- }
-
- command_print(cmd_ctx, "pic32mx unlocked");
-
- return ERROR_OK;
-}
-#endif
-
-int pic32mx_chip_erase(struct flash_bank_s *bank)
-{
- target_t *target = bank->target;
- u32 status;
-
- if (target->state != TARGET_HALTED)
- {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
- LOG_INFO("PIC32MX chip erase called");
-
-#if 0
- /* unlock option flash registers */
- target_write_u32(target, PIC32MX_FLASH_KEYR, KEY1);
- target_write_u32(target, PIC32MX_FLASH_KEYR, KEY2);
-
- /* chip erase flash memory */
- target_write_u32(target, PIC32MX_FLASH_CR, FLASH_MER);
- target_write_u32(target, PIC32MX_FLASH_CR, FLASH_MER|FLASH_STRT);
-
- status = pic32mx_wait_status_busy(bank, 10);
-
- target_write_u32(target, PIC32MX_FLASH_CR, FLASH_LOCK);
-
- if( status & FLASH_WRPRTERR )
- {
- LOG_ERROR("pic32mx device protected");
- return ERROR_OK;
- }
-
- if( status & FLASH_PGERR )
- {
- LOG_ERROR("pic32mx device programming failed");
- return ERROR_OK;
- }
-#endif
-
- return ERROR_OK;
-}
-
-int pic32mx_handle_chip_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- flash_bank_t *bank;
- int i;
-
-#if 0
- if (argc != 0)
- {
- command_print(cmd_ctx, "pic32mx chip_erase");
- return ERROR_OK;
- }
-
- bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
- if (!bank)
- {
- command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
- return ERROR_OK;
- }
-
- if (pic32mx_chip_erase(bank) == ERROR_OK)
- {
- /* set all sectors as erased */
- for (i = 0; i < bank->num_sectors; i++)
- {
- bank->sectors[i].is_erased = 1;
- }
-
- command_print(cmd_ctx, "pic32mx chip erase complete");
- }
- else
- {
- command_print(cmd_ctx, "pic32mx chip erase failed");
- }
-#endif
-
- return ERROR_OK;
-}
-
-int pic32mx_handle_pgm_word_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- flash_bank_t *bank;
- u32 address, value;
- int i;
- int status, res;
-
- if (argc != 3)
- {
- command_print(cmd_ctx, "pic32mx pgm_word <addr> <value> <bank>");
- return ERROR_OK;
- }
-
- address = strtoul(args[0], NULL, 0);
- value = strtoul(args[1], NULL, 0);
-
- bank = get_flash_bank_by_num(strtoul(args[2], NULL, 0));
- if (!bank)
- {
- command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[2]);
- return ERROR_OK;
- }
- if (address < bank->base || address >= (bank->base+bank->size))
- {
- command_print(cmd_ctx, "flash address '%s' is out of bounds", args[0]);
- return ERROR_OK;
- }
-
- res = ERROR_OK;
- status = pic32mx_write_word(bank, address, value);
- if( status & NVMCON_NVMERR )
- res = ERROR_FLASH_OPERATION_FAILED;
- if( status & NVMCON_LVDERR )
- res = ERROR_FLASH_OPERATION_FAILED;
-
- if (res == ERROR_OK)
- command_print(cmd_ctx, "pic32mx pgm word complete");
- else
- command_print(cmd_ctx, "pic32mx pgm word failed (status=0x%x)", status);
-
- return ERROR_OK;
-}
+/***************************************************************************
+ * Copyright (C) 2005 by Dominic Rath *
+ * Dom...@gm... *
+ * *
+ * Copyright (C) 2008 by Spencer Oliver *
+ * sp...@sp... *
+ * *
+ * Copyright (C) 2008 by John McCarthy *
+ * jg...@ma... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "replacements.h"
+
+#include "pic32mx.h"
+#include "flash.h"
+#include "target.h"
+#include "log.h"
+#include "mips32.h"
+#include "algorithm.h"
+#include "binarybuffer.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+static
+struct pic32mx_devs_s {
+ u8 devid;
+ char *name;
+ u32 pfm_size;
+} pic32mx_devs[] = {
+ { 0x78, "460F512L USB", 512 },
+ { 0x74, "460F256L USB", 256 },
+ { 0x6D, "440F128L USB", 128 },
+ { 0x56, "440F512H USB", 512 },
+ { 0x52, "440F256H USB", 256 },
+ { 0x4D, "440F128H USB", 128 },
+ { 0x42, "420F032H USB", 32 },
+ { 0x38, "360F512L", 512 },
+ { 0x34, "360F256L", 256 },
+ { 0x2D, "340F128L", 128 },
+ { 0x2A, "320F128L", 128 },
+ { 0x16, "340F512H", 512 },
+ { 0x12, "340F256H", 256 },
+ { 0x0D, "340F128H", 128 },
+ { 0x0A, "320F128H", 128 },
+ { 0x06, "320F064H", 64 },
+ { 0x02, "320F032H", 32 },
+ { 0x00, NULL, 0 }
+};
+
+int pic32mx_register_commands(struct command_context_s *cmd_ctx);
+int pic32mx_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
+int pic32mx_erase(struct flash_bank_s *bank, int first, int last);
+int pic32mx_protect(struct flash_bank_s *bank, int set, int first, int last);
+int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
+int pic32mx_probe(struct flash_bank_s *bank);
+int pic32mx_auto_probe(struct flash_bank_s *bank);
+int pic32mx_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int pic32mx_protect_check(struct flash_bank_s *bank);
+int pic32mx_info(struct flash_bank_s *bank, char *buf, int buf_size);
+
+#if 0
+int pic32mx_handle_lock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int pic32mx_handle_unlock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+#endif
+int pic32mx_handle_chip_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int pic32mx_handle_pgm_word_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int pic32mx_chip_erase(struct flash_bank_s *bank);
+
+flash_driver_t pic32mx_flash =
+{
+ .name = "pic32mx",
+ .register_commands = pic32mx_register_commands,
+ .flash_bank_command = pic32mx_flash_bank_command,
+ .erase = pic32mx_erase,
+ .protect = pic32mx_protect,
+ .write = pic32mx_write,
+ .probe = pic32mx_probe,
+ .auto_probe = pic32mx_auto_probe,
+ .erase_check = default_flash_mem_blank_check,
+ .protect_check = pic32mx_protect_check,
+ .info = pic32mx_info
+};
+
+int pic32mx_register_commands(struct command_context_s *cmd_ctx)
+{
+ command_t *pic32mx_cmd = register_command(cmd_ctx, NULL, "pic32mx", NULL, COMMAND_ANY, "pic32mx flash specific commands");
+
+#if 0
+ register_command(cmd_ctx, pic32mx_cmd, "lock", pic32mx_handle_lock_command, COMMAND_EXEC,
+ "lock device");
+ register_command(cmd_ctx, pic32mx_cmd, "unlock", pic32mx_handle_unlock_command, COMMAND_EXEC,
+ "unlock protected device");
+#endif
+ register_command(cmd_ctx, pic32mx_cmd, "chip_erase", pic32mx_handle_chip_erase_command, COMMAND_EXEC,
+ "erase device");
+ register_command(cmd_ctx, pic32mx_cmd, "pgm_word", pic32mx_handle_pgm_word_command, COMMAND_EXEC,
+ "program a word");
+ return ERROR_OK;
+}
+
+/* flash bank pic32mx <base> <size> 0 0 <target#>
+ */
+int pic32mx_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
+{
+ pic32mx_flash_bank_t *pic32mx_info;
+
+ if (argc < 6)
+ {
+ LOG_WARNING("incomplete flash_bank pic32mx configuration");
+ return ERROR_FLASH_BANK_INVALID;
+ }
+
+ pic32mx_info = malloc(sizeof(pic32mx_flash_bank_t));
+ bank->driver_priv = pic32mx_info;
+
+ pic32mx_info->write_algorithm = NULL;
+ pic32mx_info->probed = 0;
+
+ return ERROR_OK;
+}
+
+u32 pic32mx_get_flash_status(flash_bank_t *bank)
+{
+ target_t *target = bank->target;
+ u32 status;
+
+ target_read_u32(target, PIC32MX_NVMCON, &status);
+
+ return status;
+}
+
+u32 pic32mx_wait_status_busy(flash_bank_t *bank, int timeout)
+{
+ u32 status;
+
+ /* wait for busy to clear */
+ while (((status = pic32mx_get_flash_status(bank)) & NVMCON_NVMWR) && (timeout-- > 0))
+ {
+ LOG_DEBUG("status: 0x%x", status);
+ alive_sleep(1);
+ }
+ if(timeout <= 0)
+ LOG_DEBUG("timeout: status: 0x%x", status);
+
+ return status;
+}
+
+int pic32mx_nvm_exec(struct flash_bank_s *bank, u32 op, u32 timeout)
+{
+ target_t *target = bank->target;
+ u32 status;
+
+ target_write_u32(target, PIC32MX_NVMCON, NVMCON_NVMWREN|op);
+
+ /* unlock flash registers */
+ target_write_u32(target, PIC32MX_NVMKEY, NVMKEY1);
+ target_write_u32(target, PIC32MX_NVMKEY, NVMKEY2);
+
+ /* start operation */
+ target_write_u32(target, PIC32MX_NVMCONSET, NVMCON_NVMWR);
+
+ status = pic32mx_wait_status_busy(bank, timeout);
+
+ /* lock flash registers */
+ target_write_u32(target, PIC32MX_NVMCONCLR, NVMCON_NVMWREN);
+
+ return status;
+}
+
+int pic32mx_protect_check(struct flash_bank_s *bank)
+{
+ target_t *target = bank->target;
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
+
+ u32 devcfg0;
+ int s;
+ int num_pages;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ target_read_u32(target, PIC32MX_DEVCFG0, &devcfg0);
+ if((devcfg0 & (1<<28)) == 0) /* code protect bit */
+ num_pages = 0xffff; /* All pages protected */
+ else if(bank->base == PIC32MX_KSEG1_BOOT_FLASH)
+ {
+ if(devcfg0 & (1<<24))
+ num_pages = 0; /* All pages unprotected */
+ else
+ num_pages = 0xffff; /* All pages protected */
+ }
+ else /* pgm flash */
+ num_pages = (~devcfg0 >> 12) & 0xff;
+ for (s = 0; s < bank->num_sectors && s < num_pages; s++)
+ bank->sectors[s].is_protected = 1;
+ for (; s < bank->num_sectors; s++)
+ bank->sectors[s].is_protected = 0;
+
+ return ERROR_OK;
+}
+
+int pic32mx_erase(struct flash_bank_s *bank, int first, int last)
+{
+ target_t *target = bank->target;
+ int i;
+ u32 status;
+
+ if (bank->target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+#if 0
+ if ((first == 0) && (last == (bank->num_sectors - 1)) && (bank->base == PIC32MX_KSEG0_PGM_FLASH || bank->base == PIC32MX_KSEG1_PGM_FLASH))
+ {
+ status = pic32mx_nvm_exec(bank, NVMCON_OP_PFM_ERASE, 50);
+ if( status & NVMCON_NVMERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ return ERROR_OK;
+ }
+#endif
+
+ for (i = first; i <= last; i++)
+ {
+ target_write_u32(target, PIC32MX_NVMADDR, bank->base + bank->sectors[i].offset);
+
+ status = pic32mx_nvm_exec(bank, NVMCON_OP_PAGE_ERASE, 10);
+
+ if( status & NVMCON_NVMERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ bank->sectors[i].is_erased = 1;
+ }
+
+ return ERROR_OK;
+}
+
+int pic32mx_protect(struct flash_bank_s *bank, int set, int first, int last)
+{
+ pic32mx_flash_bank_t *pic32mx_info = NULL;
+ target_t *target = bank->target;
+ u16 prot_reg[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
+ int i, reg, bit;
+ int status;
+ u32 protection;
+
+ pic32mx_info = bank->driver_priv;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+#if 0
+ if ((first && (first % pic32mx_info->ppage_size)) || ((last + 1) && (last + 1) % pic32mx_info->ppage_size))
+ {
+ LOG_WARNING("sector start/end incorrect - stm32 has %dK sector protection", pic32mx_info->ppage_size);
+ return ERROR_FLASH_SECTOR_INVALID;
+ }
+
+ /* medium density - each bit refers to a 4bank protection
+ * high density - each bit refers to a 2bank protection */
+ target_read_u32(target, PIC32MX_FLASH_WRPR, &protection);
+
+ prot_reg[0] = (u16)protection;
+ prot_reg[1] = (u16)(protection >> 8);
+ prot_reg[2] = (u16)(protection >> 16);
+ prot_reg[3] = (u16)(protection >> 24);
+
+ if (pic32mx_info->ppage_size == 2)
+ {
+ /* high density flash */
+
+ /* bit 7 controls sector 62 - 255 protection */
+ if (last > 61)
+ {
+ if (set)
+ prot_reg[3] &= ~(1 << 7);
+ else
+ prot_reg[3] |= (1 << 7);
+ }
+
+ if (first > 61)
+ first = 62;
+ if (last > 61)
+ last = 61;
+
+ for (i = first; i <= last; i++)
+ {
+ reg = (i / pic32mx_info->ppage_size) / 8;
+ bit = (i / pic32mx_info->ppage_size) - (reg * 8);
+
+ if( set )
+ prot_reg[reg] &= ~(1 << bit);
+ else
+ prot_reg[reg] |= (1 << bit);
+ }
+ }
+ else
+ {
+ /* medium density flash */
+ for (i = first; i <= last; i++)
+ {
+ reg = (i / pic32mx_info->ppage_size) / 8;
+ bit = (i / pic32mx_info->ppage_size) - (reg * 8);
+
+ if( set )
+ prot_reg[reg] &= ~(1 << bit);
+ else
+ prot_reg[reg] |= (1 << bit);
+ }
+ }
+
+ if ((status = pic32mx_erase_options(bank)) != ERROR_OK)
+ return status;
+
+ pic32mx_info->option_bytes.protection[0] = prot_reg[0];
+ pic32mx_info->option_bytes.protection[1] = prot_reg[1];
+ pic32mx_info->option_bytes.protection[2] = prot_reg[2];
+ pic32mx_info->option_bytes.protection[3] = prot_reg[3];
+
+ return pic32mx_write_options(bank);
+#else
+ return ERROR_OK;
+#endif
+}
+
+int pic32mx_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
+{
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
+ target_t *target = bank->target;
+ u32 buffer_size = 8192;
+ working_area_t *source;
+ u32 address = bank->base + offset;
+ reg_param_t reg_params[4];
+#if 0
+ armv7m_algorithm_t armv7m_info;
+ int retval = ERROR_OK;
+
+ u8 pic32mx_flash_write_code[] = {
+ /* write: */
+ 0xDF, 0xF8, 0x24, 0x40, /* ldr r4, PIC32MX_FLASH_CR */
+ 0x09, 0x4D, /* ldr r5, PIC32MX_FLASH_SR */
+ 0x4F, 0xF0, 0x01, 0x03, /* mov r3, #1 */
+ 0x23, 0x60, /* str r3, [r4, #0] */
+ 0x30, 0xF8, 0x02, 0x3B, /* ldrh r3, [r0], #2 */
+ 0x21, 0xF8, 0x02, 0x3B, /* strh r3, [r1], #2 */
+ /* busy: */
+ 0x2B, 0x68, /* ldr r3, [r5, #0] */
+ 0x13, 0xF0, 0x01, 0x0F, /* tst r3, #0x01 */
+ 0xFB, 0xD0, /* beq busy */
+ 0x13, 0xF0, 0x14, 0x0F, /* tst r3, #0x14 */
+ 0x01, 0xD1, /* bne exit */
+ 0x01, 0x3A, /* subs r2, r2, #1 */
+ 0xED, 0xD1, /* bne write */
+ /* exit: */
+ 0xFE, 0xE7, /* b exit */
+ 0x10, 0x20, 0x02, 0x40, /* PIC32MX_FLASH_CR: .word 0x40022010 */
+ 0x0C, 0x20, 0x02, 0x40 /* PIC32MX_FLASH_SR: .word 0x4002200C */
+ };
+
+ /* flash write code */
+ if (target_alloc_working_area(target, sizeof(pic32mx_flash_write_code), &pic32mx_info->write_algorithm) != ERROR_OK)
+ {
+ LOG_WARNING("no working area available, can't do block memory writes");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ };
+
+ if ((retval=target_write_buffer(target, pic32mx_info->write_algorithm->address, sizeof(pic32mx_flash_write_code), pic32mx_flash_write_code))!=ERROR_OK)
+ return retval;
+
+ /* memory buffer */
+ while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK)
+ {
+ buffer_size /= 2;
+ if (buffer_size <= 256)
+ {
+ /* if we already allocated the writing code, but failed to get a buffer, free the algorithm */
+ if (pic32mx_info->write_algorithm)
+ target_free_working_area(target, pic32mx_info->write_algorithm);
+
+ LOG_WARNING("no large enough working area available, can't do block memory writes");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
+ };
+
+ armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
+ armv7m_info.core_mode = ARMV7M_MODE_ANY;
+
+ init_reg_param(®_params[0], "r0", 32, PARAM_OUT);
+ init_reg_param(®_params[1], "r1", 32, PARAM_OUT);
+ init_reg_param(®_params[2], "r2", 32, PARAM_OUT);
+ init_reg_param(®_params[3], "r3", 32, PARAM_IN);
+
+ while (count > 0)
+ {
+ u32 thisrun_count = (count > (buffer_size / 2)) ? (buffer_size / 2) : count;
+
+ if ((retval = target_write_buffer(target, source->address, thisrun_count * 2, buffer))!=ERROR_OK)
+ break;
+
+ buf_set_u32(reg_params[0].value, 0, 32, source->address);
+ buf_set_u32(reg_params[1].value, 0, 32, address);
+ buf_set_u32(reg_params[2].value, 0, 32, thisrun_count);
+
+ if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, pic32mx_info->write_algorithm->address, \
+ pic32mx_info->write_algorithm->address + (sizeof(pic32mx_flash_write_code) - 10), 10000, &armv7m_info)) != ERROR_OK)
+ {
+ LOG_ERROR("error executing pic32mx flash write algorithm");
+ retval = ERROR_FLASH_OPERATION_FAILED;
+ break;
+ }
+
+ if (buf_get_u32(reg_params[3].value, 0, 32) & 0x14)
+ {
+ retval = ERROR_FLASH_OPERATION_FAILED;
+ break;
+ }
+
+ buffer += thisrun_count * 2;
+ address += thisrun_count * 2;
+ count -= thisrun_count;
+ }
+
+ target_free_working_area(target, source);
+ target_free_working_area(target, pic32mx_info->write_algorithm);
+
+ destroy_reg_param(®_params[0]);
+ destroy_reg_param(®_params[1]);
+ destroy_reg_param(®_params[2]);
+ destroy_reg_param(®_params[3]);
+
+ return retval;
+#else
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+#endif
+}
+
+int pic32mx_write_word(struct flash_bank_s *bank, u32 address, u32 word)
+{
+ target_t *target = bank->target;
+
+ target_write_u32(target, PIC32MX_NVMADDR, address);
+ target_write_u32(target, PIC32MX_NVMDATA, word);
+
+ return pic32mx_nvm_exec(bank, NVMCON_OP_WORD_PROG, 5);
+}
+
+int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
+{
+ target_t *target = bank->target;
+ u32 words_remaining = (count / 4);
+ u32 bytes_remaining = (count & 0x00000003);
+ u32 address = bank->base + offset;
+ u32 bytes_written = 0;
+ u32 status;
+ u32 retval;
+
+ if (bank->target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ if (offset & 0x3)
+ {
+ LOG_WARNING("offset 0x%x breaks required 4-byte alignment", offset);
+ return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
+ }
+
+ /* multiple words (4-byte) to be programmed? */
+ if (words_remaining > 0)
+ {
+ /* try using a block write */
+ if ((retval = pic32mx_write_block(bank, buffer, offset, words_remaining)) != ERROR_OK)
+ {
+ if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
+ {
+ /* if block write failed (no sufficient working area),
+ * we use normal (slow) single dword accesses */
+ LOG_WARNING("couldn't use block writes, falling back to single memory accesses");
+ }
+ else if (retval == ERROR_FLASH_OPERATION_FAILED)
+ {
+ LOG_ERROR("flash writing failed with error code: 0x%x", retval);
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+ }
+ else
+ {
+ buffer += words_remaining * 4;
+ address += words_remaining * 4;
+ words_remaining = 0;
+ }
+ }
+
+ while (words_remaining > 0)
+ {
+ status = pic32mx_write_word(bank, address, *(u32*)(buffer + bytes_written));
+
+ if( status & NVMCON_NVMERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+
+ bytes_written += 4;
+ words_remaining--;
+ address += 4;
+ }
+
+ if (bytes_remaining)
+ {
+ u8 last_word[4] = {0xff, 0xff, 0xff, 0xff};
+ int i = 0;
+
+ while(bytes_remaining > 0)
+ {
+ /* Assumes little endian */
+ last_word[i++] = *(buffer + bytes_written);
+ bytes_remaining--;
+ bytes_written++;
+ }
+
+ status = pic32mx_write_word(bank, address, *(u32*)last_word);
+
+ if( status & NVMCON_NVMERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+
+ return ERROR_OK;
+}
+
+int pic32mx_probe(struct flash_bank_s *bank)
+{
+ target_t *target = bank->target;
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
+ mips32_common_t *mips32 = target->arch_info;
+ mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
+ int i;
+ u16 num_pages;
+ u32 device_id;
+ int page_size;
+
+ pic32mx_info->probed = 0;
+
+ device_id = ejtag_info->idcode;
+ LOG_INFO( "device id = 0x%08x (manuf 0x%03x dev 0x%02x, ver 0x%03x)", device_id, (device_id>>1)&0x7ff, (device_id>>12)&0xff, (device_id>>20)&0xfff );
+
+ if(((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
+ LOG_WARNING( "Cannot identify target as a PIC32MX family." );
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+
+ page_size = 4096;
+ if(bank->base == PIC32MX_KSEG1_BOOT_FLASH || bank->base == 1) {
+ /* 0xBFC00000: Boot flash size fixed at 12k */
+ num_pages = 12;
+ } else {
+ /* 0xBD000000: Program flash size varies with device */
+ for(i=0; pic32mx_devs[i].name != NULL; i++)
+ if(pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
+ num_pages = pic32mx_devs[i].pfm_size;
+ break;
+ }
+ if(pic32mx_devs[i].name == NULL) {
+ LOG_WARNING( "Cannot identify target as a PIC32MX family." );
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+ }
+
+#if 0
+ if (bank->target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ /* get flash size from target */
+ if (target_read_u16(target, 0x1FFFF7E0, &num_pages) != ERROR_OK)
+ {
+ /* failed reading flash size, default to max target family */
+ num_pages = 0xffff;
+ }
+#endif
+
+ LOG_INFO( "flash size = %dkbytes", num_pages );
+
+ /* calculate numbers of pages */
+ num_pages /= (page_size / 1024);
+
+ if(bank->base == 0) bank->base = PIC32MX_KSEG1_PGM_FLASH;
+ if(bank->base == 1) bank->base = PIC32MX_KSEG1_BOOT_FLASH;
+ bank->size = (num_pages * page_size);
+ bank->num_sectors = num_pages;
+ bank->chip_width = 4;
+ bank->bus_width = 4;
+ bank->sectors = malloc(sizeof(flash_sector_t) * num_pages);
+
+ for (i = 0; i < num_pages; i++)
+ {
+ bank->sectors[i].offset = i * page_size;
+ bank->sectors[i].size = page_size;
+ bank->sectors[i].is_erased = -1;
+ bank->sectors[i].is_protected = 1;
+ }
+
+ pic32mx_info->probed = 1;
+
+ return ERROR_OK;
+}
+
+int pic32mx_auto_probe(struct flash_bank_s *bank)
+{
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
+ if (pic32mx_info->probed)
+ return ERROR_OK;
+ return pic32mx_probe(bank);
+}
+
+int pic32mx_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ return ERROR_OK;
+}
+
+int pic32mx_info(struct flash_bank_s *bank, char *buf, int buf_size)
+{
+ target_t *target = bank->target;
+ mips32_common_t *mips32 = target->arch_info;
+ mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
+ u32 device_id;
+ int printed, i;
+
+ device_id = ejtag_info->idcode;
+
+ if(((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
+ snprintf(buf, buf_size, "Cannot identify target as a PIC32MX family (manufacturer 0x%03d != 0x%03d)\n", (device_id>>1)&0x7ff, PIC32MX_MANUF_ID);
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+ for(i=0; pic32mx_devs[i].name != NULL; i++)
+ if(pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
+ printed = snprintf(buf, buf_size, "PIC32MX%s", pic32mx_devs[i].name);
+ break;
+ }
+ if(pic32mx_devs[i].name == NULL) {
+ snprintf(buf, buf_size, "Cannot identify target as a PIC32MX family\n");
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+ buf += printed;
+ buf_size -= printed;
+ printed = snprintf(buf, buf_size, " Ver: 0x%03x", (device_id>>20)&0xfff);
+
+ return ERROR_OK;
+}
+
+#if 0
+int pic32mx_handle_lock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ flash_bank_t *bank;
+ target_t *target = NULL;
+ pic32mx_flash_bank_t *pic32mx_info = NULL;
+
+ if (argc < 1)
+ {
+ command_print(cmd_ctx, "pic32mx lock <bank>");
+ return ERROR_OK;
+ }
+
+ bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
+ if (!bank)
+ {
+ command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
+ return ERROR_OK;
+ }
+
+ pic32mx_info = bank->driver_priv;
+
+ target = bank->target;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ if (pic32mx_erase_options(bank) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "pic32mx failed to erase options");
+ return ERROR_OK;
+ }
+
+ /* set readout protection */
+ pic32mx_info->option_bytes.RDP = 0;
+
+ if (pic32mx_write_options(bank) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "pic32mx failed to lock device");
+ return ERROR_OK;
+ }
+
+ command_print(cmd_ctx, "pic32mx locked");
+
+ return ERROR_OK;
+}
+
+int pic32mx_handle_unlock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ flash_bank_t *bank;
+ target_t *target = NULL;
+ pic32mx_flash_bank_t *pic32mx_info = NULL;
+
+ if (argc < 1)
+ {
+ command_print(cmd_ctx, "pic32mx unlock <bank>");
+ return ERROR_OK;
+ }
+
+ bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
+ if (!bank)
+ {
+ command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
+ return ERROR_OK;
+ }
+
+ pic32mx_info = bank->driver_priv;
+
+ target = bank->target;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ if (pic32mx_erase_options(bank) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "pic32mx failed to unlock device");
+ return ERROR_OK;
+ }
+
+ if (pic32mx_write_options(bank) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "pic32mx failed to lock device");
+ return ERROR_OK;
+ }
+
+ command_print(cmd_ctx, "pic32mx unlocked");
+
+ return ERROR_OK;
+}
+#endif
+
+int pic32mx_chip_erase(struct flash_bank_s *bank)
+{
+ target_t *target = bank->target;
+ u32 status;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ LOG_INFO("PIC32MX chip erase called");
+
+#if 0
+ /* unlock option flash registers */
+ target_write_u32(target, PIC32MX_FLASH_KEYR, KEY1);
+ target_write_u32(target, PIC32MX_FLASH_KEYR, KEY2);
+
+ /* chip erase flash memory */
+ target_write_u32(target, PIC32MX_FLASH_CR, FLASH_MER);
+ target_write_u32(target, PIC32MX_FLASH_CR, FLASH_MER|FLASH_STRT);
+
+ status = pic32mx_wait_status_busy(bank, 10);
+
+ target_write_u32(target, PIC32MX_FLASH_CR, FLASH_LOCK);
+
+ if( status & FLASH_WRPRTERR )
+ {
+ LOG_ERROR("pic32mx device protected");
+ return ERROR_OK;
+ }
+
+ if( status & FLASH_PGERR )
+ {
+ LOG_ERROR("pic32mx device programming failed");
+ return ERROR_OK;
+ }
+#endif
+
+ return ERROR_OK;
+}
+
+int pic32mx_handle_chip_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ flash_bank_t *bank;
+ int i;
+
+#if 0
+ if (argc != 0)
+ {
+ command_print(cmd_ctx, "pic32mx chip_erase");
+ return ERROR_OK;
+ }
+
+ bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
+ if (!bank)
+ {
+ command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
+ return ERROR_OK;
+ }
+
+ if (pic32mx_chip_erase(bank) == ERROR_OK)
+ {
+ /* set all sectors as erased */
+ for (i = 0; i < bank->num_sectors; i++)
+ {
+ bank->sectors[i].is_erased = 1;
+ }
+
+ command_print(cmd_ctx, "pic32mx chip erase complete");
+ }
+ else
+ {
+ command_print(cmd_ctx, "pic32mx chip erase failed");
+ }
+#endif
+
+ return ERROR_OK;
+}
+
+int pic32mx_handle_pgm_word_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ flash_bank_t *bank;
+ u32 address, value;
+ int i;
+ int status, res;
+
+ if (argc != 3)
+ {
+ command_print(cmd_ctx, "pic32mx pgm_word <addr> <value> <bank>");
+ return ERROR_OK;
+ }
+
+ address = strtoul(args[0], NULL, 0);
+ value = strtoul(args[1], NULL, 0);
+
+ bank = get_flash_bank_by_num(strtoul(args[2], NULL, 0));
+ if (!bank)
+ {
+ command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[2]);
+ return ERROR_OK;
+ }
+ if (address < bank->base || address >= (bank->base+bank->size))
+ {
+ command_print(cmd_ctx, "flash address '%s' is out of bounds", args[0]);
+ return ERROR_OK;
+ }
+
+ res = ERROR_OK;
+ status = pic32mx_write_word(bank, address, value);
+ if( status & NVMCON_NVMERR )
+ res = ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ res = ERROR_FLASH_OPERATION_FAILED;
+
+ if (res == ERROR_OK)
+ command_print(cmd_ctx, "pic32mx pgm word complete");
+ else
+ command_print(cmd_ctx, "pic32mx pgm word failed (status=0x%x)", status);
+
+ return ERROR_OK;
+}
Property changes on: trunk/src/flash/pic32mx.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/src/flash/pic32mx.h
===================================================================
--- trunk/src/flash/pic32mx.h 2009-01-02 23:58:16 UTC (rev 1296)
+++ trunk/src/flash/pic32mx.h 2009-01-03 08:56:52 UTC (rev 1297)
@@ -1,105 +1,105 @@
-/***************************************************************************
- * Copyright (C) 2005 by Dominic Rath *
- * Dom...@gm... *
- * *
- * Copyright (C) 2008 by Spencer Oliver *
- * sp...@sp... *
- * *
- * Copyright (C) 2008 by John McCarthy *
- * jg...@ma... *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#ifndef PIC32MX_H
-#define PIC32MX_H
-
-#include "flash.h"
-#include "target.h"
-
-typedef struct pic32mx_flash_bank_s
-{
- working_area_t *write_algorithm;
- int devid;
- int ppage_size;
- int probed;
-} pic32mx_flash_bank_t;
-
-#define PIC32MX_MANUF_ID 0x029
-
-/* pic32mx memory locations */
-
-#define PIC32MX_KUSEG_PGM_FLASH 0x7D000000
-#define PIC32MX_KUSEG_RAM 0x7F000000
-
-#define PIC32MX_KSEG0_RAM 0x80000000
-#define PIC32MX_KSEG0_PGM_FLASH 0x9D000000
-#define PIC32MX_KSEG0_BOOT_FLASH 0x9FC00000
-
-#define PIC32MX_KSEG1_RAM 0xA0000000
-#define PIC32MX_KSEG1_PGM_FLASH 0xBD000000
-#define PIC32MX_KSEG1_PERIPHERAL 0xBF800000
-#define PIC32MX_KSEG1_BOOT_FLASH 0xBFC00000
-
-#define PIC32MX_PHYS_RAM 0x00000000
-#define PIC32MX_PHYS_PGM_FLASH 0x1D000000
-#define PIC32MX_PHYS_PERIPHERALS 0x1F800000
-#define PIC32MX_PHYS_BOOT_FLASH 0x1FC00000
-
-/* pic32mx configuration register locations */
-
-#define PIC32MX_DEVCFG0 0xBFC02FFC
-#define PIC32MX_DEVCFG1 0xBFC02FF8
-#define PIC32MX_DEVCFG2 0xBFC02FF4
-#define PIC32MX_DEVCFG3 0XBFC02FF0
-#define PIC32MX_DEVID 0xBF80F220
-
-/* pic32mx flash controller register locations */
-
-#define PIC32MX_NVMCON 0xBF80F400
-#define PIC32MX_NVMCONCLR 0xBF80F404
-#define PIC32MX_NVMCONSET 0xBF80F408
-#define PIC32MX_NVMCONINV 0xBF80F40C
-#define NVMCON_NVMWR (1<<15)
-#define NVMCON_NVMWREN (1<<14)
-#define NVMCON_NVMERR (1<<13)
-#define NVMCON_LVDERR (1<<12)
-#define NVMCON_LVDSTAT (1<<11)
-#define NVMCON_OP_PFM_ERASE 0x5
-#define NVMCON_OP_PAGE_ERASE 0x4
-#define NVMCON_OP_ROW_PROG 0x3
-#define NVMCON_OP_WORD_PROG 0x1
-#define NVMCON_OP_NOP 0x0
-
-#define PIC32MX_NVMKEY 0xBF80F410
-#define PIC32MX_NVMADDR 0xBF80F420
-#define PIC32MX_NVMADDRCLR 0xBF80F424
-#define PIC32MX_NVMADDRSET 0xBF80F428
-#define PIC32MX_NVMADDRINV 0xBF80F42C
-#define PIC32MX_NVMDATA 0xBF80F430
-#define PIC32MX_NVMSRCADDR 0xBF80F440
-
-/* flash unlock keys */
-
-#define NVMKEY1 0xAA996655
-#define NVMKEY2 0x556699AA
-
-typedef struct pic32mx_mem_layout_s {
- u32 sector_start;
- u32 sector_size;
-} pic32mx_mem_layout_t;
-
-#endif /* PIC32MX_H */
-
+/***************************************************************************
+ * Copyright (C) 2005 by Dominic Rath *
+ * Dom...@gm... *
+ * *
+ * Copyright (C) 2008 by Spencer Oliver *
+ * sp...@sp... *
+ * *
+ * Copyright (C) 2008 by John McCarthy *
+ * jg...@ma... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PIC32MX_H
+#define PIC32MX_H
+
+#include "flash.h"
+#include "target.h"
+
+typedef struct pic32mx_flash_bank_s
+{
+ working_area_t *write_algorithm;
+ int devid;
+ int ppage_size;
+ int probed;
+} pic32mx_flash_bank_t;
+
+#define PIC32MX_MANUF_ID 0x029
+
+/* pic32mx memory locations */
+
+#define PIC32MX_KUSEG_PGM_FLASH 0x7D000000
+#define PIC32MX_KUSEG_RAM 0x7F000000
+
+#define PIC32MX_KSEG0_RAM 0x80000000
+#define PIC32MX_KSEG0_PGM_FLASH 0x9D000000
+#define PIC32MX_KSEG0_BOOT_FLASH 0x9FC00000
+
+#define PIC32MX_KSEG1_RAM 0xA0000000
+#define PIC32MX_KSEG1_PGM_FLASH 0xBD000000
+#define PIC32MX_KSEG1_PERIPHERAL 0xBF800000
+#define PIC32MX_KSEG1_BOOT_FLASH 0xBFC00000
+
+#define PIC32MX_PHYS_RAM 0x00000000
+#define PIC32MX_PHYS_PGM_FLASH 0x1D000000
+#define PIC32MX_PHYS_PERIPHERALS 0x1F800000
+#define PIC32MX_PHYS_BOOT_FLASH 0x1FC00000
+
+/* pic32mx configuration register locations */
+
+#define PIC32MX_DEVCFG0 0xBFC02FFC
+#define PIC32MX_DEVCFG1 0xBFC02FF8
+#define PIC32MX_DEVCFG2 0xBFC02FF4
+#define PIC32MX_DEVCFG3 0XBFC02FF0
+#define PIC32MX_DEVID 0xBF80F220
+
+/* pic32mx flash controller register locations */
+
+#define PIC32MX_NVMCON 0xBF80F400
+#define PIC32MX_NVMCONCLR 0xBF80F404
+#define PIC32MX_NVMCONSET 0xBF80F408
+#define PIC32MX_NVMCONINV 0xBF80F40C
+#define NVMCON_NVMWR (1<<15)
+#define NVMCON_NVMWREN (1<<14)
+#define NVMCON_NVMERR (1<<13)
+#define NVMCON_LVDERR (1<<12)
+#define NVMCON_LVDSTAT (1<<11)
+#define NVMCON_OP_PFM_ERASE 0x5
+#define NVMCON_OP_PAGE_ERASE 0x4
+#define NVMCON_OP_ROW_PROG 0x3
+#define NVMCON_OP_WORD_PROG 0x1
+#define NVMCON_OP_NOP 0x0
+
+#define PIC32MX_NVMKEY 0xBF80F410
+#define PIC32MX_NVMADDR 0xBF80F420
+#define PIC32MX_NVMADDRCLR 0xBF80F424
+#define PIC32MX_NVMADDRSET 0xBF80F428
+#define PIC32MX_NVMADDRI...
[truncated message content] |
|
From: <oh...@ma...> - 2009-01-03 00:58:24
|
Author: oharboe
Date: 2009-01-03 00:58:16 +0100 (Sat, 03 Jan 2009)
New Revision: 1296
Added:
trunk/src/flash/pic32mx.c
trunk/src/flash/pic32mx.h
trunk/src/target/board/pic-p32mx.cfg
Modified:
trunk/src/flash/Makefile.am
trunk/src/flash/flash.c
trunk/src/target/mips_ejtag.h
trunk/src/target/mips_m4k.c
trunk/src/target/target/pic32mx.cfg
Log:
John McCarthy <jg...@ma...> pic32mx flash wip
Modified: trunk/src/flash/Makefile.am
===================================================================
--- trunk/src/flash/Makefile.am 2009-01-02 23:52:46 UTC (rev 1295)
+++ trunk/src/flash/Makefile.am 2009-01-02 23:58:16 UTC (rev 1296)
@@ -4,7 +4,7 @@
noinst_LIBRARIES = libflash.a
libflash_a_SOURCES = flash.c lpc2000.c cfi.c non_cfi.c at91sam7.c at91sam7_old.c str7x.c str9x.c aduc702x.c nand.c lpc3180_nand_controller.c \
stellaris.c str9xpec.c stm32x.c tms470.c ecos.c \
- s3c24xx_nand.c s3c2410_nand.c s3c2412_nand.c s3c2440_nand.c s3c2443_nand.c lpc288x.c ocl.c mflash.c
+ s3c24xx_nand.c s3c2410_nand.c s3c2412_nand.c s3c2440_nand.c s3c2443_nand.c lpc288x.c ocl.c mflash.c pic32mx.c
noinst_HEADERS = flash.h lpc2000.h cfi.h non_cfi.h at91sam7.h at91sam7_old.h str7x.h str9x.h nand.h lpc3180_nand_controller.h \
stellaris.h str9xpec.h stm32x.h tms470.h s3c24xx_nand.h s3c24xx_regs_nand.h lpc288x.h mflash.h \
- ocl.h
+ ocl.h pic32mx.h
Modified: trunk/src/flash/flash.c
===================================================================
--- trunk/src/flash/flash.c 2009-01-02 23:52:46 UTC (rev 1295)
+++ trunk/src/flash/flash.c 2009-01-02 23:58:16 UTC (rev 1296)
@@ -78,6 +78,7 @@
extern flash_driver_t ecosflash_flash;
extern flash_driver_t lpc288x_flash;
extern flash_driver_t ocl_flash;
+extern flash_driver_t pic32mx_flash;
flash_driver_t *flash_drivers[] = {
&lpc2000_flash,
@@ -94,6 +95,7 @@
&ecosflash_flash,
&lpc288x_flash,
&ocl_flash,
+ &pic32mx_flash,
NULL,
};
@@ -316,14 +318,17 @@
/* put flash bank in linked list */
if (flash_banks)
{
+ int bank_num = 0;
/* find last flash bank */
- for (p = flash_banks; p && p->next; p = p->next);
+ for (p = flash_banks; p && p->next; p = p->next) bank_num++;
if (p)
p->next = c;
+ c->bank_number = bank_num + 1;
}
else
{
flash_banks = c;
+ c->bank_number = 0;
}
found = 1;
Added: trunk/src/flash/pic32mx.c
===================================================================
--- trunk/src/flash/pic32mx.c 2009-01-02 23:52:46 UTC (rev 1295)
+++ trunk/src/flash/pic32mx.c 2009-01-02 23:58:16 UTC (rev 1296)
@@ -0,0 +1,902 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Dominic Rath *
+ * Dom...@gm... *
+ * *
+ * Copyright (C) 2008 by Spencer Oliver *
+ * sp...@sp... *
+ * *
+ * Copyright (C) 2008 by John McCarthy *
+ * jg...@ma... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "replacements.h"
+
+#include "pic32mx.h"
+#include "flash.h"
+#include "target.h"
+#include "log.h"
+#include "mips32.h"
+#include "algorithm.h"
+#include "binarybuffer.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+static
+struct pic32mx_devs_s {
+ u8 devid;
+ char *name;
+ u32 pfm_size;
+} pic32mx_devs[] = {
+ { 0x78, "460F512L USB", 512 },
+ { 0x74, "460F256L USB", 256 },
+ { 0x6D, "440F128L USB", 128 },
+ { 0x56, "440F512H USB", 512 },
+ { 0x52, "440F256H USB", 256 },
+ { 0x4D, "440F128H USB", 128 },
+ { 0x42, "420F032H USB", 32 },
+ { 0x38, "360F512L", 512 },
+ { 0x34, "360F256L", 256 },
+ { 0x2D, "340F128L", 128 },
+ { 0x2A, "320F128L", 128 },
+ { 0x16, "340F512H", 512 },
+ { 0x12, "340F256H", 256 },
+ { 0x0D, "340F128H", 128 },
+ { 0x0A, "320F128H", 128 },
+ { 0x06, "320F064H", 64 },
+ { 0x02, "320F032H", 32 },
+ { 0x00, NULL, 0 }
+};
+
+int pic32mx_register_commands(struct command_context_s *cmd_ctx);
+int pic32mx_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
+int pic32mx_erase(struct flash_bank_s *bank, int first, int last);
+int pic32mx_protect(struct flash_bank_s *bank, int set, int first, int last);
+int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
+int pic32mx_probe(struct flash_bank_s *bank);
+int pic32mx_auto_probe(struct flash_bank_s *bank);
+int pic32mx_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int pic32mx_protect_check(struct flash_bank_s *bank);
+int pic32mx_info(struct flash_bank_s *bank, char *buf, int buf_size);
+
+#if 0
+int pic32mx_handle_lock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int pic32mx_handle_unlock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+#endif
+int pic32mx_handle_chip_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int pic32mx_handle_pgm_word_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int pic32mx_chip_erase(struct flash_bank_s *bank);
+
+flash_driver_t pic32mx_flash =
+{
+ .name = "pic32mx",
+ .register_commands = pic32mx_register_commands,
+ .flash_bank_command = pic32mx_flash_bank_command,
+ .erase = pic32mx_erase,
+ .protect = pic32mx_protect,
+ .write = pic32mx_write,
+ .probe = pic32mx_probe,
+ .auto_probe = pic32mx_auto_probe,
+ .erase_check = default_flash_mem_blank_check,
+ .protect_check = pic32mx_protect_check,
+ .info = pic32mx_info
+};
+
+int pic32mx_register_commands(struct command_context_s *cmd_ctx)
+{
+ command_t *pic32mx_cmd = register_command(cmd_ctx, NULL, "pic32mx", NULL, COMMAND_ANY, "pic32mx flash specific commands");
+
+#if 0
+ register_command(cmd_ctx, pic32mx_cmd, "lock", pic32mx_handle_lock_command, COMMAND_EXEC,
+ "lock device");
+ register_command(cmd_ctx, pic32mx_cmd, "unlock", pic32mx_handle_unlock_command, COMMAND_EXEC,
+ "unlock protected device");
+#endif
+ register_command(cmd_ctx, pic32mx_cmd, "chip_erase", pic32mx_handle_chip_erase_command, COMMAND_EXEC,
+ "erase device");
+ register_command(cmd_ctx, pic32mx_cmd, "pgm_word", pic32mx_handle_pgm_word_command, COMMAND_EXEC,
+ "program a word");
+ return ERROR_OK;
+}
+
+/* flash bank pic32mx <base> <size> 0 0 <target#>
+ */
+int pic32mx_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
+{
+ pic32mx_flash_bank_t *pic32mx_info;
+
+ if (argc < 6)
+ {
+ LOG_WARNING("incomplete flash_bank pic32mx configuration");
+ return ERROR_FLASH_BANK_INVALID;
+ }
+
+ pic32mx_info = malloc(sizeof(pic32mx_flash_bank_t));
+ bank->driver_priv = pic32mx_info;
+
+ pic32mx_info->write_algorithm = NULL;
+ pic32mx_info->probed = 0;
+
+ return ERROR_OK;
+}
+
+u32 pic32mx_get_flash_status(flash_bank_t *bank)
+{
+ target_t *target = bank->target;
+ u32 status;
+
+ target_read_u32(target, PIC32MX_NVMCON, &status);
+
+ return status;
+}
+
+u32 pic32mx_wait_status_busy(flash_bank_t *bank, int timeout)
+{
+ u32 status;
+
+ /* wait for busy to clear */
+ while (((status = pic32mx_get_flash_status(bank)) & NVMCON_NVMWR) && (timeout-- > 0))
+ {
+ LOG_DEBUG("status: 0x%x", status);
+ alive_sleep(1);
+ }
+ if(timeout <= 0)
+ LOG_DEBUG("timeout: status: 0x%x", status);
+
+ return status;
+}
+
+int pic32mx_nvm_exec(struct flash_bank_s *bank, u32 op, u32 timeout)
+{
+ target_t *target = bank->target;
+ u32 status;
+
+ target_write_u32(target, PIC32MX_NVMCON, NVMCON_NVMWREN|op);
+
+ /* unlock flash registers */
+ target_write_u32(target, PIC32MX_NVMKEY, NVMKEY1);
+ target_write_u32(target, PIC32MX_NVMKEY, NVMKEY2);
+
+ /* start operation */
+ target_write_u32(target, PIC32MX_NVMCONSET, NVMCON_NVMWR);
+
+ status = pic32mx_wait_status_busy(bank, timeout);
+
+ /* lock flash registers */
+ target_write_u32(target, PIC32MX_NVMCONCLR, NVMCON_NVMWREN);
+
+ return status;
+}
+
+int pic32mx_protect_check(struct flash_bank_s *bank)
+{
+ target_t *target = bank->target;
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
+
+ u32 devcfg0;
+ int s;
+ int num_pages;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ target_read_u32(target, PIC32MX_DEVCFG0, &devcfg0);
+ if((devcfg0 & (1<<28)) == 0) /* code protect bit */
+ num_pages = 0xffff; /* All pages protected */
+ else if(bank->base == PIC32MX_KSEG1_BOOT_FLASH)
+ {
+ if(devcfg0 & (1<<24))
+ num_pages = 0; /* All pages unprotected */
+ else
+ num_pages = 0xffff; /* All pages protected */
+ }
+ else /* pgm flash */
+ num_pages = (~devcfg0 >> 12) & 0xff;
+ for (s = 0; s < bank->num_sectors && s < num_pages; s++)
+ bank->sectors[s].is_protected = 1;
+ for (; s < bank->num_sectors; s++)
+ bank->sectors[s].is_protected = 0;
+
+ return ERROR_OK;
+}
+
+int pic32mx_erase(struct flash_bank_s *bank, int first, int last)
+{
+ target_t *target = bank->target;
+ int i;
+ u32 status;
+
+ if (bank->target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+#if 0
+ if ((first == 0) && (last == (bank->num_sectors - 1)) && (bank->base == PIC32MX_KSEG0_PGM_FLASH || bank->base == PIC32MX_KSEG1_PGM_FLASH))
+ {
+ status = pic32mx_nvm_exec(bank, NVMCON_OP_PFM_ERASE, 50);
+ if( status & NVMCON_NVMERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ return ERROR_OK;
+ }
+#endif
+
+ for (i = first; i <= last; i++)
+ {
+ target_write_u32(target, PIC32MX_NVMADDR, bank->base + bank->sectors[i].offset);
+
+ status = pic32mx_nvm_exec(bank, NVMCON_OP_PAGE_ERASE, 10);
+
+ if( status & NVMCON_NVMERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ bank->sectors[i].is_erased = 1;
+ }
+
+ return ERROR_OK;
+}
+
+int pic32mx_protect(struct flash_bank_s *bank, int set, int first, int last)
+{
+ pic32mx_flash_bank_t *pic32mx_info = NULL;
+ target_t *target = bank->target;
+ u16 prot_reg[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
+ int i, reg, bit;
+ int status;
+ u32 protection;
+
+ pic32mx_info = bank->driver_priv;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+#if 0
+ if ((first && (first % pic32mx_info->ppage_size)) || ((last + 1) && (last + 1) % pic32mx_info->ppage_size))
+ {
+ LOG_WARNING("sector start/end incorrect - stm32 has %dK sector protection", pic32mx_info->ppage_size);
+ return ERROR_FLASH_SECTOR_INVALID;
+ }
+
+ /* medium density - each bit refers to a 4bank protection
+ * high density - each bit refers to a 2bank protection */
+ target_read_u32(target, PIC32MX_FLASH_WRPR, &protection);
+
+ prot_reg[0] = (u16)protection;
+ prot_reg[1] = (u16)(protection >> 8);
+ prot_reg[2] = (u16)(protection >> 16);
+ prot_reg[3] = (u16)(protection >> 24);
+
+ if (pic32mx_info->ppage_size == 2)
+ {
+ /* high density flash */
+
+ /* bit 7 controls sector 62 - 255 protection */
+ if (last > 61)
+ {
+ if (set)
+ prot_reg[3] &= ~(1 << 7);
+ else
+ prot_reg[3] |= (1 << 7);
+ }
+
+ if (first > 61)
+ first = 62;
+ if (last > 61)
+ last = 61;
+
+ for (i = first; i <= last; i++)
+ {
+ reg = (i / pic32mx_info->ppage_size) / 8;
+ bit = (i / pic32mx_info->ppage_size) - (reg * 8);
+
+ if( set )
+ prot_reg[reg] &= ~(1 << bit);
+ else
+ prot_reg[reg] |= (1 << bit);
+ }
+ }
+ else
+ {
+ /* medium density flash */
+ for (i = first; i <= last; i++)
+ {
+ reg = (i / pic32mx_info->ppage_size) / 8;
+ bit = (i / pic32mx_info->ppage_size) - (reg * 8);
+
+ if( set )
+ prot_reg[reg] &= ~(1 << bit);
+ else
+ prot_reg[reg] |= (1 << bit);
+ }
+ }
+
+ if ((status = pic32mx_erase_options(bank)) != ERROR_OK)
+ return status;
+
+ pic32mx_info->option_bytes.protection[0] = prot_reg[0];
+ pic32mx_info->option_bytes.protection[1] = prot_reg[1];
+ pic32mx_info->option_bytes.protection[2] = prot_reg[2];
+ pic32mx_info->option_bytes.protection[3] = prot_reg[3];
+
+ return pic32mx_write_options(bank);
+#else
+ return ERROR_OK;
+#endif
+}
+
+int pic32mx_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
+{
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
+ target_t *target = bank->target;
+ u32 buffer_size = 8192;
+ working_area_t *source;
+ u32 address = bank->base + offset;
+ reg_param_t reg_params[4];
+#if 0
+ armv7m_algorithm_t armv7m_info;
+ int retval = ERROR_OK;
+
+ u8 pic32mx_flash_write_code[] = {
+ /* write: */
+ 0xDF, 0xF8, 0x24, 0x40, /* ldr r4, PIC32MX_FLASH_CR */
+ 0x09, 0x4D, /* ldr r5, PIC32MX_FLASH_SR */
+ 0x4F, 0xF0, 0x01, 0x03, /* mov r3, #1 */
+ 0x23, 0x60, /* str r3, [r4, #0] */
+ 0x30, 0xF8, 0x02, 0x3B, /* ldrh r3, [r0], #2 */
+ 0x21, 0xF8, 0x02, 0x3B, /* strh r3, [r1], #2 */
+ /* busy: */
+ 0x2B, 0x68, /* ldr r3, [r5, #0] */
+ 0x13, 0xF0, 0x01, 0x0F, /* tst r3, #0x01 */
+ 0xFB, 0xD0, /* beq busy */
+ 0x13, 0xF0, 0x14, 0x0F, /* tst r3, #0x14 */
+ 0x01, 0xD1, /* bne exit */
+ 0x01, 0x3A, /* subs r2, r2, #1 */
+ 0xED, 0xD1, /* bne write */
+ /* exit: */
+ 0xFE, 0xE7, /* b exit */
+ 0x10, 0x20, 0x02, 0x40, /* PIC32MX_FLASH_CR: .word 0x40022010 */
+ 0x0C, 0x20, 0x02, 0x40 /* PIC32MX_FLASH_SR: .word 0x4002200C */
+ };
+
+ /* flash write code */
+ if (target_alloc_working_area(target, sizeof(pic32mx_flash_write_code), &pic32mx_info->write_algorithm) != ERROR_OK)
+ {
+ LOG_WARNING("no working area available, can't do block memory writes");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ };
+
+ if ((retval=target_write_buffer(target, pic32mx_info->write_algorithm->address, sizeof(pic32mx_flash_write_code), pic32mx_flash_write_code))!=ERROR_OK)
+ return retval;
+
+ /* memory buffer */
+ while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK)
+ {
+ buffer_size /= 2;
+ if (buffer_size <= 256)
+ {
+ /* if we already allocated the writing code, but failed to get a buffer, free the algorithm */
+ if (pic32mx_info->write_algorithm)
+ target_free_working_area(target, pic32mx_info->write_algorithm);
+
+ LOG_WARNING("no large enough working area available, can't do block memory writes");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
+ };
+
+ armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
+ armv7m_info.core_mode = ARMV7M_MODE_ANY;
+
+ init_reg_param(®_params[0], "r0", 32, PARAM_OUT);
+ init_reg_param(®_params[1], "r1", 32, PARAM_OUT);
+ init_reg_param(®_params[2], "r2", 32, PARAM_OUT);
+ init_reg_param(®_params[3], "r3", 32, PARAM_IN);
+
+ while (count > 0)
+ {
+ u32 thisrun_count = (count > (buffer_size / 2)) ? (buffer_size / 2) : count;
+
+ if ((retval = target_write_buffer(target, source->address, thisrun_count * 2, buffer))!=ERROR_OK)
+ break;
+
+ buf_set_u32(reg_params[0].value, 0, 32, source->address);
+ buf_set_u32(reg_params[1].value, 0, 32, address);
+ buf_set_u32(reg_params[2].value, 0, 32, thisrun_count);
+
+ if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, pic32mx_info->write_algorithm->address, \
+ pic32mx_info->write_algorithm->address + (sizeof(pic32mx_flash_write_code) - 10), 10000, &armv7m_info)) != ERROR_OK)
+ {
+ LOG_ERROR("error executing pic32mx flash write algorithm");
+ retval = ERROR_FLASH_OPERATION_FAILED;
+ break;
+ }
+
+ if (buf_get_u32(reg_params[3].value, 0, 32) & 0x14)
+ {
+ retval = ERROR_FLASH_OPERATION_FAILED;
+ break;
+ }
+
+ buffer += thisrun_count * 2;
+ address += thisrun_count * 2;
+ count -= thisrun_count;
+ }
+
+ target_free_working_area(target, source);
+ target_free_working_area(target, pic32mx_info->write_algorithm);
+
+ destroy_reg_param(®_params[0]);
+ destroy_reg_param(®_params[1]);
+ destroy_reg_param(®_params[2]);
+ destroy_reg_param(®_params[3]);
+
+ return retval;
+#else
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+#endif
+}
+
+int pic32mx_write_word(struct flash_bank_s *bank, u32 address, u32 word)
+{
+ target_t *target = bank->target;
+
+ target_write_u32(target, PIC32MX_NVMADDR, address);
+ target_write_u32(target, PIC32MX_NVMDATA, word);
+
+ return pic32mx_nvm_exec(bank, NVMCON_OP_WORD_PROG, 5);
+}
+
+int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
+{
+ target_t *target = bank->target;
+ u32 words_remaining = (count / 4);
+ u32 bytes_remaining = (count & 0x00000003);
+ u32 address = bank->base + offset;
+ u32 bytes_written = 0;
+ u32 status;
+ u32 retval;
+
+ if (bank->target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ if (offset & 0x3)
+ {
+ LOG_WARNING("offset 0x%x breaks required 4-byte alignment", offset);
+ return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
+ }
+
+ /* multiple words (4-byte) to be programmed? */
+ if (words_remaining > 0)
+ {
+ /* try using a block write */
+ if ((retval = pic32mx_write_block(bank, buffer, offset, words_remaining)) != ERROR_OK)
+ {
+ if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
+ {
+ /* if block write failed (no sufficient working area),
+ * we use normal (slow) single dword accesses */
+ LOG_WARNING("couldn't use block writes, falling back to single memory accesses");
+ }
+ else if (retval == ERROR_FLASH_OPERATION_FAILED)
+ {
+ LOG_ERROR("flash writing failed with error code: 0x%x", retval);
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+ }
+ else
+ {
+ buffer += words_remaining * 4;
+ address += words_remaining * 4;
+ words_remaining = 0;
+ }
+ }
+
+ while (words_remaining > 0)
+ {
+ status = pic32mx_write_word(bank, address, *(u32*)(buffer + bytes_written));
+
+ if( status & NVMCON_NVMERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+
+ bytes_written += 4;
+ words_remaining--;
+ address += 4;
+ }
+
+ if (bytes_remaining)
+ {
+ u8 last_word[4] = {0xff, 0xff, 0xff, 0xff};
+ int i = 0;
+
+ while(bytes_remaining > 0)
+ {
+ /* Assumes little endian */
+ last_word[i++] = *(buffer + bytes_written);
+ bytes_remaining--;
+ bytes_written++;
+ }
+
+ status = pic32mx_write_word(bank, address, *(u32*)last_word);
+
+ if( status & NVMCON_NVMERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+
+ return ERROR_OK;
+}
+
+int pic32mx_probe(struct flash_bank_s *bank)
+{
+ target_t *target = bank->target;
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
+ mips32_common_t *mips32 = target->arch_info;
+ mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
+ int i;
+ u16 num_pages;
+ u32 device_id;
+ int page_size;
+
+ pic32mx_info->probed = 0;
+
+ device_id = ejtag_info->idcode;
+ LOG_INFO( "device id = 0x%08x (manuf 0x%03x dev 0x%02x, ver 0x%03x)", device_id, (device_id>>1)&0x7ff, (device_id>>12)&0xff, (device_id>>20)&0xfff );
+
+ if(((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
+ LOG_WARNING( "Cannot identify target as a PIC32MX family." );
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+
+ page_size = 4096;
+ if(bank->base == PIC32MX_KSEG1_BOOT_FLASH || bank->base == 1) {
+ /* 0xBFC00000: Boot flash size fixed at 12k */
+ num_pages = 12;
+ } else {
+ /* 0xBD000000: Program flash size varies with device */
+ for(i=0; pic32mx_devs[i].name != NULL; i++)
+ if(pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
+ num_pages = pic32mx_devs[i].pfm_size;
+ break;
+ }
+ if(pic32mx_devs[i].name == NULL) {
+ LOG_WARNING( "Cannot identify target as a PIC32MX family." );
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+ }
+
+#if 0
+ if (bank->target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ /* get flash size from target */
+ if (target_read_u16(target, 0x1FFFF7E0, &num_pages) != ERROR_OK)
+ {
+ /* failed reading flash size, default to max target family */
+ num_pages = 0xffff;
+ }
+#endif
+
+ LOG_INFO( "flash size = %dkbytes", num_pages );
+
+ /* calculate numbers of pages */
+ num_pages /= (page_size / 1024);
+
+ if(bank->base == 0) bank->base = PIC32MX_KSEG1_PGM_FLASH;
+ if(bank->base == 1) bank->base = PIC32MX_KSEG1_BOOT_FLASH;
+ bank->size = (num_pages * page_size);
+ bank->num_sectors = num_pages;
+ bank->chip_width = 4;
+ bank->bus_width = 4;
+ bank->sectors = malloc(sizeof(flash_sector_t) * num_pages);
+
+ for (i = 0; i < num_pages; i++)
+ {
+ bank->sectors[i].offset = i * page_size;
+ bank->sectors[i].size = page_size;
+ bank->sectors[i].is_erased = -1;
+ bank->sectors[i].is_protected = 1;
+ }
+
+ pic32mx_info->probed = 1;
+
+ return ERROR_OK;
+}
+
+int pic32mx_auto_probe(struct flash_bank_s *bank)
+{
+ pic32mx_flash_bank_t *pic32mx_info = bank->driver_priv;
+ if (pic32mx_info->probed)
+ return ERROR_OK;
+ return pic32mx_probe(bank);
+}
+
+int pic32mx_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ return ERROR_OK;
+}
+
+int pic32mx_info(struct flash_bank_s *bank, char *buf, int buf_size)
+{
+ target_t *target = bank->target;
+ mips32_common_t *mips32 = target->arch_info;
+ mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
+ u32 device_id;
+ int printed, i;
+
+ device_id = ejtag_info->idcode;
+
+ if(((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
+ snprintf(buf, buf_size, "Cannot identify target as a PIC32MX family (manufacturer 0x%03d != 0x%03d)\n", (device_id>>1)&0x7ff, PIC32MX_MANUF_ID);
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+ for(i=0; pic32mx_devs[i].name != NULL; i++)
+ if(pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
+ printed = snprintf(buf, buf_size, "PIC32MX%s", pic32mx_devs[i].name);
+ break;
+ }
+ if(pic32mx_devs[i].name == NULL) {
+ snprintf(buf, buf_size, "Cannot identify target as a PIC32MX family\n");
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+ buf += printed;
+ buf_size -= printed;
+ printed = snprintf(buf, buf_size, " Ver: 0x%03x", (device_id>>20)&0xfff);
+
+ return ERROR_OK;
+}
+
+#if 0
+int pic32mx_handle_lock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ flash_bank_t *bank;
+ target_t *target = NULL;
+ pic32mx_flash_bank_t *pic32mx_info = NULL;
+
+ if (argc < 1)
+ {
+ command_print(cmd_ctx, "pic32mx lock <bank>");
+ return ERROR_OK;
+ }
+
+ bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
+ if (!bank)
+ {
+ command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
+ return ERROR_OK;
+ }
+
+ pic32mx_info = bank->driver_priv;
+
+ target = bank->target;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ if (pic32mx_erase_options(bank) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "pic32mx failed to erase options");
+ return ERROR_OK;
+ }
+
+ /* set readout protection */
+ pic32mx_info->option_bytes.RDP = 0;
+
+ if (pic32mx_write_options(bank) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "pic32mx failed to lock device");
+ return ERROR_OK;
+ }
+
+ command_print(cmd_ctx, "pic32mx locked");
+
+ return ERROR_OK;
+}
+
+int pic32mx_handle_unlock_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ flash_bank_t *bank;
+ target_t *target = NULL;
+ pic32mx_flash_bank_t *pic32mx_info = NULL;
+
+ if (argc < 1)
+ {
+ command_print(cmd_ctx, "pic32mx unlock <bank>");
+ return ERROR_OK;
+ }
+
+ bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
+ if (!bank)
+ {
+ command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
+ return ERROR_OK;
+ }
+
+ pic32mx_info = bank->driver_priv;
+
+ target = bank->target;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ if (pic32mx_erase_options(bank) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "pic32mx failed to unlock device");
+ return ERROR_OK;
+ }
+
+ if (pic32mx_write_options(bank) != ERROR_OK)
+ {
+ command_print(cmd_ctx, "pic32mx failed to lock device");
+ return ERROR_OK;
+ }
+
+ command_print(cmd_ctx, "pic32mx unlocked");
+
+ return ERROR_OK;
+}
+#endif
+
+int pic32mx_chip_erase(struct flash_bank_s *bank)
+{
+ target_t *target = bank->target;
+ u32 status;
+
+ if (target->state != TARGET_HALTED)
+ {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ LOG_INFO("PIC32MX chip erase called");
+
+#if 0
+ /* unlock option flash registers */
+ target_write_u32(target, PIC32MX_FLASH_KEYR, KEY1);
+ target_write_u32(target, PIC32MX_FLASH_KEYR, KEY2);
+
+ /* chip erase flash memory */
+ target_write_u32(target, PIC32MX_FLASH_CR, FLASH_MER);
+ target_write_u32(target, PIC32MX_FLASH_CR, FLASH_MER|FLASH_STRT);
+
+ status = pic32mx_wait_status_busy(bank, 10);
+
+ target_write_u32(target, PIC32MX_FLASH_CR, FLASH_LOCK);
+
+ if( status & FLASH_WRPRTERR )
+ {
+ LOG_ERROR("pic32mx device protected");
+ return ERROR_OK;
+ }
+
+ if( status & FLASH_PGERR )
+ {
+ LOG_ERROR("pic32mx device programming failed");
+ return ERROR_OK;
+ }
+#endif
+
+ return ERROR_OK;
+}
+
+int pic32mx_handle_chip_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ flash_bank_t *bank;
+ int i;
+
+#if 0
+ if (argc != 0)
+ {
+ command_print(cmd_ctx, "pic32mx chip_erase");
+ return ERROR_OK;
+ }
+
+ bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
+ if (!bank)
+ {
+ command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
+ return ERROR_OK;
+ }
+
+ if (pic32mx_chip_erase(bank) == ERROR_OK)
+ {
+ /* set all sectors as erased */
+ for (i = 0; i < bank->num_sectors; i++)
+ {
+ bank->sectors[i].is_erased = 1;
+ }
+
+ command_print(cmd_ctx, "pic32mx chip erase complete");
+ }
+ else
+ {
+ command_print(cmd_ctx, "pic32mx chip erase failed");
+ }
+#endif
+
+ return ERROR_OK;
+}
+
+int pic32mx_handle_pgm_word_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ flash_bank_t *bank;
+ u32 address, value;
+ int i;
+ int status, res;
+
+ if (argc != 3)
+ {
+ command_print(cmd_ctx, "pic32mx pgm_word <addr> <value> <bank>");
+ return ERROR_OK;
+ }
+
+ address = strtoul(args[0], NULL, 0);
+ value = strtoul(args[1], NULL, 0);
+
+ bank = get_flash_bank_by_num(strtoul(args[2], NULL, 0));
+ if (!bank)
+ {
+ command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[2]);
+ return ERROR_OK;
+ }
+ if (address < bank->base || address >= (bank->base+bank->size))
+ {
+ command_print(cmd_ctx, "flash address '%s' is out of bounds", args[0]);
+ return ERROR_OK;
+ }
+
+ res = ERROR_OK;
+ status = pic32mx_write_word(bank, address, value);
+ if( status & NVMCON_NVMERR )
+ res = ERROR_FLASH_OPERATION_FAILED;
+ if( status & NVMCON_LVDERR )
+ res = ERROR_FLASH_OPERATION_FAILED;
+
+ if (res == ERROR_OK)
+ command_print(cmd_ctx, "pic32mx pgm word complete");
+ else
+ command_print(cmd_ctx, "pic32mx pgm word failed (status=0x%x)", status);
+
+ return ERROR_OK;
+}
Added: trunk/src/flash/pic32mx.h
===================================================================
--- trunk/src/flash/pic32mx.h 2009-01-02 23:52:46 UTC (rev 1295)
+++ trunk/src/flash/pic32mx.h 2009-01-02 23:58:16 UTC (rev 1296)
@@ -0,0 +1,105 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Dominic Rath *
+ * Dom...@gm... *
+ * *
+ * Copyright (C) 2008 by Spencer Oliver *
+ * sp...@sp... *
+ * *
+ * Copyright (C) 2008 by John McCarthy *
+ * jg...@ma... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PIC32MX_H
+#define PIC32MX_H
+
+#include "flash.h"
+#include "target.h"
+
+typedef struct pic32mx_flash_bank_s
+{
+ working_area_t *write_algorithm;
+ int devid;
+ int ppage_size;
+ int probed;
+} pic32mx_flash_bank_t;
+
+#define PIC32MX_MANUF_ID 0x029
+
+/* pic32mx memory locations */
+
+#define PIC32MX_KUSEG_PGM_FLASH 0x7D000000
+#define PIC32MX_KUSEG_RAM 0x7F000000
+
+#define PIC32MX_KSEG0_RAM 0x80000000
+#define PIC32MX_KSEG0_PGM_FLASH 0x9D000000
+#define PIC32MX_KSEG0_BOOT_FLASH 0x9FC00000
+
+#define PIC32MX_KSEG1_RAM 0xA0000000
+#define PIC32MX_KSEG1_PGM_FLASH 0xBD000000
+#define PIC32MX_KSEG1_PERIPHERAL 0xBF800000
+#define PIC32MX_KSEG1_BOOT_FLASH 0xBFC00000
+
+#define PIC32MX_PHYS_RAM 0x00000000
+#define PIC32MX_PHYS_PGM_FLASH 0x1D000000
+#define PIC32MX_PHYS_PERIPHERALS 0x1F800000
+#define PIC32MX_PHYS_BOOT_FLASH 0x1FC00000
+
+/* pic32mx configuration register locations */
+
+#define PIC32MX_DEVCFG0 0xBFC02FFC
+#define PIC32MX_DEVCFG1 0xBFC02FF8
+#define PIC32MX_DEVCFG2 0xBFC02FF4
+#define PIC32MX_DEVCFG3 0XBFC02FF0
+#define PIC32MX_DEVID 0xBF80F220
+
+/* pic32mx flash controller register locations */
+
+#define PIC32MX_NVMCON 0xBF80F400
+#define PIC32MX_NVMCONCLR 0xBF80F404
+#define PIC32MX_NVMCONSET 0xBF80F408
+#define PIC32MX_NVMCONINV 0xBF80F40C
+#define NVMCON_NVMWR (1<<15)
+#define NVMCON_NVMWREN (1<<14)
+#define NVMCON_NVMERR (1<<13)
+#define NVMCON_LVDERR (1<<12)
+#define NVMCON_LVDSTAT (1<<11)
+#define NVMCON_OP_PFM_ERASE 0x5
+#define NVMCON_OP_PAGE_ERASE 0x4
+#define NVMCON_OP_ROW_PROG 0x3
+#define NVMCON_OP_WORD_PROG 0x1
+#define NVMCON_OP_NOP 0x0
+
+#define PIC32MX_NVMKEY 0xBF80F410
+#define PIC32MX_NVMADDR 0xBF80F420
+#define PIC32MX_NVMADDRCLR 0xBF80F424
+#define PIC32MX_NVMADDRSET 0xBF80F428
+#define PIC32MX_NVMADDRINV 0xBF80F42C
+#define PIC32MX_NVMDATA 0xBF80F430
+#define PIC32MX_NVMSRCADDR 0xBF80F440
+
+/* flash unlock keys */
+
+#define NVMKEY1 0xAA996655
+#define NVMKEY2 0x556699AA
+
+typedef struct pic32mx_mem_layout_s {
+ u32 sector_start;
+ u32 sector_size;
+} pic32mx_mem_layout_t;
+
+#endif /* PIC32MX_H */
+
Added: trunk/src/target/board/pic-p32mx.cfg
===================================================================
--- trunk/src/target/board/pic-p32mx.cfg 2009-01-02 23:52:46 UTC (rev 1295)
+++ trunk/src/target/board/pic-p32mx.cfg 2009-01-02 23:58:16 UTC (rev 1296)
@@ -0,0 +1,8 @@
+# The Olimex PIC-P32MX has a PIC32MX
+
+set CPUTAPID 0x40916053
+source [find target/pic32mx.cfg]
+
+init
+flash probe 0
+flash probe 1
Modified: trunk/src/target/mips_ejtag.h
===================================================================
--- trunk/src/target/mips_ejtag.h 2009-01-02 23:52:46 UTC (rev 1295)
+++ trunk/src/target/mips_ejtag.h 2009-01-02 23:58:16 UTC (rev 1296)
@@ -102,6 +102,7 @@
{
jtag_tap_t *tap;
u32 impcode;
+ u32 idcode;
/*int use_dma;*/
u32 ejtag_ctrl;
} mips_ejtag_t;
Modified: trunk/src/target/mips_m4k.c
===================================================================
--- trunk/src/target/mips_m4k.c 2009-01-02 23:52:46 UTC (rev 1295)
+++ trunk/src/target/mips_m4k.c 2009-01-02 23:58:16 UTC (rev 1296)
@@ -50,6 +50,7 @@
int mips_m4k_examine(struct target_s *target);
int mips_m4k_assert_reset(target_t *target);
int mips_m4k_deassert_reset(target_t *target);
+int mips_m4k_checksum_memory(target_t *target, u32 address, u32 size, u32 *checksum);
target_type_t mips_m4k_target =
{
@@ -73,7 +74,7 @@
.read_memory = mips_m4k_read_memory,
.write_memory = mips_m4k_write_memory,
.bulk_write_memory = mips_m4k_bulk_write_memory,
- .checksum_memory = NULL,
+ .checksum_memory = mips_m4k_checksum_memory,
.blank_check_memory = NULL,
.run_algorithm = mips32_run_algorithm,
@@ -766,7 +767,8 @@
if (!target->type->examined)
{
mips_ejtag_get_idcode(ejtag_info, &idcode, NULL);
-
+ ejtag_info->idcode = idcode;
+
if (((idcode >> 1) & 0x7FF) == 0x29)
{
/* we are using a pic32mx so select ejtag port
@@ -790,3 +792,8 @@
{
return mips_m4k_write_memory(target, address, 4, count, buffer);
}
+
+int mips_m4k_checksum_memory(target_t *target, u32 address, u32 size, u32 *checksum)
+{
+ return ERROR_FAIL; /* use bulk read method */
+}
Modified: trunk/src/target/target/pic32mx.cfg
===================================================================
--- trunk/src/target/target/pic32mx.cfg 2009-01-02 23:52:46 UTC (rev 1295)
+++ trunk/src/target/target/pic32mx.cfg 2009-01-02 23:58:16 UTC (rev 1296)
@@ -26,13 +26,15 @@
#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
-jtag newtap $_CPUNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1 -expected-id $_CPUTAPID
+jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_CPUTAPID
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME mips_m4k -endian $_ENDIAN -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0xa0000000 -work-area-size 16384 -work-area-backup 0
+flash bank pic32mx 0xbd000000 0 0 0 0
+flash bank pic32mx 0xbfc00000 0 0 0 0
# For more information about the configuration files, take a look at:
# openocd.texi
|
|
From: <oh...@ma...> - 2009-01-03 00:52:59
|
Author: oharboe Date: 2009-01-03 00:52:46 +0100 (Sat, 03 Jan 2009) New Revision: 1295 Modified: trunk/src/target/mips_ejtag.c Log: John McCarthy <jg...@ma...> keep_alive() fix Modified: trunk/src/target/mips_ejtag.c =================================================================== --- trunk/src/target/mips_ejtag.c 2009-01-01 16:06:46 UTC (rev 1294) +++ trunk/src/target/mips_ejtag.c 2009-01-02 23:52:46 UTC (rev 1295) @@ -144,6 +144,8 @@ return retval; } + keep_alive(); + return ERROR_OK; } |
|
From: ntfreak at B. <nt...@ma...> - 2009-01-01 17:06:47
|
Author: ntfreak
Date: 2009-01-01 17:06:46 +0100 (Thu, 01 Jan 2009)
New Revision: 1294
Modified:
trunk/doc/openocd.texi
trunk/src/helper/options.c
trunk/src/helper/replacements.c
trunk/src/helper/replacements.h
trunk/src/server/gdb_server.c
trunk/src/server/server.c
Log:
- add gdb pipe support to native win32 (--pipe option)
Modified: trunk/doc/openocd.texi
===================================================================
--- trunk/doc/openocd.texi 2008-12-28 21:40:39 UTC (rev 1293)
+++ trunk/doc/openocd.texi 2009-01-01 16:06:46 UTC (rev 1294)
@@ -557,7 +557,6 @@
target library is in the search path by default.
For details on the @option{-p} option. @xref{Connecting to GDB}.
-Option @option{-p} is not currently supported under native win32.
Note! OpenOCD will launch the GDB & telnet server even if it can not
establish a connection with the target. In general, it is possible for
Modified: trunk/src/helper/options.c
===================================================================
--- trunk/src/helper/options.c 2008-12-28 21:40:39 UTC (rev 1293)
+++ trunk/src/helper/options.c 2009-01-01 16:06:46 UTC (rev 1294)
@@ -149,14 +149,8 @@
/* pipes unsupported on hosted platforms */
LOG_WARNING("pipes not supported on this platform");
#else
-#ifdef IS_MINGW
- /* pipes currently unsupported on win32 */
- LOG_WARNING("pipes currently unsupported on win32");
- exit(1);
-#else
server_use_pipes = 1;
#endif
-#endif
break;
}
}
Modified: trunk/src/helper/replacements.c
===================================================================
--- trunk/src/helper/replacements.c 2008-12-28 21:40:39 UTC (rev 1293)
+++ trunk/src/helper/replacements.c 2009-01-01 16:06:46 UTC (rev 1294)
@@ -68,6 +68,10 @@
#include <stdio.h>
+#ifdef _WIN32
+#include <io.h>
+#endif
+
/* replacements for gettimeofday */
#ifndef HAVE_GETTIMEOFDAY
@@ -137,3 +141,151 @@
return (char *) memcpy (new, s, len);
}
#endif
+
+#ifdef _WIN32
+int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+{
+ DWORD ms_total, limit;
+ HANDLE handles[MAXIMUM_WAIT_OBJECTS];
+ int handle_slot_to_fd[MAXIMUM_WAIT_OBJECTS];
+ int n_handles = 0, i;
+ fd_set sock_read, sock_write, sock_except;
+ fd_set aread, awrite, aexcept;
+ int sock_max_fd = -1;
+ struct timeval tvslice;
+ int retcode;
+
+#define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set))
+
+ /* calculate how long we need to wait in milliseconds */
+ if (tv == NULL) {
+ ms_total = INFINITE;
+ } else {
+ ms_total = tv->tv_sec * 1000;
+ ms_total += tv->tv_usec / 1000;
+ }
+
+ FD_ZERO(&sock_read);
+ FD_ZERO(&sock_write);
+ FD_ZERO(&sock_except);
+
+ /* build an array of handles for non-sockets */
+ for (i = 0; i < max_fd; i++) {
+ if (SAFE_FD_ISSET(i, rfds) || SAFE_FD_ISSET(i, wfds) || SAFE_FD_ISSET(i, efds)) {
+ handles[n_handles] = (HANDLE)_get_osfhandle(i);
+ if (handles[n_handles] == INVALID_HANDLE_VALUE) {
+ /* socket */
+ if (SAFE_FD_ISSET(i, rfds)) {
+ FD_SET(i, &sock_read);
+ }
+ if (SAFE_FD_ISSET(i, wfds)) {
+ FD_SET(i, &sock_write);
+ }
+ if (SAFE_FD_ISSET(i, efds)) {
+ FD_SET(i, &sock_except);
+ }
+ if (i > sock_max_fd) {
+ sock_max_fd = i;
+ }
+ } else {
+ handle_slot_to_fd[n_handles] = i;
+ n_handles++;
+ }
+ }
+ }
+
+ if (n_handles == 0) {
+ /* plain sockets only - let winsock handle the whole thing */
+ return select(max_fd, rfds, wfds, efds, tv);
+ }
+
+ /* mixture of handles and sockets; lets multiplex between
+ * winsock and waiting on the handles */
+
+ FD_ZERO(&aread);
+ FD_ZERO(&awrite);
+ FD_ZERO(&aexcept);
+
+ limit = GetTickCount() + ms_total;
+ do {
+ retcode = 0;
+
+ if (sock_max_fd >= 0) {
+ /* overwrite the zero'd sets here; the select call
+ * will clear those that are not active */
+ aread = sock_read;
+ awrite = sock_write;
+ aexcept = sock_except;
+
+ tvslice.tv_sec = 0;
+ tvslice.tv_usec = 100000;
+
+ retcode = select(sock_max_fd+1, &aread, &awrite, &aexcept, &tvslice);
+ }
+ if (n_handles > 0) {
+ /* check handles */
+ DWORD wret;
+
+ wret = MsgWaitForMultipleObjects(n_handles, handles, FALSE, retcode > 0 ? 0 : 100, QS_ALLEVENTS);
+
+ if (wret == WAIT_TIMEOUT) {
+ /* set retcode to 0; this is the default.
+ * select() may have set it to something else,
+ * in which case we leave it alone, so this branch
+ * does nothing */
+ ;
+ } else if (wret == WAIT_FAILED) {
+ if (retcode == 0) {
+ retcode = -1;
+ }
+ } else {
+ if (retcode < 0) {
+ retcode = 0;
+ }
+ for (i = 0; i < n_handles; i++) {
+ if (WAIT_OBJECT_0 == WaitForSingleObject(handles[i], 0)) {
+ if (SAFE_FD_ISSET(handle_slot_to_fd[i], rfds)) {
+ DWORD dwBytes;
+
+ if (PeekNamedPipe((HANDLE)_get_osfhandle(handle_slot_to_fd[i]), NULL, 0, NULL, &dwBytes, NULL))
+ {
+ /* check to see if gdb pipe has data available */
+ if (dwBytes)
+ {
+ FD_SET(handle_slot_to_fd[i], &aread);
+ retcode++;
+ }
+ }
+ else
+ {
+ FD_SET(handle_slot_to_fd[i], &aread);
+ retcode++;
+ }
+ }
+ if (SAFE_FD_ISSET(handle_slot_to_fd[i], wfds)) {
+ FD_SET(handle_slot_to_fd[i], &awrite);
+ retcode++;
+ }
+ if (SAFE_FD_ISSET(handle_slot_to_fd[i], efds)) {
+ FD_SET(handle_slot_to_fd[i], &aexcept);
+ retcode++;
+ }
+ }
+ }
+ }
+ }
+ } while (retcode == 0 && (ms_total == INFINITE || GetTickCount() < limit));
+
+ if (rfds) {
+ *rfds = aread;
+ }
+ if (wfds) {
+ *wfds = awrite;
+ }
+ if (efds) {
+ *efds = aexcept;
+ }
+
+ return retcode;
+}
+#endif
Modified: trunk/src/helper/replacements.h
===================================================================
--- trunk/src/helper/replacements.h 2008-12-28 21:40:39 UTC (rev 1293)
+++ trunk/src/helper/replacements.h 2009-01-01 16:06:46 UTC (rev 1294)
@@ -180,6 +180,9 @@
}
#endif /* IS_MINGW */
+
+int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);
+
#endif /* _WIN32 */
/* generic socket functions for Windows and Posix */
@@ -221,6 +224,15 @@
#endif
}
+static __inline int socket_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+{
+#ifdef _WIN32
+ return win_select(max_fd, rfds, wfds, efds, tv);
+#else
+ return select(max_fd, rfds, wfds, efds, tv);
+#endif
+}
+
#ifndef HAVE_ELF_H
typedef struct
Modified: trunk/src/server/gdb_server.c
===================================================================
--- trunk/src/server/gdb_server.c 2008-12-28 21:40:39 UTC (rev 1293)
+++ trunk/src/server/gdb_server.c 2009-01-01 16:06:46 UTC (rev 1294)
@@ -126,7 +126,7 @@
tv.tv_sec = timeout_s;
tv.tv_usec = 0;
- if (select(connection->fd + 1, &read_fds, NULL, NULL, &tv) == 0)
+ if (socket_select(connection->fd + 1, &read_fds, NULL, NULL, &tv) == 0)
{
/* This can typically be because a "monitor" command took too long
* before printing any progress messages
Modified: trunk/src/server/server.c
===================================================================
--- trunk/src/server/server.c 2008-12-28 21:40:39 UTC (rev 1293)
+++ trunk/src/server/server.c 2009-01-01 16:06:46 UTC (rev 1294)
@@ -97,12 +97,11 @@
}
else if (service->type == CONNECTION_PIPE)
{
-#ifndef _WIN32
c->fd = service->fd;
/* do not check for new connections again on stdin */
service->fd = -1;
-#endif
+
LOG_INFO("accepting '%s' connection from pipe", service->name);
if ((retval = service->new_connection(c)) != ERROR_OK)
{
@@ -223,6 +222,8 @@
LOG_WARNING("cannot change stdout mode to binary");
if (_setmode(_fileno(stdin), _O_BINARY) < 0)
LOG_WARNING("cannot change stdin mode to binary");
+ if (_setmode(_fileno(stderr), _O_BINARY) < 0)
+ LOG_WARNING("cannot change stderr mode to binary");
#else
socket_nonblock(c->fd);
#endif
@@ -365,7 +366,7 @@
kept_alive();
/* Only while we're sleeping we'll let others run */
- retval = select(fd_max + 1, &read_fds, NULL, NULL, &tv);
+ retval = socket_select(fd_max + 1, &read_fds, NULL, NULL, &tv);
openocd_sleep_postlude();
if (retval == -1)
@@ -503,7 +504,7 @@
WORD wVersionRequested;
WSADATA wsaData;
- wVersionRequested = MAKEWORD( 2, 2 );
+ wVersionRequested = MAKEWORD(2, 2);
if (WSAStartup(wVersionRequested, &wsaData) != 0)
{
@@ -511,7 +512,16 @@
exit(-1);
}
- SetConsoleCtrlHandler( ControlHandler, TRUE );
+ if (server_use_pipes == 0)
+ {
+ /* register ctrl-c handler */
+ SetConsoleCtrlHandler(ControlHandler, TRUE);
+ }
+ else
+ {
+ /* we are using pipes so ignore ctrl-c */
+ SetConsoleCtrlHandler(NULL, TRUE);
+ }
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
|
|
From: <oh...@ma...> - 2008-12-28 22:40:47
|
Author: oharboe
Date: 2008-12-28 22:40:39 +0100 (Sun, 28 Dec 2008)
New Revision: 1293
Modified:
trunk/src/flash/nand.c
trunk/src/helper/jim.c
trunk/src/jtag/usbprog.c
trunk/src/target/target.c
Log:
Uwe Hermann <uw...@he...> One of them is fixing a few compiler warnings (see attached patch) and
likely also one (non-cosmetic) bug (the 'id_buff' change, which seems to
be a buffer overflow).
Modified: trunk/src/flash/nand.c
===================================================================
--- trunk/src/flash/nand.c 2008-12-28 10:58:34 UTC (rev 1292)
+++ trunk/src/flash/nand.c 2008-12-28 21:40:39 UTC (rev 1293)
@@ -375,7 +375,7 @@
int nand_probe(struct nand_device_s *device)
{
u8 manufacturer_id, device_id;
- u8 id_buff[5];
+ u8 id_buff[6];
int retval;
int i;
Modified: trunk/src/helper/jim.c
===================================================================
--- trunk/src/helper/jim.c 2008-12-28 10:58:34 UTC (rev 1292)
+++ trunk/src/helper/jim.c 2008-12-28 21:40:39 UTC (rev 1293)
@@ -49,6 +49,7 @@
#define JIM_DYNLIB /* Dynamic library support for UNIX and WIN32 */
#endif /* JIM_ANSIC */
+#define _GNU_SOURCE /* for vasprintf() */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Modified: trunk/src/jtag/usbprog.c
===================================================================
--- trunk/src/jtag/usbprog.c 2008-12-28 10:58:34 UTC (rev 1292)
+++ trunk/src/jtag/usbprog.c 2008-12-28 21:40:39 UTC (rev 1293)
@@ -93,7 +93,7 @@
struct usbprog_jtag * usbprog_jtag_handle;
-struct usbprog_jtag* usbprog_jtag_open();
+struct usbprog_jtag* usbprog_jtag_open(void);
void usbprog_jtag_close(struct usbprog_jtag *usbprog_jtag);
void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag);
unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen);
@@ -405,7 +405,7 @@
struct usb_bus *busses;
-struct usbprog_jtag* usbprog_jtag_open()
+struct usbprog_jtag* usbprog_jtag_open(void)
{
struct usb_bus *bus;
struct usb_device *dev;
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2008-12-28 10:58:34 UTC (rev 1292)
+++ trunk/src/target/target.c 2008-12-28 21:40:39 UTC (rev 1293)
@@ -4014,7 +4014,7 @@
static int fastload_num;
static struct FastLoad *fastload;
-static void free_fastload()
+static void free_fastload(void)
{
if (fastload!=NULL)
{
|
|
From: ntfreak at B. <nt...@ma...> - 2008-12-28 11:58:35
|
Author: ntfreak Date: 2008-12-28 11:58:34 +0100 (Sun, 28 Dec 2008) New Revision: 1292 Modified: trunk/src/jtag/vsllink.c trunk/testing/build.test1/Makefile trunk/testing/build.test1/Makefile.confuse trunk/testing/build.test1/Makefile.ftd2xx trunk/testing/build.test1/Makefile.libftdi trunk/testing/build.test1/Makefile.libusb trunk/testing/build.test1/Makefile.openocd trunk/testing/build.test1/README.TXT trunk/testing/build.test1/local.uses trunk/testing/build.test1/mingw32_help/include/elf.h trunk/testing/build.test1/mingw32_help/include/sys/cdefs.h trunk/testing/build.test1/mingw32_help/include/sys/elf32.h trunk/testing/build.test1/mingw32_help/include/sys/elf64.h trunk/testing/build.test1/mingw32_help/include/sys/elf_common.h trunk/testing/build.test1/mingw32_help/include/sys/elf_generic.h trunk/testing/build.test2/Makefile trunk/testing/build.test2/README.txt trunk/testing/build.test2/local.uses Log: - fix missing/incorrect svn file props Property changes on: trunk/src/jtag/vsllink.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/Makefile ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/Makefile.confuse ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/Makefile.ftd2xx ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/Makefile.libftdi ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/Makefile.libusb ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/Makefile.openocd ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Modified: trunk/testing/build.test1/README.TXT =================================================================== --- trunk/testing/build.test1/README.TXT 2008-12-28 01:08:56 UTC (rev 1291) +++ trunk/testing/build.test1/README.TXT 2008-12-28 10:58:34 UTC (rev 1292) @@ -1,39 +1,39 @@ --- Duane Ellis'es test case for building numerous openocd configurations... -Dec 26,2008 ---------------------------------------------------------------------------- - -1) Make a directory some where.. - - mkdir ~/test - -2) Change to that directory - - cd ~/test - -3) Checkout OpenOCD in that directory. - - cd ~/test - svn co https://svn.berlios.de/svnroot/repos/openocd/trunk openocd - -4) Copy the "build.test1" directory to the "~/work" directory. - - - cd ~/test - cp ~/openocd/testing/build.test1/. ~/test/. - -5) If needed, download various components. - - cd ~/work - make all.download - - -6) For Linux - type: - - cd ~/work - make linux.buildtest - -7) For Cygwin - type: - - cd ~/work - make cygwin.buildtest - +-- Duane Ellis'es test case for building numerous openocd configurations... +Dec 26,2008 +--------------------------------------------------------------------------- + +1) Make a directory some where.. + + mkdir ~/test + +2) Change to that directory + + cd ~/test + +3) Checkout OpenOCD in that directory. + + cd ~/test + svn co https://svn.berlios.de/svnroot/repos/openocd/trunk openocd + +4) Copy the "build.test1" directory to the "~/work" directory. + + + cd ~/test + cp ~/openocd/testing/build.test1/. ~/test/. + +5) If needed, download various components. + + cd ~/work + make all.download + + +6) For Linux - type: + + cd ~/work + make linux.buildtest + +7) For Cygwin - type: + + cd ~/work + make cygwin.buildtest + Property changes on: trunk/testing/build.test1/README.TXT ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/local.uses ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/mingw32_help/include/elf.h ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/mingw32_help/include/sys/cdefs.h ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/mingw32_help/include/sys/elf32.h ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/mingw32_help/include/sys/elf64.h ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/mingw32_help/include/sys/elf_common.h ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test1/mingw32_help/include/sys/elf_generic.h ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test2/Makefile ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Modified: trunk/testing/build.test2/README.txt =================================================================== --- trunk/testing/build.test2/README.txt 2008-12-28 01:08:56 UTC (rev 1291) +++ trunk/testing/build.test2/README.txt 2008-12-28 10:58:34 UTC (rev 1292) @@ -1,59 +1,59 @@ - -This makefile is how I Duane Ellis (op...@du...) builds -openocd test purposes on Cygwin. I have included it here so others -might also make use of the same configuration that I use to develop -Openocd. - ---Duane Ellis - -To make use of it do the following: - -(1) Check out openocd in the standard way. - -For example - in cygwin, type this: - - bash$ mkdir -p /home/duane/test - bash$ cd /home/duane/test - bash$ svn co https://svn.berlios.de/svnroot/repos/openocd/trunk openocd - -(2) COPY this folder "right above" where you have OpenOCD. - - bash$ cd /home/duane/test - bash$ cp ./openocd/testing/build.test2/* /home/duane/test/. - -(3) OPTIONALLY - - You might want to review the file "local.uses" - Change options and so forth at the top of the file. - -(4) Initially, you need to download some additional files. - These include "libftdi", "libconfuse", and the ftd2xx drivers. - -(5) You also need to build the supporting libraries and install them - (They are installed "locally" only) - - Type this command: - - bash$ cd /home/duane/test - - bash$ make initial.build - - which: (1) downloads files - (2) builds the libs - (3) builds OpenOCD - -(6) As you hack upon OpenOCD... to rebuild OpenOCD... - - bash$ cd /home/duane/test - - bash$ make remake - - which: (1) re-bootstraps - (2) re-configures - (3) re-builds - (4) re-installs. - -======= -**END** -======= - + +This makefile is how I Duane Ellis (op...@du...) builds +openocd test purposes on Cygwin. I have included it here so others +might also make use of the same configuration that I use to develop +Openocd. + +--Duane Ellis + +To make use of it do the following: + +(1) Check out openocd in the standard way. + +For example - in cygwin, type this: + + bash$ mkdir -p /home/duane/test + bash$ cd /home/duane/test + bash$ svn co https://svn.berlios.de/svnroot/repos/openocd/trunk openocd + +(2) COPY this folder "right above" where you have OpenOCD. + + bash$ cd /home/duane/test + bash$ cp ./openocd/testing/build.test2/* /home/duane/test/. + +(3) OPTIONALLY + + You might want to review the file "local.uses" + Change options and so forth at the top of the file. + +(4) Initially, you need to download some additional files. + These include "libftdi", "libconfuse", and the ftd2xx drivers. + +(5) You also need to build the supporting libraries and install them + (They are installed "locally" only) + + Type this command: + + bash$ cd /home/duane/test + + bash$ make initial.build + + which: (1) downloads files + (2) builds the libs + (3) builds OpenOCD + +(6) As you hack upon OpenOCD... to rebuild OpenOCD... + + bash$ cd /home/duane/test + + bash$ make remake + + which: (1) re-bootstraps + (2) re-configures + (3) re-builds + (4) re-installs. + +======= +**END** +======= + Property changes on: trunk/testing/build.test2/README.txt ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native Property changes on: trunk/testing/build.test2/local.uses ___________________________________________________________________ Name: svn:executable - * Name: svn:eol-style + native |
|
From: <du...@ma...> - 2008-12-28 02:08:59
|
Author: duane
Date: 2008-12-28 02:08:56 +0100 (Sun, 28 Dec 2008)
New Revision: 1291
Modified:
trunk/src/jtag/vsllink.c
Log:
Updates from SimonQian
Modified: trunk/src/jtag/vsllink.c
===================================================================
--- trunk/src/jtag/vsllink.c 2008-12-27 23:23:06 UTC (rev 1290)
+++ trunk/src/jtag/vsllink.c 2008-12-28 01:08:56 UTC (rev 1291)
@@ -694,8 +694,8 @@
void vsllink_runtest(int num_cycles)
{
- int i, j;
- int tms_len, first_tms = 0, tms_cmd_pos;
+ int i = 0, j;
+ int tms_len, first_tms = 0, tms_cmd_pos = 0;
enum tap_state saved_end_state = end_state;
if (cur_state != TAP_IDLE)
@@ -971,7 +971,7 @@
result = vsllink_usb_write(vsllink_jtag_handle, 3);
if (result != 3)
{
- LOG_ERROR("VSLLink command VSLLINK_CMD_SET_PORT failed (%d)", result);
+ LOG_ERROR("VSLLink command VSLLINK_CMD_SET_PORT failed (%d)", result);
}
}
@@ -1054,8 +1054,7 @@
static int pending_scan_results_length;
static pending_scan_result_t pending_scan_results_buffer[MAX_PENDING_SCAN_RESULTS];
-
-void vsllink_tap_init()
+void vsllink_tap_init(void)
{
vsllink_usb_out_buffer_idx = 0;
vsllink_usb_in_want_length = 0;
@@ -1103,7 +1102,7 @@
/* Pad and send a tap sequence to the device, and receive the answer.
* For the purpose of padding we assume that we are in idle or pause state. */
-int vsllink_tap_execute()
+int vsllink_tap_execute(void)
{
int i;
int result;
@@ -1185,7 +1184,7 @@
/*****************************************************************************/
/* VSLLink USB low-level functions */
-vsllink_jtag_t* vsllink_usb_open()
+vsllink_jtag_t* vsllink_usb_open(void)
{
struct usb_bus *busses;
struct usb_bus *bus;
|
|
From: <du...@ma...> - 2008-12-28 00:23:09
|
Author: duane Date: 2008-12-28 00:23:06 +0100 (Sun, 28 Dec 2008) New Revision: 1290 Added: trunk/testing/build.test2/ trunk/testing/build.test2/Makefile trunk/testing/build.test2/README.txt trunk/testing/build.test2/local.uses Log: Added another test build configuration Added: trunk/testing/build.test2/Makefile =================================================================== --- trunk/testing/build.test2/Makefile 2008-12-27 22:43:56 UTC (rev 1289) +++ trunk/testing/build.test2/Makefile 2008-12-27 23:23:06 UTC (rev 1290) @@ -0,0 +1,193 @@ +# -*- mode: makefile -*- +#======================================== +# DO NOT DELETE THE LINE BELOW +_default: default +# DO NOT DELETE THE LINE_ABOVE +#======================================== + +#======================================== +# +# There are no user configurable options here. +# +# All user configurable options are in local.uses +# +include ./local.uses +# +#======================================== + +#======================================== +# This is the USB driver for the FTDI2XX chips. +# It is a "closed" solution from FTDICHIP.COM +# Some claim it is faster then the open/free +# solution: win32-libusb+libftdi. +# +ftd2xx.download: + mkdir -p ${VIRGINS} + wget -O ${FTD2XX_ZIPFILE_LOCAL} \ + ${FTD2XX_ZIPFILE_URL} + +ftd2xx.unpack: + rm -rf ${FTD2XX_WIN32_DIR} + mkdir -p ${FTD2XX_WIN32_DIR} + cd ${FTD2XX_WIN32_DIR} && unzip \ + ${FTD2XX_ZIPFILE_LOCAL} + +ftd2xx.build: + @echo "Nothing to do for: $@" + +ftd2xx.configure: + @echo "Nothing to do for: $@" + +ftd2xx.install: + @echo "Nothing to do for: $@" + +clean:: + rm -rf ${FTD2XX_WIN32_DIR} + +ftd2xx.all: ftd2xx.unpack ftd2xx.configure \ + ftd2xx.build ftd2xx.install + + +#========================================- +# LIBFTDI - requires LIBCONFUSE.. +# So we handle it here :-( + +libconfuse.download: + mkdir -p virgins + wget -O ${LIBCONFUSE_TARFILE_LOCAL} \ + ${LIBCONFUSE_TARFILE_URL} + +libconfuse.unpack: + tar xfz ${LIBCONFUSE_TARFILE_LOCAL} + +clean:: + rm -rf ${LIBCONFUSE_SRC_DIR} + +libconfuse.configure: + rm -rf ${LIBCONFUSE_BUILD_DIR} + mkdir -p ${LIBCONFUSE_BUILD_DIR} + cd ${LIBCONFUSE_BUILD_DIR} && \ + ${LIBCONFUSE_SRC_DIR}/configure \ + --prefix=${PREFIX} + +clean:: + rm -rf ${LIBCONFUSE_BUILD_DIR} + +libconfuse.build: + cd ${LIBCONFUSE_BUILD_DIR} && ${MAKE} + +libconfuse.install: + cd ${LIBCONFUSE_BUILD_DIR} && ${MAKE} install + +libconfuse.all: libconfuse.unpack libconfuse.configure \ + libconfuse.build libconfuse.install + +#======================================== +# LIBFTDI - the open source (and free) +# alternative to (closed) FTD2XX drivers. + +libftdi.download: + mkdir -p virgins + wget -O ${LIBFTDI_TARFILE_LOCAL} \ + ${LIBFTDI_TARFILE_URL} + +libftdi.unpack: + tar xfz ${LIBFTDI_TARFILE_LOCAL} + +clean:: + rm -rf ${LIBFTDI_SRC_DIR} + +libftdi.configure: + rm -rf ${LIBFTDI_BUILD_DIR} + mkdir -p ${LIBFTDI_BUILD_DIR} + cd ${LIBFTDI_BUILD_DIR} && \ + ${LIBFTDI_SRC_DIR}/configure \ + --prefix=${PREFIX} + +clean:: + rm -rf ${LIBFTDI_BUILD_DIR} + +libftdi.build: + cd ${LIBFTDI_BUILD_DIR} && ${MAKE} + +libftdi.install: + cd ${LIBFTDI_BUILD_DIR} && ${MAKE} install + +libftdi.all: libftdi.unpack libftdi.configure \ + libftdi.build libftdi.install + +#======================================== +# Openocd... + +openocd.bootstrap: + cd ${OPENOCD_SRC_DIR} && bash ./bootstrap + +openocd.configure: + rm -rf ${OPENOCD_BUILD_DIR} + mkdir -p ${OPENOCD_BUILD_DIR} + cd ${OPENOCD_BUILD_DIR} && ${OPENOCD_SRC_DIR}/configure \ + --prefix=${INSTALL_DIR} \ + ${OPENOCD_CONFIG_OPTIONS} + +openocd.build: + cd ${OPENOCD_BUILD_DIR} && ${MAKE} + +openocd.docs: + cd ${OPENOCD_BUILD_DIR}/docs && ${MAKE} + +openocd.docs.pdf: + cd ${OPENOCD_BUILD_DIR}/docs && ${MAKE} pdf + +openocd.docs.html: + cd ${OPENOCD_BUILD_DIR}/docs && ${MAKE} html + +# fixme: +# need to add a "make one huge html file target" + +openocd.install: + cd ${OPENOCD_BUILD_DIR} && ${MAKE} install + +#======================================== +# The world... + +# Manual step. +download.all: \ + ftd2xx.download \ + libconfuse.download \ + libftdi.download + +ifeq (x"${FT2232_DRIVER}",x"ftd2xx") +prebuild: ftd2xx.all +endif + +ifeq (x"${FT2232_DRIVER}",x"libftdi") +prebuild: libconfuse.all libftdi.all +endif + +remake: \ + openocd.bootstrap \ + openocd.configure \ + openocd.build \ + openocd.install + +initial.build : download.all prebuild remake + +all: + @echo "" + @echo " This makefile does not support an 'all' target" + @echo "" + @echo " If this is your *FIRST* time building... " + @echo " Then use this command: \"make initial.build\"" + @echo "" + @echo " The \"default\" target is for openocd developers" + @echo " and rebuilds openocd completely.." + @echo "" + +default: + test -d ${OPENOCD_SRC_DIR} || (echo "Where is: The OPENOCD source?"; exit 1) + ${MAKE} remake + +whatis_%: + @echo "" + @echo "Makevariable: $* => ${${*}}" + @echo "" Property changes on: trunk/testing/build.test2/Makefile ___________________________________________________________________ Name: svn:executable + * Added: trunk/testing/build.test2/README.txt =================================================================== --- trunk/testing/build.test2/README.txt 2008-12-27 22:43:56 UTC (rev 1289) +++ trunk/testing/build.test2/README.txt 2008-12-27 23:23:06 UTC (rev 1290) @@ -0,0 +1,59 @@ + +This makefile is how I Duane Ellis (op...@du...) builds +openocd test purposes on Cygwin. I have included it here so others +might also make use of the same configuration that I use to develop +Openocd. + +--Duane Ellis + +To make use of it do the following: + +(1) Check out openocd in the standard way. + +For example - in cygwin, type this: + + bash$ mkdir -p /home/duane/test + bash$ cd /home/duane/test + bash$ svn co https://svn.berlios.de/svnroot/repos/openocd/trunk openocd + +(2) COPY this folder "right above" where you have OpenOCD. + + bash$ cd /home/duane/test + bash$ cp ./openocd/testing/build.test2/* /home/duane/test/. + +(3) OPTIONALLY + + You might want to review the file "local.uses" + Change options and so forth at the top of the file. + +(4) Initially, you need to download some additional files. + These include "libftdi", "libconfuse", and the ftd2xx drivers. + +(5) You also need to build the supporting libraries and install them + (They are installed "locally" only) + + Type this command: + + bash$ cd /home/duane/test + + bash$ make initial.build + + which: (1) downloads files + (2) builds the libs + (3) builds OpenOCD + +(6) As you hack upon OpenOCD... to rebuild OpenOCD... + + bash$ cd /home/duane/test + + bash$ make remake + + which: (1) re-bootstraps + (2) re-configures + (3) re-builds + (4) re-installs. + +======= +**END** +======= + Property changes on: trunk/testing/build.test2/README.txt ___________________________________________________________________ Name: svn:executable + * Added: trunk/testing/build.test2/local.uses =================================================================== --- trunk/testing/build.test2/local.uses 2008-12-27 22:43:56 UTC (rev 1289) +++ trunk/testing/build.test2/local.uses 2008-12-27 23:23:06 UTC (rev 1290) @@ -0,0 +1,161 @@ +# -*- mode: makefile -*- +#======================================== +# DO NOT REMOVE THE LINE BELOW +HERE := $(shell pwd) +# DO NOT REMOVE THE LINE ABOVE +#======================================== + +# These are common CYGWIN build settings. +# Comment out things you do not want. +# Or unComment things you want. + +# PCs always have printer ports... +X86_PRINTER_PORT ?= y + +# Chose *ONE* of these three solutions. +#FTD2232_DRIVER = none +FT2232_DRIVER = ftd2xx +#FT2232_DRIVER = libftdi + +# Do you have "libusb" installed? +ifeq (x"${FT2232_DRIVER}",x"libftdi") +# With LIBFTDI... LIBUSB is manditory. +USE_LIBUSB = y +endif + +# By default... we assume libusb not present. +USE_LIBUSB ?= n + +#======================================== +# DO NOT EDIT SETTINGS BELOW THIS LINE +#======================================== + + + +#======================================== +# House keeping... + +# Solve problems on systems with DASH.. Grrr... +SHELL=/bin/bash +export SHELL + +VIRGINS ?= ${HERE}/virgins +INSTALL_DIR ?= $(HERE)/install +PREFIX ?= ${INSTALL_DIR} + +# Determine the build platform. +BUILD_SYSNAME_Linux =linux +BUILD_SYSNAME_linux =linux +BUILD_SYSNAME_CYGWIN_NT =cygwin +BUILD_SYSNAME_MINGW32_NT =mingw32 +BUILD_SYSNAME_Darwin =darwin +BUILD_SYSNAME_darwin =darwin +BUILD_SYSNAME :=$(BUILD_SYSNAME_$(shell uname --sysname | cut -d'-' -f1)) + +# And machine (ie: i686, x86_64, or what ever) +BUILD_MACHINE :=$(BUILD_SYSNAME).$(shell uname -m) + + +#======================================== +# + +FTD2XX_LINUX_VERSION=0.4.16 +FTD2XX_LINUX_DIR = ${HERE}/libftd2xx${FTD2XX_LINUX_VERSION} +FTD2XX_LINUX_64_DIR = ${HERE}/libftd2xx${FTD2XX_LINUX_VERSION}_x86_64 + + +# Wiggler type interfaces are here. +OPENOCD_CONFIG_OPTIONS_printer_y += --enable-parport +OPENOCD_CONFIG_OPTIONS_printer_y += --enable-parport-giveio +OPENOCD_CONFIG_OPTIONS_printer_y += --enable-gw16012 +OPENOCD_CONFIG_OPTIONS_printer_y += --enable-parport-giveio +OPENOCD_CONFIG_OPTIONS_printer_y += --enable-amtjtagaccel + + +# FTD2XX only supports these +OPENOCD_CONFIG_OPTIONS_ft2232_none = +OPENOCD_CONFIG_OPTIONS_ft2232_ftd2xx = --enable-ft2232_ftd2xx --enable-presto_ftd2xx --with-ftd2xx-win32-zipdir=${FTD2XX_WIN32_DIR} +OPENOCD_CONFIG_OPTIONS_ft2232_libftdi = --enable-ft2232_libftdi --enable-presto_libftdi + +# LIBUSB - adds support for these. +OPENOCD_CONFIG_OPTIONS_libusb_y += --enable-jlink +OPENOCD_CONFIG_OPTIONS_libusb_y += --enable-usbprog +OPENOCD_CONFIG_OPTIONS_libusb_y += --enable-rlink +OPENOCD_CONFIG_OPTIONS_libusb_y += --enable-vsllink +OPENOCD_CONFIG_OPTIONS_libusb_y += --enable-usbprog + +#======================================== +# EXPLICITY NOT SUPPORTED INTERFACES +# +# zy1000.c +# This is a standalone hardware box +# it is *NOT* a cygwin thing. +# +# at91rm9200.c +# This is a uC/Linux (or linux) that +# runs uC/Linux and uses the gpio pins +# to bit-bang JTAG stuff. +# +# ep93xx.c +# Just like at91rm9200 - different chip. + +#======================================== +# Build OPENOCD config options... +# Always enable "dummy" +OPENOCD_CONFIG_OPTIONS += --enable-dummy +# +# Today: Cannot enable 'oocd_trace' on cygwin. +# it assumes/uses termios functions like +# cfmakeraw() which do not exist on cygwin. +# +#OPENOCD_CONFIG_OPTIONS += --enable-oocd-trace +# +# Add printer options.. +OPENOCD_CONFIG_OPTIONS += ${OPENOCD_CONFIG_OPTIONS_printer_${X86_PRINTER_PORT}} + +# Add the FTD2232 based options. +OPENOCD_CONFIG_OPTIONS += ${OPENOCD_CONFIG_OPTIONS_ft2232_${FT2232_DRIVER}} + +# Add LIBUSB based options. +OPENOCD_CONFIG_OPTIONS += ${OPENOCD_CONFIG_OPTIONS_libusb_${USE_LIBUSB}} + + +#======================================== +# WARNING... the file on the ftdi chip site has a SPACE in the filename GRRR!!! +# We fix that with the "-O" option to wget. +FTD2XX_WIN32_VERSION=2.04.14 +FTD2XX_WIN32_DIR = ${HERE}/ftd2xx.win32 + +FTD2XX_ZIPFILE_LOCAL=${VIRGINS}/cdm.${FTD2XX_WIN32_VERSION}.zip +# Damn thing has a space in the F-ing filename! +FTD2XX_ZIPFILE_URL ="http://www.ftdichip.com/Drivers/CDM/CDM ${FTD2XX_WIN32_VERSION}.zip" + + +#======================================== +# LIBCONFUSE - used by LIBFTDI.. +LIBCONFUSE_VERSION=2.5 +LIBCONFUSE_TARFILE_LOCAL=${VIRGINS}/confuse-${LIBCONFUSE_VERSION}.tar.gz +LIBCONFUSE_TARFILE_URL =http://www.intra2net.com/de/produkte/opensource/ftdi/TGZ/confuse-${LIBCONFUSE_VERSION}.tar.gz + +LIBCONFUSE_SRC_DIR =${HERE}/confuse-${LIBCONFUSE_VERSION} +LIBCONFUSE_BUILD_DIR =${HERE}/confuse-build + + +#======================================== +# LIBFTDI... (which uses libusb, and libconfuse) +LIBFTDI_VERSION=0.14 +LIBFTDI_TARFILE_LOCAL = ${VIRGINS}/libftdi-${LIBFTDI_VERSION}.tar.gz +LIBFTDI_TARFILE_URL = http://www.intra2net.com/de/produkte/opensource/ftdi/TGZ/libftdi-${LIBFTDI_VERSION}.tar.gz + +LIBFTDI_SRC_DIR = ${HERE}/libftdi-${LIBFTDI_VERSION} +LIBFTDI_BUILD_DIR= ${HERE}/libftdi-build + +#======================================== +# Finally - OpenOCD... +# +OPENOCD_BUILD_DIR =${HERE}/openocd-build +OPENOCD_SRC_DIR =${HERE}/openocd + +#======================================== +# END .. +#======================================== Property changes on: trunk/testing/build.test2/local.uses ___________________________________________________________________ Name: svn:executable + * |
|
From: <du...@ma...> - 2008-12-27 23:43:58
|
Author: duane
Date: 2008-12-27 23:43:56 +0100 (Sat, 27 Dec 2008)
New Revision: 1289
Modified:
trunk/src/jtag/vsllink.c
Log:
Warnings cleanup ... finish up earlier commit
Modified: trunk/src/jtag/vsllink.c
===================================================================
--- trunk/src/jtag/vsllink.c 2008-12-27 22:40:51 UTC (rev 1288)
+++ trunk/src/jtag/vsllink.c 2008-12-27 22:43:56 UTC (rev 1289)
@@ -200,8 +200,8 @@
void vsllink_simple_command(u8 command);
/* VSLLink tap buffer functions */
-void vsllink_tap_init();
-int vsllink_tap_execute();
+void vsllink_tap_init(void);
+int vsllink_tap_execute(void);
void vsllink_tap_ensure_space(int scans, int bytes);
void vsllink_tap_append_scan(int length, u8 *buffer, scan_command_t *command, int offset);
@@ -971,7 +971,7 @@
result = vsllink_usb_write(vsllink_jtag_handle, 3);
if (result != 3)
{
- LOG_ERROR("VSLLink command VSLLINK_CMD_SET_PORT failed (%d)");
+ LOG_ERROR("VSLLink command VSLLINK_CMD_SET_PORT failed (%d)", result);
}
}
@@ -1054,7 +1054,6 @@
static int pending_scan_results_length;
static pending_scan_result_t pending_scan_results_buffer[MAX_PENDING_SCAN_RESULTS];
-static int last_tms;
void vsllink_tap_init()
{
@@ -1106,7 +1105,7 @@
* For the purpose of padding we assume that we are in idle or pause state. */
int vsllink_tap_execute()
{
- int i, j;
+ int i;
int result;
int first = 0;
@@ -1242,7 +1241,6 @@
int vsllink_usb_message(vsllink_jtag_t *vsllink_jtag, int out_length, int in_length)
{
int result;
- int result2;
result = vsllink_usb_write(vsllink_jtag, out_length);
if (result == out_length)
|
|
From: <du...@ma...> - 2008-12-27 23:40:53
|
Author: duane Date: 2008-12-27 23:40:51 +0100 (Sat, 27 Dec 2008) New Revision: 1288 Added: trunk/src/jtag/vsllink.c Log: Missed the svn add on earlier commit, duh Added: trunk/src/jtag/vsllink.c =================================================================== --- trunk/src/jtag/vsllink.c 2008-12-27 22:35:35 UTC (rev 1287) +++ trunk/src/jtag/vsllink.c 2008-12-27 22:40:51 UTC (rev 1288) @@ -0,0 +1,1334 @@ +/*************************************************************************** + * Copyright (C) 2007 by Simon Qian <Sim...@Si...> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +/* Versaloon is a programming tool for multiple MCUs. + * OpenOCD and MSP430 supports are distributed under GPLv2. + * You can find it at http://www.SimonQian.com/en/Versaloon. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "replacements.h" + +#include "jtag.h" + +#include <usb.h> +#include <string.h> + +#include "log.h" + +//#define _VSLLINK_IN_DEBUG_MODE_ + +/* enable this to view USB communication + */ +#if 0 +#define _DEBUG_USB_COMMS_ +#endif + +#ifdef _DEBUG_JTAG_IO_ +#define DEBUG_JTAG_IO(expr ...) LOG_DEBUG(expr) +#else +#define DEBUG_JTAG_IO(expr ...) +#endif + +#define VID 0x03EB +#define PID 0x2103 +#define VSLLINK_WRITE_ENDPOINT 0x02 +#define VSLLINK_READ_ENDPOINT 0x82 + +u16 vsllink_vid = VID; +u16 vsllink_pid = PID; +u8 vsllink_bulkout = VSLLINK_WRITE_ENDPOINT; +u8 vsllink_bulkin = VSLLINK_READ_ENDPOINT; + +#define VSLLINK_USB_TIMEOUT 1000 + +static int VSLLINK_BufferSize = 1024; + +/* Global USB buffers */ +static int vsllink_usb_out_buffer_idx; +static int vsllink_usb_in_want_length; +static u8* vsllink_usb_in_buffer = NULL; +static u8* vsllink_usb_out_buffer = NULL; + +/* Constants for VSLLink command */ +#define VSLLINK_CMD_CONN 0x80 +#define VSLLINK_CMD_DISCONN 0x81 +#define VSLLINK_CMD_SET_SPEED 0x82 +#define VSLLINK_CMD_SET_PORT 0x90 +#define VSLLINK_CMD_GET_PORT 0x91 +#define VSLLINK_CMD_SET_PORTDIR 0x92 +#define VSLLINK_CMD_HW_JTAGSEQCMD 0xA0 + +#define VSLLINK_CMDJTAGSEQ_TMSBYTE 0x00 +#define VSLLINK_CMDJTAGSEQ_SCAN 0x80 + +#define VSLLINK_CMDJTAGSEQ_CMDMSK 0xC0 +#define VSLLINK_CMDJTAGSEQ_LENMSK 0x3F + +#define JTAG_PINMSK_SRST (1 << 0) +#define JTAG_PINMSK_TRST (1 << 1) +#define JTAG_PINMSK_USR1 (1 << 2) +#define JTAG_PINMSK_USR2 (1 << 3) +#define JTAG_PINMSK_TCK (1 << 4) +#define JTAG_PINMSK_TMS (1 << 5) +#define JTAG_PINMSK_TDI (1 << 6) +#define JTAG_PINMSK_TDO (1 << 7) + + +#define VSLLINK_TAP_MOVE(from, to) VSLLINK_tap_move[tap_move_map[from]][tap_move_map[to]] + +/* VSLLINK_tap_move[i][j]: tap movement command to go from state i to state j + * 0: Test-Logic-Reset + * 1: Run-Test/Idle + * 2: Shift-DR + * 3: Pause-DR + * 4: Shift-IR + * 5: Pause-IR + * + * SD->SD and SI->SI have to be caught in interface specific code + */ +u8 VSLLINK_tap_move[6][6] = +{ +/* TLR RTI SD PD SI PI */ + {0xff, 0x00, 0x2f, 0x0a, 0x37, 0x16}, /* TLR */ + {0xff, 0x00, 0x45, 0x05, 0x4b, 0x0b}, /* RTI */ + {0xff, 0x61, 0x00, 0x01, 0x0f, 0x2f}, /* SD */ + {0xff, 0x60, 0x40, 0x17, 0x3c, 0x2f}, /* PD */ + {0xff, 0x61, 0x07, 0x17, 0x00, 0x01}, /* SI */ + {0xff, 0x60, 0x38, 0x17, 0x40, 0x2f} /* PI */ +}; + +u8 VSLLINK_TAP_MOVE_FROM_E1[6] = +{ +// TLR RTI SD PD SI PI + 0xff, 0x60, 0x38, 0x5c, 0x3c, 0x5E +}; + +u8 VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[7][6][2] = +{ +/* stuff offset */ + {/* TLR */ + {1, 0,}, /* TLR */ + {1, 0,}, /* RTI */ + {1, 0,}, /* SD */ + {1, 0,}, /* PD */ + {1, 0,}, /* SI */ + {1, 0,}}, /* PI */ + {/* RTI */ + {1, 0,}, /* TLR */ + {0, 0,}, /* RTI */ + {0, 4,}, /* SD */ + {0, 7,}, /* PD */ + {0, 5,}, /* SI */ + {0, 7,}}, /* PI */ + {/* SD */ + {0, 0,}, /* TLR */ + {0, 0,}, /* RTI */ + {0, 0,}, /* SD */ + {0, 0,}, /* PD */ + {0, 0,}, /* SI */ + {0, 0,}}, /* PI */ + {/* PD */ + {0, 0,}, /* TLR */ + {0, 0,}, /* RTI */ + {0, 0,}, /* SD */ + {0, 0,}, /* PD */ + {0, 0,}, /* SI */ + {0, 0,}}, /* PI */ + {/* SI */ + {0, 0,}, /* TLR */ + {0, 0,}, /* RTI */ + {0, 0,}, /* SD */ + {0, 0,}, /* PD */ + {0, 0,}, /* SI */ + {0, 0,}}, /* PI */ + {/* PI */ + {0, 0,}, /* TLR */ + {0, 0,}, /* RTI */ + {0, 0,}, /* SD */ + {0, 0,}, /* PD */ + {0, 0,}, /* SI */ + {0, 0,}}, /* PI */ +}; + +u8 VSLLINK_BIT_MSK[8] = +{ + 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f +}; + +/* External interface functions */ +int vsllink_execute_queue(void); +int vsllink_speed(int speed); +int vsllink_khz(int khz, int *jtag_speed); +int vsllink_speed_div(int jtag_speed, int *khz); +int vsllink_register_commands(struct command_context_s *cmd_ctx); +int vsllink_init(void); +int vsllink_quit(void); + +/* CLI command handler functions */ +int vsllink_handle_usb_vid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); + +/* Queue command functions */ +void vsllink_end_state(enum tap_state state); +void vsllink_state_move(void); +void vsllink_path_move(int num_states, enum tap_state *path); +void vsllink_runtest(int num_cycles); +void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +void vsllink_reset(int trst, int srst); +void vsllink_simple_command(u8 command); + +/* VSLLink tap buffer functions */ +void vsllink_tap_init(); +int vsllink_tap_execute(); +void vsllink_tap_ensure_space(int scans, int bytes); +void vsllink_tap_append_scan(int length, u8 *buffer, scan_command_t *command, int offset); + +/* VSLLink lowlevel functions */ +typedef struct vsllink_jtag +{ + struct usb_dev_handle* usb_handle; +} vsllink_jtag_t; + +vsllink_jtag_t *vsllink_usb_open(void); +void vsllink_usb_close(vsllink_jtag_t *vsllink_jtag); +int vsllink_usb_message(vsllink_jtag_t *vsllink_jtag, int out_length, int in_length); +int vsllink_usb_write(vsllink_jtag_t *vsllink_jtag, int out_length); +int vsllink_usb_read(vsllink_jtag_t *vsllink_jtag); + +void vsllink_debug_buffer(u8 *buffer, int length); + +int vsllink_tms_data_len = 0; +u8* vsllink_tms_cmd_pos; + +vsllink_jtag_t* vsllink_jtag_handle; + +/***************************************************************************/ +/* External interface implementation */ + +jtag_interface_t vsllink_interface = +{ + .name = "vsllink", + .execute_queue = vsllink_execute_queue, + .speed = vsllink_speed, + .khz = vsllink_khz, + .speed_div = vsllink_speed_div, + .register_commands = vsllink_register_commands, + .init = vsllink_init, + .quit = vsllink_quit +}; + +int vsllink_execute_queue(void) +{ + jtag_command_t *cmd = jtag_command_queue; + int scan_size; + enum scan_type type; + u8 *buffer; + + DEBUG_JTAG_IO("--------------------------------------------------------------------------------"); + + vsllink_usb_out_buffer[0] = VSLLINK_CMD_HW_JTAGSEQCMD; + vsllink_usb_out_buffer_idx = 3; + while (cmd != NULL) + { + switch (cmd->type) + { + case JTAG_END_STATE: + DEBUG_JTAG_IO("end_state: %i", cmd->cmd.end_state->end_state); + + if (cmd->cmd.end_state->end_state != -1) + { + vsllink_end_state(cmd->cmd.end_state->end_state); + } + break; + + case JTAG_RUNTEST: + DEBUG_JTAG_IO( "runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \ + cmd->cmd.runtest->end_state); + + if (cmd->cmd.runtest->end_state != -1) + { + vsllink_end_state(cmd->cmd.runtest->end_state); + } + vsllink_runtest(cmd->cmd.runtest->num_cycles); + break; + + case JTAG_STATEMOVE: + DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state); + + if (cmd->cmd.statemove->end_state != -1) + { + vsllink_end_state(cmd->cmd.statemove->end_state); + } + vsllink_state_move(); + break; + + case JTAG_PATHMOVE: + DEBUG_JTAG_IO("pathmove: %i states, end in %i", \ + cmd->cmd.pathmove->num_states, \ + cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + + vsllink_path_move(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path); + break; + + case JTAG_SCAN: + if (cmd->cmd.scan->end_state != -1) + { + vsllink_end_state(cmd->cmd.scan->end_state); + } + + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); + if (cmd->cmd.scan->ir_scan) + { + DEBUG_JTAG_IO("JTAG Scan write IR(%d bits), end in %d:", scan_size, cmd->cmd.scan->end_state); + } + else + { + DEBUG_JTAG_IO("JTAG Scan write DR(%d bits), end in %d:", scan_size, cmd->cmd.scan->end_state); + } + +#ifdef _DEBUG_JTAG_IO_ + vsllink_debug_buffer(buffer, (scan_size + 7) >> 3); +#endif + + type = jtag_scan_type(cmd->cmd.scan); + + vsllink_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size, cmd->cmd.scan); + break; + + case JTAG_RESET: + DEBUG_JTAG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + + vsllink_tap_execute(); + + if (cmd->cmd.reset->trst == 1) + { + cur_state = TAP_RESET; + } + vsllink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); + + vsllink_usb_out_buffer[0] = VSLLINK_CMD_HW_JTAGSEQCMD; + vsllink_usb_out_buffer_idx = 3; + break; + + case JTAG_SLEEP: + DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us); + vsllink_tap_execute(); + jtag_sleep(cmd->cmd.sleep->us); + break; + + default: + LOG_ERROR("BUG: unknown JTAG command type encountered"); + exit(-1); + } + cmd = cmd->next; + } + + return vsllink_tap_execute(); +} + +int vsllink_speed(int speed) +{ + int result; + + vsllink_usb_out_buffer[0] = VSLLINK_CMD_SET_SPEED; + vsllink_usb_out_buffer[1] = (speed >> 0) & 0xff; + vsllink_usb_out_buffer[2] = (speed >> 8) & 0xFF; + + result = vsllink_usb_write(vsllink_jtag_handle, 3); + + if (result == 3) + { + return ERROR_OK; + } + else + { + LOG_ERROR("VSLLink setting speed failed (%d)", result); + return ERROR_JTAG_DEVICE_ERROR; + } + + return ERROR_OK; +} + +int vsllink_khz(int khz, int *jtag_speed) +{ + *jtag_speed = khz; + + return ERROR_OK; +} + +int vsllink_speed_div(int jtag_speed, int *khz) +{ + *khz = jtag_speed; + + return ERROR_OK; +} + +int vsllink_register_commands(struct command_context_s *cmd_ctx) +{ + register_command(cmd_ctx, NULL, "vsllink_usb_vid", vsllink_handle_usb_vid_command, + COMMAND_CONFIG, NULL); + register_command(cmd_ctx, NULL, "vsllink_usb_pid", vsllink_handle_usb_pid_command, + COMMAND_CONFIG, NULL); + register_command(cmd_ctx, NULL, "vsllink_usb_bulkin", vsllink_handle_usb_bulkin_command, + COMMAND_CONFIG, NULL); + register_command(cmd_ctx, NULL, "vsllink_usb_bulkout", vsllink_handle_usb_bulkout_command, + COMMAND_CONFIG, NULL); + + return ERROR_OK; +} + +int vsllink_init(void) +{ + int check_cnt; + int result; + char version_str[100]; + + vsllink_usb_in_buffer = malloc(VSLLINK_BufferSize); + vsllink_usb_out_buffer = malloc(VSLLINK_BufferSize); + if ((vsllink_usb_in_buffer == NULL) || (vsllink_usb_out_buffer == NULL)) + { + LOG_ERROR("Not enough memory"); + exit(-1); + } + + vsllink_jtag_handle = vsllink_usb_open(); + + if (vsllink_jtag_handle == 0) + { + LOG_ERROR("Can't find USB JTAG Interface! Please check connection and permissions."); + return ERROR_JTAG_INIT_FAILED; + } + + check_cnt = 0; + while (check_cnt < 3) + { + vsllink_simple_command(VSLLINK_CMD_CONN); + result = vsllink_usb_read(vsllink_jtag_handle); + + if (result > 2) + { + vsllink_usb_in_buffer[result] = 0; + VSLLINK_BufferSize = vsllink_usb_in_buffer[0] + (vsllink_usb_in_buffer[1] << 8); + strncpy(version_str, (char *)vsllink_usb_in_buffer + 2, sizeof(version_str)); + LOG_INFO(version_str); + + // free the pre-alloc memroy + free(vsllink_usb_in_buffer); + free(vsllink_usb_out_buffer); + vsllink_usb_in_buffer = NULL; + vsllink_usb_out_buffer = NULL; + + // alloc new memory + vsllink_usb_in_buffer = malloc(VSLLINK_BufferSize); + vsllink_usb_out_buffer = malloc(VSLLINK_BufferSize); + if ((vsllink_usb_in_buffer == NULL) || (vsllink_usb_out_buffer == NULL)) + { + LOG_ERROR("Not enough memory"); + exit(-1); + } + else + { + LOG_INFO("buffer size for USB is %d bytes", VSLLINK_BufferSize); + } + break; + } + vsllink_simple_command(VSLLINK_CMD_DISCONN); + + check_cnt++; + } + + if (check_cnt == 3) + { + // It's dangerout to proced + LOG_ERROR("VSLLink initial failed"); + exit(-1); + } + + // Set SRST and TRST to output, Set USR1 and USR2 to input + vsllink_usb_out_buffer[0] = VSLLINK_CMD_SET_PORTDIR; + vsllink_usb_out_buffer[1] = JTAG_PINMSK_SRST | JTAG_PINMSK_TRST | JTAG_PINMSK_USR1 | JTAG_PINMSK_USR2; + vsllink_usb_out_buffer[2] = JTAG_PINMSK_SRST | JTAG_PINMSK_TRST; + result = vsllink_usb_write(vsllink_jtag_handle, 3); + if (result != 3) + { + LOG_ERROR("VSLLink USB send data error"); + exit(-1); + } + + vsllink_reset(0, 0); + + LOG_INFO("VSLLink JTAG Interface ready"); + + vsllink_tap_init(); + + return ERROR_OK; +} + +int vsllink_quit(void) +{ + if ((vsllink_usb_in_buffer != NULL) && (vsllink_usb_out_buffer != NULL)) + { + vsllink_simple_command(VSLLINK_CMD_DISCONN); + vsllink_usb_close(vsllink_jtag_handle); + } + + if (vsllink_usb_in_buffer != NULL) + { + free(vsllink_usb_in_buffer); + } + if (vsllink_usb_out_buffer != NULL) + { + free(vsllink_usb_out_buffer); + } + return ERROR_OK; +} + +// when vsllink_tms_data_len > 0, vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] is the byte that need to be appended. +// length of VSLLINK_CMDJTAGSEQ_TMSBYTE has been set. +void VSLLINK_add_tms_from_RTI(enum tap_state state) +{ + u8 tms_scan = VSLLINK_TAP_MOVE(TAP_IDLE, state); + u16 tms2; + + if ((cur_state != TAP_IDLE) || (state == TAP_IDLE) || (vsllink_tms_data_len <= 0) || (vsllink_tms_data_len >= 8) || (vsllink_tms_cmd_pos == NULL)) + { + LOG_ERROR("There MUST be some bugs in the driver"); + exit(-1); + } + + tms2 = (tms_scan & VSLLINK_BIT_MSK[VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[1][tap_move_map[state]][1]]) << vsllink_tms_data_len; + if (VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[1][tap_move_map[state]][0] == 1) + { + tms2 |= VSLLINK_BIT_MSK[8 - vsllink_tms_data_len] << (vsllink_tms_data_len + VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[1][tap_move_map[state]][1]); + } + tms2 |= (tms_scan >> VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[1][tap_move_map[state]][1]) << (8 + VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[1][tap_move_map[state]][1]); + + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] |= (tms2 >> 0) & 0xff; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tms2 >> 8) & 0xff; + + vsllink_tms_data_len = 0; + vsllink_tms_cmd_pos = NULL; +} + +/***************************************************************************/ +/* Queue command implementations */ + +void vsllink_end_state(enum tap_state state) +{ + if (tap_move_map[state] != -1) + { + end_state = state; + } + else + { + LOG_ERROR("BUG: %i is not a valid end state", state); + exit(-1); + } +} + +/* Goes to the end state. */ +void vsllink_state_move(void) +{ + if (vsllink_tms_data_len > 0) + { + VSLLINK_add_tms_from_RTI(end_state); + } + else + { + vsllink_tap_ensure_space(0, 2); + + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(cur_state, end_state); + } + + cur_state = end_state; +} + +// write tms from current vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] +void vsllink_add_path(int start, int num, enum tap_state *path) +{ + int i; + + for (i = start; i < (start + num); i++) + { + if ((i & 7) == 0) + { + if (i > 0) + { + vsllink_usb_out_buffer[++vsllink_usb_out_buffer_idx] = 0; + } + else + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = 0; + } + } + + if (path[i - start] == tap_transitions[cur_state].high) + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] |= 1 << (i & 7); + } + else + { + LOG_ERROR("BUG: %d -> %d isn't a valid TAP transition", cur_state, path[i]); + exit(-1); + } + + cur_state = path[i]; + } + end_state = cur_state; +} + +void vsllink_path_move(int num_states, enum tap_state *path) +{ + int i, tms_len, tms_cmd_pos, path_idx = 0; + + if (vsllink_tms_data_len > 0) + { + if ((vsllink_tms_data_len + num_states) < 8) + { + vsllink_add_path(vsllink_tms_data_len, num_states, path); + num_states = 0; + } + else if ((vsllink_tms_data_len + num_states) < 16) + { + if ((*vsllink_tms_cmd_pos & VSLLINK_CMDJTAGSEQ_LENMSK) \ + < VSLLINK_CMDJTAGSEQ_LENMSK) + { + *vsllink_tms_cmd_pos++; + vsllink_add_path(vsllink_tms_data_len, num_states, path); + } + else + { + // need a new VSLLINK_CMDJTAGSEQ_TMSBYTE command + // if vsllink_tms_data_len > 0, length of VSLLINK_CMDJTAGSEQ_TMSBYTE MUST be > 1(tms_len > 2) + *vsllink_tms_cmd_pos--; + vsllink_add_path(vsllink_tms_data_len, 8 - vsllink_tms_data_len, path); + vsllink_usb_out_buffer_idx++; + vsllink_tap_ensure_space(0, 3); + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE | 1; + vsllink_tms_cmd_pos = vsllink_usb_out_buffer + vsllink_usb_out_buffer_idx; + vsllink_add_path(vsllink_tms_data_len, num_states + vsllink_tms_data_len - 8, path + 8 - vsllink_tms_data_len); + } + vsllink_tms_data_len = (vsllink_tms_data_len + num_states) & 7; + num_states = 0; + } + else + { + vsllink_add_path(vsllink_tms_data_len, 16 - vsllink_tms_data_len, path); + path_idx = 16 - vsllink_tms_data_len; + vsllink_usb_out_buffer_idx++; + + num_states -= 16 - vsllink_tms_data_len; + path += 16 - vsllink_tms_data_len; + vsllink_tms_data_len = 0; + vsllink_tms_cmd_pos = NULL; + } + } + + if (num_states > 0) + { + // Normal operation, don't need to append tms data + vsllink_tms_data_len = num_states & 7; + + while (num_states > 0) + { + if (num_states > ((VSLLINK_CMDJTAGSEQ_LENMSK + 1) * 8)) + { + i = (VSLLINK_CMDJTAGSEQ_LENMSK + 1) * 8; + } + else + { + i = num_states; + } + tms_len = (i + 7) >> 3; + vsllink_tap_ensure_space(0, tms_len + 2); + tms_cmd_pos = vsllink_usb_out_buffer_idx; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE | (tms_len - 1); + + vsllink_add_path(0, i, path + path_idx); + + path_idx += i; + num_states -= i; + } + + if (vsllink_tms_data_len > 0) + { + if (tms_len < (VSLLINK_CMDJTAGSEQ_LENMSK + 1)) + { + vsllink_usb_out_buffer[tms_cmd_pos]++; + vsllink_usb_out_buffer = vsllink_usb_out_buffer + tms_cmd_pos; + } + else + { + vsllink_usb_out_buffer[tms_cmd_pos]--; + tms_len = vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx]; + vsllink_tap_ensure_space(0, 3); + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE | 1; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = tms_len; + } + } + } +} + +void vsllink_runtest(int num_cycles) +{ + int i, j; + int tms_len, first_tms = 0, tms_cmd_pos; + enum tap_state saved_end_state = end_state; + + if (cur_state != TAP_IDLE) + { + vsllink_end_state(TAP_IDLE); + + if (vsllink_tms_data_len > 0) + { + VSLLINK_add_tms_from_RTI(end_state); + } + else + { + first_tms = 1; + } + } + + if (vsllink_tms_data_len > 0) + { + // cur_state == TAP_IDLE + if ((vsllink_tms_data_len + num_cycles) < 8) + { + vsllink_tms_data_len += num_cycles; + num_cycles = 0; + } + else if ((vsllink_tms_data_len + num_cycles) < 16) + { + if ((*vsllink_tms_cmd_pos & VSLLINK_CMDJTAGSEQ_LENMSK) \ + < VSLLINK_CMDJTAGSEQ_LENMSK) + { + *vsllink_tms_cmd_pos++; + vsllink_usb_out_buffer[++vsllink_usb_out_buffer_idx] = 0; + } + else + { + // need a new VSLLINK_CMDJTAGSEQ_TMSBYTE command + // if vsllink_tms_data_len > 0, length of VSLLINK_CMDJTAGSEQ_TMSBYTE MUST be > 1(tms_len > 2) + *vsllink_tms_cmd_pos--; + vsllink_tap_ensure_space(0, 3); + vsllink_usb_out_buffer[++vsllink_usb_out_buffer_idx] = VSLLINK_CMDJTAGSEQ_TMSBYTE | 1; + vsllink_tms_cmd_pos = vsllink_usb_out_buffer + vsllink_usb_out_buffer_idx; + vsllink_usb_out_buffer[++vsllink_usb_out_buffer_idx] = 0; + } + vsllink_tms_data_len = (vsllink_tms_data_len + num_cycles) & 7; + num_cycles = 0; + } + else + { + vsllink_usb_out_buffer[++vsllink_usb_out_buffer_idx] = 0; + vsllink_usb_out_buffer_idx++; + + num_cycles -= 16 - vsllink_tms_data_len; + vsllink_tms_data_len = 0; + vsllink_tms_cmd_pos = NULL; + } + } + + tms_len = ((num_cycles + 7) >> 3) + first_tms; + if (tms_len > 0) + { + // Normal operation, don't need to append tms data + vsllink_tms_data_len = num_cycles & 7; + + if (vsllink_tms_data_len > 0) + { + tms_len += 1; + } + // tms_len includes the length of tms byte to append + + // Make sure there is enough space + // 1 more byte maybe needed for the last tms move + vsllink_tap_ensure_space(0, (tms_len / VSLLINK_CMDJTAGSEQ_LENMSK) + tms_len + 1); + + while(tms_len > 0) + { + if (tms_len > (VSLLINK_CMDJTAGSEQ_LENMSK + 1)) + { + i = VSLLINK_CMDJTAGSEQ_LENMSK + 1; + } + else + { + i = tms_len; + } + + tms_cmd_pos = vsllink_usb_out_buffer_idx; + + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE | (i - 1); + + if (first_tms) + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(cur_state, end_state); + first_tms = 0; + j = i - 1; + } + else + { + j = i; + } + + while (j-- > 0) + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 0; + } + + tms_len -= i; + } + + // post process vsllink_usb_out_buffer_idx + if (vsllink_tms_data_len > 0) + { + vsllink_usb_out_buffer_idx -= 2; + } + + // Set end_state + vsllink_end_state(saved_end_state); + cur_state = TAP_IDLE; + if (saved_end_state != TAP_IDLE) + { + if (vsllink_tms_data_len > 0) + { + VSLLINK_add_tms_from_RTI(end_state); + } + else + { + if (i < (VSLLINK_CMDJTAGSEQ_LENMSK + 1)) + { + vsllink_usb_out_buffer[tms_cmd_pos]++; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(TAP_IDLE, end_state); + } + else + { + vsllink_tap_ensure_space(0, 2); + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(TAP_IDLE, end_state); + } + } + cur_state = saved_end_state; + } + + if (vsllink_tms_data_len > 0) + { + vsllink_tms_cmd_pos = vsllink_usb_out_buffer + tms_cmd_pos; + } + } + else + { + // Set end_state if no RTI shifts + vsllink_end_state(saved_end_state); + cur_state = TAP_IDLE; + if (saved_end_state != TAP_IDLE) + { + vsllink_tap_ensure_space(0, 2); + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(TAP_IDLE, end_state); + + cur_state = saved_end_state; + } + } +} + +void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) +{ + enum tap_state saved_end_state; + u8 bits_left, tms_tmp, tdi_len; + int i; + + tdi_len = ((scan_size + 7) >> 3); + if ((tdi_len + 7) > VSLLINK_BufferSize) + { + LOG_ERROR("Your implementation of VSLLink has not enough buffer"); + exit(-1); + } + + saved_end_state = end_state; + + /* Move to appropriate scan state */ + vsllink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT); + + if (vsllink_tms_data_len > 0) + { + if (cur_state == end_state) + { + *vsllink_tms_cmd_pos--; + tms_tmp = vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx]; + vsllink_tap_ensure_space(1, tdi_len + 7); + + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_SCAN | 1; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1) >> 0) & 0xff; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1)>> 8) & 0xff; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = tms_tmp; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = buffer[0] << (8 - vsllink_tms_data_len); + + for (i = 0; i < tdi_len; i++) + { + buffer[i] >>= 8 - vsllink_tms_data_len; + if (i != tdi_len) + { + buffer[i] += buffer[i + 1] << vsllink_tms_data_len; + } + } + + vsllink_tap_append_scan(scan_size - vsllink_tms_data_len, buffer, command, vsllink_tms_data_len); + scan_size -= 8 - vsllink_tms_data_len; + } + else + { + VSLLINK_add_tms_from_RTI(end_state); + vsllink_tap_ensure_space(1, tdi_len + 5); + + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_SCAN; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tdi_len >> 0) & 0xff; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tdi_len >> 8) & 0xff; + + vsllink_tap_append_scan(scan_size, buffer, command, 0); + } + } + else + { + vsllink_tap_ensure_space(1, tdi_len + 7); + + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_SCAN | 1; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1) >> 0) & 0xff; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1)>> 8) & 0xff; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(cur_state, end_state); + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 0; + + vsllink_tap_append_scan(scan_size, buffer, command, 8); + } + vsllink_end_state(saved_end_state); + + bits_left = scan_size & 0x07; + cur_state = ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE; + + if (bits_left > 0) + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 1 << (bits_left - 1); + } + else + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 1 << 7; + } + + if (cur_state != end_state) + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE_FROM_E1[tap_move_map[end_state]]; + } + else + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 0; + } + + cur_state = end_state; +} + +void vsllink_reset(int trst, int srst) +{ + int result; + + LOG_DEBUG("trst: %i, srst: %i", trst, srst); + + /* Signals are active low */ + vsllink_usb_out_buffer[0] = VSLLINK_CMD_SET_PORT; + vsllink_usb_out_buffer[1] = JTAG_PINMSK_SRST | JTAG_PINMSK_TRST; + vsllink_usb_out_buffer[2] = 0; + if (srst == 0) + { + vsllink_usb_out_buffer[2] |= JTAG_PINMSK_SRST; + } + if (trst == 0) + { + vsllink_usb_out_buffer[2] |= JTAG_PINMSK_TRST; + } + + result = vsllink_usb_write(vsllink_jtag_handle, 3); + if (result != 3) + { + LOG_ERROR("VSLLink command VSLLINK_CMD_SET_PORT failed (%d)"); + } +} + +void vsllink_simple_command(u8 command) +{ + int result; + + DEBUG_JTAG_IO("0x%02x", command); + + vsllink_usb_out_buffer[0] = command; + result = vsllink_usb_write(vsllink_jtag_handle, 1); + + if (result != 1) + { + LOG_ERROR("VSLLink command 0x%02x failed (%d)", command, result); + } +} + +int vsllink_handle_usb_vid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + if (argc != 1) { + LOG_ERROR("parameter error, should be one parameter for VID"); + return ERROR_OK; + } + + vsllink_vid = strtol(args[0], NULL, 0); + + return ERROR_OK; +} + +int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + if (argc != 1) { + LOG_ERROR("parameter error, should be one parameter for PID"); + return ERROR_OK; + } + + vsllink_pid = strtol(args[0], NULL, 0); + + return ERROR_OK; +} + +int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + if (argc != 1) { + LOG_ERROR("parameter error, should be one parameter for BULKIN endpoint"); + return ERROR_OK; + } + + vsllink_bulkin = strtol(args[0], NULL, 0) | 0x80; + + return ERROR_OK; +} + +int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + if (argc != 1) { + LOG_ERROR("parameter error, should be one parameter for BULKOUT endpoint"); + return ERROR_OK; + } + + vsllink_bulkout = strtol(args[0], NULL, 0); + + return ERROR_OK; +} + +/***************************************************************************/ +/* VSLLink tap functions */ + +typedef struct +{ + int length; /* Number of bits to read */ + int offset; + scan_command_t *command; /* Corresponding scan command */ + u8 *buffer; +} pending_scan_result_t; + +#define MAX_PENDING_SCAN_RESULTS 256 + +static int pending_scan_results_length; +static pending_scan_result_t pending_scan_results_buffer[MAX_PENDING_SCAN_RESULTS]; + +static int last_tms; + +void vsllink_tap_init() +{ + vsllink_usb_out_buffer_idx = 0; + vsllink_usb_in_want_length = 0; + pending_scan_results_length = 0; +} + +void vsllink_tap_ensure_space(int scans, int bytes) +{ + int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length; + int available_bytes = VSLLINK_BufferSize - vsllink_usb_out_buffer_idx; + + if (scans > available_scans || bytes > available_bytes) + { + vsllink_tap_execute(); + vsllink_usb_out_buffer[0] = VSLLINK_CMD_HW_JTAGSEQCMD; + vsllink_usb_out_buffer_idx = 3; + } +} + +void vsllink_tap_append_scan(int length, u8 *buffer, scan_command_t *command, int offset) +{ + pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length]; + int i; + + if (offset > 0) + { + vsllink_usb_in_want_length += ((length + 7) >> 3) + 1; + } + else + { + vsllink_usb_in_want_length += (length + 7) >> 3; + } + pending_scan_result->length = length; + pending_scan_result->offset = offset; + pending_scan_result->command = command; + pending_scan_result->buffer = buffer; + + for (i = 0; i < ((length + 7) >> 3); i++) + { + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = buffer[i]; + } + + pending_scan_results_length++; +} + +/* Pad and send a tap sequence to the device, and receive the answer. + * For the purpose of padding we assume that we are in idle or pause state. */ +int vsllink_tap_execute() +{ + int i, j; + int result; + int first = 0; + + if (vsllink_tms_data_len > 0) + { + if (vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] & (1 << (vsllink_tms_data_len - 1))) + { + // last tms bit is '1' + // the only possible state is TLR, no need to control the number of shifts in RLT + // There MUST be some errors in the code + LOG_ERROR("last tms bit is '1'"); + exit(-1); + } + else + { + // last tms bit is '0' + vsllink_usb_out_buffer_idx++; + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 0; + vsllink_tms_data_len = 0; + } + } + + if (vsllink_usb_out_buffer_idx > 3) + { + if (vsllink_usb_out_buffer[0] == VSLLINK_CMD_HW_JTAGSEQCMD) + { + vsllink_usb_out_buffer[1] = (vsllink_usb_out_buffer_idx >> 0) & 0xff; + vsllink_usb_out_buffer[2] = (vsllink_usb_out_buffer_idx >> 8) & 0xff; + } + + result = vsllink_usb_message(vsllink_jtag_handle, vsllink_usb_out_buffer_idx, vsllink_usb_in_want_length); + + if (result == vsllink_usb_in_want_length) + { + for (i = 0; i < pending_scan_results_length; i++) + { + pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[i]; + u8 *buffer = pending_scan_result->buffer; + int length = pending_scan_result->length; + int offset = pending_scan_result->offset; + scan_command_t *command = pending_scan_result->command; + + /* Copy to buffer */ + buf_set_buf(vsllink_usb_in_buffer, first * 8 + offset, buffer, 0, length); + first += (length + offset + 7) >> 3; + + DEBUG_JTAG_IO("JTAG scan read(%d bits):", length); +#ifdef _DEBUG_JTAG_IO_ + vsllink_debug_buffer(buffer, (length + 7) >> 3); +#endif + + if (jtag_read_buffer(buffer, command) != ERROR_OK) + { + vsllink_tap_init(); + return ERROR_JTAG_QUEUE_FAILED; + } + + if (pending_scan_result->buffer != NULL) + { + free(pending_scan_result->buffer); + pending_scan_result->buffer = NULL; + } + } + } + else + { + LOG_ERROR("vsllink_tap_execute, wrong result %d, expected %d", result, vsllink_usb_in_want_length); + return ERROR_JTAG_QUEUE_FAILED; + } + + vsllink_tap_init(); + } + + return ERROR_OK; +} + +/*****************************************************************************/ +/* VSLLink USB low-level functions */ + +vsllink_jtag_t* vsllink_usb_open() +{ + struct usb_bus *busses; + struct usb_bus *bus; + struct usb_device *dev; + + vsllink_jtag_t *result; + + result = (vsllink_jtag_t*) malloc(sizeof(vsllink_jtag_t)); + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + busses = usb_get_busses(); + + /* find vsllink_jtag device in usb bus */ + + for (bus = busses; bus; bus = bus->next) + { + for (dev = bus->devices; dev; dev = dev->next) + { + if ((dev->descriptor.idVendor == vsllink_vid) && (dev->descriptor.idProduct == vsllink_pid)) + { + result->usb_handle = usb_open(dev); + + /* usb_set_configuration required under win32 */ + usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue); + usb_claim_interface(result->usb_handle, 0); + +#if 0 + /* + * This makes problems under Mac OS X. And is not needed + * under Windows. Hopefully this will not break a linux build + */ + usb_set_altinterface(result->usb_handle, 0); +#endif + return result; + } + } + } + + free(result); + return NULL; +} + +void vsllink_usb_close(vsllink_jtag_t *vsllink_jtag) +{ + usb_close(vsllink_jtag->usb_handle); + free(vsllink_jtag); +} + +/* Send a message and receive the reply. */ +int vsllink_usb_message(vsllink_jtag_t *vsllink_jtag, int out_length, int in_length) +{ + int result; + int result2; + + result = vsllink_usb_write(vsllink_jtag, out_length); + if (result == out_length) + { + if (in_length > 0) + { + result = vsllink_usb_read(vsllink_jtag); + if (result == in_length ) + { + return result; + } + else + { + LOG_ERROR("usb_bulk_read failed (requested=%d, result=%d)", in_length, result); + return -1; + } + } + return 0; + } + else + { + LOG_ERROR("usb_bulk_write failed (requested=%d, result=%d)", out_length, result); + return -1; + } +} + +/* Write data from out_buffer to USB. */ +int vsllink_usb_write(vsllink_jtag_t *vsllink_jtag, int out_length) +{ + int result; + + if (out_length > VSLLINK_BufferSize) + { + LOG_ERROR("vsllink_jtag_write illegal out_length=%d (max=%d)", out_length, VSLLINK_BufferSize); + return -1; + } + + result = usb_bulk_write(vsllink_jtag->usb_handle, vsllink_bulkout, \ + (char *)vsllink_usb_out_buffer, out_length, VSLLINK_USB_TIMEOUT); + + DEBUG_JTAG_IO("vsllink_usb_write, out_length = %d, result = %d", out_length, result); + +#ifdef _DEBUG_USB_COMMS_ + LOG_DEBUG("USB out:"); + vsllink_debug_buffer(vsllink_usb_out_buffer, out_length); +#endif + +#ifdef _VSLLINK_IN_DEBUG_MODE_ + usleep(100000); +#endif + + return result; +} + +/* Read data from USB into in_buffer. */ +int vsllink_usb_read(vsllink_jtag_t *vsllink_jtag) +{ + int result = usb_bulk_read(vsllink_jtag->usb_handle, vsllink_bulkin, \ + (char *)vsllink_usb_in_buffer, VSLLINK_BufferSize, VSLLINK_USB_TIMEOUT); + + DEBUG_JTAG_IO("vsllink_usb_read, result = %d", result); + +#ifdef _DEBUG_USB_COMMS_ + LOG_DEBUG("USB in:"); + vsllink_debug_buffer(vsllink_usb_in_buffer, result); +#endif + return result; +} + +#define BYTES_PER_LINE 16 + +void vsllink_debug_buffer(u8 *buffer, int length) +{ + char line[81]; + char s[4]; + int i; + int j; + + for (i = 0; i < length; i += BYTES_PER_LINE) + { + snprintf(line, 5, "%04x", i); + for (j = i; j < i + BYTES_PER_LINE && j < length; j++) + { + snprintf(s, 4, " %02x", buffer[j]); + strcat(line, s); + } + LOG_DEBUG(line); + } +} |
|
From: <du...@ma...> - 2008-12-27 23:35:38
|
Author: duane
Date: 2008-12-27 23:35:35 +0100 (Sat, 27 Dec 2008)
New Revision: 1287
Modified:
trunk/src/jtag/bitq.c
trunk/src/jtag/rlink/rlink.c
Log:
Tweaks - old crusty code with some warnings & errors - minor stuff
Modified: trunk/src/jtag/bitq.c
===================================================================
--- trunk/src/jtag/bitq.c 2008-12-27 21:00:16 UTC (rev 1286)
+++ trunk/src/jtag/bitq.c 2008-12-27 22:35:35 UTC (rev 1287)
@@ -169,10 +169,12 @@
int i;
for (i=0; i<=cmd->num_states; i++) {
- if (tap_transitions[cur_state].low == cmd->path[i]) bitq_io(0, 0, 0);
- else if (tap_transitions[cur_state].high == cmd->path[i]) bitq_io(1, 0, 0);
+ if (tap_transitions[cur_state].low == cmd->path[i])
+ bitq_io(0, 0, 0);
+ else if (tap_transitions[cur_state].high == cmd->path[i])
+ bitq_io(1, 0, 0);
else {
- LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[i)]);
+ LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", jtag_state_name(cur_state), jtag_state_name(cmd->path[i]));
exit(-1);
}
Modified: trunk/src/jtag/rlink/rlink.c
===================================================================
--- trunk/src/jtag/rlink/rlink.c 2008-12-27 21:00:16 UTC (rev 1286)
+++ trunk/src/jtag/rlink/rlink.c 2008-12-27 22:35:35 UTC (rev 1287)
@@ -427,8 +427,7 @@
*/
static
int
-dtc_start_download(
-) {
+dtc_start_download(void) {
int usb_err;
u8 ep2txr;
@@ -611,8 +610,7 @@
static
int
-dtc_queue_init(
-) {
+dtc_queue_init(void) {
dtc_queue.rq_head = NULL;
dtc_queue.rq_tail = NULL;
dtc_queue.cmd_index = 0;
@@ -663,8 +661,7 @@
static
int
-dtc_queue_run(
-) {
+dtc_queue_run(void) {
dtc_reply_queue_entry_t *rq_p, *rq_next;
int retval;
int usb_err;
@@ -808,8 +805,7 @@
static
int
-tap_state_queue_init(
-) {
+tap_state_queue_init(void) {
tap_state_queue.length = 0;
tap_state_queue.buffer = 0;
return(0);
@@ -818,8 +814,7 @@
static
int
-tap_state_queue_run(
-) {
+tap_state_queue_run(void) {
int i;
int bits;
u8 byte;
|
|
From: <du...@ma...> - 2008-12-27 22:00:19
|
Author: duane
Date: 2008-12-27 22:00:16 +0100 (Sat, 27 Dec 2008)
New Revision: 1286
Modified:
trunk/doc/openocd.texi
Log:
Added note to user manual for packagers of OpenOCD
Modified: trunk/doc/openocd.texi
===================================================================
--- trunk/doc/openocd.texi 2008-12-27 16:31:28 UTC (rev 1285)
+++ trunk/doc/openocd.texi 2008-12-27 21:00:16 UTC (rev 1286)
@@ -133,6 +133,46 @@
you. Chances are that that binary is from some SVN version that is more
stable than SVN trunk where bleeding edge development takes place.
+@section Packagers Please Read!
+
+If you are a @b{PACKAGER} of OpenOCD if you
+
+@enumerate
+@item @b{Sell dongles} and include pre-built binaries
+@item @b{Supply tools} ie: A complete development solution
+@item @b{Supply IDEs} like Eclipse, or RHIDE, etc.
+@item @b{Build packages} ie: RPM files, or DEB files for a Linux Distro
+@end enumerate
+
+As a @b{PACKAGER} - you are at the top of the food chain. You solve
+problems for downstream users. What you fix or solve - solves hundreds
+if not thousands of user questions. If something does not work for you
+please let us know. That said, would also like you to follow a few
+suggestions:
+
+@enumerate
+@item @b{Always build with Printer Ports Enabled}
+@item @b{Try where possible to use LIBFTDI + LIBUSB} You cover more bases
+@end enumerate
+
+It is your decision..
+
+@itemize @bullet
+@item @b{Why YES to LIBFTDI + LIBUSB}
+@itemize @bullet
+@item @b{LESS} work - libusb perhaps already there
+@item @b{LESS} work - identical code multiple platforms
+@item @b{MORE} dongles are supported
+@item @b{MORE} platforms are supported
+@item @b{MORE} complete solution
+@end itemize
+@item @b{Why not LIBFTDI + LIBUSB} (ie: ftd2xx instead)
+@itemize @bullet
+@item @b{LESS} Some say it is slower.
+@item @b{LESS} complex to distribute (external dependencies)
+@end itemize
+@end itemize
+
@section Building From Source
You can download the current SVN version with SVN client of your choice from the
|
|
From: <du...@ma...> - 2008-12-27 17:31:31
|
Author: duane
Date: 2008-12-27 17:31:28 +0100 (Sat, 27 Dec 2008)
New Revision: 1285
Modified:
trunk/configure.in
Log:
From Dirk Behme - another set of typos
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2008-12-27 15:00:36 UTC (rev 1284)
+++ trunk/configure.in 2008-12-27 16:31:28 UTC (rev 1285)
@@ -55,8 +55,7 @@
LDFLAGS="$LDFLAGS -L$OCDxprefix/lib"
# RPATH becomes an issue on Linux only
- if test $host_os = linux-gnu || $host_os = linux
- then
+ if test $host_os = linux-gnu || test $host_os = linux ; then
LDFLAGS="$LDFLAGS -Wl,-rpath,$OCDxprefix/lib"
fi
# The "INCDIR" is also usable
@@ -500,7 +499,7 @@
AC_MSG_CHECKING([for libftd2xx.a (linux)])
# Must be linux -
# Cause FTDICHIP does not supply a MAC-OS version
- if test $host_os != linux-gnu && $host_os != linux ; then
+ if test $host_os != linux-gnu && test $host_os != linux ; then
AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try --enable-ft2232-libftdi instead])
fi
# Are we given a TAR directory?
|
|
From: <du...@ma...> - 2008-12-27 16:00:46
|
Author: duane
Date: 2008-12-27 16:00:36 +0100 (Sat, 27 Dec 2008)
New Revision: 1284
Modified:
trunk/configure.in
Log:
Some systems report linux as host, others linux-gnu... grrr
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2008-12-27 13:47:36 UTC (rev 1283)
+++ trunk/configure.in 2008-12-27 15:00:36 UTC (rev 1284)
@@ -55,7 +55,7 @@
LDFLAGS="$LDFLAGS -L$OCDxprefix/lib"
# RPATH becomes an issue on Linux only
- if test $host_os = linux-gnu
+ if test $host_os = linux-gnu || $host_os = linux
then
LDFLAGS="$LDFLAGS -Wl,-rpath,$OCDxprefix/lib"
fi
@@ -500,7 +500,7 @@
AC_MSG_CHECKING([for libftd2xx.a (linux)])
# Must be linux -
# Cause FTDICHIP does not supply a MAC-OS version
- if test $host_os != linux-gnu; then
+ if test $host_os != linux-gnu && $host_os != linux ; then
AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try --enable-ft2232-libftdi instead])
fi
# Are we given a TAR directory?
|
|
From: <du...@ma...> - 2008-12-27 14:47:49
|
Author: duane
Date: 2008-12-27 14:47:36 +0100 (Sat, 27 Dec 2008)
New Revision: 1283
Modified:
trunk/configure.in
Log:
Missed support for without --exec-prefix and ftd2xx stuff
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2008-12-27 03:13:50 UTC (rev 1282)
+++ trunk/configure.in 2008-12-27 13:47:36 UTC (rev 1283)
@@ -36,15 +36,28 @@
# And - if we are being installed there - the odds are
# The libraries unique to what we are are there too.
#
+
+# Expand nd deal with NONE - just like configure will do later
+OCDprefix=$prefix
+OCDxprefix=$exec_prefix
+test x"$OCDprefix" = xNONE && OCDprefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test x"$OCDxprefix" = xNONE && OCDxprefix="$OCDprefix"
+
+
# what matters is the "exec-prefix"
-if test $exec_prefix != $ac_default_prefix
+if test "$OCDxprefix" != "$ac_default_prefix"
then
+ # We are installing in a non-standard place
+ # Nonstandard --prefix and/or --exec-prefix
+ # We have an override of some sort.
# use build specific install library dir
- LDFLAGS="$LDFLAGS -L$libdir"
+
+ LDFLAGS="$LDFLAGS -L$OCDxprefix/lib"
# RPATH becomes an issue on Linux only
if test $host_os = linux-gnu
then
- LDFLAGS="$LDFLAGS -Wl,-rpath,$libdir"
+ LDFLAGS="$LDFLAGS -Wl,-rpath,$OCDxprefix/lib"
fi
# The "INCDIR" is also usable
CFLAGS="$CFLAGS -I$includedir"
|
|
From: <du...@ma...> - 2008-12-27 04:13:54
|
Author: duane
Date: 2008-12-27 04:13:50 +0100 (Sat, 27 Dec 2008)
New Revision: 1282
Modified:
trunk/src/jtag/rlink/rlink.c
Log:
From Lou...@fi...
Modified: trunk/src/jtag/rlink/rlink.c
===================================================================
--- trunk/src/jtag/rlink/rlink.c 2008-12-27 03:07:32 UTC (rev 1281)
+++ trunk/src/jtag/rlink/rlink.c 2008-12-27 03:13:50 UTC (rev 1282)
@@ -1001,18 +1001,29 @@
}
usb_err = ep1_generic_commandl(
- pHDev, 5,
+ pHDev, 6,
EP1_CMD_MEMORY_WRITE,
ST7_PADR >> 8,
ST7_PADR,
1,
- bitmap
+ bitmap,
+ EP1_CMD_DTC_GET_CACHED_STATUS
);
if(usb_err < 0) {
LOG_ERROR("%s: %s\n", __func__, usb_strerror());
exit(1);
}
+
+ usb_err = usb_bulk_read(
+ pHDev, USB_EP1IN_ADDR,
+ &bitmap, 1,
+ USB_TIMEOUT_MS
+ );
+ if(usb_err < 1) {
+ LOG_ERROR("%s: %s\n", __func__, usb_strerror());
+ exit(1);
+ }
}
|
|
From: <du...@ma...> - 2008-12-27 04:07:36
|
Author: duane
Date: 2008-12-27 04:07:32 +0100 (Sat, 27 Dec 2008)
New Revision: 1281
Modified:
trunk/src/jtag/ft2232.c
trunk/src/jtag/jtag.c
Log:
Quoteify the FT2232 description list, and a missed fix from Dirk Behme about jtag tapisenabled
Modified: trunk/src/jtag/ft2232.c
===================================================================
--- trunk/src/jtag/ft2232.c 2008-12-27 02:56:55 UTC (rev 1280)
+++ trunk/src/jtag/ft2232.c 2008-12-27 03:07:32 UTC (rev 1281)
@@ -1469,7 +1469,7 @@
{
LOG_ERROR("ListDevices: %lu\n", num_devices);
for (i = 0; i < num_devices; i++)
- LOG_ERROR("%i: %s", i, desc_array[i]);
+ LOG_ERROR("%i: \"%s\"", i, desc_array[i]);
}
for (i = 0; i < num_devices; i++)
Modified: trunk/src/jtag/jtag.c
===================================================================
--- trunk/src/jtag/jtag.c 2008-12-27 02:56:55 UTC (rev 1280)
+++ trunk/src/jtag/jtag.c 2008-12-27 03:07:32 UTC (rev 1281)
@@ -2071,7 +2071,7 @@
}
switch( n->value ){
case JTAG_CMD_TAPISENABLED:
- // below
+ e = t->enabled;
break;
case JTAG_CMD_TAPENABLE:
jtag_tap_handle_event( t, JTAG_TAP_EVENT_ENABLE);
|
|
From: <du...@ma...> - 2008-12-27 03:57:01
|
Author: duane
Date: 2008-12-27 03:56:55 +0100 (Sat, 27 Dec 2008)
New Revision: 1280
Modified:
trunk/configure.in
trunk/doc/openocd.texi
trunk/src/Makefile.am
trunk/src/jtag/Makefile.am
trunk/src/jtag/jtag.c
trunk/testing/build.test1/Makefile.openocd
Log:
Added dongle VSLLINK - from Simon Qian
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2008-12-27 02:21:38 UTC (rev 1279)
+++ trunk/configure.in 2008-12-27 02:56:55 UTC (rev 1280)
@@ -156,8 +156,8 @@
)
AC_ARG_ENABLE(gccwarnings,
- AS_HELP_STRING([--enable-gccwarnings], [Enable compiler warnings, default no]),
- [gcc_warnings=$enableval], [gcc_warnings=no])
+ AS_HELP_STRING([--enable-gccwarnings], [Enable compiler warnings, default yes]),
+ [gcc_warnings=$enableval], [gcc_warnings=yes])
AC_ARG_ENABLE(parport,
AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
@@ -243,6 +243,10 @@
AS_HELP_STRING([--enable-jlink], [Enable building support for the Segger J-Link JTAG Programmer]),
[build_jlink=$enableval], [build_jlink=no])
+AC_ARG_ENABLE(vsllink,
+ AS_HELP_STRING([--enable-vsllink], [Enable building support for the Versaloon-Link JTAG Programmer]),
+ [build_vsllink=$enableval], [build_vsllink=no])
+
AC_ARG_ENABLE(rlink,
AS_HELP_STRING([--enable-rlink], [Enable building support for the Raisonance RLink JTAG Programmer]),
[build_rlink=$enableval], [build_rlink=no])
@@ -412,6 +416,12 @@
AC_DEFINE(BUILD_JLINK, 0, [0 if you don't want the J-Link JTAG driver.])
fi
+if test $build_vsllink = yes; then
+ AC_DEFINE(BUILD_VSLLINK, 1, [1 if you want the Versaloon-Link JTAG driver.])
+else
+ AC_DEFINE(BUILD_VSLLINK, 0, [0 if you don't want the Versaloon-Link JTAG driver.])
+fi
+
if test $build_rlink = yes; then
AC_DEFINE(BUILD_RLINK, 1, [1 if you want the RLink JTAG driver.])
else
@@ -631,6 +641,7 @@
AM_CONDITIONAL(USBPROG, test $build_usbprog = yes)
AM_CONDITIONAL(OOCD_TRACE, test $build_oocd_trace = yes)
AM_CONDITIONAL(JLINK, test $build_jlink = yes)
+AM_CONDITIONAL(VSLLINK, test $build_vsllink = yes)
AM_CONDITIONAL(RLINK, test $build_rlink = yes)
AM_CONDITIONAL(IS_CYGWIN, test $is_cygwin = yes)
AM_CONDITIONAL(IS_MINGW, test $is_mingw = yes)
Modified: trunk/doc/openocd.texi
===================================================================
--- trunk/doc/openocd.texi 2008-12-27 02:21:38 UTC (rev 1279)
+++ trunk/doc/openocd.texi 2008-12-27 02:56:55 UTC (rev 1280)
@@ -222,6 +222,8 @@
@item
@option{--enable-jlink} - From SEGGER
@item
+@option{--enable-vsllink}
+@item
@option{--enable-rlink} - Raisonance.com dongle.
@end itemize
@@ -395,6 +397,9 @@
@item @b{USB - Presto}
@* Link: @url{http://tools.asix.net/prg_presto.htm}
+
+@item @b{Versaloon-Link}
+@* Link: @url{http://www.simonqian.com/en/Versaloon}
@end itemize
@section IBM PC Parallel Printer Port Based
@@ -1140,6 +1145,9 @@
@item @b{rlink}
@* Raisonance RLink usb adapter
+
+@item @b{vsllink}
+@* vsllink is part of Versaloon which is a versatile USB programmer.
@comment - End parameters
@end itemize
@comment - End Interface
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2008-12-27 02:21:38 UTC (rev 1279)
+++ trunk/src/Makefile.am 2008-12-27 02:56:55 UTC (rev 1280)
@@ -50,10 +50,14 @@
if RLINK
LIBUSB = -lusb
else
+if VSLLINK
+LIBUSB = -lusb
+else
LIBUSB =
endif
endif
endif
+endif
Modified: trunk/src/jtag/Makefile.am
===================================================================
--- trunk/src/jtag/Makefile.am 2008-12-27 02:21:38 UTC (rev 1279)
+++ trunk/src/jtag/Makefile.am 2008-12-27 02:56:55 UTC (rev 1280)
@@ -96,7 +96,13 @@
RLINKFILES =
endif
+if VSLLINK
+VSLLINKFILES = vsllink.c
+else
+VSLLINKFILES =
+endif
+
libjtag_a_SOURCES = jtag.c $(BITBANGFILES) $(PARPORTFILES) $(DUMMYFILES) $(FT2232FILES) $(AMTJTAGACCELFILES) $(EP93XXFILES) \
- $(AT91RM9200FILES) $(GW16012FILES) $(BITQFILES) $(PRESTOFILES) $(USBPROGFILES) $(ECOSBOARDFILES) $(JLINKFILES) $(RLINKFILES)
+ $(AT91RM9200FILES) $(GW16012FILES) $(BITQFILES) $(PRESTOFILES) $(USBPROGFILES) $(ECOSBOARDFILES) $(JLINKFILES) $(RLINKFILES) $(VSLLINKFILES)
noinst_HEADERS = bitbang.h jtag.h
Modified: trunk/src/jtag/jtag.c
===================================================================
--- trunk/src/jtag/jtag.c 2008-12-27 02:21:38 UTC (rev 1279)
+++ trunk/src/jtag/jtag.c 2008-12-27 02:56:55 UTC (rev 1280)
@@ -196,6 +196,10 @@
extern jtag_interface_t jlink_interface;
#endif
+#if BUILD_VSLLINK == 1
+ extern jtag_interface_t vsllink_interface;
+#endif
+
#if BUILD_RLINK == 1
extern jtag_interface_t rlink_interface;
#endif
@@ -237,6 +241,9 @@
#if BUILD_JLINK == 1
&jlink_interface,
#endif
+#if BUILD_VSLLINK == 1
+ &vsllink_interface,
+#endif
#if BUILD_RLINK == 1
&rlink_interface,
#endif
Modified: trunk/testing/build.test1/Makefile.openocd
===================================================================
--- trunk/testing/build.test1/Makefile.openocd 2008-12-27 02:21:38 UTC (rev 1279)
+++ trunk/testing/build.test1/Makefile.openocd 2008-12-27 02:56:55 UTC (rev 1280)
@@ -40,7 +40,7 @@
CONFIG_OPTIONS_win32_libftdi = --enable-parport --enable-ft2232_libftdi
# Default build for win32... is the ftd2xx type build.
-PERMUTE_win32 ?= $(BUILD_SYSNAME)_ftd2xx
+PERMUTE_win32 ?= ftd2xx
CONFIG_OPTIONS_win32 ?= $(CONFIG_OPTIONS_win32_$(PERMUTE_win32))
CONFIG_OPTIONS_cygwin = $(CONFIG_OPTIONS_win32)
CONFIG_OPTIONS_mingw32 = $(CONFIG_OPTIONS_win32)
|
|
From: <du...@ma...> - 2008-12-27 03:21:43
|
Author: duane
Date: 2008-12-27 03:21:38 +0100 (Sat, 27 Dec 2008)
New Revision: 1279
Modified:
trunk/src/jtag/rlink/rlink.c
Log:
Warning removal from lou...@fi...
Modified: trunk/src/jtag/rlink/rlink.c
===================================================================
--- trunk/src/jtag/rlink/rlink.c 2008-12-27 02:18:06 UTC (rev 1278)
+++ trunk/src/jtag/rlink/rlink.c 2008-12-27 02:21:38 UTC (rev 1279)
@@ -132,7 +132,7 @@
usb_ret = usb_bulk_write(
pHDev,
USB_EP1OUT_ADDR,
- usb_buffer, sizeof(usb_buffer),
+ (char *)usb_buffer, sizeof(usb_buffer),
USB_TIMEOUT_MS
);
@@ -249,7 +249,7 @@
usb_ret = usb_bulk_write(
pHDev, USB_EP1OUT_ADDR,
- usb_buffer, sizeof(usb_buffer),
+ (char *)usb_buffer, sizeof(usb_buffer),
USB_TIMEOUT_MS
);
@@ -359,7 +359,7 @@
case DTCLOAD_ENTRY:
/* store entry addresses somewhere */
- if(!strncmp("download", buffer + 1, 8)) {
+ if(!strncmp("download", (char *)buffer + 1, 8)) {
dtc_entry_download = buffer[0];
}
break;
@@ -449,7 +449,7 @@
/* read back ep2txr */
usb_err = usb_bulk_read(
pHDev, USB_EP1IN_ADDR,
- &ep2txr, 1,
+ (char *)&ep2txr, 1,
USB_TIMEOUT_MS
);
if(usb_err < 0) return(usb_err);
@@ -476,7 +476,7 @@
/* wait for completion */
usb_err = usb_bulk_read(
pHDev, USB_EP1IN_ADDR,
- &ep2txr, 1,
+ (char *)&ep2txr, 1,
USB_TIMEOUT_MS
);
@@ -502,7 +502,7 @@
usb_err = usb_bulk_write(
pHDev,
USB_EP2OUT_ADDR,
- command_buffer, USB_EP2BANK_SIZE,
+ (char *)command_buffer, USB_EP2BANK_SIZE,
USB_TIMEOUT_MS
);
if(usb_err < 0) return(usb_err);
@@ -523,7 +523,7 @@
usb_err = usb_bulk_read(
pHDev,
USB_EP1IN_ADDR,
- ep2_buffer, 1,
+ (char *)ep2_buffer, 1,
USB_TIMEOUT_MS
);
if(usb_err < 0) return(usb_err);
@@ -544,7 +544,7 @@
usb_err = usb_bulk_read(
pHDev,
USB_EP2IN_ADDR,
- ep2_buffer, sizeof(ep2_buffer),
+ (char *)ep2_buffer, sizeof(ep2_buffer),
USB_TIMEOUT_MS
);
@@ -1662,7 +1662,7 @@
}
j = usb_bulk_read(
pHDev, USB_EP1IN_ADDR,
- reply_buffer, sizeof(reply_buffer),
+ (char *)reply_buffer, sizeof(reply_buffer),
200
);
if(j != -ETIMEDOUT) break;
@@ -1701,7 +1701,7 @@
usb_bulk_read(
pHDev, USB_EP1IN_ADDR,
- reply_buffer, 1,
+ (char *)reply_buffer, 1,
USB_TIMEOUT_MS
);
@@ -1726,7 +1726,7 @@
usb_bulk_read(
pHDev, USB_EP1IN_ADDR,
- reply_buffer, 1,
+ (char *)reply_buffer, 1,
USB_TIMEOUT_MS
);
|
|
From: <du...@ma...> - 2008-12-27 03:18:09
|
Author: duane
Date: 2008-12-27 03:18:06 +0100 (Sat, 27 Dec 2008)
New Revision: 1278
Modified:
trunk/doc/openocd.texi
Log:
From Dirk Behme - Further docu fixes
Modified: trunk/doc/openocd.texi
===================================================================
--- trunk/doc/openocd.texi 2008-12-27 01:44:29 UTC (rev 1277)
+++ trunk/doc/openocd.texi 2008-12-27 02:18:06 UTC (rev 1278)
@@ -1459,7 +1459,7 @@
@itemize @bullet
@item @b{-irlen NUMBER} - the length in bits of the instruction register
@item @b{-ircapture NUMBER} - the ID code capture command.
-@item @b{-irmask NUMBER} - the corrisponding mask for the ir register.
+@item @b{-irmask NUMBER} - the corresponding mask for the ir register.
@comment END REQUIRED
@end itemize
An example of a FOOBAR Tap
@@ -2399,14 +2399,12 @@
@section Daemon Commands
-@subsection sleep
-@b{sleep} <@var{msec}>
+@subsection sleep [@var{msec}]
@cindex sleep
@*Wait for n milliseconds before resuming. Useful in connection with script files
(@var{script} command and @var{target_script} configuration).
-@subsection sleep
-@b{shutdown}
+@subsection shutdown
@cindex shutdown
@*Close the OpenOCD daemon, disconnecting all clients (GDB, Telnet, Other).
@@ -2803,7 +2801,8 @@
example if you need to control a JTAG Route Controller (ie: the
OMAP3530 on the Beagle Board has one) you might use these commands in
a script or an event procedure.
-
+@section Commands
+@cindex Commands
@itemize @bullet
@item @b{scan_chain}
@cindex scan_chain
@@ -2837,7 +2836,45 @@
Display/modify variable field <@var{var}> <@var{field}> [@var{value}|@var{flip}].
@end itemize
+@section Tap states
+@cindex Tap states
+Available tap_states are:
+@itemize @bullet
+@item @b{RESET}
+@cindex RESET
+@item @b{IDLE}
+@cindex IDLE
+@item @b{DRSELECT}
+@cindex DRSELECT
+@item @b{DRCAPTURE}
+@cindex DRCAPTURE
+@item @b{DRSHIFT}
+@cindex DRSHIFT
+@item @b{DREXIT1}
+@cindex DREXIT1
+@item @b{DRPAUSE}
+@cindex DRPAUSE
+@item @b{DREXIT2}
+@cindex DREXIT2
+@item @b{DRUPDATE}
+@cindex DRUPDATE
+@item @b{IRSELECT}
+@cindex IRSELECT
+@item @b{IRCAPTURE}
+@cindex IRCAPTURE
+@item @b{IRSHIFT}
+@cindex IRSHIFT
+@item @b{IREXIT1}
+@cindex IREXIT1
+@item @b{IRPAUSE}
+@cindex IRPAUSE
+@item @b{IREXIT2}
+@cindex IREXIT2
+@item @b{IRUPDATE}
+@cindex IRUPDATE
+@end itemize
+
@node TFTP
@chapter TFTP
@cindex TFTP
|
|
From: <du...@ma...> - 2008-12-27 02:44:36
|
Author: duane
Date: 2008-12-27 02:44:29 +0100 (Sat, 27 Dec 2008)
New Revision: 1277
Added:
trunk/testing/build.test1/README.TXT
Modified:
trunk/testing/build.test1/Makefile
trunk/testing/build.test1/Makefile.libusb
Log:
Added documentation for build test case1
Modified: trunk/testing/build.test1/Makefile
===================================================================
--- trunk/testing/build.test1/Makefile 2008-12-27 01:30:06 UTC (rev 1276)
+++ trunk/testing/build.test1/Makefile 2008-12-27 01:44:29 UTC (rev 1277)
@@ -81,6 +81,13 @@
cd $(EXEC_PREFIX)/lib && ln -s libftd2xx.so.$(FTD2XX_LINUX_VERSION) libftd2xx.so
+all.download:
+ mkdir -p ${VIRGINS}
+ ${MAKE} -f Makefile.confuse download
+ ${MAKE} -f Makefile.libftdi download
+ ${MAKE} -f Makefile.ftd2xx download
+ ${MAKE} -f Makefile.libusb download
+
.PHONY: linux.buildtest \
linux.easy.buildtest \
linux.ftd2xx_installed \
@@ -88,3 +95,4 @@
linux.ftd2xx_installed.setup
+
Modified: trunk/testing/build.test1/Makefile.libusb
===================================================================
--- trunk/testing/build.test1/Makefile.libusb 2008-12-27 01:30:06 UTC (rev 1276)
+++ trunk/testing/build.test1/Makefile.libusb 2008-12-27 01:44:29 UTC (rev 1277)
@@ -10,8 +10,8 @@
$(error Please use the win32 specific port of LibUSB not the Unix version)
endif
-TARFILE_LOCAL = ${VIRGINS}/libusb-${LIBUSB_VERSION}.tar.bz2
-TARFILE_URL = http://downloads.sourceforge.net/libusb/libusb-${LIBUSB_VERSION}.tar.gz
+TARFILE_LOCAL = ${VIRGINS}/libusb-${LIBUSB_VERSION_linux}.tar.bz2
+TARFILE_URL = http://downloads.sourceforge.net/libusb/libusb-${LIBUSB_VERSION_linux}.tar.gz
LIBUSB_SRC_DIR = ${HERE}/libusb-${LIBUSB_VERSION}
LIBUSB_BUILD_DIR = ${HERE}/libusb-build
Added: trunk/testing/build.test1/README.TXT
===================================================================
--- trunk/testing/build.test1/README.TXT 2008-12-27 01:30:06 UTC (rev 1276)
+++ trunk/testing/build.test1/README.TXT 2008-12-27 01:44:29 UTC (rev 1277)
@@ -0,0 +1,39 @@
+-- Duane Ellis'es test case for building numerous openocd configurations...
+Dec 26,2008
+---------------------------------------------------------------------------
+
+1) Make a directory some where..
+
+ mkdir ~/test
+
+2) Change to that directory
+
+ cd ~/test
+
+3) Checkout OpenOCD in that directory.
+
+ cd ~/test
+ svn co https://svn.berlios.de/svnroot/repos/openocd/trunk openocd
+
+4) Copy the "build.test1" directory to the "~/work" directory.
+
+
+ cd ~/test
+ cp ~/openocd/testing/build.test1/. ~/test/.
+
+5) If needed, download various components.
+
+ cd ~/work
+ make all.download
+
+
+6) For Linux - type:
+
+ cd ~/work
+ make linux.buildtest
+
+7) For Cygwin - type:
+
+ cd ~/work
+ make cygwin.buildtest
+
Property changes on: trunk/testing/build.test1/README.TXT
___________________________________________________________________
Name: svn:executable
+ *
|