#endif
-#define ZYLIN_VERSION "1.46"
+#define ZYLIN_VERSION "1.47"
#define ZYLIN_DATE __DATE__
#define ZYLIN_TIME __TIME__
/* hmmm.... we can't pick up the right # during build if we've checked this out
static bool serialLog = true;
static bool writeLog = true;
+char hwaddr[512];
struct FastLoad
{
return ERROR_OK;
}
+
+
+
extern flash_driver_t *flash_drivers[];
extern target_type_t *target_types[];
savePower = power;
if (power)
{
- HAL_WRITE_UINT32(0x08000014, 0x8);
+ HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x14, 0x8);
} else
{
- HAL_WRITE_UINT32(0x08000010, 0x8);
+ HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x8);
}
}
HAL_DIAG_WRITE_CHAR(c);
}
+#ifdef CYGPKG_HAL_ZYLIN_PHI
printDccChar(c);
+#endif
}
#define SHOW_RESULT(a, b) diag_printf(#a " failed %d\n", (int)b)
cyg_mutex_lock(&httpstate.jim_lock);
}
+
+void format(void)
+{
+ diag_printf("Formatting JFFS2...\n");
+
+ cyg_io_handle_t handle;
+
+ Cyg_ErrNo err;
+ err = cyg_io_lookup(CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, &handle);
+ if (err != ENOERR)
+ {
+ diag_printf("Flash Error cyg_io_lookup: %d\n", err);
+ reboot();
+ }
+
+
+ cyg_uint32 len;
+ cyg_io_flash_getconfig_devsize_t ds;
+ len = sizeof (ds);
+ err = cyg_io_get_config(handle,
+ CYG_IO_GET_CONFIG_FLASH_DEVSIZE, &ds, &len);
+ if (err != ENOERR)
+ {
+ diag_printf("Flash error cyg_io_get_config %d\n", err);
+ reboot();
+ }
+
+ cyg_io_flash_getconfig_erase_t e;
+ void *err_addr;
+ len = sizeof (e);
+
+ e.offset = 0;
+ e.len = ds.dev_size;
+ e.err_address = &err_addr;
+
+ diag_printf("Formatting 0x%08x bytes\n", ds.dev_size);
+ err = cyg_io_get_config(handle, CYG_IO_GET_CONFIG_FLASH_ERASE,
+ &e, &len);
+ if (err != ENOERR)
+ {
+ diag_printf("Flash erase error %d offset 0x%p\n", err, err_addr);
+ reboot();
+ }
+
+ diag_printf("Flash formatted successfully\n");
+
+ reboot();
+}
+
+
+
+static int
+zylinjtag_Jim_Command_format_jffs2(Jim_Interp *interp,
+ int argc,
+ Jim_Obj * const *argv)
+{
+ if (argc != 1)
+ {
+ return JIM_ERR;
+ }
+
+ format();
+ for(;;);
+}
+
+
static int
zylinjtag_Jim_Command_rm(Jim_Interp *interp,
int argc,
int argc,
Jim_Obj * const *argv)
{
- int s;
- struct ifreq ifr;
- s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s >= 0)
- {
- strcpy(ifr.ifr_name, "eth0");
- int res;
- res = ioctl(s, SIOCGIFHWADDR, &ifr);
- close(s);
-
- if (res < 0)
- {
- return JIM_OK;
- }
- }
Jim_Obj *tclOutput = Jim_NewStringObj(interp, "", 0);
- char hwaddr[512];
- sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
- (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[0],
- (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[1],
- (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[2],
- (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[3],
- (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[4],
- (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[5]);
-
Jim_AppendString(httpstate.jim_interp, tclOutput, hwaddr, strlen(hwaddr));
Jim_SetResult(interp, tclOutput);
extern Jim_Interp *interp;
+
static void zylinjtag_startNetwork()
{
// Bring TCP/IP up immediately before we're ready to accept commands.
Jim_CreateCommand(httpstate.jim_interp, "mac", zylinjtag_Jim_Command_mac, NULL, NULL);
Jim_CreateCommand(httpstate.jim_interp, "ip", zylinjtag_Jim_Command_ip, NULL, NULL);
Jim_CreateCommand(httpstate.jim_interp, "rm", zylinjtag_Jim_Command_rm, NULL, NULL);
+ Jim_CreateCommand(httpstate.jim_interp, "format_jffs2", zylinjtag_Jim_Command_format_jffs2, NULL, NULL);
cyg_httpd_start();
diag_printf("Web server running\n");
+ int s;
+ struct ifreq ifr;
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (s >= 0)
+ {
+ strcpy(ifr.ifr_name, "eth0");
+ int res;
+ res = ioctl(s, SIOCGIFHWADDR, &ifr);
+ close(s);
+
+ if (res < 0)
+ {
+ diag_printf("Can't obtain MAC address\n");
+ reboot();
+ }
+ }
+
+ sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
+ (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[0],
+ (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[1],
+ (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[2],
+ (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[3],
+ (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[4],
+ (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[5]);
+
+
+ discover_message=alloc_printf("ZY1000 Zylin JTAG debugger MAC %s", hwaddr);
+
discover_launch();
}
char *infoStr = "unknown";
switch (exception)
{
+#ifdef CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION
case CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION:
infoStr = "undefined instruction";
break;
case CYGNUM_HAL_VECTOR_ABORT_DATA:
infoStr = "abort data";
break;
+#endif
default:
break;
}
static char forwardBuffer[1024]; // NB! must be smaller than a TCP/IP packet!!!!!
static char backwardBuffer[1024];
-static cyg_io_handle_t serial_handle;
void setNoDelay(int session, int flag)
{
continue;
}
+#ifdef CYGPKG_PROFILE_GPROF
start_profile();
+#endif
int actual = 0;
int actual2 = 0;
int pos, pos2;
int handle_uart_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- if (argc != 1)
+ static int current_baud = 38400;
+ if (argc == 0)
+ {
+ command_print(cmd_ctx, "%d", current_baud);
+ return ERROR_OK;
+ } else if (argc != 1)
{
- command_print(cmd_ctx, "usage: uart <baudrate>");
return ERROR_INVALID_ARGUMENTS;
}
- int baud = atol(args[0]);
+ current_baud = atol(args[0]);
- switch (baud)
+ int baud;
+ switch (current_baud)
{
case 9600:
baud = CYGNUM_SERIAL_BAUD_9600;
//get existing serial configuration
len = sizeof(cyg_serial_info_t);
int err;
+ cyg_io_handle_t serial_handle;
+
+ err = cyg_io_lookup("/dev/ser0", &serial_handle);
+ if (err != ENOERR)
+ {
+ LOG_ERROR("/dev/ser0 not found\n");
+ return ERROR_FAIL;
+ }
+
+
err = cyg_io_get_config(serial_handle, CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, &buf, &len);
err = cyg_io_get_config(serial_handle, CYG_IO_GET_CONFIG_SERIAL_INFO, &buf, &len);
if (err != ENOERR)
ramblockdevice=(cyg_uint8 *)malloc(ramblockdevice_size);
memset(ramblockdevice, 0xff, ramblockdevice_size);
+
+
+#ifdef CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION
setHandler(CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION);
setHandler(CYGNUM_HAL_VECTOR_ABORT_PREFETCH);
setHandler(CYGNUM_HAL_VECTOR_ABORT_DATA);
+#endif
int err;
- err = cyg_io_lookup("/dev/ser0", &serial_handle);
- if (err != ENOERR)
- {
- diag_printf("/dev/ser0 not found\n");
- reboot();
- }
setPower(true); // on by default
err = mount("/dev/flash1", "/config", "jffs2");
if (err < 0)
{
- diag_printf("unable to mount jffs\n");
- reboot();
- }
-
- /* are we using a ram disk instead of a flash disk? This is used
- * for ZY1000 live demo...
- *
- * copy over flash disk to ram block device
- */
- if (boolParam("ramdisk"))
- {
- diag_printf("Unmounting /config from flash and using ram instead\n");
- err=umount("/config");
- if (err < 0)
+ diag_printf("unable to mount jffs2, falling back to ram disk..\n");
+ err = mount("", "/config", "ramfs");
+ if (err<0)
{
- diag_printf("unable to unmount jffs\n");
+ diag_printf("unable to mount /config as ramdisk.\n");
reboot();
}
-
- err = mount("/dev/flash1", "/config2", "jffs2");
- if (err < 0)
+ } else
+ {
+ /* are we using a ram disk instead of a flash disk? This is used
+ * for ZY1000 live demo...
+ *
+ * copy over flash disk to ram block device
+ */
+ if (boolParam("ramdisk"))
{
- diag_printf("unable to mount jffs\n");
- reboot();
- }
+ diag_printf("Unmounting /config from flash and using ram instead\n");
+ err=umount("/config");
+ if (err < 0)
+ {
+ diag_printf("unable to unmount jffs\n");
+ reboot();
+ }
- err = mount("/dev/ram", "/config", "jffs2");
- if (err < 0)
- {
- diag_printf("unable to mount ram block device\n");
- reboot();
- }
+ err = mount("/dev/flash1", "/config2", "jffs2");
+ if (err < 0)
+ {
+ diag_printf("unable to mount jffs\n");
+ reboot();
+ }
-// copydir("/config2", "/config");
- copyfile("/config2/ip", "/config/ip");
- copydir("/config2/settings", "/config/settings");
+ err = mount("/dev/ram", "/config", "jffs2");
+ if (err < 0)
+ {
+ diag_printf("unable to mount ram block device\n");
+ reboot();
+ }
- umount("/config2");
- } else
- {
- /* we're not going to use a ram block disk */
- free(ramblockdevice);
+ // copydir("/config2", "/config");
+ copyfile("/config2/ip", "/config/ip");
+ copydir("/config2/settings", "/config/settings");
+
+ umount("/config2");
+ } else
+ {
+ /* we're not going to use a ram block disk */
+ free(ramblockdevice);
+ }
}