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