Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
picsimlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
picsimlab
Commits
93fd9618
Commit
93fd9618
authored
Aug 06, 2020
by
lcgamboa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new: support to use unix domain socket !minor
parent
c1333d15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
16 deletions
+38
-16
src/boards/board_qemu_stm32.cc
src/boards/board_qemu_stm32.cc
+38
-16
No files found.
src/boards/board_qemu_stm32.cc
View file @
93fd9618
...
@@ -59,10 +59,18 @@ board_qemu_stm32::MSetSerial(const char * port) {
...
@@ -59,10 +59,18 @@ board_qemu_stm32::MSetSerial(const char * port) {
int
int
board_qemu_stm32
::
MInit
(
const
char
*
processor
,
const
char
*
fname
,
float
freq
)
board_qemu_stm32
::
MInit
(
const
char
*
processor
,
const
char
*
fname
,
float
freq
)
{
{
struct
sockaddr_in
serv
,
cli
;
struct
sockaddr_in
servm
;
#ifdef _TCP_
struct
sockaddr_in
serv
,
cli
;
#else
struct
sockaddr_un
serv
,
cli
;
#endif
char
buff
[
100
];
char
buff
[
100
];
int
n
;
int
n
;
char
fname_
[
300
];
char
cmd
[
500
];
#ifdef _WIN_
#ifdef _WIN_
int
clilen
;
int
clilen
;
#else
#else
...
@@ -79,7 +87,7 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
...
@@ -79,7 +87,7 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
serialfd
[
2
]
=
-
1
;
serialfd
[
2
]
=
-
1
;
serialfd
[
3
]
=
-
1
;
serialfd
[
3
]
=
-
1
;
#ifdef _TCP_
if
((
listenfd
=
socket
(
PF_INET
,
SOCK_STREAM
,
0
))
<
0
)
if
((
listenfd
=
socket
(
PF_INET
,
SOCK_STREAM
,
0
))
<
0
)
{
{
printf
(
"socket error : %s
\n
"
,
strerror
(
errno
));
printf
(
"socket error : %s
\n
"
,
strerror
(
errno
));
...
@@ -94,7 +102,20 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
...
@@ -94,7 +102,20 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
serv
.
sin_family
=
AF_INET
;
serv
.
sin_family
=
AF_INET
;
serv
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
serv
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
serv
.
sin_port
=
htons
(
2200
);
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
);
#endif
if
(
bind
(
listenfd
,
(
sockaddr
*
)
&
serv
,
sizeof
(
serv
))
<
0
)
if
(
bind
(
listenfd
,
(
sockaddr
*
)
&
serv
,
sizeof
(
serv
))
<
0
)
{
{
printf
(
"bind error : %s
\n
"
,
strerror
(
errno
));
printf
(
"bind error : %s
\n
"
,
strerror
(
errno
));
...
@@ -107,11 +128,10 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
...
@@ -107,11 +128,10 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
exit
(
1
);
exit
(
1
);
}
}
char
fname_
[
300
];
//change .hex to .bin
//change .hex to .bin
strncpy
(
fname_
,
fname
,
299
);
strncpy
(
fname_
,
fname
,
299
);
strncpy
(
fname_
+
(
strlen
(
fname_
)
-
3
),
"bin"
,
299
)
;
fname_
[
strlen
(
fname_
)
-
3
]
=
0
;
strncat
(
fname_
,
"bin"
,
299
);
if
(
!
lxFileExists
(
fname_
))
if
(
!
lxFileExists
(
fname_
))
{
{
...
@@ -131,14 +151,14 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
...
@@ -131,14 +151,14 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
}
}
}
}
char
cmd
[
500
];
snprintf
(
cmd
,
499
,
"cd %s; ./qemu-system-arm -M stm32-f103c8-picsimlab -pflash %s -serial %s -qmp tcp:localhost:2500,server,nowait &"
,
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/"
,
"/home/gamboa/projetos/qemu_stm32/arm-softmmu/"
,
fname_
,
fname_
,
"/dev/tnt2"
"/dev/tnt2"
);
);
printf
(
"%s"
,
(
const
char
*
)
cmd
);
printf
(
"%s
\n
"
,
(
const
char
*
)
cmd
);
system
(
cmd
);
system
(
cmd
);
clilen
=
sizeof
(
cli
);
clilen
=
sizeof
(
cli
);
...
@@ -162,12 +182,12 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
...
@@ -162,12 +182,12 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
printf
(
"socket error : %s
\n
"
,
strerror
(
errno
));
printf
(
"socket error : %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
exit
(
1
);
}
}
memset
(
&
serv
,
0
,
sizeof
(
serv
));
memset
(
&
serv
m
,
0
,
sizeof
(
servm
));
serv
.
sin_family
=
AF_INET
;
serv
m
.
sin_family
=
AF_INET
;
serv
.
sin_addr
.
s_addr
=
inet_addr
(
"127.0.0.1"
);
serv
m
.
sin_addr
.
s_addr
=
inet_addr
(
"127.0.0.1"
);
serv
.
sin_port
=
htons
(
2500
);
serv
m
.
sin_port
=
htons
(
2500
);
if
(
connect
(
sockmon
,
(
sockaddr
*
)
&
serv
,
sizeof
(
serv
))
<
0
)
if
(
connect
(
sockmon
,
(
sockaddr
*
)
&
serv
m
,
sizeof
(
servm
))
<
0
)
{
{
printf
(
"connect error : %s
\n
"
,
strerror
(
errno
));
printf
(
"connect error : %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
exit
(
1
);
...
@@ -190,6 +210,7 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
...
@@ -190,6 +210,7 @@ board_qemu_stm32::MInit(const char * processor, const char * fname, float freq)
Window1
.
menu1_File_SaveHex
.
SetEnable
(
0
);
Window1
.
menu1_File_SaveHex
.
SetEnable
(
0
);
Window1
.
filedialog1
.
SetFileName
(
lxT
(
"untitled.bin"
));
Window1
.
filedialog1
.
SetFileName
(
lxT
(
"untitled.bin"
));
Window1
.
filedialog1
.
SetFilter
(
lxT
(
"Bin Files (*.bin)|*.bin;*.BIN"
));
Window1
.
filedialog1
.
SetFilter
(
lxT
(
"Bin Files (*.bin)|*.bin;*.BIN"
));
return
0
;
//ret;
return
0
;
//ret;
}
}
...
@@ -408,7 +429,8 @@ board_qemu_stm32::MDumpMemory(const char * fname)
...
@@ -408,7 +429,8 @@ board_qemu_stm32::MDumpMemory(const char * fname)
//change .hex to .bin
//change .hex to .bin
strncpy
(
fname_
,
fname
,
299
);
strncpy
(
fname_
,
fname
,
299
);
strncpy
(
fname_
+
(
strlen
(
fname_
)
-
3
),
"bin"
,
299
);
fname_
[
strlen
(
fname_
)
-
3
]
=
0
;
strncat
(
fname_
,
"bin"
,
299
);
qemu_cmd
(
"stop"
);
qemu_cmd
(
"stop"
);
snprintf
(
cmd
,
500
,
"{
\"
execute
\"
:
\"
pmemsave
\"
,
\"
arguments
\"
: {
\"
val
\"
: 134217728,
\"
size
\"
: 65536,
\"
filename
\"
:
\"
%s
\"
} }
\n
"
,
fname_
);
snprintf
(
cmd
,
500
,
"{
\"
execute
\"
:
\"
pmemsave
\"
,
\"
arguments
\"
: {
\"
val
\"
: 134217728,
\"
size
\"
: 65536,
\"
filename
\"
:
\"
%s
\"
} }
\n
"
,
fname_
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment