Hello,
On 07.08.20 23:03, Daly, Connor G. wrote:
Genode beginner here. Been working with the platform for a few weeks trying to port a standard Linux application I wrote to Genode. My program uses sockets, both for sending and receiving, and judging from the code in tcp_terminal, the only way to do sockets is with libc rather than native Genode. I've been trying to implement the first few phases of my program in Genode, but when I run them, no log messages seem to appear and I can't really tell if my program is doing anything. When I remove the libc relevant pieces of code and run my program through a base/Component, everything logs just fine. I created a small test program to find my mistake, so this piece of code does not log anything to qemu with a Linux target platform:
I tried you test program and getting:
[init] child "widget" [init] RAM quota: 776K [init] cap quota: 16 [init] ELF binary: widget [init] priority: 0 [init -> widget] upgrading quota donation for PD session (0 bytes, 4 caps) [init] child "widget" requests resources: ram_quota=0, cap_quota=4
The resource request stalls your application until the request gets fulfilled. Since you have a static scenario configured, there is nobody looking at such requests and nobody will respond/upgrade the resource request of your component. Since your scenario is static anyway, you will just have to increase the assigned cap quota of your component, e.g.
</default-route> - <default caps="50"/> + <default caps="55"/> <start name="widget">
or just a bit more, e.g. 100.
Now I tried to re-run your test, and get:
[init] child "widget" [init] RAM quota: 776K [init] cap quota: 21 [init] ELF binary: widget [init] priority: 0 affinity 1x1 0x0 1x0 diag=0, label="init -> widget", ram_quota=31996, cap_quota=5 [init] child "widget" requests resources: ram_quota=266240
Again, a resource request, but this time your configured memory is not sufficient. So, I increased it a bit:
<default caps="55"/> <start name="widget"> - <resource name="RAM" quantum="1M"/> + <resource name="RAM" quantum="1300K"/> </start>
and now I get your "Hello world":
genode build completed using 'core-linux' as 'core' using 'ld-linux.lib.so' as 'ld.lib.so' spawn ./core Genode 20.05-159-g2b601c847f <local changes> 17592186044415 MiB RAM and 8997 caps assigned to init [init] parent provides [init] service "LOG" [init] service "PD" [init] service "CPU" [init] service "ROM" [init] service "IO_MEM" [init] service "IO_PORT" [init] service "RAM" [init] child "widget" [init] RAM quota: 1052K [init] cap quota: 21 [init] ELF binary: widget [init] priority: 0 [init -> widget] Hello world Run script execution successful.
Just some further notes:
If you just porting a normal libc/posix application, without any interactions with Genode services codewise, you can just start with your normal main() entry, e.g.
repos/libports/src/test/libc/main.cc repos/libports/src/test/libc/target.mk repos/libports/run/libc.run
Additionally, your libc program needs some stdio/stderr/socket etc. configuration, look into the libc.run or tcp_terminal.run example, eg. the <vfs> and <libc> xml nodes are crucial, not optional ;-). Since you are doing network, you may also look into repos/libports/run/lwip.run as inspiration.
Hope it helps,
Alex.