X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Faduc702x.c;h=02270aefbdc3adb3bc60a7229166122304d0760d;hp=69c8274a0c0b3a6375a8cf994ff01111d0cc9871;hb=a17907d1067be45bd2aa4cc9bd108eccaf2e4df2;hpb=0073e7a69e55eb435fc2e274ba245a27779963e4 diff --git a/src/flash/nor/aduc702x.c b/src/flash/nor/aduc702x.c index 69c8274a0c..02270aefbd 100644 --- a/src/flash/nor/aduc702x.c +++ b/src/flash/nor/aduc702x.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include static int aduc702x_build_sector_list(struct flash_bank *bank); @@ -105,19 +105,19 @@ static int aduc702x_erase(struct flash_bank *bank, int first, int last) /* mass erase */ if (((first | last) == 0) || ((first == 0) && (last >= bank->num_sectors))) { - LOG_DEBUG("performing mass erase.\n"); + LOG_DEBUG("performing mass erase."); target_write_u16(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEDAT, 0x3cff); target_write_u16(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEADR, 0xffc3); target_write_u8(target, ADUC702x_FLASH + ADUC702x_FLASH_FEECON, 0x06); if (aduc702x_check_flash_completion(target, 3500) != ERROR_OK) { - LOG_ERROR("mass erase failed\n"); + LOG_ERROR("mass erase failed"); aduc702x_set_write_enable(target, 0); return ERROR_FLASH_OPERATION_FAILED; } - LOG_DEBUG("mass erase successful.\n"); + LOG_DEBUG("mass erase successful."); return ERROR_OK; } else { unsigned long adr; @@ -132,12 +132,12 @@ static int aduc702x_erase(struct flash_bank *bank, int first, int last) if (aduc702x_check_flash_completion(target, 50) != ERROR_OK) { - LOG_ERROR("failed to erase sector at address 0x%08lX\n", adr); + LOG_ERROR("failed to erase sector at address 0x%08lX", adr); aduc702x_set_write_enable(target, 0); return ERROR_FLASH_SECTOR_NOT_ERASED; } - LOG_DEBUG("erased sector at address 0x%08lX\n", adr); + LOG_DEBUG("erased sector at address 0x%08lX", adr); } } @@ -165,7 +165,7 @@ static int aduc702x_write_block(struct flash_bank *bank, uint8_t *buffer, uint32 struct working_area *source; uint32_t address = bank->base + offset; struct reg_param reg_params[6]; - struct armv4_5_algorithm armv4_5_info; + struct arm_algorithm armv4_5_info; int retval = ERROR_OK; if (((count%2)!=0)||((offset%2)!=0)) @@ -188,7 +188,7 @@ static int aduc702x_write_block(struct flash_bank *bank, uint8_t *buffer, uint32 r6 - set to 2, used to write flash command */ - uint32_t aduc702x_flash_write_code[] = { + static const uint32_t aduc702x_flash_write_code[] = { //<_start>: 0xe3a05008, // mov r5, #8 ; 0x8 0xe5845004, // str r5, [r4, #4] @@ -227,7 +227,7 @@ static int aduc702x_write_block(struct flash_bank *bank, uint8_t *buffer, uint32 } /* memory buffer */ - while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK) + while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) @@ -241,7 +241,7 @@ static int aduc702x_write_block(struct flash_bank *bank, uint8_t *buffer, uint32 } } - armv4_5_info.common_magic = ARMV4_5_COMMON_MAGIC; + armv4_5_info.common_magic = ARM_COMMON_MAGIC; armv4_5_info.core_mode = ARM_MODE_SVC; armv4_5_info.core_state = ARM_STATE_ARM; @@ -330,20 +330,20 @@ static int aduc702x_write_single(struct flash_bank *bank, uint8_t *buffer, uint3 if (aduc702x_check_flash_completion(target, 1) != ERROR_OK) { - LOG_ERROR("single write failed for address 0x%08lX\n", (unsigned long)(offset + x)); + LOG_ERROR("single write failed for address 0x%08lX", (unsigned long)(offset + x)); aduc702x_set_write_enable(target, 0); return ERROR_FLASH_OPERATION_FAILED; } } - LOG_DEBUG("wrote %d bytes at address 0x%08lX\n", (int)count, (unsigned long)(offset + x)); + LOG_DEBUG("wrote %d bytes at address 0x%08lX", (int)count, (unsigned long)(offset + x)); aduc702x_set_write_enable(target, 0); return ERROR_OK; } -int aduc702x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) +static int aduc702x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) { int retval; @@ -412,14 +412,15 @@ static int aduc702x_check_flash_completion(struct target* target, unsigned int t } struct flash_driver aduc702x_flash = { - .name = "aduc702x", - .flash_bank_command = &aduc702x_flash_bank_command, - .erase = &aduc702x_erase, - .protect = &aduc702x_protect, - .write = &aduc702x_write, - .probe = &aduc702x_probe, - .auto_probe = &aduc702x_probe, - .erase_check = &default_flash_blank_check, - .protect_check = &aduc702x_protect_check, - .info = &aduc702x_info - }; + .name = "aduc702x", + .flash_bank_command = aduc702x_flash_bank_command, + .erase = aduc702x_erase, + .protect = aduc702x_protect, + .write = aduc702x_write, + .read = default_flash_read, + .probe = aduc702x_probe, + .auto_probe = aduc702x_probe, + .erase_check = default_flash_blank_check, + .protect_check = aduc702x_protect_check, + .info = aduc702x_info +};