From 5f1d2d34803b7b3d534536c61125a1aba38b21cb Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Sat, 31 Dec 2016 12:41:17 +0100 Subject: [PATCH] Save some bytes with common printf error/warning functions --- u-boot/board/ar7240/common/ar7240_s26_phy.c | 6 +-- u-boot/board/ar7240/common/athrs17_phy.c | 1 - u-boot/board/ar7240/common/athrs27_phy.c | 6 +-- u-boot/board/ar7240/common/qca-eth-953x.c | 37 ----------------- u-boot/board/ar7240/common/spi_flash.c | 6 +-- u-boot/common/cmd_bootm.c | 22 +++++----- u-boot/common/cmd_custom.c | 4 +- u-boot/common/cmd_flash.c | 18 ++++----- u-boot/common/cmd_itest.c | 6 +-- u-boot/common/cmd_load.c | 26 ++++++------ u-boot/common/cmd_mem.c | 45 ++++++++++++--------- u-boot/common/cmd_net.c | 7 ++-- u-boot/common/cmd_nvedit.c | 10 ++--- u-boot/common/cmd_qcaclk.c | 18 ++++----- u-boot/common/console.c | 37 ++++++++++++----- u-boot/common/env_common.c | 6 +-- u-boot/common/env_flash.c | 4 +- u-boot/common/flash.c | 16 ++++---- u-boot/common/hush.c | 18 ++++----- u-boot/common/main.c | 9 +++-- u-boot/cpu/mips/ar7240/ag7240.c | 25 +++--------- u-boot/cpu/mips/ar7240/ag934x.c | 4 +- u-boot/cpu/mips/cpu.c | 3 +- u-boot/httpd/httpd.c | 36 ++++++++--------- u-boot/include/common.h | 2 + u-boot/lib_mips/board.c | 4 +- u-boot/net/bootp.c | 13 +++--- u-boot/net/eth.c | 2 +- u-boot/net/httpd.c | 4 +- u-boot/net/net.c | 37 ++++++++--------- u-boot/net/sntp.c | 2 +- u-boot/net/tftp.c | 13 +++--- 32 files changed, 213 insertions(+), 234 deletions(-) diff --git a/u-boot/board/ar7240/common/ar7240_s26_phy.c b/u-boot/board/ar7240/common/ar7240_s26_phy.c index 455596b..8be4ca1 100644 --- a/u-boot/board/ar7240/common/ar7240_s26_phy.c +++ b/u-boot/board/ar7240/common/ar7240_s26_phy.c @@ -584,7 +584,7 @@ int athrs26_phy_speed(int ethUnit){ case 2: return(_1000BASET); default: - printf("## Error: unknown eth speed!\n"); + printf_err("unknown eth speed!\n"); } } } @@ -794,7 +794,7 @@ unsigned int s26_rd_phy(unsigned int phy_addr, unsigned int reg_addr){ i++; if(i > 824) { - printf("## Error: MDIO_BUSY!\n"); + printf_err("MDIO_BUSY!\n"); break; } @@ -826,7 +826,7 @@ void s26_wr_phy(unsigned int phy_addr, unsigned int reg_addr, unsigned int write i++; if(i > 824) { - printf("## Error: MDIO_BUSY!\n"); + printf_err("MDIO_BUSY!\n"); break; } diff --git a/u-boot/board/ar7240/common/athrs17_phy.c b/u-boot/board/ar7240/common/athrs17_phy.c index 40fe37f..82bb763 100644 --- a/u-boot/board/ar7240/common/athrs17_phy.c +++ b/u-boot/board/ar7240/common/athrs17_phy.c @@ -240,7 +240,6 @@ int athrs17_phy_setup(int ethUnit){ timeout--; if(timeout <= 0){ - printf("## Error: negotiation timed out on ethernet port: %d\n", phyUnit); break; } } diff --git a/u-boot/board/ar7240/common/athrs27_phy.c b/u-boot/board/ar7240/common/athrs27_phy.c index 4bae6b8..fb2196d 100644 --- a/u-boot/board/ar7240/common/athrs27_phy.c +++ b/u-boot/board/ar7240/common/athrs27_phy.c @@ -524,7 +524,7 @@ int athrs27_phy_speed(int ethUnit, int phyUnit){ phySpeed = _1000BASET; break; default: - printf("## Error: unknown eth speed!\n"); + printf_err("unknown eth speed!\n"); } } @@ -717,7 +717,7 @@ unsigned int s27_rd_phy(unsigned int phy_addr, unsigned int reg_addr){ i++; if(i > 824) { - printf("## Error: MDIO_BUSY!\n"); + printf_err("MDIO_BUSY!\n"); break; } @@ -749,7 +749,7 @@ void s27_wr_phy(unsigned int phy_addr, unsigned int reg_addr, unsigned int write i++; if(i > 824) { - printf("## Error: MDIO_BUSY!\n"); + printf_err("MDIO_BUSY!\n"); break; } diff --git a/u-boot/board/ar7240/common/qca-eth-953x.c b/u-boot/board/ar7240/common/qca-eth-953x.c index 18723cf..a3c9e3f 100644 --- a/u-boot/board/ar7240/common/qca-eth-953x.c +++ b/u-boot/board/ar7240/common/qca-eth-953x.c @@ -99,8 +99,6 @@ ath_gmac_send(struct eth_device *dev, volatile void *packet, int length) if (!ath_gmac_tx_owned_by_dma(f)) break; } - if (i == MAX_WAIT) - printf("Tx Timed out\n"); f->pkt_start_addr = 0; f->pkt_size = 0; @@ -177,7 +175,6 @@ void ath_gmac_mii_setup(ath_gmac_mac_t *mac) ath_reg_wr(SWITCH_CLOCK_SPARE_ADDRESS, 0x231); //ath_reg_wr(SWITCH_CLOCK_SPARE_ADDRESS, 0x520); if ((mac->mac_unit == 1)) { - //printf("Honey Bee ----> MAC 1 S27 PHY *\n"); ath_reg_wr(ATH_ETH_CFG, ETH_CFG_ETH_RXDV_DELAY_SET(3) | ETH_CFG_ETH_RXD_DELAY_SET(3)| ETH_CFG_RGMII_GE0_SET(1)); @@ -194,8 +191,6 @@ void ath_gmac_mii_setup(ath_gmac_mac_t *mac) } if (is_vir_phy()) { - //printf("Honey Bee ---->VIR PHY*\n"); - ath_reg_wr(ATH_ETH_CFG, ETH_CFG_ETH_RXDV_DELAY_SET(3) | ETH_CFG_ETH_RXD_DELAY_SET(3)| ETH_CFG_RGMII_GE0_SET(1)); @@ -211,7 +206,6 @@ void ath_gmac_mii_setup(ath_gmac_mac_t *mac) } if (is_s27()) { mgmt_cfg_val = 2; - //printf("Scorpion ---->S27 PHY*\n"); ath_reg_wr(ETH_CFG_ADDRESS, ETH_CFG_MII_GE0_SET(1)| ETH_CFG_MII_GE0_SLAVE_SET(1)); udelay(1000); @@ -255,11 +249,6 @@ static void ath_gmac_hw_start(ath_gmac_mac_t *mac) ath_gmac_reg_wr(mac, ATH_MAC_FIFO_CFG_5, 0x7ffff); ath_gmac_reg_wr(mac, ATH_MAC_FIFO_CFG_3, 0x1f00140); - - //printf(": cfg1 %#x cfg2 %#x\n", ath_gmac_reg_rd(mac, ATH_MAC_CFG1), - // ath_gmac_reg_rd(mac, ATH_MAC_CFG2)); - - } static int ath_gmac_check_link(ath_gmac_mac_t *mac) @@ -297,7 +286,6 @@ static int ath_gmac_check_link(ath_gmac_mac_t *mac) break; default: - printf("Invalid speed detected\n"); return 0; } @@ -307,8 +295,6 @@ static int ath_gmac_check_link(ath_gmac_mac_t *mac) mac->duplex = duplex; mac->speed = speed; - printf("dup %d speed %d\n", duplex, speed); - ath_gmac_set_mac_duplex(mac,duplex); return 1; @@ -358,7 +344,6 @@ static int ath_gmac_alloc_fifo(int ndesc, ath_gmac_desc_t ** fifo) size += CFG_CACHELINE_SIZE - 1; if ((p = malloc(size)) == NULL) { - //printf("Cant allocate fifos\n"); return -1; } @@ -439,7 +424,6 @@ athr_mgmt_init(void) ath_reg_wr(GPIO_OUT_FUNCTION4_ADDRESS, rddata); #endif - //printf ("%s ::done\n",__func__); } int ath_gmac_enet_initialize(bd_t * bis) @@ -448,8 +432,6 @@ int ath_gmac_enet_initialize(bd_t * bis) u32 mask, mac_h, mac_l; int i; - //printf("%s...\n", __func__); - /* Switch Analog and digital reset seq */ mask = ATH_RESET_GE1_PHY | ATH_RESET_GE0_PHY; ath_reg_rmw_set(RST_RESET_ADDRESS, mask); @@ -499,9 +481,6 @@ int ath_gmac_enet_initialize(bd_t * bis) if(!i) { mask = (ATH_RESET_GE0_MAC | ATH_RESET_GE1_MAC | ATH_RESET_GE0_MDIO | ATH_RESET_GE1_MDIO); - - //printf("%s: reset mask:%x \n", __func__, mask); - ath_reg_rmw_set(RST_RESET_ADDRESS, mask); udelay(1000 * 100); @@ -529,19 +508,16 @@ int ath_gmac_enet_initialize(bd_t * bis) if (ath_gmac_macs[i]->mac_unit == 0) { /* WAN Phy */ #ifdef CFG_ATHRS27_PHY - //printf("S27 reg init\n"); athrs27_reg_init(); mask = ATH_RESET_GE0_MAC; ath_reg_rmw_clear(RST_RESET_ADDRESS, mask); #endif #ifdef CONFIG_VIR_PHY - //printf("VIRPhy reg init \n"); athr_vir_reg_init(); #endif } else { #ifdef CFG_ATHRS27_PHY - //printf("S27 reg init\n"); athrs27_reg_init_lan(); mask = ATH_RESET_GE1_MAC; ath_reg_rmw_clear(RST_RESET_ADDRESS, mask); @@ -567,7 +543,6 @@ int ath_gmac_enet_initialize(bd_t * bis) ath_gmac_phy_setup(ath_gmac_macs[i]->mac_unit); - //printf("%s up\n",dev[i]->name); } @@ -594,9 +569,6 @@ ath_gmac_miiphy_read(char *devname, uint32_t phy_addr, uint8_t reg, uint16_t *da rddata = ath_gmac_reg_rd(mac, ATH_MII_MGMT_IND) & 0x1; }while(rddata && --ii); - if (ii == 0) - printf("ERROR:%s:%d transaction failed\n",__func__,__LINE__); - ath_gmac_reg_wr(mac, ATH_MII_MGMT_CMD, 0x0); ath_gmac_reg_wr(mac, ATH_MII_MGMT_ADDRESS, addr); @@ -608,9 +580,6 @@ ath_gmac_miiphy_read(char *devname, uint32_t phy_addr, uint8_t reg, uint16_t *da rddata = ath_gmac_reg_rd(mac, ATH_MII_MGMT_IND) & 0x1; }while(rddata && --ii); - if(ii==0) - printf("Error!!! Leave ath_gmac_miiphy_read without polling correct status!\n"); - val = ath_gmac_reg_rd(mac, ATH_MII_MGMT_STATUS); ath_gmac_reg_wr(mac, ATH_MII_MGMT_CMD, 0x0); @@ -638,9 +607,6 @@ ath_gmac_miiphy_write(char *devname, uint32_t phy_addr, uint8_t reg, uint16_t da rddata = ath_gmac_reg_rd(mac, ATH_MII_MGMT_IND) & 0x1; } while (rddata && --ii); - if (ii == 0) - printf("ERROR:%s:%d transaction failed\n",__func__,__LINE__); - ath_gmac_reg_wr(mac, ATH_MII_MGMT_ADDRESS, addr); ath_gmac_reg_wr(mac, ATH_MII_MGMT_CTRL, data); @@ -648,9 +614,6 @@ ath_gmac_miiphy_write(char *devname, uint32_t phy_addr, uint8_t reg, uint16_t da rddata = ath_gmac_reg_rd(mac, ATH_MII_MGMT_IND) & 0x1; } while (rddata && --ii); - if (ii == 0) - printf("Error!!! Leave ath_gmac_miiphy_write without polling correct status!\n"); - return 0; } //#endif /* CONFIG_CMD_MII */ diff --git a/u-boot/board/ar7240/common/spi_flash.c b/u-boot/board/ar7240/common/spi_flash.c index 21954db..b16b8cd 100644 --- a/u-boot/board/ar7240/common/spi_flash.c +++ b/u-boot/board/ar7240/common/spi_flash.c @@ -57,7 +57,7 @@ u32 flash_init(void) jedec_id = qca_sf_jedec_id(bank); if (jedec_id == 0) { - printf("## Error: SPI NOR FLASH chip in bank #%d\n" + printf_err("SPI NOR FLASH chip in bank #%d\n" " is not responding, skipping\n\n", bank + 1); continue; } @@ -73,7 +73,7 @@ u32 flash_init(void) info->sector_size = sfdp_ss; info->erase_cmd = sfdp_ec; - printf("** Warning: SPI NOR FLASH in bank #%d is\n" + printf_wrn("SPI NOR FLASH in bank #%d is\n" " unknown, JEDEC ID: 0x%06X\n\n", bank + 1, jedec_id); printf(" Information provided in SFDP:\n" @@ -95,7 +95,7 @@ u32 flash_init(void) #error "Not supported CONFIG_DEFAULT_FLASH_SIZE_IN_MB value!" #endif - printf("## Error: SPI NOR FLASH chip in bank #%d\n" + printf_err("SPI NOR FLASH chip in bank #%d\n" " is unknown, JEDEC ID: 0x%06X, will\n" " use fixed/predefined size: ", bank + 1, jedec_id); print_size(info->size, "\n\n"); diff --git a/u-boot/common/cmd_bootm.c b/u-boot/common/cmd_bootm.c index 000ad3c..c848308 100644 --- a/u-boot/common/cmd_bootm.c +++ b/u-boot/common/cmd_bootm.c @@ -433,13 +433,13 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) case TPL_IH_VERSION_V2: case TPL_IH_VERSION_V3: default: - puts("## Error: unsupported image header\n"); + printf_err("unsupported image header\n"); return 1; } /* Always verify header CRC */ if (ih_header_crc(hdr, tpl_type) != 0) { - puts("## Error: header checksum mismatch!\n"); + printf_err("header checksum mismatch!\n"); return 1; } @@ -451,7 +451,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if (ih_data_crc(data, hdr, tpl_type, verify) != 0) { - puts("## Error: data checksum mismatch!\n"); + printf_err("data checksum mismatch!\n"); return 1; } @@ -462,7 +462,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* We support only MIPS */ if (hdr->ih_arch != IH_CPU_MIPS) { - puts("## Error: unsupported architecture!\n"); + printf_err("unsupported architecture!\n"); return 1; } @@ -481,7 +481,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; default: - puts("## Error: unsupported image type!\n"); + printf_err("unsupported image type!\n"); return 1; } @@ -523,15 +523,15 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /* TODO: more verbose LZMA errors */ if (i != LZMA_RESULT_OK) { puts("ERROR\n"); - printf("## Error: LZMA error '%d'!\n", i); + printf_err("LZMA error '%d'!\n", i); return 1; } puts("OK!\n"); break; default: - printf("## Error: unsupported compression type '%s'!\n", - ih_comp_type(hdr->ih_comp)); + printf_err("unsupported compression type '%s'!\n", + ih_comp_type(hdr->ih_comp)); return 1; } @@ -603,13 +603,13 @@ int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) case TPL_IH_VERSION_V2: case TPL_IH_VERSION_V3: default: - puts("## Error: unsupported image header\n"); + printf_err("unsupported image header\n"); return 1; } /* Always verify header CRC */ if (ih_header_crc(hdr, tpl_type) != 0) { - puts("## Error: header checksum mismatch!\n"); + printf_err("header checksum mismatch!\n"); return 1; } @@ -621,7 +621,7 @@ int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if (ih_data_crc(data, hdr, tpl_type, 1) != 0) { - puts("## Error: data checksum mismatch!\n"); + printf_err("data checksum mismatch!\n"); return 1; } diff --git a/u-boot/common/cmd_custom.c b/u-boot/common/cmd_custom.c index fd2c3b2..a9e7efa 100644 --- a/u-boot/common/cmd_custom.c +++ b/u-boot/common/cmd_custom.c @@ -78,7 +78,7 @@ int do_set_mac(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]){ } if(j != 5){ - puts("## Error: given MAC address has wrong format (should be: xx:xx:xx:xx:xx:xx)!\n"); + printf_err("given MAC address has wrong format (should be: xx:xx:xx:xx:xx:xx)!\n"); return(1); } @@ -86,7 +86,7 @@ int do_set_mac(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]){ data_pointer = (unsigned char *)CONFIG_LOADADDR; if(!data_pointer){ - puts("## Error: couldn't allocate RAM for data block backup!\n"); + printf_err("couldn't allocate RAM for data block backup!\n"); return(1); } diff --git a/u-boot/common/cmd_flash.c b/u-boot/common/cmd_flash.c index b992f99..fea96d7 100644 --- a/u-boot/common/cmd_flash.c +++ b/u-boot/common/cmd_flash.c @@ -180,7 +180,7 @@ static int addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last if(!found){ /* error, addres not in flash */ - printf("## Error: end address (0x%08lx) not in FLASH!\n", *addr_last); + printf_err("end address (0x%08lx) not in FLASH!\n", *addr_last); return(-1); } @@ -240,14 +240,14 @@ static int flash_fill_sect_ranges(ulong addr_first, ulong addr_last, int *s_firs if(addr_last > b_end){ s_last[bank] = s_end; } else { - puts("## Error: end address not on sector boundary\n"); + printf_err("end address not on sector boundary\n"); rcode = 1; break; } } if(s_last[bank] < s_first[bank]){ - puts("## Error: end sector precedes start sector\n"); + printf_err("end sector precedes start sector\n"); rcode = 1; break; } @@ -256,11 +256,11 @@ static int flash_fill_sect_ranges(ulong addr_first, ulong addr_last, int *s_firs addr_first = (sect == s_end) ? b_end + 1 : info->start[sect + 1]; (*s_count) += s_last[bank] - s_first[bank] + 1; } else if(addr_first >= info->start[0] && addr_first < b_end){ - puts("## Error: start address not on sector boundary\n"); + printf_err("start address not on sector boundary\n"); rcode = 1; break; } else if(s_last[bank] >= 0){ - puts("## Error: cannot span across banks when they are mapped in reverse order\n"); + printf_err("cannot span across banks when they are mapped in reverse order\n"); rcode = 1; break; } @@ -292,7 +292,7 @@ int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ if((n = abbrev_spec(argv[1], &info, §_first, §_last)) != 0){ if(n < 0){ - puts("## Error: bad sector spec\n"); + printf_err("bad sector spec\n"); return(1); } printf("Erase FLASH sectors %d-%d in bank #%d ", sect_first, sect_last, (info - flash_info) + 1); @@ -309,7 +309,7 @@ int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ bank = simple_strtoul(argv[2], NULL, 16); if((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)){ - printf("## Error: only FLASH banks #1...#%d supported\n", CFG_MAX_FLASH_BANKS); + printf_err("only FLASH banks #1...#%d supported\n", CFG_MAX_FLASH_BANKS); return(1); } @@ -320,7 +320,7 @@ int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ } if(addr_spec(argv[1], argv[2], &addr_first, &addr_last) < 0){ - printf("## Error: bad address format\n"); + printf_err("bad address format\n"); return(1); } @@ -353,7 +353,7 @@ int flash_sect_erase(ulong addr_first, ulong addr_last){ } printf("Erased sectors: %d\n\n", erased); } else if(rcode == 0){ - puts("## Error: start and/or end address not on sector boundary\n"); + printf_err("start and/or end address not on sector boundary\n"); rcode = 1; } return(rcode); diff --git a/u-boot/common/cmd_itest.c b/u-boot/common/cmd_itest.c index 75148d4..e61d23c 100644 --- a/u-boot/common/cmd_itest.c +++ b/u-boot/common/cmd_itest.c @@ -131,7 +131,7 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) value = a % b; break; default: - printf("## Error: invalid op\n"); + printf_err("invalid op\n"); return 1; } @@ -271,7 +271,7 @@ static int binary_test(char *op, char *arg1, char *arg2, int w) } } - printf("## Error: unknown operator '%s'\n", op); + printf_err("unknown operator '%s'\n", op); /* Op code not found */ return 0; @@ -304,7 +304,7 @@ int do_itest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) break; case -1: default: - puts("## Error: invalid data width specifier\n"); + printf_err("invalid data width specifier\n"); value = 0; break; } diff --git a/u-boot/common/cmd_load.c b/u-boot/common/cmd_load.c index f5baaa7..4556d89 100644 --- a/u-boot/common/cmd_load.c +++ b/u-boot/common/cmd_load.c @@ -114,8 +114,8 @@ int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if(i == N_BAUDRATES){ - printf("## Error: baudrate %d bps is not supported, will use current: %d bps\n", - load_baudrate, current_baudrate); + printf_err("baudrate %d bps is not supported, will use current: %d bps\n", + load_baudrate, current_baudrate); } else { switch_baudrate(load_baudrate, 0); } @@ -139,7 +139,7 @@ int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if(addr == ~0){ - printf("## Error: S-Record download aborted!\n"); + printf_err("S-Record download aborted!\n"); rcode = 1; } @@ -308,8 +308,8 @@ int do_save_serial(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if(i == N_BAUDRATES){ - printf("## Error: baudrate %d bps is not supported, will use current: %d bps\n", - save_baudrate, current_baudrate); + printf_err("baudrate %d bps is not supported, will use current: %d bps\n", + save_baudrate, current_baudrate); } else { switch_baudrate(save_baudrate, 0); } @@ -323,7 +323,7 @@ int do_save_serial(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if(save_serial(offset, size)){ - printf("## Error: S-Record upload aborted!\n"); + printf_err("S-Record upload aborted!\n"); } else { printf("\nS-Record upload complete!\n"); } @@ -476,13 +476,13 @@ int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if(address == 0){ - printf("## Error: destination address can't be 0x0!\n"); + printf_err("destination address can't be 0x0!\n"); return 1; } /* don't allow to write directly to FLASH (that will need erase before!) */ if(addr2info(address) != NULL){ - printf("## Error: destination address in FLASH is not allowed!\n"); + printf_err("destination address in FLASH is not allowed!\n"); return 1; } @@ -502,8 +502,8 @@ int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } if(i == N_BAUDRATES){ - printf("## Error: baudrate %d bps is not supported, will use current: %d bps\n", - load_baudrate, current_baudrate); + printf_err("baudrate %d bps is not supported, will use current: %d bps\n", + load_baudrate, current_baudrate); } else { switch_baudrate(load_baudrate, 0); } @@ -527,7 +527,8 @@ int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) sprintf(buf, "%X", size_dl); setenv("filesize", buf); } else { - printf("\n## Error: downloaded data size is zero!\n"); + puts("\n"); + printf_err("downloaded data size is zero!\n"); rcode = 1; } @@ -1064,7 +1065,8 @@ static ulong load_serial_ymodem(ulong address) memcpy((char *)(store_addr), ymodemBuf, res); } } else { - printf("\n## Error: %s\n", xyzModem_error(err)); + puts("\n"); + printf_err("%s\n", xyzModem_error(err)); } xyzModem_stream_close(&err); diff --git a/u-boot/common/cmd_mem.c b/u-boot/common/cmd_mem.c index 33fb04d..d1eaba4 100644 --- a/u-boot/common/cmd_mem.c +++ b/u-boot/common/cmd_mem.c @@ -113,8 +113,8 @@ int do_mem_crc32(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } else { vcrc = simple_strtoul(*av++, NULL, 16); if (vcrc != crc) { - printf("## Error: CRC32 checksum for data at 0x%08lX ~ 0x%08lX: 0x%08lX (not 0x%08lX!)\n", - addr, addr + length - 1, crc, vcrc); + printf_err("CRC32 checksum for data at 0x%08lX ~ 0x%08lX: 0x%08lX (not 0x%08lX!)\n", + addr, addr + length - 1, crc, vcrc); return 1; } @@ -319,7 +319,7 @@ int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) count = simple_strtoul(argv[3], NULL, 16); if (count == 0) { - puts("## Error: zero length?\n"); + printf_err("zero length?\n"); return 1; } @@ -414,14 +414,14 @@ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) end = (ulong *)CFG_MEMTEST_END; if ((uint)start >= (uint)end) { - puts("## Error: end address must be bigger than start address!\n"); + printf_err("end address must be bigger than start address!\n"); return 1; } if (((uint)start < (uint)CFG_MEMTEST_START) || ((uint)end > (uint)CFG_MEMTEST_END)) { - printf("## Error: start and end addresses should be in 0x%08X...0x%08X range!\n", - (uint)CFG_MEMTEST_START, (uint)CFG_MEMTEST_END); + printf_err("start and end addresses should be in 0x%08X...0x%08X range!\n", + (uint)CFG_MEMTEST_START, (uint)CFG_MEMTEST_END); return 1; } @@ -474,16 +474,16 @@ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) readback = *addr; if (readback != val) - printf("## Error (data line): expected 0x%08lX, found 0x%08lX\n", - val, readback); + printf_err("(data line): expected 0x%08lX, found 0x%08lX\n", + val, readback); *addr = ~val; *dummy = val; readback = *addr; if (readback != ~val) - printf("## Error (data line): expected 0x%08lX, found 0x%08lX\n", - ~val, readback); + printf_err("(data line): expected 0x%08lX, found 0x%08lX\n", + ~val, readback); } } @@ -548,8 +548,9 @@ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) temp = start[offset]; if (temp != pattern) { - printf("\n## Error: address bit stuck high @ 0x%.8lX, expected 0x%.8lX, found 0x%.8lX\n", - (ulong)&start[offset], pattern, temp); + puts("\n"); + printf_err("address bit stuck high @ 0x%.8lX, expected 0x%.8lX, found 0x%.8lX\n", + (ulong)&start[offset], pattern, temp); return 1; } @@ -564,8 +565,9 @@ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) temp = start[offset]; if ((temp != pattern) && (offset != test_offset)) { - printf("\n## Error: address bit stuck low or shorted @ 0x%.8lX, expected 0x%.8lX, found 0x%.8lX\n", - (ulong)&start[offset], pattern, temp); + puts("\n"); + printf_err("address bit stuck low or shorted @ 0x%.8lX, expected 0x%.8lX, found 0x%.8lX\n", + (ulong)&start[offset], pattern, temp); return 1; } @@ -597,8 +599,9 @@ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) temp = start[offset]; if (temp != pattern) { - printf("\n## Error (read/write) @ 0x%.8lX: expected 0x%.8lX, found 0x%.8lX)\n", - (ulong)&start[offset], pattern, temp); + puts("\n"); + printf_err("(read/write) @ 0x%.8lX: expected 0x%.8lX, found 0x%.8lX)\n", + (ulong)&start[offset], pattern, temp); return 1; } @@ -613,8 +616,9 @@ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) temp = start[offset]; if (temp != anti_pattern) { - printf("\n## Error (read/write): @ 0x%.8lX: expected 0x%.8lX, found 0x%.8lX)\n", - (ulong)&start[offset], anti_pattern, temp); + puts("\n"); + printf_err("(read/write): @ 0x%.8lX: expected 0x%.8lX, found 0x%.8lX)\n", + (ulong)&start[offset], anti_pattern, temp); return 1; } @@ -644,8 +648,9 @@ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) readback = *addr; if (readback != val) { - printf("\n## Error @ 0x%08X: found %08lX, expected %08lX\n", - (uint)addr, readback, val); + puts("\n"); + printf_err("@ 0x%08X: found %08lX, expected %08lX\n", + (uint)addr, readback, val); rcode = 1; } diff --git a/u-boot/common/cmd_net.c b/u-boot/common/cmd_net.c index a9d0cc1..f02dbaf 100644 --- a/u-boot/common/cmd_net.c +++ b/u-boot/common/cmd_net.c @@ -210,7 +210,8 @@ int do_ping(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ } if(NetLoop(PING) < 0){ - printf("\n## Error: ping failed, host %s is not alive!\n\n", argv[1]); + puts("\n"); + printf_err("ping failed, host %s is not alive!\n\n", argv[1]); return(1); } @@ -233,7 +234,7 @@ int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ } else { NetNtpServerIP = string_to_ip(argv[1]); if(NetNtpServerIP == 0){ - printf("## Error: bad SNTP server IP address\n"); + printf_err("bad SNTP server IP address\n"); return(1); } } @@ -247,7 +248,7 @@ int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ } if(NetLoop(SNTP) < 0){ - printf("## Error: SNTP host %s not responding\n", argv[1]); + printf_err("SNTP host %s not responding\n", argv[1]); return(1); } diff --git a/u-boot/common/cmd_nvedit.c b/u-boot/common/cmd_nvedit.c index 7a198d7..fa735a2 100644 --- a/u-boot/common/cmd_nvedit.c +++ b/u-boot/common/cmd_nvedit.c @@ -146,7 +146,7 @@ int do_printenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ break; } if(k < 0){ - printf("## Error: \"%s\" not defined\n", name); + printf_err("'%s' not defined\n", name); rcode++; } } @@ -202,7 +202,7 @@ int _do_setenv(int flag, int argc, char *argv[]){ if(console != -1){ if(argc < 3){ /* Cannot delete it! */ - printf("## Error: can't delete \"%s\"\n", name); + printf_err("can't delete '%s'\n", name); return(1); } @@ -232,8 +232,8 @@ int _do_setenv(int flag, int argc, char *argv[]){ } if(i == N_BAUDRATES){ - printf("## Error: baudrate %d bps is not supported,\n", baudrate); - printf(" choose one from the list:\n\n"); + printf_err("baudrate %d bps is not supported,\n" + " choose one from the list:\n\n", baudrate); for(i = 0; i < N_BAUDRATES; ++i){ printf("- %7d bps%s\n", baudrate_table[i], baudrate_table[i] == gd->baudrate ? " [current]" : ""); } @@ -314,7 +314,7 @@ int _do_setenv(int flag, int argc, char *argv[]){ } if(len > (&env_data[ENV_SIZE] - env)){ - printf("## Error: environment overflow, \"%s\" deleted\n", name); + printf_err("environment overflow, '%s' deleted\n", name); return(1); } diff --git a/u-boot/common/cmd_qcaclk.c b/u-boot/common/cmd_qcaclk.c index fae1cdf..b0e33b0 100644 --- a/u-boot/common/cmd_qcaclk.c +++ b/u-boot/common/cmd_qcaclk.c @@ -160,8 +160,7 @@ int do_set_clk(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #ifndef CONFIG_QCA_GPIO_OC_RECOVERY_BTN puts("\n"); - puts("** Warning:"); - puts(" your device does not support O/C revovery mode!\n"); + printf_wrn("\n your device does not support O/C revovery mode!\n"); #endif puts("\n"); @@ -170,7 +169,7 @@ int do_set_clk(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) i = simple_strtoul(argv[1], NULL, 10); if (i > clk_profiles_cnt || i < 1) { - printf("## Error: selected profile should be in range 1..%d!\n\n", + printf_err("selected profile should be in range 1..%d!\n\n", clk_profiles_cnt); return 1; } @@ -203,7 +202,7 @@ int do_set_clk(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) CONFIG_QCA_PLL_IN_FLASH_BLOCK_SIZE); if (run_command(buf, 0) < 0) { - puts("## Error: could not make data backup in RAM!\n\n"); + printf_err("could not make data backup in RAM!\n\n"); return 1; } @@ -234,7 +233,7 @@ int do_set_clk(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) CONFIG_QCA_PLL_IN_FLASH_BLOCK_SIZE); if (run_command(buf, 0) < 0) { - puts("## Error: could not erase FLASH and copy data back from RAM!\n\n"); + printf_err("could not erase FLASH and copy data back from RAM!\n\n"); return 1; } @@ -254,8 +253,7 @@ int do_set_clk(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif #else puts("\n"); - puts("** Warning:"); - puts(" your device does not support O/C revovery mode!\n"); + printf_wrn("\n your device does not support O/C revovery mode!\n"); #endif /* CONFIG_QCA_GPIO_OC_RECOVERY_BTN */ puts("\n"); @@ -282,7 +280,7 @@ int do_clear_clk(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) CONFIG_QCA_PLL_IN_FLASH_BLOCK_SIZE); if (run_command(buf, 0) < 0) { - puts("## Error: could not make data backup in RAM!\n\n"); + printf_err("could not make data backup in RAM!\n\n"); return 1; } @@ -304,11 +302,11 @@ int do_clear_clk(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) CONFIG_QCA_PLL_IN_FLASH_BLOCK_SIZE); if (run_command(buf, 0) < 0) { - puts("## Error: could not erase FLASH and copy data back from RAM!\n\n"); + printf_err("could not erase FLASH and copy data back from RAM!\n\n"); return 1; } } else { - puts("** Warning: clock configuration is not stored in FLASH!\n\n"); + printf_wrn("clock configuration is not stored in FLASH!\n\n"); return 1; } diff --git a/u-boot/common/console.c b/u-boot/common/console.c index 8d0f720..0ce11d6 100644 --- a/u-boot/common/console.c +++ b/u-boot/common/console.c @@ -209,7 +209,6 @@ void puts(const char *s){ void printf(const char *fmt, ...){ va_list args; - //uint i; char printbuffer[CFG_PBSIZE]; va_start(args, fmt); @@ -217,28 +216,44 @@ void printf(const char *fmt, ...){ /* For this to work, printbuffer must be larger than * anything we ever want to print. */ - //i = vsprintf(printbuffer, fmt, args); vsprintf(printbuffer, fmt, args); va_end(args); /* Print the string */ puts(printbuffer); } -#if 0 -void vprintf(const char *fmt, va_list args){ - //uint i; + +void printf_err(const char *fmt, ...) +{ + va_list args; char printbuffer[CFG_PBSIZE]; - /* For this to work, printbuffer must be larger than - * anything we ever want to print. - */ - //i = vsprintf(printbuffer, fmt, args); + va_start(args, fmt); + + puts("## Error: "); + vsprintf(printbuffer, fmt, args); + va_end(args); - /* Print the string */ puts(printbuffer); } -#endif + +void printf_wrn(const char *fmt, ...) +{ + va_list args; + + char printbuffer[CFG_PBSIZE]; + + va_start(args, fmt); + + puts("** Warning: "); + + vsprintf(printbuffer, fmt, args); + va_end(args); + + puts(printbuffer); +} + /* test if ctrl-c was pressed */ static int ctrlc_disabled = 0; /* see disable_ctrl() */ static int ctrlc_was_pressed = 0; diff --git a/u-boot/common/env_common.c b/u-boot/common/env_common.c index 9e9e58e..722add9 100644 --- a/u-boot/common/env_common.c +++ b/u-boot/common/env_common.c @@ -202,12 +202,12 @@ void env_relocate(void) if (gd->env_valid == 0) { #if !defined(CFG_ENV_IS_NOWHERE) - puts("** Warning: bad env CRC, using default,\n" - " use 'saveenv' to save it in FLASH\n\n"); + printf_wrn("bad env CRC, using default,\n" + " use 'saveenv' to save it in FLASH\n\n"); #endif if (sizeof(default_environment) > ENV_SIZE) { - puts("## Error: default env is too big!\n"); + printf_err("default env is too big!\n"); return; } diff --git a/u-boot/common/env_flash.c b/u-boot/common/env_flash.c index 54913d2..34ba997 100644 --- a/u-boot/common/env_flash.c +++ b/u-boot/common/env_flash.c @@ -144,7 +144,7 @@ int saveenv(void){ if(up_data){ if((saved_data = malloc(up_data)) == NULL){ - printf("## Error: unable to save the rest of sector (%ld)\n", up_data); + printf_err("unable to save the rest of sector (%ld)\n", up_data); goto Done; } @@ -291,7 +291,7 @@ void env_relocate_spec(void){ } if(gd->env_valid == 2){ - puts("** Warning: some problems detected reading environment, recovered successfully\n"); + printf_wrn("some problems detected reading environment, recovered successfully\n"); } #endif /* CFG_ENV_ADDR_REDUND */ diff --git a/u-boot/common/flash.c b/u-boot/common/flash.c index 4e92b2e..ee8e01a 100644 --- a/u-boot/common/flash.c +++ b/u-boot/common/flash.c @@ -151,28 +151,28 @@ void flash_perror(int err) case ERR_OK: break; case ERR_TIMOUT: - puts("## Error: timeout writing to FLASH\n"); + printf_err("timeout writing to FLASH\n"); break; case ERR_NOT_ERASED: - puts("## Error: FLASH not erased\n"); + printf_err("FLASH not erased\n"); break; case ERR_INVAL: - puts("## Error: outside available FLASH\n"); + printf_err("outside available FLASH\n"); break; case ERR_ALIGN: - puts("## Error: start and/or end address not on sector boundary\n"); + printf_err("start and/or end address not on sector boundary\n"); break; case ERR_UNKNOWN_FLASH_VENDOR: - puts("## Error: unknown vendor of FLASH\n"); + printf_err("unknown vendor of FLASH\n"); break; case ERR_UNKNOWN_FLASH_TYPE: - puts("## Error: unknown type of FLASH\n"); + printf_err("unknown type of FLASH\n"); break; case ERR_PROG_ERROR: - puts("## Error: general FLASH programming error\n"); + printf_err("general FLASH programming error\n"); break; default: - printf("## Error: %s[%d] FIXME: rc=%d\n", __FILE__, __LINE__, err); + printf_err("%s[%d] FIXME: rc=%d\n", __FILE__, __LINE__, err); break; } } diff --git a/u-boot/common/hush.c b/u-boot/common/hush.c index 8d9edd9..0b0e7d0 100644 --- a/u-boot/common/hush.c +++ b/u-boot/common/hush.c @@ -226,7 +226,7 @@ static inline void debug_printf(const char *format, ...) { #define final_printf debug_printf static void syntax_err(void) { - printf("## Error: syntax error!\n"); + printf_err("syntax error!\n"); } static void *xmalloc(size_t size); @@ -571,13 +571,13 @@ static int run_pipe_real(struct pipe *pi) { * "help;flinfo" must not execute */ if (strchr(child->argv[i], ';')) { - printf("## Error: unknown command '%s' - try 'help' or use 'run' command\n", child->argv[i]); + printf_err("unknown command '%s' - try 'help' or use 'run' command\n", child->argv[i]); return -1; } /* Look up command in command table */ if ((cmdtp = find_cmd(child->argv[i])) == NULL) { - printf("## Error: unknown command '%s' - try 'help'\n", child->argv[i]); + printf_err("unknown command '%s' - try 'help'\n", child->argv[i]); return -1; /* give up after bad command */ } else { int rcode; @@ -587,7 +587,7 @@ static int run_pipe_real(struct pipe *pi) { /* avoid "bootd" recursion */ if (cmdtp->cmd == do_bootd) { if (flag & CMD_FLAG_BOOTD) { - printf ("## Error: 'bootd' recursion detected!\n"); + printf_err("'bootd' recursion detected!\n"); return -1; } else { flag |= CMD_FLAG_BOOTD; @@ -833,7 +833,7 @@ static int set_local_var(const char *s, int flg_export) { name = strdup(s); if (getenv(name) != NULL) { - printf("## Error: there is a global environment variable with the same name!\n"); + printf_err("there is a global environment variable with the same name!\n"); free(name); return -1; } @@ -861,7 +861,7 @@ static int set_local_var(const char *s, int flg_export) { result++; } else { if (cur->flg_read_only) { - error_msg("%s: readonly variable", name); + printf_err("%s: readonly variable", name); result = -1; } else { if (flg_export > 0 || cur->flg_export > 1) @@ -1361,7 +1361,7 @@ int parse_stream_outer(struct in_str *inp, int flag) { code = 0; /* XXX hackish way to not allow exit from main loop */ if (inp->peek == file_peek) { - printf("## Error: exit not allowed from main input shell!\n"); + printf_err("exit not allowed from main input shell!\n"); continue; } break; @@ -1444,7 +1444,7 @@ static void *xmalloc(size_t size) { void *p = NULL; if (!(p = malloc(size))) { - printf("## Error: memory not allocated!\n"); + printf_err("memory not allocated!\n"); for (;;) ; } @@ -1455,7 +1455,7 @@ static void *xrealloc(void *ptr, size_t size) { void *p = NULL; if (!(p = realloc(ptr, size))) { - printf("## Error: memory not allocated!\n"); + printf_err("memory not allocated!\n"); for (;;) ; } diff --git a/u-boot/common/main.c b/u-boot/common/main.c index 9150820..6237d15 100644 --- a/u-boot/common/main.c +++ b/u-boot/common/main.c @@ -388,7 +388,7 @@ int parse_line(char *line, char *argv[]) *line++ = '\0'; } - printf("## Error: too many args (max. %d)\n", CFG_MAXARGS); + printf_err("too many args (max. %d)\n", CFG_MAXARGS); return nargs; } @@ -540,7 +540,7 @@ int run_command(const char *cmd, int flag){ return -1; if (strlen(cmd) >= CFG_CBSIZE) { - puts("## Error: command too long!\n"); + printf_err("command too long!\n"); return -1; } @@ -585,7 +585,8 @@ int run_command(const char *cmd, int flag){ /* Look up command in command table */ if ((cmdtp = find_cmd(argv[0])) == NULL) { - printf("## Error: unknown command '%s' - try 'help'\n\n", argv[0]); + printf_err("unknown command '%s' - try 'help'\n", argv[0]); + puts("\n"); /* Give up after bad command */ rc = -1; @@ -629,7 +630,7 @@ int do_run(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) char *arg; if ((arg = getenv(argv[i])) == NULL) { - printf("## Error: '%s' not defined\n", argv[i]); + printf_err("'%s' not defined\n", argv[i]); return 1; } diff --git a/u-boot/cpu/mips/ar7240/ag7240.c b/u-boot/cpu/mips/ar7240/ag7240.c index b63cee3..16a67aa 100644 --- a/u-boot/cpu/mips/ar7240/ag7240.c +++ b/u-boot/cpu/mips/ar7240/ag7240.c @@ -65,9 +65,8 @@ static int ag7240_send(struct eth_device *dev, volatile void *packet, int length } } - if (i == MAX_WAIT) { - printf("Tx Timed out\n"); - } + if (i == MAX_WAIT) + printf_err("TX timeout\n"); f->pkt_start_addr = 0; f->pkt_size = 0; @@ -340,7 +339,7 @@ static int ag7240_check_link(ag7240_mac_t *mac) default: if((s != NULL) && (strcmp(s, "nc") != 0)){ - printf("## Error: invalid speed detected\n"); + printf_err("invalid speed detected\n"); } return 0; } @@ -405,7 +404,7 @@ static int ag7240_alloc_fifo(int ndesc, ag7240_desc_t ** fifo) size += CFG_CACHELINE_SIZE - 1; if ((p = malloc(size)) == NULL) { - printf("Cant allocate fifos\n"); + printf_err("can't allocate fifos\n"); return -1; } @@ -495,12 +494,12 @@ int ag7240_enet_initialize(bd_t * bis) for (i = 0; i < CFG_AG7240_NMACS; i++) { if ((dev[i] = (struct eth_device *) malloc(sizeof(struct eth_device))) == NULL) { - puts("## Error: malloc failed\n"); + printf_err("malloc failed\n"); return 0; } if ((ag7240_macs[i] = (ag7240_mac_t *) malloc(sizeof(ag7240_mac_t))) == NULL) { - puts("## Error: malloc failed\n"); + printf_err("malloc failed\n"); return 0; } @@ -650,9 +649,6 @@ uint16_t ag7240_miiphy_read(char *devname, uint32_t phy_addr, uint8_t reg) rddata = ag7240_reg_rd(mac, AG7240_MII_MGMT_IND) & 0x1; } while (rddata && --ii); - if (ii == 0) - printf("ERROR:%s:%d transaction failed\n", __func__, __LINE__); - ag7240_reg_wr(mac, AG7240_MII_MGMT_CMD, 0x0); ag7240_reg_wr(mac, AG7240_MII_MGMT_ADDRESS, addr); ag7240_reg_wr(mac, AG7240_MII_MGMT_CMD, AG7240_MGMT_CMD_READ); @@ -662,9 +658,6 @@ uint16_t ag7240_miiphy_read(char *devname, uint32_t phy_addr, uint8_t reg) rddata = ag7240_reg_rd(mac, AG7240_MII_MGMT_IND) & 0x1; } while (rddata && --ii); - if (ii == 0) - printf("ERROR! Leave ag7240_miiphy_read without polling correct status!\n"); - val = ag7240_reg_rd(mac, AG7240_MII_MGMT_STATUS); ag7240_reg_wr(mac, AG7240_MII_MGMT_CMD, 0x0); @@ -687,16 +680,10 @@ void ag7240_miiphy_write(char *devname, uint32_t phy_addr, uint8_t reg, uint16_t rddata = ag7240_reg_rd(mac, AG7240_MII_MGMT_IND) & 0x1; } while (rddata && --ii); - if (ii == 0) - printf("ERROR:%s:%d transaction failed\n", __func__, __LINE__); - ag7240_reg_wr(mac, AG7240_MII_MGMT_ADDRESS, addr); ag7240_reg_wr(mac, AG7240_MII_MGMT_CTRL, data); do { rddata = ag7240_reg_rd(mac, AG7240_MII_MGMT_IND) & 0x1; } while (rddata && --ii); - - if (ii == 0) - printf("ERROR! Leave ag7240_miiphy_write without polling correct status!\n"); } diff --git a/u-boot/cpu/mips/ar7240/ag934x.c b/u-boot/cpu/mips/ar7240/ag934x.c index 850c29b..5bdd578 100644 --- a/u-boot/cpu/mips/ar7240/ag934x.c +++ b/u-boot/cpu/mips/ar7240/ag934x.c @@ -402,7 +402,7 @@ static int ag7240_check_link(ag7240_mac_t *mac) default: if ((s != NULL) && (strcmp(s, "nc") != 0)) { - printf("## Error: invalid speed detected\n"); + printf_err("invalid speed detected\n"); } return 0; } @@ -462,7 +462,7 @@ static int ag7240_alloc_fifo(int ndesc, ag7240_desc_t ** fifo) size += CFG_CACHELINE_SIZE - 1; if ((p = malloc(size)) == NULL) { - printf("## Error: cant allocate fifos\n"); + printf_err("can't allocate fifos\n"); return -1; } diff --git a/u-boot/cpu/mips/cpu.c b/u-boot/cpu/mips/cpu.c index f8eeec8..687c246 100644 --- a/u-boot/cpu/mips/cpu.c +++ b/u-boot/cpu/mips/cpu.c @@ -19,7 +19,8 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) full_reset(); /* After full chip reset we should not reach next step... */ - printf("\n## Error: RESET FAILED!\n"); + puts("\n"); + printf_err("RESET FAILED!\n"); return 0; } diff --git a/u-boot/httpd/httpd.c b/u-boot/httpd/httpd.c index 1303e79..447dda7 100644 --- a/u-boot/httpd/httpd.c +++ b/u-boot/httpd/httpd.c @@ -130,7 +130,7 @@ static int httpd_findandstore_firstchunk(void){ if(end){ #if defined(WEBFAILSAFE_DISABLE_UBOOT_UPGRADE) - printf("## Error: U-Boot upgrade is not allowed on this board!\n"); + printf_err("U-Boot upgrade is not allowed on this board!\n"); webfailsafe_upload_failed = 1; #else webfailsafe_upgrade_type = WEBFAILSAFE_UPGRADE_TYPE_UBOOT; @@ -142,7 +142,7 @@ static int httpd_findandstore_firstchunk(void){ if(end){ #if defined(WEBFAILSAFE_DISABLE_ART_UPGRADE) - printf("## Error: U-Boot upgrade is not allowed on this board!\n"); + printf_err("U-Boot upgrade is not allowed on this board!\n"); webfailsafe_upload_failed = 1; #else printf("Upgrade type: ART\n"); @@ -155,14 +155,14 @@ static int httpd_findandstore_firstchunk(void){ // if we don't know the flash type, we won't allow to update ART, // because we don't know flash size if(info->flash_id == FLASH_CUSTOM){ - printf("## Error: unknown FLASH type, can't update ART!\n"); + printf_err("unknown FLASH type, can't update ART!\n"); webfailsafe_upload_failed = 1; } #endif #endif /* if defined(WEBFAILSAFE_DISABLE_ART_UPGRADE) */ } else { - printf("## Error: input name not found!\n"); + printf_err("input name not found!\n"); return(0); } @@ -195,19 +195,19 @@ static int httpd_findandstore_firstchunk(void){ // U-Boot if((webfailsafe_upgrade_type == WEBFAILSAFE_UPGRADE_TYPE_UBOOT) && (hs->upload_total > CONFIG_MAX_UBOOT_SIZE)){ - printf("## Error: file too big!\n"); + printf_err("file too big!\n"); webfailsafe_upload_failed = 1; // ART } else if((webfailsafe_upgrade_type == WEBFAILSAFE_UPGRADE_TYPE_ART) && (hs->upload_total != WEBFAILSAFE_UPLOAD_ART_SIZE_IN_BYTES)){ - printf("## Error: wrong file size, should be: %d bytes!\n", WEBFAILSAFE_UPLOAD_ART_SIZE_IN_BYTES); + printf_err("wrong file size, should be: %d bytes!\n", WEBFAILSAFE_UPLOAD_ART_SIZE_IN_BYTES); webfailsafe_upload_failed = 1; // firmware can't exceed: (FLASH_SIZE - WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES) } else if(hs->upload_total > (info->size - WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES)){ - printf("## Error: file too big!\n"); + printf_err("file too big!\n"); webfailsafe_upload_failed = 1; } @@ -227,7 +227,7 @@ static int httpd_findandstore_firstchunk(void){ } } else { - printf("## Error: couldn't find start of data!\n"); + printf_err("couldn't find start of data!\n"); } } @@ -306,7 +306,7 @@ void httpd_appcall(void){ } if(i != 0){ - printf("## Error: request file name too long!\n"); + printf_err("request file name too long!\n"); httpd_state_reset(); uip_abort(); return; @@ -321,7 +321,7 @@ void httpd_appcall(void){ } else { // check if we have requested file if(!fs_open((const char *)&uip_appdata[4], &fsfile)){ - printf("## Error: file not found!\n"); + printf_err("file not found!\n"); fs_open(file_404_html.name, &fsfile); } } @@ -373,14 +373,14 @@ void httpd_appcall(void){ #endif } else { - printf("## Error: couldn't find \"Content-Length\"!\n"); + printf_err("couldn't find 'Content-Length'!\n"); httpd_state_reset(); uip_abort(); return; } } else { - printf("## Error: couldn't find \"Content-Length\"!\n"); + printf_err("couldn't find 'Content-Length'!\n"); httpd_state_reset(); uip_abort(); return; @@ -388,7 +388,7 @@ void httpd_appcall(void){ // we don't support very small files (< 10 KB) if(hs->upload_total < 10240){ - printf("## Error: request for upload < 10 KB data!\n"); + printf_err("request for upload < 10 KB data!\n"); httpd_state_reset(); uip_abort(); return; @@ -427,21 +427,21 @@ void httpd_appcall(void){ #endif } else { - printf("## Error: couldn't allocate memory for boundary!\n"); + printf_err("couldn't allocate memory for boundary!\n"); httpd_state_reset(); uip_abort(); return; } } else { - printf("## Error: couldn't find boundary!\n"); + printf_err("couldn't find boundary!\n"); httpd_state_reset(); uip_abort(); return; } } else { - printf("## Error: couldn't find boundary!\n"); + printf_err("couldn't find boundary!\n"); httpd_state_reset(); uip_abort(); return; @@ -458,7 +458,7 @@ void httpd_appcall(void){ webfailsafe_data_pointer = (u8_t *)CONFIG_LOADADDR; if(!webfailsafe_data_pointer){ - printf("## Error: couldn't allocate RAM for data!\n"); + printf_err("couldn't allocate RAM for data!\n"); httpd_state_reset(); uip_abort(); return; @@ -544,7 +544,7 @@ void httpd_appcall(void){ if(!data_start_found){ if(!httpd_findandstore_firstchunk()){ - printf("## Error: couldn't find start of data in next packet!\n"); + printf_err("couldn't find start of data in next packet!\n"); httpd_state_reset(); uip_abort(); return; diff --git a/u-boot/include/common.h b/u-boot/include/common.h index 610da12..6db3a56 100644 --- a/u-boot/include/common.h +++ b/u-boot/include/common.h @@ -548,6 +548,8 @@ int tstc(void); void putc(const char c); void puts(const char *s); void printf(const char *fmt, ...); +void printf_err(const char *fmt, ...); +void printf_wrn(const char *fmt, ...); //void vprintf(const char *fmt, va_list args); /* stderr */ diff --git a/u-boot/lib_mips/board.c b/u-boot/lib_mips/board.c index 166397d..32da3c3 100644 --- a/u-boot/lib_mips/board.c +++ b/u-boot/lib_mips/board.c @@ -74,7 +74,7 @@ void *sbrk(ptrdiff_t increment) ulong new = old + increment; if ((new < mem_malloc_start) || (new > mem_malloc_end)) { - printf("## Error: sbrk: out of memory " + printf_err("sbrk: out of memory " "(%d requested > %d available)\n", increment, mem_malloc_end - old); @@ -125,7 +125,7 @@ static int init_func_ram(void) if ((gd->ram_size = dram_init()) > 0) return 0; - puts("## Error on RAM initialization!\n"); + printf_err("on RAM initialization!\n"); return 1; } #endif diff --git a/u-boot/net/bootp.c b/u-boot/net/bootp.c index 2c1277d..3620948 100644 --- a/u-boot/net/bootp.c +++ b/u-boot/net/bootp.c @@ -117,8 +117,8 @@ static void BootpCopyNetParams(Bootp_t *bp) static int truncate_sz(const char *name, int maxlen, int curlen) { if (curlen >= maxlen) { - printf("** Warning: '%s' is too long (%d - max: %d) - truncated\n", - name, curlen, maxlen); + printf_wrn("'%s' is too long (%d - max: %d) - truncated\n", + name, curlen, maxlen); curlen = maxlen - 1; } @@ -379,7 +379,8 @@ static void BootpTimeout(void) bd_t *bd = gd->bd; if (BootpTry >= TIMEOUT_COUNT) { - puts("\n## Error: retry count exceeded, starting again!\n\n"); + puts("\n"); + printf_err("retry count exceeded, starting again!\n\n"); NetStartAgain(); } else { NetSetTimeout(TIMEOUT * CFG_HZ, BootpTimeout); @@ -860,7 +861,7 @@ static void DhcpOptionsProcess(uchar *popt, Bootp_t *bp) * Tru64 Unix) it seems mind bogglingly crazy * to me */ - printf("** Warning: using vendor optional boot file\n"); + printf_wrn("using vendor optional boot file\n"); memcpy(bp->bp_file, popt + 2, size); bp->bp_file[size] = '\0'; } @@ -870,7 +871,7 @@ static void DhcpOptionsProcess(uchar *popt, Bootp_t *bp) if (dhcp_vendorex_proc(popt)) break; #endif - printf("** Warning: unhandled DHCP option in OFFER/ACK: %d\n", *popt); + printf_wrn("unhandled DHCP option in OFFER/ACK: %d\n", *popt); break; } @@ -1063,7 +1064,7 @@ static void DhcpHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len) break; default: - puts("## Error: DHCP in INVALID STATE\n"); + printf_err("DHCP in INVALID STATE\n"); break; } } diff --git a/u-boot/net/eth.c b/u-boot/net/eth.c index 875fbb3..685b33d 100644 --- a/u-boot/net/eth.c +++ b/u-boot/net/eth.c @@ -132,7 +132,7 @@ int eth_initialize(bd_t *bis){ #endif if(!eth_devices){ - puts("## Error: no ethernet found\n"); + printf_err("no ethernet found\n"); } else { struct eth_device *dev = eth_devices; char *ethprime = getenv("ethprime"); diff --git a/u-boot/net/httpd.c b/u-boot/net/httpd.c index 6f9c4a2..7bcc79a 100644 --- a/u-boot/net/httpd.c +++ b/u-boot/net/httpd.c @@ -70,7 +70,7 @@ int do_http_upgrade(const ulong size, const int upgrade_type){ backup_size - size); if(!run_command(buf, 0)){ - printf("## Error: couldn't backup FLASH data before U-Boot image upgrade!\n"); + printf_err("couldn't backup FLASH data before U-Boot image upgrade!\n"); return(-1); } } @@ -160,7 +160,7 @@ int do_http_progress(const int state){ break; case WEBFAILSAFE_PROGRESS_UPGRADE_FAILED: - printf("## Error: HTTP ugrade failed!\n\n"); + printf_err("HTTP ugrade failed!\n\n"); // blink LED fast for 4 sec for(i = 0; i < 80; ++i){ diff --git a/u-boot/net/net.c b/u-boot/net/net.c index 4e30c8b..84b5fd7 100644 --- a/u-boot/net/net.c +++ b/u-boot/net/net.c @@ -226,7 +226,7 @@ void ArpRequest(void){ if((NetArpWaitPacketIP & NetOurSubnetMask) != (NetOurIP & NetOurSubnetMask)){ if(NetOurGatewayIP == 0){ - puts("** Warning: gatewayip needed but not set\n"); + printf_wrn("gatewayip needed but not set\n"); NetArpWaitReplyIP = NetArpWaitPacketIP; } else { NetArpWaitReplyIP = NetOurGatewayIP; @@ -254,7 +254,7 @@ void ArpTimeoutCheck(void){ NetArpWaitTry++; if(NetArpWaitTry >= ARP_TIMEOUT_COUNT){ - puts("## Error: ARP retry count exceeded, starting again\n"); + printf_err("ARP retry count exceeded, starting again\n"); NetArpWaitTry = 0; NetStartAgain(); } else { @@ -866,7 +866,7 @@ void NetReceive(volatile uchar * inpkt, int len){ arp = (ARP_t *)ip; if(len < ARP_HDR_SIZE){ - printf("## Error: bad length %d < %d\n", len, ARP_HDR_SIZE); + printf_err("bad length %d < %d\n", len, ARP_HDR_SIZE); return; } @@ -946,7 +946,7 @@ void NetReceive(volatile uchar * inpkt, int len){ return; default: #ifdef ET_DEBUG - printf("## Error: unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op)); + printf_err("unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op)); #endif return; } @@ -958,12 +958,12 @@ void NetReceive(volatile uchar * inpkt, int len){ #endif arp = (ARP_t *)ip; if(len < ARP_HDR_SIZE){ - printf("## Error: bad length %d < %d\n", len, ARP_HDR_SIZE); + printf_err("bad length %d < %d\n", len, ARP_HDR_SIZE); return; } if((ntohs(arp->ar_op) != RARPOP_REPLY) || (ntohs(arp->ar_hrd) != ARP_ETHER) || (ntohs(arp->ar_pro) != PROT_IP) || (arp->ar_hln != 6) || (arp->ar_pln != 4)){ - puts("## Error: invalid RARP header\n"); + printf_err("invalid RARP header\n"); } else { NetCopyIP(&NetOurIP, &arp->ar_data[16]); if(NetServerIP == 0){ @@ -985,7 +985,7 @@ void NetReceive(volatile uchar * inpkt, int len){ } if(len < ntohs(ip->ip_len)){ - printf("## Error: len bad %d < %d\n", len, ntohs(ip->ip_len)); + printf_err("len bad %d < %d\n", len, ntohs(ip->ip_len)); return; } @@ -1003,7 +1003,8 @@ void NetReceive(volatile uchar * inpkt, int len){ if(!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)){ #ifdef ET_DEBUG - puts("\n## Error: checksum bad\n"); + puts("\n"); + printf_err("checksum bad\n"); #endif return; } @@ -1097,7 +1098,7 @@ void NetReceive(volatile uchar * inpkt, int len){ } if((xsum != 0x00000000) && (xsum != 0x0000ffff)){ - printf("## Error: UDP wrong checksum %08x %08x\n", xsum, ntohs(ip->udp_xsum)); + printf_err("UDP wrong checksum %08x %08x\n", xsum, ntohs(ip->udp_xsum)); return; } } @@ -1122,7 +1123,7 @@ static int net_check_prereq(proto_t protocol){ #if defined(CONFIG_CMD_PING) case PING: if(NetPingIP == 0){ - puts("## Error: ping address not given\n"); + printf_err("ping address not given\n"); return(1); } goto common; @@ -1130,7 +1131,7 @@ static int net_check_prereq(proto_t protocol){ #if defined(CONFIG_CMD_SNTP) case SNTP: if(NetNtpServerIP == 0){ - puts("## Error: NTP server address not given\n"); + printf_err("NTP server address not given\n"); return(1); } goto common; @@ -1141,14 +1142,14 @@ static int net_check_prereq(proto_t protocol){ case NETCONS: case TFTP: if(NetServerIP == 0){ - puts("## Error: serverip not set\n"); + printf_err("serverip not set\n"); return(1); } #if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) common: #endif if(NetOurIP == 0){ - puts("## Error: ipaddr not set\n"); + printf_err("ipaddr not set\n"); return(1); } /* Fall through */ @@ -1164,20 +1165,20 @@ static int net_check_prereq(proto_t protocol){ switch(num){ case -1: - puts("## Error: no ethernet found\n"); + printf_err("no ethernet found\n"); return(1); case 0: - puts("## Error: ethaddr not set\n"); + printf_err("ethaddr not set\n"); break; default: - printf("## Error: eth%daddr not set\n", num); + printf_err("eth%daddr not set\n", num); break; } NetStartAgain(); return(2); #else - puts("## Error: ethaddr not set\n"); + printf_err("ethaddr not set\n"); return(1); #endif } @@ -1478,7 +1479,7 @@ int NetLoopHttpd(void){ if(ethinit_attempt > 0){ eth_halt(); - printf("## Error: couldn't initialize eth (cable disconnected?)!\n\n"); + printf_err("couldn't initialize eth (cable disconnected?)!\n\n"); return(-1); } diff --git a/u-boot/net/sntp.c b/u-boot/net/sntp.c index af832ff..1fa9914 100644 --- a/u-boot/net/sntp.c +++ b/u-boot/net/sntp.c @@ -46,7 +46,7 @@ static void SntpSend(void){ } static void SntpTimeout(void){ - puts("## Error: timeout\n"); + printf_err("timeout\n"); NetState = NETLOOP_FAIL; return; diff --git a/u-boot/net/tftp.c b/u-boot/net/tftp.c index afa322f..4b9855a 100644 --- a/u-boot/net/tftp.c +++ b/u-boot/net/tftp.c @@ -249,7 +249,7 @@ static void TftpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len){ #ifdef ET_DEBUG if(TftpState == STATE_RRQ){ - puts("## Error: server did not acknowledge timeout option!\n"); + printf_err("server did not acknowledge timeout option!\n"); } #endif @@ -262,7 +262,8 @@ static void TftpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len){ TftpBlockWrapOffset = 0; if(TftpBlock != 1){ /* Assertion */ - printf("\n## Error: first block is not block 1 (%ld), starting again!\n\n", TftpBlock); + puts("\n"); + printf_err("first block is not block 1 (%ld), starting again!\n\n", TftpBlock); NetStartAgain(); break; } @@ -298,7 +299,8 @@ static void TftpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len){ break; case TFTP_ERROR: - printf("\n## Error: '%s' (%d), starting again!\n\n", pkt + 2, ntohs(*(ushort *)pkt)); + puts("\n"); + printf_err("'%s' (%d), starting again!\n\n", pkt + 2, ntohs(*(ushort *)pkt)); NetStartAgain(); break; } @@ -308,7 +310,8 @@ static void TftpTimeout(void){ bd_t *bd = gd->bd; if(++TftpTimeoutCount > TIMEOUT_COUNT){ - puts("\n\n## Error: retry count exceeded, starting again!\n\n"); + puts("\n\n"); + printf_err("retry count exceeded, starting again!\n\n"); NetStartAgain(); } else { puts("T "); @@ -328,7 +331,7 @@ void TftpStart(void){ sprintf(default_filename, "%02lX%02lX%02lX%02lX.img", NetOurIP & 0xFF, (NetOurIP >> 8) & 0xFF, (NetOurIP >> 16) & 0xFF, (NetOurIP >> 24) & 0xFF); tftp_filename = default_filename; - printf("** Warning: no boot file name, using: '%s'\n", tftp_filename); + printf_wrn("no boot file name, using: '%s'\n", tftp_filename); } else { tftp_filename = BootFile; } -- 2.25.1