flash/nor: improved API of flash_driver.info & fixed buffer overruns
[openocd.git] / src / flash / nor / at91sam4.c
index 5b56c42415035bcd2fd2599583477736e7c8d6cd..b7ae7f69132ffb9009815d19a28944910e4548e5 100644 (file)
@@ -22,7 +22,7 @@
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ****************************************************************************/
 
-/* Some of the the lower level code was based on code supplied by
+/* Some of the lower level code was based on code supplied by
  * ATMEL under this copyright. */
 
 /* BEGIN ATMEL COPYRIGHT */
@@ -166,7 +166,7 @@ struct sam4_cfg {
 };
 
 struct sam4_bank_private {
-       int probed;
+       bool probed;
        /* DANGER: THERE ARE DRAGONS HERE.. */
        /* NOTE: If you add more 'ghost' pointers */
        /* be aware that you must *manually* update */
@@ -212,7 +212,7 @@ struct sam4_chip_details {
 
 struct sam4_chip {
        struct sam4_chip *next;
-       int probed;
+       bool probed;
 
        /* this is "initialized" from the global const structure */
        struct sam4_chip_details details;
@@ -235,7 +235,7 @@ static struct sam4_chip *get_current_sam4(struct command_invocation *cmd)
 
        t = get_current_target(cmd->ctx);
        if (!t) {
-               command_print(cmd, "No current target?");
+               command_print_sameline(cmd, "No current target?\n");
                return NULL;
        }
 
@@ -243,7 +243,7 @@ static struct sam4_chip *get_current_sam4(struct command_invocation *cmd)
        if (!p) {
                /* this should not happen */
                /* the command is not registered until the chip is created? */
-               command_print(cmd, "No SAM4 chips exist?");
+               command_print_sameline(cmd, "No SAM4 chips exist?\n");
                return NULL;
        }
 
@@ -252,7 +252,7 @@ static struct sam4_chip *get_current_sam4(struct command_invocation *cmd)
                        return p;
                p = p->next;
        }
-       command_print(cmd, "Cannot find SAM4 chip?");
+       command_print_sameline(cmd, "Cannot find SAM4 chip?\n");
        return NULL;
 }
 
@@ -275,14 +275,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 /*             .bank[0] = { */
                {
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK0_BASE_C32,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  1024 * 1024,
                                .nsectors   =  128,
                                .sector_size = 8192,
@@ -290,14 +290,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                        },
 /*             .bank[1] = { */
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 1,
                                .base_address = FLASH_BANK1_BASE_C32,
                                .controller_address = 0x400e0c00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  1024 * 1024,
                                .nsectors   =  128,
                                .sector_size = 8192,
@@ -316,14 +316,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 /*             .bank[0] = { */
                {
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK0_BASE_C32,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  1024 * 1024,
                                .nsectors   =  128,
                                .sector_size = 8192,
@@ -331,14 +331,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                        },
 /*             .bank[1] = { */
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 1,
                                .base_address = FLASH_BANK1_BASE_C32,
                                .controller_address = 0x400e0c00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  1024 * 1024,
                                .nsectors   =  128,
                                .sector_size = 8192,
@@ -357,14 +357,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_C,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -372,8 +372,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -390,14 +390,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_C,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  512 * 1024,
                        .nsectors   =  64,
                        .sector_size = 8192,
@@ -405,8 +405,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -423,14 +423,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_C,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  256 * 1024,
                        .nsectors   =  32,
                        .sector_size = 8192,
@@ -438,8 +438,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -458,14 +458,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -473,8 +473,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -493,14 +493,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  512 * 1024,
                        .nsectors   =  64,
                        .sector_size = 8192,
@@ -508,8 +508,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -526,14 +526,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  512 * 1024,
                        .nsectors   =  64,
                        .sector_size = 8192,
@@ -541,8 +541,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -559,14 +559,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  512 * 1024,
                        .nsectors   =  64,
                        .sector_size = 8192,
@@ -574,8 +574,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -592,14 +592,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -607,8 +607,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -625,14 +625,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -640,8 +640,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -660,14 +660,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -675,8 +675,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -694,14 +694,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 /*             .bank[0] = { */
                {
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -709,8 +709,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -727,14 +727,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -742,8 +742,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -760,14 +760,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -775,8 +775,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -793,14 +793,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  1024 * 1024,
                        .nsectors   =  128,
                        .sector_size = 8192,
@@ -808,8 +808,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -826,14 +826,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  512 * 1024,
                        .nsectors   =  64,
                        .sector_size = 8192,
@@ -841,8 +841,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -859,14 +859,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  512 * 1024,
                        .nsectors   =  64,
                        .sector_size = 8192,
@@ -874,8 +874,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -892,14 +892,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  512 * 1024,
                        .nsectors   =  64,
                        .sector_size = 8192,
@@ -907,8 +907,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -926,14 +926,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  256 * 1024,
                        .nsectors   =  32,
                        .sector_size = 8192,
@@ -941,8 +941,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -960,14 +960,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  256 * 1024,
                        .nsectors   =  32,
                        .sector_size = 8192,
@@ -975,8 +975,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -994,14 +994,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  256 * 1024,
                        .nsectors   =  32,
                        .sector_size = 8192,
@@ -1009,8 +1009,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -1028,14 +1028,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  128 * 1024,
                        .nsectors   =  16,
                        .sector_size = 8192,
@@ -1043,8 +1043,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -1062,14 +1062,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  128 * 1024,
                        .nsectors   =  16,
                        .sector_size = 8192,
@@ -1077,8 +1077,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -1096,14 +1096,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*             .bank[0] = {*/
                  {
-                       .probed = 0,
+                       .probed = false,
                        .pChip  = NULL,
                        .pBank  = NULL,
                        .bank_number = 0,
                        .base_address = FLASH_BANK_BASE_S,
                        .controller_address = 0x400e0a00,
                        .flash_wait_states = 5,
-                       .present = 1,
+                       .present = true,
                        .size_bytes =  128 * 1024,
                        .nsectors   =  16,
                        .sector_size = 8192,
@@ -1111,8 +1111,8 @@ static const struct sam4_chip_details all_sam4_details[] = {
                  },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
@@ -1131,14 +1131,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 /*             .bank[0] = { */
                {
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK0_BASE_SD,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  1024 * 1024,
                                .nsectors   =  128,
                                .sector_size = 8192,
@@ -1147,14 +1147,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 
 /*             .bank[1] = { */
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 1,
                                .base_address = FLASH_BANK1_BASE_2048K_SD,
                                .controller_address = 0x400e0c00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  1024 * 1024,
                                .nsectors   =  128,
                                .sector_size = 8192,
@@ -1175,14 +1175,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 /*             .bank[0] = { */
                {
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK0_BASE_SD,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  1024 * 1024,
                                .nsectors   =  128,
                                .sector_size = 8192,
@@ -1191,14 +1191,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 
 /*             .bank[1] = { */
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 1,
                                .base_address = FLASH_BANK1_BASE_2048K_SD,
                                .controller_address = 0x400e0c00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  1024 * 1024,
                                .nsectors   =  128,
                                .sector_size = 8192,
@@ -1219,14 +1219,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 /*             .bank[0] = { */
                {
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK0_BASE_SD,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  512 * 1024,
                                .nsectors   =  64,
                                .sector_size = 8192,
@@ -1235,14 +1235,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 
 /*             .bank[1] = { */
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 1,
                                .base_address = FLASH_BANK1_BASE_1024K_SD,
                                .controller_address = 0x400e0c00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  512 * 1024,
                                .nsectors   =  64,
                                .sector_size = 8192,
@@ -1263,14 +1263,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 /*             .bank[0] = { */
                {
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK0_BASE_SD,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  512 * 1024,
                                .nsectors   =  64,
                                .sector_size = 8192,
@@ -1279,14 +1279,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 
 /*             .bank[1] = { */
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 1,
                                .base_address = FLASH_BANK1_BASE_1024K_SD,
                                .controller_address = 0x400e0c00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  512 * 1024,
                                .nsectors   =  64,
                                .sector_size = 8192,
@@ -1307,14 +1307,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
 /*             .bank[0] = {*/
                {
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK_BASE_S,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  512 * 1024,
                                .nsectors   =  64,
                                .sector_size = 8192,
@@ -1322,15 +1322,15 @@ static const struct sam4_chip_details all_sam4_details[] = {
                        },
 /*             .bank[1] = {*/
                  {
-                       .present = 0,
-                       .probed = 0,
+                       .present = false,
+                       .probed = false,
                        .bank_number = 1,
 
                  },
                }
        },
 
-       /* atsamg55g19 */
+       /* atsamg55g19 Rev.A */
        {
                .chipid_cidr    = 0x24470ae0,
                .name           = "atsamg55g19",
@@ -1342,14 +1342,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*                     .bank[0] = */
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK_BASE_S,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  512 * 1024,
                                .nsectors   =  64,
                                .sector_size = 8192,
@@ -1357,14 +1357,48 @@ static const struct sam4_chip_details all_sam4_details[] = {
                        },
 /*                     .bank[1] = */
                        {
-                               .present = 0,
-                               .probed = 0,
+                               .present = false,
+                               .probed = false,
                                .bank_number = 1,
                        },
                }
        },
 
-       /* atsamg55j19 */
+       /* atsamg55g19 Rev.B */
+       {
+               .chipid_cidr    = 0x24470ae1,
+               .name           = "atsamg55g19b",
+               .total_flash_size     = 512 * 1024,
+               .total_sram_size      = 160 * 1024,
+               .n_gpnvms       = 2,
+               .n_banks        = 1,
+
+               {
+/*                     .bank[0] = */
+                       {
+                               .probed = false,
+                               .pChip  = NULL,
+                               .pBank  = NULL,
+                               .bank_number = 0,
+                               .base_address = FLASH_BANK_BASE_S,
+                               .controller_address = 0x400e0a00,
+                               .flash_wait_states = 5,
+                               .present = true,
+                               .size_bytes =  512 * 1024,
+                               .nsectors   =  64,
+                               .sector_size = 8192,
+                               .page_size   = 512,
+                       },
+/*                     .bank[1] = */
+                       {
+                               .present = false,
+                               .probed = false,
+                               .bank_number = 1,
+                       },
+               }
+       },
+
+       /* atsamg55j19 Rev.A */
        {
                .chipid_cidr    = 0x24570ae0,
                .name           = "atsamg55j19",
@@ -1376,14 +1410,14 @@ static const struct sam4_chip_details all_sam4_details[] = {
                {
 /*                     .bank[0] = */
                        {
-                               .probed = 0,
+                               .probed = false,
                                .pChip  = NULL,
                                .pBank  = NULL,
                                .bank_number = 0,
                                .base_address = FLASH_BANK_BASE_S,
                                .controller_address = 0x400e0a00,
                                .flash_wait_states = 5,
-                               .present = 1,
+                               .present = true,
                                .size_bytes =  512 * 1024,
                                .nsectors   =  64,
                                .sector_size = 8192,
@@ -1391,8 +1425,42 @@ static const struct sam4_chip_details all_sam4_details[] = {
                        },
 /*                     .bank[1] = */
                        {
-                               .present = 0,
-                               .probed = 0,
+                               .present = false,
+                               .probed = false,
+                               .bank_number = 1,
+                       },
+               }
+       },
+
+       /* atsamg55j19 Rev.B */
+       {
+               .chipid_cidr    = 0x24570ae1,
+               .name           = "atsamg55j19b",
+               .total_flash_size     = 512 * 1024,
+               .total_sram_size      = 160 * 1024,
+               .n_gpnvms       = 2,
+               .n_banks        = 1,
+
+               {
+/*                     .bank[0] = */
+                       {
+                               .probed = false,
+                               .pChip  = NULL,
+                               .pBank  = NULL,
+                               .bank_number = 0,
+                               .base_address = FLASH_BANK_BASE_S,
+                               .controller_address = 0x400e0a00,
+                               .flash_wait_states = 5,
+                               .present = true,
+                               .size_bytes =  512 * 1024,
+                               .nsectors   =  64,
+                               .sector_size = 8192,
+                               .page_size   = 512,
+                       },
+/*                     .bank[1] = */
+                       {
+                               .present = false,
+                               .probed = false,
                                .bank_number = 1,
                        },
                }
@@ -1641,6 +1709,9 @@ static int FLASHD_EraseEntireBank(struct sam4_bank_private *pPrivate)
 /**
  * Erases the entire flash.
  * @param pPrivate - the info about the bank.
+ * @param firstPage
+ * @param numPages
+ * @param status
  */
 static int FLASHD_ErasePages(struct sam4_bank_private *pPrivate,
                                                         int firstPage,
@@ -1896,7 +1967,7 @@ static uint32_t sam4_reg_fieldname(struct sam4_chip *pChip,
        }
 
        /* show the basics */
-       LOG_USER_N("\t%*s: %*" PRId32 " [0x%0*" PRIx32 "] ",
+       LOG_USER_N("\t%*s: %*" PRIu32 " [0x%0*" PRIx32 "] ",
                REG_NAME_WIDTH, regname,
                dwidth, v,
                hwidth, v);
@@ -2472,7 +2543,7 @@ FLASH_BANK_COMMAND_HANDLER(sam4_flash_bank_command)
                pChip->target = bank->target;
                /* assumption is this runs at 32khz */
                pChip->cfg.slow_freq = 32768;
-               pChip->probed = 0;
+               pChip->probed = false;
        }
 
        switch (bank->base) {
@@ -2509,7 +2580,7 @@ FLASH_BANK_COMMAND_HANDLER(sam4_flash_bank_command)
 }
 
 /**
- * Remove all chips from the internal list without distingushing which one
+ * Remove all chips from the internal list without distinguishing which one
  * is owned by this bank. This simplification works only for one shot
  * deallocation like current flash_free_all_banks()
  */
@@ -2549,7 +2620,7 @@ static int sam4_GetDetails(struct sam4_bank_private *pPrivate)
                sam4_explain_chipid_cidr(pPrivate->pChip);
                return ERROR_FAIL;
        } else {
-               LOG_DEBUG("SAM4 Found chip %s, CIDR 0x%08x", pDetails->name, pDetails->chipid_cidr);
+               LOG_DEBUG("SAM4 Found chip %s, CIDR 0x%08" PRIx32, pDetails->name, pDetails->chipid_cidr);
        }
 
        /* DANGER: THERE ARE DRAGONS HERE */
@@ -2585,19 +2656,16 @@ static int sam4_GetDetails(struct sam4_bank_private *pPrivate)
        return ERROR_OK;
 }
 
-static int sam4_info(struct flash_bank *bank, char *buf, int buf_size)
+static int sam4_info(struct flash_bank *bank, struct command_invocation *cmd)
 {
        struct sam4_bank_private *pPrivate;
        int k = bank->size / 1024;
 
        pPrivate = get_sam4_bank_private(bank);
-       if (pPrivate == NULL) {
-               buf[0] = '\0';
+       if (pPrivate == NULL)
                return ERROR_FAIL;
-       }
 
-       snprintf(buf, buf_size,
-               "%s bank %d: %d kB at " TARGET_ADDR_FMT,
+       command_print_sameline(cmd, "%s bank %d: %d kB at " TARGET_ADDR_FMT,
                pPrivate->pChip->details.name,
                pPrivate->bank_number,
                k,
@@ -2608,12 +2676,11 @@ static int sam4_info(struct flash_bank *bank, char *buf, int buf_size)
 
 static int sam4_probe(struct flash_bank *bank)
 {
-       unsigned x;
        int r;
        struct sam4_bank_private *pPrivate;
 
 
-       LOG_DEBUG("Begin: Bank: %d", bank->bank_number);
+       LOG_DEBUG("Begin: Bank: %u", bank->bank_number);
        if (bank->target->state != TARGET_HALTED) {
                LOG_ERROR("Target not halted");
                return ERROR_TARGET_NOT_HALTED;
@@ -2638,7 +2705,7 @@ static int sam4_probe(struct flash_bank *bank)
                return r;
 
        /* update the flash bank size */
-       for (x = 0; x < SAM4_MAX_FLASH_BANKS; x++) {
+       for (unsigned int x = 0; x < SAM4_MAX_FLASH_BANKS; x++) {
                if (bank->base == pPrivate->pChip->details.bank[x].base_address) {
                        bank->size = pPrivate->pChip->details.bank[x].size_bytes;
                        LOG_DEBUG("SAM4 Set flash bank to " TARGET_ADDR_FMT " - "
@@ -2656,7 +2723,7 @@ static int sam4_probe(struct flash_bank *bank)
                }
                bank->num_sectors = pPrivate->nsectors;
 
-               for (x = 0; ((int)(x)) < bank->num_sectors; x++) {
+               for (unsigned int x = 0; x < bank->num_sectors; x++) {
                        bank->sectors[x].size = pPrivate->sector_size;
                        bank->sectors[x].offset = x * (pPrivate->sector_size);
                        /* mark as unknown */
@@ -2665,7 +2732,7 @@ static int sam4_probe(struct flash_bank *bank)
                }
        }
 
-       pPrivate->probed = 1;
+       pPrivate->probed = true;
 
        r = sam4_protect_check(bank);
        if (r != ERROR_OK)
@@ -2693,11 +2760,11 @@ static int sam4_auto_probe(struct flash_bank *bank)
        return sam4_probe(bank);
 }
 
-static int sam4_erase(struct flash_bank *bank, int first, int last)
+static int sam4_erase(struct flash_bank *bank, unsigned int first,
+               unsigned int last)
 {
        struct sam4_bank_private *pPrivate;
        int r;
-       int i;
        int pageCount;
        /*16 pages equals 8KB - Same size as a lock region*/
        pageCount = 16;
@@ -2719,26 +2786,26 @@ static int sam4_erase(struct flash_bank *bank, int first, int last)
        if (!(pPrivate->probed))
                return ERROR_FLASH_BANK_NOT_PROBED;
 
-       if ((first == 0) && ((last + 1) == ((int)(pPrivate->nsectors)))) {
+       if ((first == 0) && ((last + 1) == pPrivate->nsectors)) {
                /* whole chip */
                LOG_DEBUG("Here");
                return FLASHD_EraseEntireBank(pPrivate);
        }
        LOG_INFO("sam4 does not auto-erase while programming (Erasing relevant sectors)");
-       LOG_INFO("sam4 First: 0x%08x Last: 0x%08x", (unsigned int)(first), (unsigned int)(last));
-       for (i = first; i <= last; i++) {
+       LOG_INFO("sam4 First: 0x%08x Last: 0x%08x", first, last);
+       for (unsigned int i = first; i <= last; i++) {
                /*16 pages equals 8KB - Same size as a lock region*/
                r = FLASHD_ErasePages(pPrivate, (i * pageCount), pageCount, &status);
-               LOG_INFO("Erasing sector: 0x%08x", (unsigned int)(i));
+               LOG_INFO("Erasing sector: 0x%08x", i);
                if (r != ERROR_OK)
-                       LOG_ERROR("SAM4: Error performing Erase page @ lock region number %d",
-                               (unsigned int)(i));
+                       LOG_ERROR("SAM4: Error performing Erase page @ lock region number %u",
+                               i);
                if (status & (1 << 2)) {
-                       LOG_ERROR("SAM4: Lock Region %d is locked", (unsigned int)(i));
+                       LOG_ERROR("SAM4: Lock Region %u is locked", i);
                        return ERROR_FAIL;
                }
                if (status & (1 << 1)) {
-                       LOG_ERROR("SAM4: Flash Command error @lock region %d", (unsigned int)(i));
+                       LOG_ERROR("SAM4: Flash Command error @lock region %u", i);
                        return ERROR_FAIL;
                }
        }
@@ -2746,7 +2813,8 @@ static int sam4_erase(struct flash_bank *bank, int first, int last)
        return ERROR_OK;
 }
 
-static int sam4_protect(struct flash_bank *bank, int set, int first, int last)
+static int sam4_protect(struct flash_bank *bank, int set, unsigned int first,
+               unsigned int last)
 {
        struct sam4_bank_private *pPrivate;
        int r;
@@ -2762,9 +2830,9 @@ static int sam4_protect(struct flash_bank *bank, int set, int first, int last)
                return ERROR_FLASH_BANK_NOT_PROBED;
 
        if (set)
-               r = FLASHD_Lock(pPrivate, (unsigned)(first), (unsigned)(last));
+               r = FLASHD_Lock(pPrivate, first, last);
        else
-               r = FLASHD_Unlock(pPrivate, (unsigned)(first), (unsigned)(last));
+               r = FLASHD_Unlock(pPrivate, first, last);
        LOG_DEBUG("End: r=%d", r);
 
        return r;
@@ -2873,7 +2941,7 @@ static int sam4_write(struct flash_bank *bank,
        struct sam4_bank_private *pPrivate;
        uint8_t *pagebuffer;
 
-       /* incase we bail further below, set this to null */
+       /* in case we bail further below, set this to null */
        pagebuffer = NULL;
 
        /* ignore dumb requests */
@@ -3009,8 +3077,7 @@ static int sam4_write(struct flash_bank *bank,
        LOG_DEBUG("Done!");
        r = ERROR_OK;
 done:
-       if (pagebuffer)
-               free(pagebuffer);
+       free(pagebuffer);
        return r;
 }
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)