Commit cd528a00 authored by lcgamboa's avatar lcgamboa

chg: new boards support to cross compile to windows !minor

parent 93fd9618
......@@ -18,8 +18,10 @@ override CFLAGS+= -D_VERSION_=\"$(VERSION)\" -Wall -O2 -D_SHARE_=\"${sharedir}\"
override CFLAGS+= -DEXT_BROWSER
#override CFLAGS+=-fsanitize=address
ELIBS_= $(addsuffix .a ,$(ELIBS))
LIBS = `lxrad-config --libs` -lpicsim -lsimavr -lelf
LIBS+= $(ELIBS)
LIBS+= $(ELIBS_)
#LIBS= ../../picsim/src/libpicsim_dbg.a ../../LXRAD_WX/libteste/liblxrad.a ../../simavr/simavr/obj-x86_64-linux-gnu/libsimavr.a\
-lopenal `wx-config --libs` `wx-config --libs stc`
......
......@@ -25,7 +25,8 @@ OBJS_EXP = boards/board_MPLAB_Xpress.o boards/board_Curiosity.o boards/board_x.
exp: OBJS+=$(OBJS_EXP)
exp: EFLAGS=-D_EXPERIMENTAL_
exp: ELIBS= ../../ucsim-0.6/picsimlab/libucsim.a
#static libraries without suffix
exp: ELIBS= ../../ucsim-0.6/picsimlab/libucsim
exp: $(OBJS_EXP) all
......
......@@ -20,9 +20,10 @@ override CFLAGS += -DEXT_BROWSER -D_VERSION_=\"${VERSION}\" -Wall -ggdb -D_SHARE
#override CFLAGS+= -D_NOTHREAD
#override CFLAGS+=-fsanitize=address
#LIBS = `lxrad_X11-config --libs` -lpicsim -lsimavr -lelf -lminizip
LIBS = `lxrad_X11-config --libs` ../../picsim/src/libpicsim_dbg.a ../../simavr/simavr/obj-x86_64-linux-gnu/libsimavr.a -lelf -lminizip
LIBS+= $(ELIBS)
ELIBS_= $(addsuffix .a ,$(ELIBS))
#LIBS = $(ELIBS_) `lxrad_X11-config --libs` -lpicsim -lsimavr -lelf -lminizip
LIBS = $(ELIBS_) `lxrad_X11-config --libs` ../../picsim/src/libpicsim_dbg.a ../../simavr/simavr/obj-x86_64-linux-gnu/libsimavr.a -lelf -lminizip
#lxrad automatic generated block end, don't edit above!
......
......@@ -8,9 +8,10 @@ override CFLAGS+= -DEXT_BROWSER
override CFLAGS+=-I../dev_w64/lib/wx/include/x86_64-w64-mingw32-msw-unicode-3.1 -I../dev_w64/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMSW__
#CFLAGS+=`x86_64-w64-mingw32-msw-unicode-3.1 --cxxflags`
LIBS= -llxrad -lOpenAL32 -lpicsim -lsimavr -lws2_32 -L../dev_w64/lib
ELIBS_= $(addsuffix .aw ,$(ELIBS))
LIBS= $(ELIBS_) -llxrad -lOpenAL32 -lpicsim -lsimavr -lws2_32 -L../dev_w64/lib
LIBS+= -Wl,--subsystem,windows -mwindows -lwx_mswu_xrc-3.1-x86_64-w64-mingw32 -lwx_mswu_html-3.1-x86_64-w64-mingw32 -lwx_mswu_qa-3.1-x86_64-w64-mingw32 -lwx_mswu_core-3.1-x86_64-w64-mingw32 -lwx_baseu_xml-3.1-x86_64-w64-mingw32 -lwx_baseu_net-3.1-x86_64-w64-mingw32 -lwx_baseu-3.1-x86_64-w64-mingw32
LIBS+= $(ELIBS)
#LIBS+=`x86_64-w64-mingw32-msw-unicode-3.1 --libs`
......
......@@ -9,9 +9,11 @@ override CFLAGS+= -I../dev_w32/lib/wx/include/i686-w64-mingw32-msw-unicode-3.1 -
#CFLAGS +=`i686-w64-mingw32-msw-unicode-3.1 --cxxflags`
LIBS= -llxrad -lOpenAL32 -lpicsim -lsimavr -lws2_32 -L../dev_w32/lib
ELIBS_= $(addsuffix .aw32 ,$(ELIBS))
LIBS= $(ELIBS_) -llxrad -lOpenAL32 -lpicsim -lsimavr -lws2_32 -L../dev_w32/lib
LIBS+= -Wl,--subsystem,windows -mwindows -lwx_mswu_xrc-3.1-i686-w64-mingw32 -lwx_mswu_html-3.1-i686-w64-mingw32 -lwx_mswu_qa-3.1-i686-w64-mingw32 -lwx_mswu_core-3.1-i686-w64-mingw32 -lwx_baseu_xml-3.1-i686-w64-mingw32 -lwx_baseu_net-3.1-i686-w64-mingw32 -lwx_baseu-3.1-i686-w64-mingw32
LIBS+= $(ELIBS)
#LIBS+=`i686-w64-mingw32-msw-unicode-3.1 --libs`
all: $(OBJS)
......
......@@ -18,10 +18,12 @@ override CFLAGS += -D_VERSION_=\"$(VERSION)\" -Wall -O2 -D_SHARE_=\"${sharedir}\
override CFLAGS+= -DEXT_BROWSER
#override CFLAGS+=-fsanitize=address
ELIBS_= $(addsuffix .a ,$(ELIBS))
LIBS= ../../picsim/src/libpicsim.a ../../lxrad/lib/liblxrad.a \
../../simavr/simavr/obj-x86_64-linux-gnu/libsimavr.a\
-lopenal `wx-config --libs` `wx-config --libs stc`
LIBS+= $(ELIBS)
LIBS+= $(ELIBS_)
#lxrad automatic generated block end, don't edit above!
......
......@@ -96,7 +96,7 @@ cboard_Blue_Pill::Reset(void)
#ifndef _WIN_
if (serialfd[0] > 0)
#else
if (serial[0].serialfd != INVALID_HANDLE_VALUE)
if (serialfd[0] != INVALID_HANDLE_VALUE)
#endif
Window1.statusbar1.SetField (2, lxT ("Serial: ") +
String::FromAscii (SERIALDEVICE) + lxT (":") + itoa (serialbaud) + lxT ("(") +
......@@ -118,7 +118,7 @@ cboard_Blue_Pill::RefreshStatus(void)
#ifndef _WIN_
if (serialfd[0] > 0)
#else
if (pic.serial[0].serialfd != INVALID_HANDLE_VALUE)
if (serialfd[0] != INVALID_HANDLE_VALUE)
#endif
Window1.statusbar1.SetField (2, lxT ("Serial: ") +
String::FromAscii (SERIALDEVICE) + lxT (":") + itoa (serialbaud) + lxT ("(") +
......
......@@ -36,12 +36,12 @@ void setnblock(int sock_descriptor);
#include<sys/un.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include <lxrad/lxutils.h>
#define INVALID_HANDLE_VALUE -1;
#else
#include<winsock2.h>
#include<ws2tcpip.h>
WORD wVersionRequested = 2;
WSADATA wsaData;
#define SHUT_RDWR SD_BOTH
#define _TCP_
#endif
board_qemu_stm32::board_qemu_stm32(void)
......@@ -60,17 +60,17 @@ int
board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
{
struct sockaddr_in servm;
#ifdef _TCP_
struct sockaddr_in serv, cli;
#ifdef _TCP_
struct sockaddr_in serv, cli;
#else
struct sockaddr_un serv, cli;
struct sockaddr_un serv, cli;
#endif
char buff[100];
int n;
char fname_[300];
char cmd[500];
#ifdef _WIN_
int clilen;
#else
......@@ -82,10 +82,10 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
pins_reset ();
serialfd[0] = -1;
serialfd[1] = -1;
serialfd[2] = -1;
serialfd[3] = -1;
serialfd[0] = INVALID_HANDLE_VALUE;
serialfd[1] = INVALID_HANDLE_VALUE;
serialfd[2] = INVALID_HANDLE_VALUE;
serialfd[3] = INVALID_HANDLE_VALUE;
#ifdef _TCP_
if ((listenfd = socket (PF_INET, SOCK_STREAM, 0)) < 0)
......@@ -103,19 +103,18 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
serv.sin_addr.s_addr = htonl (INADDR_ANY);
serv.sin_port = htons (2200);
#else
if ((listenfd = socket (PF_UNIX, SOCK_STREAM, 0)) < 0)
{
printf ("socket error : %s \n", strerror (errno));
exit (1);
};
//unlink("/tmp/.picsimlab_qemu");
memset (&serv, 0, sizeof (serv));
serv.sun_family = AF_UNIX;
serv.sun_path[0]=0;
strncpy(serv.sun_path+1, "picsimlab_qemu", sizeof(serv.sun_path)-2);
if ((listenfd = socket (PF_UNIX, SOCK_STREAM, 0)) < 0)
{
printf ("socket error : %s \n", strerror (errno));
exit (1);
}
memset (&serv, 0, sizeof (serv));
serv.sun_family = AF_UNIX;
serv.sun_path[0] = 0;
strncpy (serv.sun_path + 1, "picsimlab_qemu", sizeof (serv.sun_path) - 2);
#endif
if (bind (listenfd, (sockaddr *) & serv, sizeof (serv)) < 0)
{
printf ("bind error : %s \n", strerror (errno));
......@@ -130,7 +129,7 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
//change .hex to .bin
strncpy (fname_, fname, 299);
fname_[strlen (fname_) - 3]=0;
fname_[strlen (fname_) - 3] = 0;
strncat (fname_, "bin", 299);
if (!lxFileExists (fname_))
......@@ -151,20 +150,39 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
}
}
snprintf (cmd, 499, "cd %s; ./qemu-system-arm -M stm32-f103c8-picsimlab -pflash %s -serial %s -qmp tcp:localhost:2500,server,nowait &",
"/home/gamboa/projetos/qemu_stm32/arm-softmmu/",
fname_,
"/dev/tnt2"
);
printf ("%s\n", (const char *)cmd);
//verify if qemu executable exists
#ifdef _WIN_
if( ! lxFileExists (Window1.GetSharePath () + lxT ("/../qemu-stm32.exe" )))
#else
if((!lxFileExists("/usr/bin/qemu-stm32"))&&(!lxFileExists("/usr/local/bin/qemu-stm32")))
#endif
{
Message ("qemu-stm32 not found!");
close (listenfd);
return -1;
}
system (cmd);
#ifdef _WIN_
snprintf (cmd, 499, "qemu-stm32 -M stm32-f103c8-picsimlab -qmp tcp:localhost:2500,server,nowait -pflash \"%s\"",
fname_
);
#else
snprintf (cmd, 499, "qemu-stm32 -M stm32-f103c8-picsimlab -serial %s -qmp tcp:localhost:2500,server,nowait -pflash \"%s\"",
SERIALDEVICE ,fname_
);
#endif
printf ("%s\n", (const char *) cmd);
#ifdef _WIN_
lxExecute (Window1.GetSharePath () + lxT ("/../") + cmd);
#else
lxExecute (cmd, lxEXEC_MAKE_GROUP_LEADER);
#endif
clilen = sizeof (cli);
if (
(sockfd =
accept (listenfd, (sockaddr *) & cli, & clilen)) < 0)
(sockfd = accept (listenfd, (sockaddr *) & cli, & clilen)) < 0)
{
printf ("accept error : %s \n", strerror (errno));
exit (1);
......@@ -202,14 +220,15 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
buff[n] = 0;
printf ("%s", buff);
connected = 1;
qemu_cmd ("qmp_capabilities");
connected = 1;
Window1.menu1_File_LoadHex.SetText ("Load Bin");
Window1.menu1_File_SaveHex.SetEnable (0);
Window1.filedialog1.SetFileName(lxT("untitled.bin"));
Window1.filedialog1.SetFilter(lxT("Bin Files (*.bin)|*.bin;*.BIN"));
Window1.filedialog1.SetFileName (lxT ("untitled.bin"));
Window1.filedialog1.SetFilter (lxT ("Bin Files (*.bin)|*.bin;*.BIN"));
return 0; //ret;
}
......@@ -223,12 +242,18 @@ board_qemu_stm32::MEnd(void)
}
close (sockfd);
connected = 0;
Window1.menu1_File_LoadHex.SetText ("Load Hex");
Window1.menu1_File_SaveHex.SetEnable (1);
Window1.filedialog1.SetFileName(lxT("untitled.hex"));
Window1.filedialog1.SetFilter(lxT("Hex Files (*.hex)|*.hex;*.HEX"));
sleep(1);
Window1.filedialog1.SetFileName (lxT ("untitled.hex"));
Window1.filedialog1.SetFilter (lxT ("Hex Files (*.hex)|*.hex;*.HEX"));
//Wait for qemu shutdown
#ifdef _WIN_
Sleep (1000);
#else
sleep (1);
#endif
}
void
......@@ -262,9 +287,7 @@ board_qemu_stm32::CpuInitialized(void)
void
board_qemu_stm32::DebugLoop(void) {
}
}
String
board_qemu_stm32::MGetPinName(int pin)
......@@ -429,7 +452,7 @@ board_qemu_stm32::MDumpMemory(const char * fname)
//change .hex to .bin
strncpy (fname_, fname, 299);
fname_[strlen (fname_) - 3]=0;
fname_[strlen (fname_) - 3] = 0;
strncat (fname_, "bin", 299);
qemu_cmd ("stop");
......@@ -444,7 +467,6 @@ board_qemu_stm32::DebugInit(int dtyppe) //argument not used in picm only mplabx
return 0; //!mplabxd_init (this, Window1.Get_debug_port ()) - 1;
}
int
board_qemu_stm32::MGetPinCount(void)
{
......@@ -477,10 +499,10 @@ board_qemu_stm32::MSetPin(int pin, unsigned char value)
if ((connected)&&(pins[pin - 1].value != value))
{
unsigned char val = (0x7F & pin);
if(value)
val|=0x80;
if (send (sockfd, &val, 1, 0) != 1)
if (value)
val |= 0x80;
if (send (sockfd, (const char *) &val, 1, 0) != 1)
{
printf ("send error : %s \n", strerror (errno));
exit (1);
......@@ -505,7 +527,6 @@ board_qemu_stm32::MGetPin(int pin)
return 0; //get_pin (pin);
}
void
board_qemu_stm32::MReset(int flags)
{
......@@ -515,7 +536,6 @@ board_qemu_stm32::MReset(int flags)
}
}
const picpin *
board_qemu_stm32::MGetPinsValues(void)
{
......@@ -532,7 +552,7 @@ board_qemu_stm32::MStep(void)
{
while ((n = recv (sockfd, &buff, 1, 0)) > 0)
{
pins[(0x7F & buff) - 1].value = ((0x80 & buff) > 0);
pins[(0x7F & buff) - 1].value = ((0x80 & buff) > 0);
}
}
}
......@@ -542,7 +562,6 @@ board_qemu_stm32::MStepResume(void) {
//if (pic.s2 == 1)step ();
}
int
board_qemu_stm32::qemu_cmd(const char * cmd, int raw)
{
......@@ -551,6 +570,7 @@ board_qemu_stm32::qemu_cmd(const char * cmd, int raw)
char buffout[400];
unsigned int size;
if (!connected) return -1;
/*
//clear messages
if ((n = recv (sockmon, buffout, 399, 0)) < 0)
......@@ -560,8 +580,8 @@ board_qemu_stm32::qemu_cmd(const char * cmd, int raw)
buffout[n] = 0;
printf ("(%s)=(%s) \n", buffin, buffout);
*/
*/
if (raw)
{
strcpy (buffin, cmd);
......@@ -579,7 +599,11 @@ board_qemu_stm32::qemu_cmd(const char * cmd, int raw)
exit (1);
}
#ifdef _WIN_
Sleep (1);
#else
usleep (1000);
#endif
if ((n = recv (sockmon, buffout, 399, 0)) < 0)
{
......
......@@ -57,7 +57,12 @@ class board_qemu_stm32: virtual public board
void pins_reset(void);
protected:
int qemu_cmd(const char * cmd, int raw =0);
#ifdef _WIN_
HANDLE serialfd[4];
#else
int serialfd[4];
#endif
int procid;
picpin pins[256];
unsigned int serialbaud;
float serialexbaud;
......
......@@ -100,7 +100,7 @@ cboard_uCboard::Reset(void)
#ifndef _WIN_
if (serialfd > 0)
#else
if (serial[0].serialfd != INVALID_HANDLE_VALUE)
if (serialfd != INVALID_HANDLE_VALUE)
#endif
Window1.statusbar1.SetField (2, lxT ("Serial: ") +
String::FromAscii (SERIALDEVICE) + lxT (":") + itoa (serialbaud) + lxT ("(") +
......@@ -122,7 +122,7 @@ cboard_uCboard::RefreshStatus(void)
#ifndef _WIN_
if (serialfd > 0)
#else
if (pic.serial[0].serialfd != INVALID_HANDLE_VALUE)
if (serialfd != INVALID_HANDLE_VALUE)
#endif
Window1.statusbar1.SetField (2, lxT ("Serial: ") +
String::FromAscii (SERIALDEVICE) + lxT (":") + itoa (serialbaud) + lxT ("(") +
......
......@@ -51,7 +51,7 @@ static const char pinnames[3][40][10] = {
"P1.0", "P1.1", "P1.2", "P1.3", "P1.4", "P1.5", "P1.6", "P1.7",
"P2.0", "P2.1", "P2.2", "P2.3", "P2.4", "P2.5", "P2.6", "P2.7",
"P3.0", "P3.1", "P3.2", "P3.3", "P3.4", "P3.5", "P3.6", "P3.7",
"VCC","GND","RST", "XTAL1", "XTAL2","NC", "NC", "NC" }
"RST","INT1","INT2", "INT3", "INT5","INT7", "GND", "VCC" }
};
......
......@@ -60,7 +60,11 @@ class board_ucsim: virtual public board
unsigned int serialbaud;
float serialexbaud;
float freq;
#ifdef _WIN_
HANDLE serialfd;
#else
int serialfd;
#endif
int procid;
};
......
......@@ -46,8 +46,8 @@
#include <fcntl.h>
#else
#include<winsock.h>
WORD wVersionRequested = 2;
WSADATA wsaData;
static WORD wVersionRequested = 2;
static WSADATA wsaData;
#ifndef MSG_WAITALL
#define MSG_WAITALL (1 << 3)
#endif
......@@ -100,7 +100,7 @@ initialize_socket(void)
if (wsaData.wVersion != wVersionRequested)
{
fprintf (stderr, "\n Wrong version\n");
return 1;
return;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment