<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">On 8/28/20 11:56 AM, Porter, Jeremy wrote:<br>
>> I have RISC-V based cross compiled Linux running busybox. I have a very simple<br>
>> /etc/inittab file like this:<br>
>> <br>
>>   1 ::sysinit:/bin/busybox mount -t proc proc /proc<br>
>>   2 ::sysinit:/bin/busybox mount -t tmpfs tmpfs /tmp<br>
>>   3 ::sysinit:/bin/busybox mount -o remount,rw /dev/htifbd0 /<br>
>>   4 ::sysinit:/bin/busybox --install -s<br>
>>   5 /dev/console::sysinit:-/bin/ash<br>
>> <br>
>> How can I translate this to something toybox can use? I've tried this:<br>
>> <br>
>>   1 mount -t proc proc /proc<br>
>   2 mount -t tmpfs tmpfs /tmp<br>
>   3 mount -o remount,rw /dev/htifbd0 /<br>
>   4 #::sysinit:/bin/toybox --install -s<br>
>   5 #/dev/console::sysinit:-/bin/sh<br>
>   6 exec toybox init<br>
<br>
And when you tried it, you saw what output?</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">###Output below###</div>
<div class="PlainText">/work/qemu5/build/riscv64-softmmu/qemu-system-riscv64 --nographic -m 19000K --kernel /work/rocket-tools/riscv-pk/build/bbl
<div>qemu-system-riscv64: warning: No -bios option specified. Not loading a firmware.</div>
<div>qemu-system-riscv64: warning: This default will change in a future QEMU release. Please use the -bios option to avoid breakages when this happens.</div>
<div>qemu-system-riscv64: warning: See QEMU's deprecation documentation for details.</div>
<div>bbl loader</div>
<div>OF: fdt: Ignoring memory range 0x80000000 - 0x80200000</div>
<div>Linux version 5.8.0 (porterjl@rdrydl0-044816) (riscv64-unknown-linux-gnu-gcc (GCC) 7.2.0, GNU ld (GNU Binutils) 2.29) #107 Fri Aug 28 07:12:33 EDT 2020</div>
<div>Zone ranges:</div>
<div>  DMA32    [mem 0x0000000080200000-0x000000008128dfff]</div>
<div>  Normal   empty</div>
<div>Movable zone start for each node</div>
<div>Early memory node ranges</div>
<div>  node   0: [mem 0x0000000080200000-0x000000008128dfff]</div>
<div>Initmem setup node 0 [mem 0x0000000080200000-0x000000008128dfff]</div>
<div>software IO TLB: Cannot allocate buffer</div>
<div>SBI specification v0.1 detected</div>
<div>riscv: ISA extensions acdfimsu</div>
<div>riscv: ELF capabilities acdfim</div>
<div>Built 1 zonelists, mobility grouping on.  Total pages: 4180</div>
<div>Kernel command line: </div>
<div>Dentry cache hash table entries: 4096 (order: 3, 32768 bytes, linear)</div>
<div>Inode-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)</div>
<div>Sorting __ex_table...</div>
<div>mem auto-init: stack:off, heap alloc:off, heap free:off</div>
<div>Memory: 8040K/16952K available (823K kernel code, 3374K rwdata, 2048K rodata, 372K init, 201K bss, 8912K reserved, 0K cma-reserved)</div>
<div>NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0</div>
<div>riscv-intc: 64 local interrupts mapped</div>
<div>riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]</div>
<div>clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns</div>
<div>sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns</div>
<div>printk: console [hvc0] enabled</div>
<div>Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)</div>
<div>pid_max: default: 4096 minimum: 301</div>
<div>Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)</div>
<div>Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)</div>
<div>clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns</div>
<div>clocksource: Switched to clocksource riscv_clocksource</div>
<div>workingset: timestamp_bits=62 max_order=11 bucket_order=0</div>
<div>Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)</div>
<div>random: get_random_bytes called from 0xffffffff802049bc with crng_init=0</div>
<div>Freeing unused kernel memory: 372K</div>
<div>Run /init as init process</div>
<div>Started init</div>
<br>
<br>
</div>
<div class="PlainText">###End Output###<br>
</div>
<div class="PlainText"><br>
>Toybox init is still in pending, and thus isn't in the defconfig build. It<br>
>hasn't undergone the full <a href="https://urldefense.com/v3/__https://landley.net/toybox/cleanup.html__;!!KGKeukY!l7f45aEjunFct2lAgh4PDXhjANSCxgr8ttibt-bfdygS30JJiBTR4QnjWXtLgD9rdq9bWHVPI8jHzw$">
https://urldefense.com/v3/__https://landley.net/toybox/cleanup.html__;!!KGKeukY!l7f45aEjunFct2lAgh4PDXhjANSCxgr8ttibt-bfdygS30JJiBTR4QnjWXtLgD9rdq9bWHVPI8jHzw$</a>  review yet, so<br>
>I couldn't tell you what it does. (I'm told it worked for the people who<br>
>submitted it...)<br>
><br>
>Toybox has a built-in system builder:<br>
><br>
  <a href="https://urldefense.com/v3/__https://landley.net/toybox/faq.html*mkroot__;Iw!!KGKeukY!l7f45aEjunFct2lAgh4PDXhjANSCxgr8ttibt-bfdygS30JJiBTR4QnjWXtLgD9rdq9bWHWy5UZWrw$">
https://urldefense.com/v3/__https://landley.net/toybox/faq.html*mkroot__;Iw!!KGKeukY!l7f45aEjunFct2lAgh4PDXhjANSCxgr8ttibt-bfdygS30JJiBTR4QnjWXtLgD9rdq9bWHWy5UZWrw$</a>
<br>
></div>
<div class="PlainText"><br>
</div>
<div class="PlainText">I've been trying to get this working but I get:</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">./scripts/mkroot.sh
<div>Building natively</div>
<div>/usr/bin/ld: cannot find -lc</div>
<div>collect2: error: ld returned 1 exit status</div>
<div>Warning: host compiler can't create static binaries.</div>
<div>cleaned</div>
<div>gcc -o kconfig/conf kconfig/conf.c kconfig/zconf.tab.c -DKBUILD_NO_NLS=1 \</div>
<div>        -DPROJECT_NAME=\"ToyBox\"</div>
<div>scripts/genconfig.sh</div>
<div>yes '' | kconfig/conf -o Config.in > /dev/null</div>
<div>scripts/make.sh</div>
<div>Generate headers from toys/*/*.c...</div>
<div>generated/newtoys.h Library probe...........</div>
<div>Make generated/config.h from .config.</div>
<div>generated/flags.h generated/globals.h generated/tags.h generated/help.h</div>
<div>Compile toybox....................../usr/bin/ld: cannot find -lc</div>
<div>collect2: error: ld returned 1 exit status</div>
<div>make: *** [toybox] Error 1</div>
<br>
I'm also using RISC-V so I'd have to add a target to the script. I don't mind doing that, but I want to get something simple working first.<br>
</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">>And the init script it uses starts at:<br>
<br>
  <a href="https://urldefense.com/v3/__https://github.com/landley/toybox/blob/master/scripts/mkroot.sh*L73__;Iw!!KGKeukY!l7f45aEjunFct2lAgh4PDXhjANSCxgr8ttibt-bfdygS30JJiBTR4QnjWXtLgD9rdq9bWHXm0BlkZQ$">
https://urldefense.com/v3/__https://github.com/landley/toybox/blob/master/scripts/mkroot.sh*L73__;Iw!!KGKeukY!l7f45aEjunFct2lAgh4PDXhjANSCxgr8ttibt-bfdygS30JJiBTR4QnjWXtLgD9rdq9bWHXm0BlkZQ$</a>
<br>
<br>
>Which ends by calling "oneit", a very simple init program that runs a single<br>
>child process (with /dev/console pointing to a proper tty with signal support),<br>
>and reboots the system when that child exits.<br>
><br>
>Unfortunately the systems created by that system builder use 2 commands out of<br>
>pending (sh and route), and sh is under active development which means I broke<br>
>it recently. I added proper ${var:thingy} parsing, but haven't implemented<br>
>${var/search/replace} yet, which that init script uses. The current shell parses<br>
>it properly, but throws an error when it tries to _do_ it, because:</div>
<div class="PlainText">><br>
<a href="https://urldefense.com/v3/__https://github.com/landley/toybox/blob/master/toys/pending/sh.c*L1205__;Iw!!KGKeukY!l7f45aEjunFct2lAgh4PDXhjANSCxgr8ttibt-bfdygS30JJiBTR4QnjWXtLgD9rdq9bWHWyB268bA$">https://urldefense.com/v3/__https://github.com/landley/toybox/blob/master/toys/pending/sh.c*L1205__;Iw!!KGKeukY!l7f45aEjunFct2lAgh4PDXhjANSCxgr8ttibt-bfdygS30JJiBTR4QnjWXtLgD9rdq9bWHWyB268bA$</a>
<br>
><br>
>Which means the make root init script won't currently work as is, but I plan to<br>
>fix it up before cutting the next release. At the moment implementing "case"<br>
>statements and wildcard support, need to cycle back around to finishing the<br>
>variable expansion...<br>
><br>
>The downside of the project not being to 1.0 yet. :)</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">I actually don't need route or sh. My system is a very minimal. I suppose sh could be useful to get something happening in toybox init or oneit, but I don't have any specific requirements for it. I can put it in to get it working--it's
 still smaller than busybox. <br>
</div>
<div class="PlainText"><br>
>> It's starting partially (I think) but I'm not quite sure how to troubleshoot<br>
>> this.<br>
<br>
>Without seeing what it produced, I can't either.<br>
<br>
> My goal is to have a very small Linux. It's around 3 MB file size right<br>
> now and takes about 5 MB of memory when booted. It looks like toybox might go a<br>
> little smaller if I can get it working.<br>
<br>
>Try running /bin/sh as pid 1, and run your statements from the command line to<br>
> see what they do?</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">I don't have sh, but I can put it in to do this. <br>
</div>
<div class="PlainText"><br>
>You can also stick in "echo" statements to see what's being output, although if<br>
>your initramfs hasn't got a /dev/console entry you won't have a stdout until you<br>
>mount devtmpfs and redirect it yourself, but it looks like you're using<br>
>/dev/htifbd0 as your root so presumably you're using the root= fallback logic<br>
>which creates a temporary /dev/console node to attach PID 1's stdin/out/err to,<br>
>so this doesn't apply to that case...<br>
</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">Again, I don't have echo, but I can put it in and try this. I gave it a try, but I'm having some issues with the build (I suspect).
<br>
<br>
>Rob<br>
</div>
</span></font></div>
</div>
</body>
</html>