}
 
 int flash_command_get_bank_by_num(
-       struct command_context_s *cmd_ctx, char *str, flash_bank_t **bank)
+       struct command_context_s *cmd_ctx, const char *str, flash_bank_t **bank)
 {
        unsigned bank_num;
        COMMAND_PARSE_NUMBER(uint, str, bank_num);
 
  * @returns ERROR_OK on success, or an error indicating the problem.
  */
 int flash_command_get_bank_by_num(struct command_context_s *cmd_ctx,
-               char *str, flash_bank_t **bank);
+               const char *str, flash_bank_t **bank);
 /**
  * Returns the flash bank like get_flash_bank_by_num(), without probing.
  * @param num The flash bank number.
 
 
        /* Try and open the file */
        fileio_t fileio;
-       char *filename = args[1];
+       const char *filename = args[1];
        int ret = fileio_open( &fileio, filename, FILEIO_WRITE, FILEIO_BINARY );
        if( ret != ERROR_OK )
        {
        image.base_address = 0;
        image.start_address_set = 0;
 
-       char *filename = args[1];
-       char *type = (argc >= 3) ? args[2] : NULL;
+       const char *filename = args[1];
+       const char *type = (argc >= 3) ? args[2] : NULL;
        retval = image_open(&image, filename, type);
        if (retval != ERROR_OK)
        {
 
 }
 
 int nand_command_get_device_by_num(struct command_context_s *cmd_ctx,
-               char *str, nand_device_t **device)
+               const char *str, nand_device_t **device)
 {
        unsigned num;
        COMMAND_PARSE_NUMBER(uint, str, num);
 
 
 /// helper for parsing a nand device command argument string
 int nand_command_get_device_by_num(struct command_context_s *cmd_ctx,
-               char *str, nand_device_t **device);
+               const char *str, nand_device_t **device);
 
 
 #define                ERROR_NAND_DEVICE_INVALID               (-1100)
 
        char *name;
        int (*register_commands)(struct command_context_s *cmd_ctx);
        int (*pld_device_command)(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct pld_device_s *pld_device);
-       int (*load)(struct pld_device_s *pld_device, char *filename);
+       int (*load)(struct pld_device_s *pld_device, const char *filename);
 } pld_driver_t;
 
 typedef struct pld_device_s
 
        return ERROR_OK;
 }
 
-static int virtex2_load(struct pld_device_s *pld_device, char *filename)
+static int virtex2_load(struct pld_device_s *pld_device, const char *filename)
 {
        virtex2_pld_device_t *virtex2_info = pld_device->driver_priv;
        xilinx_bit_file_t bit_file;
 
        return ERROR_OK;
 }
 
-int xilinx_read_bit_file(xilinx_bit_file_t *bit_file, char *filename)
+int xilinx_read_bit_file(xilinx_bit_file_t *bit_file, const char *filename)
 {
        FILE *input_file;
        struct stat input_stat;
 
        uint8_t *data;
 } xilinx_bit_file_t;
 
-int xilinx_read_bit_file(xilinx_bit_file_t *bit_file, char *filename);
+int xilinx_read_bit_file(xilinx_bit_file_t *bit_file, const char *filename);
 
 #endif /* XILINX_BIT_H */
 
        ((elf->endianness == ELFDATA2LSB)? \
                le_to_h_u32((uint8_t*)&field):be_to_h_u32((uint8_t*)&field))
 
-static int autodetect_image_type(image_t *image, char *url)
+static int autodetect_image_type(image_t *image, const char *url)
 {
        int retval;
        fileio_t fileio;
        return ERROR_OK;
 }
 
-static int identify_image_type(image_t *image, char *type_string, char *url)
+static int identify_image_type(image_t *image, const char *type_string, const char *url)
 {
        if (type_string)
        {
        return ERROR_IMAGE_FORMAT_ERROR;
 }
 
-int image_open(image_t *image, char *url, char *type_string)
+int image_open(image_t *image, const char *url, const char *type_string)
 {
        int retval = ERROR_OK;
 
 
        uint8_t *buffer;
 } image_mot_t;
 
-int image_open(image_t *image, char *url, char *type_string);
+int image_open(image_t *image, const char *url, const char *type_string);
 int image_read_section(image_t *image, int section, uint32_t offset,
                uint32_t size, uint8_t *buffer, uint32_t *size_read);
 void image_close(image_t *image);
 
 
 reg_arch_type_t *reg_arch_types = NULL;
 
-reg_t* register_get_by_name(reg_cache_t *first, char *name, int search_all)
+reg_t* register_get_by_name(reg_cache_t *first,
+               const char *name, bool search_all)
 {
        int i;
        reg_cache_t *cache = first;
 
        struct reg_arch_type_s *next;
 } reg_arch_type_t;
 
-reg_t* register_get_by_name(reg_cache_t *first, char *name, int search_all);
+reg_t* register_get_by_name(reg_cache_t *first,
+               const char *name, bool search_all);
 reg_cache_t** register_get_last_cache_p(reg_cache_t **first);
 
 int register_reg_arch_type(int (*get)(reg_t *reg),
 
 }
 
 /* Dump a gmon.out histogram file. */
-static void writeGmon(uint32_t *samples, uint32_t sampleNum, char *filename)
+static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filename)
 {
        uint32_t i;
        FILE *f = fopen(filename, "w");
 
        int             tdo_mismatch = 0;
        int             result;
        int             verbose = 1;
-       char            *filename;
 
        bool            collecting_path = false;
        tap_state_t     path[XSTATE_MAX_PATH];
                return ERROR_FAIL;
        }
 
-       filename = args[1];             /* we mess with args starting point below, snapshot filename here */
+       /* we mess with args starting point below, snapshot filename here */
+       const char *filename = args[1];
 
        if (strcmp(args[0], "plain") != 0)
        {