|
From: misc j. <mis...@gm...> - 2012-08-29 16:20:05
|
Tim, > Is the JSM peculiar to the SA470R1B1, or is it the same thing as the > TMS470R1B1? I'm currently using a setup that is supposed to be for the > TMS470R1B1. > > And is the JSM functionality a matter for the JTAG hardware, or for > OpenOCD? I could go back to trying to make the JLINK work, if Segger > supports the JSM. Here are some links that describe what you need to do in order to write to flash. http://www.ti.com/lit/an/spna099a/spna099a.pdf http://www.tij.co.jp/jp/lit/ug/spnu257/spnu257.pdf http://download.ronetix.info/peedi/cfg_examples/arm7/tms470.cfg http://e2e.ti.com/support/microcontrollers/hercules/f/407/t/97056.aspx I tried modifying the tms470.c file to support the r1b1m, but have been unsuccessful in programming the flash so far. It's not complete, but I'm including the patch below anyways. (the call to tms470_unlock_flash(bank) locks up for extended periods some times .. try commenting it out and seeing what happens). I also added the following to the reset-init event handler (based on pg 4 in spna099a.pdf <http://www.ti.com/lit/an/spna099a/spna099a.pdf>). $_TARGETNAME configure -event reset-init { mww 0xffffffe0 0x4007 mww 0xfffffe04 0xb0 mww 0xfffffe00 0x0 mww 0xfffffe08 0x0 mww 0xfffffe0c 0x0 mww 0xfffffe10 0x400 mww 0xfffffe14 0x470 mww 0xfffffe18 0x0 mww 0xfffffe1c 0x0 mww 0xfffffe20 0x80 mww 0xfffffe24 0x20 mww 0xfffffe04 0x1b0 #mww 0xfffff724 0x80000000 mdw 0xffe0 4 mww 0xfffff700 0xffffffff mww 0xfffff704 0xffffffff mww 0xfffff708 0xffffffff mww 0xfffff70c 0xffffffff mww 0xffffffdc 0x7 echo "did init" } --- tms470.c 2012-08-29 08:37:00.926086864 -0700 +++ tms470_modified.c 2012-08-29 08:52:25.030087277 -0700 @@ -118,6 +118,39 @@ static const struct flash_sector TMS470R #define TMS470R1A384_BANK2_NUM_SECTORS \ ARRAY_SIZE(TMS470R1A384_BANK2_SECTORS) + + +static const struct flash_sector TMS470R1B1M_BANK0_SECTORS[] = { + {0x00000000, 0x00010000, -1, -1}, + {0x00010000, 0x00010000, -1, -1}, + {0x00020000, 0x00010000, -1, -1}, + {0x00030000, 0x00010000, -1, -1}, + {0x00040000, 0x00010000, -1, -1}, + {0x00050000, 0x00010000, -1, -1}, + {0x00060000, 0x00010000, -1, -1}, + {0x00070000, 0x00010000, -1, -1}, +}; + +#define TMS470R1B1M_BANK0_NUM_SECTORS \ + ARRAY_SIZE(TMS470R1B1M_BANK0_SECTORS) + +static const struct flash_sector TMS470R1B1M_BANK1_SECTORS[] = { + {0x00080000, 0x00010000, -1, -1}, + {0x00090000, 0x00010000, -1, -1}, + {0x000a0000, 0x00010000, -1, -1}, + {0x000b0000, 0x00010000, -1, -1}, + {0x000c0000, 0x00010000, -1, -1}, + {0x000d0000, 0x00010000, -1, -1}, + {0x000e0000, 0x00010000, -1, -1}, + {0x000f0000, 0x00010000, -1, -1}, +}; + +#define TMS470R1B1M_BANK1_NUM_SECTORS \ + ARRAY_SIZE(TMS470R1B1M_BANK1_SECTORS) + + +uint32_t gMsmPasswordLocation = 0; + /* ---------------------------------------------------------------------- */ static int tms470_read_part_info(struct flash_bank *bank) @@ -168,7 +201,7 @@ static int tms470_read_part_info(struct { case 0x0a: part_name = "TMS470R1A256"; - + gMsmPasswordLocation = 0x1fe0; if (bank->base >= 0x00040000) { LOG_ERROR("No %s flash bank contains base address 0x%08" PRIx32 ".", part_name, bank->base); @@ -188,7 +221,7 @@ static int tms470_read_part_info(struct case 0x2b: part_name = "TMS470R1A288"; - + gMsmPasswordLocation = 0x1fe0; if (bank->base < 0x00008000) { tms470_info->ordinal = 0; @@ -224,7 +257,7 @@ static int tms470_read_part_info(struct case 0x2d: part_name = "TMS470R1A384"; - + gMsmPasswordLocation = 0x1fe0; if (bank->base < 0x00020000) { tms470_info->ordinal = 0; @@ -271,6 +304,44 @@ static int tms470_read_part_info(struct } break; + + + case 0x4b: + part_name = "TMS470R1B1M"; + gMsmPasswordLocation = 0xffe0; + if (bank->base < 0x00080000) + { + tms470_info->ordinal = 0; + bank->base = 0x00000000; + bank->size = 512 * 1024; + bank->num_sectors = TMS470R1B1M_BANK0_NUM_SECTORS; + bank->sectors = malloc(sizeof(TMS470R1B1M_BANK0_SECTORS)); + if (!bank->sectors) + { + return ERROR_FLASH_OPERATION_FAILED; + } + (void)memcpy(bank->sectors, TMS470R1B1M_BANK0_SECTORS, sizeof(TMS470R1B1M_BANK0_SECTORS)); + } + else if ((bank->base >= 0x00080000) && (bank->base < 0x00100000)) + { + tms470_info->ordinal = 1; + bank->base = 0x00080000; + bank->size = 512 * 1024; + bank->num_sectors = TMS470R1B1M_BANK1_NUM_SECTORS; + bank->sectors = malloc(sizeof(TMS470R1B1M_BANK1_SECTORS)); + if (!bank->sectors) + { + return ERROR_FLASH_OPERATION_FAILED; + } + (void)memcpy(bank->sectors, TMS470R1B1M_BANK1_SECTORS, sizeof(TMS470R1B1M_BANK1_SECTORS)); + } + else + { + LOG_ERROR("No %s flash bank contains base address 0x%08" PRIx32 ".", part_name, bank->base); + return ERROR_FLASH_OPERATION_FAILED; + } + break; + default: LOG_WARNING("Could not identify part 0x%02x as a member of the TMS470 family.", (unsigned)part_number); return ERROR_FLASH_OPERATION_FAILED; @@ -467,6 +538,10 @@ static int tms470_try_flash_keys(struct target_read_u32(target, 0xFFE89C00, &orig_fmregopt); target_write_u32(target, 0xFFE89C00, 0x00); + if (gMsmPasswordLocation == 0) + { + return ERROR_FLASH_OPER_UNSUPPORTED; + } for (i = 0; i < 4; i++) { uint32_t tmp; @@ -475,7 +550,7 @@ static int tms470_try_flash_keys(struct * filtered by the chip. The purpose of this read is to * prime the unlocking logic rather than read out the value. */ - target_read_u32(target, 0x00001FF0 + 4 * i, &tmp); + target_read_u32(target, gMsmPasswordLocation + 4 * i, &tmp); LOG_INFO("tms470 writing fmpkey = 0x%08" PRIx32 "", key_set[i]); target_write_u32(target, 0xFFE89C0C, key_set[i]); @@ -492,7 +567,7 @@ static int tms470_try_flash_keys(struct { uint32_t tmp; - target_read_u32(target, 0x00001FF0 + 4 * i, &tmp); + target_read_u32(target, gMsmPasswordLocation + 4 * i, &tmp); target_write_u32(target, 0xFFE89C0C, key_set[i]); } retval = ERROR_OK; @@ -984,12 +1059,13 @@ static int tms470_write(struct flash_ban tms470_read_part_info(bank); - LOG_INFO("Writing %" PRId32 " bytes starting at 0x%08" PRIx32 "", count, bank->base + offset); - /* set GLBCTRL.4 */ target_read_u32(target, 0xFFFFFFDC, &glbctrl); target_write_u32(target, 0xFFFFFFDC, glbctrl | 0x10); + + LOG_INFO("Writing %" PRId32 " bytes starting at 0x%08" PRIx32 "", count, bank->base + offset); + (void)tms470_flash_initialize_internal_state_machine(bank); /* force max wait states */ @@ -1008,6 +1084,8 @@ static int tms470_write(struct flash_ban target_read_u32(target, 0xFFE8800C, &fmbseb); target_write_u32(target, 0xFFE8800C, 0xffff); + tms470_unlock_flash(bank); + /* read MAXPP */ target_read_u32(target, 0xFFE8A07C, &fmmaxpp); @@ -1290,4 +1368,3 @@ struct flash_driver tms470_flash = { .protect_check = tms470_protect_check, .info = get_tms470_info, }; - |