]> git.sur5r.net Git - openocd/commitdiff
- fix programming issue with lpc2101/2
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 14 Feb 2008 18:32:52 +0000 (18:32 +0000)
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 14 Feb 2008 18:32:52 +0000 (18:32 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@296 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/flash/lpc2000.c
src/flash/lpc2000.h

index d887c80565db50f759c5290590997677c64d9b09..1f689cc5305e2bd5fd12e6b769158f89b4f42e67 100644 (file)
@@ -91,7 +91,10 @@ int lpc2000_register_commands(struct command_context_s *cmd_ctx)
 int lpc2000_build_sector_list(struct flash_bank_s *bank)
 {
        lpc2000_flash_bank_t *lpc2000_info = bank->driver_priv;
-
+       
+       /* default to a 4096 write buffer */
+       lpc2000_info->cmd51_max_buffer = 4096;
+       
        if (lpc2000_info->variant == 1)
        {
                int i = 0;
@@ -156,7 +159,12 @@ int lpc2000_build_sector_list(struct flash_bank_s *bank)
                /* variant 2 has a uniform layout, only number of sectors differs */
                switch (bank->size)
                {
+                       case 4 * 1024:
+                               lpc2000_info->cmd51_max_buffer = 1024;
+                               num_sectors = 1;
+                               break;
                        case 8 * 1024:
+                               lpc2000_info->cmd51_max_buffer = 1024;
                                num_sectors = 2;
                                break;
                        case 16 * 1024:
@@ -484,7 +492,7 @@ int lpc2000_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
        }
        
        /* allocate a working area */
-       if (target_alloc_working_area(target, 4096, &download_area) != ERROR_OK)
+       if (target_alloc_working_area(target, lpc2000_info->cmd51_max_buffer, &download_area) != ERROR_OK)
        {
                ERROR("no working area specified, can't write LPC2000 internal flash");
                return ERROR_FLASH_OPERATION_FAILED;
@@ -533,8 +541,8 @@ int lpc2000_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
        while (bytes_remaining > 0)
        {
                u32 thisrun_bytes;
-               if (bytes_remaining >= 4096)
-                       thisrun_bytes = 4096;
+               if (bytes_remaining >= lpc2000_info->cmd51_max_buffer)
+                       thisrun_bytes = lpc2000_info->cmd51_max_buffer;
                else if (bytes_remaining >= 1024)
                        thisrun_bytes = 1024;
                else if ((bytes_remaining >= 512) || (!lpc2000_info->cmd51_can_256b))
index bf7358f6cb0ae3d4c48b72545505a2463eaf1804..976ac91920687387b1b17433a18165896901cd56 100644 (file)
@@ -32,6 +32,7 @@ typedef struct lpc2000_flash_bank_s
        int cmd51_can_256b;
        int cmd51_can_8192b;
        int calc_checksum;
+       int cmd51_max_buffer;
 } lpc2000_flash_bank_t;
 
 enum lpc2000_status_codes