case 2:
return(_1000BASET);
default:
- printf("## Error: unknown eth speed!\n");
+ printf_err("unknown eth speed!\n");
}
}
}
i++;
if(i > 824) {
- printf("## Error: MDIO_BUSY!\n");
+ printf_err("MDIO_BUSY!\n");
break;
}
i++;
if(i > 824) {
- printf("## Error: MDIO_BUSY!\n");
+ printf_err("MDIO_BUSY!\n");
break;
}
timeout--;\r
\r
if(timeout <= 0){\r
- printf("## Error: negotiation timed out on ethernet port: %d\n", phyUnit);\r
break;\r
}\r
}\r
phySpeed = _1000BASET;
break;
default:
- printf("## Error: unknown eth speed!\n");
+ printf_err("unknown eth speed!\n");
}
}
i++;
if(i > 824) {
- printf("## Error: MDIO_BUSY!\n");
+ printf_err("MDIO_BUSY!\n");
break;
}
i++;
if(i > 824) {
- printf("## Error: MDIO_BUSY!\n");
+ printf_err("MDIO_BUSY!\n");
break;
}
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;
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));
}
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));
}
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);
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)
break;
default:
- printf("Invalid speed detected\n");
return 0;
}
mac->duplex = duplex;
mac->speed = speed;
- printf("dup %d speed %d\n", duplex, speed);
-
ath_gmac_set_mac_duplex(mac,duplex);
return 1;
size += CFG_CACHELINE_SIZE - 1;
if ((p = malloc(size)) == NULL) {
- //printf("Cant allocate fifos\n");
return -1;
}
ath_reg_wr(GPIO_OUT_FUNCTION4_ADDRESS, rddata);
#endif
- //printf ("%s ::done\n",__func__);
}
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);
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);
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);
ath_gmac_phy_setup(ath_gmac_macs[i]->mac_unit);
- //printf("%s up\n",dev[i]->name);
}
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);
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);
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);
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 */
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;
}
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"
#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");
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;
}
}
if (ih_data_crc(data, hdr, tpl_type, verify) != 0) {
- puts("## Error: data checksum mismatch!\n");
+ printf_err("data checksum mismatch!\n");
return 1;
}
/* We support only MIPS */
if (hdr->ih_arch != IH_CPU_MIPS) {
- puts("## Error: unsupported architecture!\n");
+ printf_err("unsupported architecture!\n");
return 1;
}
break;
default:
- puts("## Error: unsupported image type!\n");
+ printf_err("unsupported image type!\n");
return 1;
}
/* 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;
}
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;
}
}
if (ih_data_crc(data, hdr, tpl_type, 1) != 0) {
- puts("## Error: data checksum mismatch!\n");
+ printf_err("data checksum mismatch!\n");
return 1;
}
}
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);
}
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);
}
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);
}
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;
}
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;
}
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);
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);
}
}
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);
}
}
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);
value = a % b;
break;
default:
- printf("## Error: invalid op\n");
+ printf_err("invalid op\n");
return 1;
}
}
}
- printf("## Error: unknown operator '%s'\n", op);
+ printf_err("unknown operator '%s'\n", op);
/* Op code not found */
return 0;
break;
case -1:
default:
- puts("## Error: invalid data width specifier\n");
+ printf_err("invalid data width specifier\n");
value = 0;
break;
}
}
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);
}
}
if(addr == ~0){
- printf("## Error: S-Record download aborted!\n");
+ printf_err("S-Record download aborted!\n");
rcode = 1;
}
}
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);
}
}
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");
}
}
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;
}
}
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);
}
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;
}
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);
} 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;
}
count = simple_strtoul(argv[3], NULL, 16);
if (count == 0) {
- puts("## Error: zero length?\n");
+ printf_err("zero length?\n");
return 1;
}
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;
}
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);
}
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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);
}
} 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);
}
}
}
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);
}
break;
}
if(k < 0){
- printf("## Error: \"%s\" not defined\n", name);
+ printf_err("'%s' not defined\n", name);
rcode++;
}
}
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);
}
}
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]" : "");
}
}
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);
}
#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");
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;
}
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;
}
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;
}
#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");
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;
}
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;
}
void printf(const char *fmt, ...){
va_list args;
- //uint i;
char printbuffer[CFG_PBSIZE];
va_start(args, 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;
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;
}
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;
}
}
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 */
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;
}
}
#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);
* "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;
/* 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;
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;
}
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)
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;
void *p = NULL;
if (!(p = malloc(size))) {
- printf("## Error: memory not allocated!\n");
+ printf_err("memory not allocated!\n");
for (;;)
;
}
void *p = NULL;
if (!(p = realloc(ptr, size))) {
- printf("## Error: memory not allocated!\n");
+ printf_err("memory not allocated!\n");
for (;;)
;
}
*line++ = '\0';
}
- printf("## Error: too many args (max. %d)\n", CFG_MAXARGS);
+ printf_err("too many args (max. %d)\n", CFG_MAXARGS);
return nargs;
}
return -1;
if (strlen(cmd) >= CFG_CBSIZE) {
- puts("## Error: command too long!\n");
+ printf_err("command too long!\n");
return -1;
}
/* 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;
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;
}
}
}
- 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;
default:
if((s != NULL) && (strcmp(s, "nc") != 0)){
- printf("## Error: invalid speed detected\n");
+ printf_err("invalid speed detected\n");
}
return 0;
}
size += CFG_CACHELINE_SIZE - 1;
if ((p = malloc(size)) == NULL) {
- printf("Cant allocate fifos\n");
+ printf_err("can't allocate fifos\n");
return -1;
}
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;
}
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);
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);
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");
}
default:
if ((s != NULL) && (strcmp(s, "nc") != 0)) {
- printf("## Error: invalid speed detected\n");
+ printf_err("invalid speed detected\n");
}
return 0;
}
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;
}
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;
}
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;
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");
// 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);
}
// 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;
}
}
} else {
- printf("## Error: couldn't find start of data!\n");
+ printf_err("couldn't find start of data!\n");
}
}
}
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;
} 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);
}
}
#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;
// 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;
#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;
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;
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;
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 */
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);
if ((gd->ram_size = dram_init()) > 0)
return 0;
- puts("## Error on RAM initialization!\n");
+ printf_err("on RAM initialization!\n");
return 1;
}
#endif
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;
}
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);
* 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';
}
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;
}
break;
default:
- puts("## Error: DHCP in INVALID STATE\n");
+ printf_err("DHCP in INVALID STATE\n");
break;
}
}
#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");
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);
}
}
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){
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;
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 {
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;
}
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;
}
#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){
}
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;
}
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;
}
}
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;
}
}
#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;
#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;
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 */
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
}
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);
}
}
static void SntpTimeout(void){
- puts("## Error: timeout\n");
+ printf_err("timeout\n");
NetState = NETLOOP_FAIL;
return;
#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
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;
}
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;
}
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 ");
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;
}