subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Thu Jan 16, 2020 4:40 pm

What I have: A Raspberry Pi Zero in OTG mode running as a "USB Gadget" for both MIDI and Ethernet (for SSH login for development).

The Problem: When I plug in my piZero to my MacOSX, it takes 28 seconds: from plugin, to MIDI device recognized. I'd like to be faster, in 5-10sec range. To support a nice consumer experience.

My Configuration:
- Running Buster Lite (2019-09-26-raspbian-buster-lite.img)
- I have a readonly FS so power can be cut without filesystem corruption (easily switched back to readwrite when I want to make a change)
- Service which creates the USB Gadget MIDI definition (and Ethernet for SSH over USB)
....- Registered to run ~ #5 at top of the systemd list, right under the display service (sudo systemctl list-dependencies to see all)
....- in the service I modprobe dwc2 and libcomposite, then create 2 USB device definitions in the /sys/kernel/config/usb_gadget/ directory - one for MIDI and one for Ethernet (so I can also SSH in).

What I've tried:
- I tried a faster microsd card, same boot up speed, no change, I figure we're CPU bound (or stuck on some hardware or network init) here... maybe piZero is slow.
- I originally was running my service from /etc/rc.local, which gave me 58second "time till MIDI". Moving my service to systemd, high up in the order, got me down to 28seconds "time till MIDI".

Ideas for next steps:
- initrd apparently can boot the pi much faster from a RAM disk (you create a disk image on your microsd card, and i’m not sure, but sounds like it slams that into memory as a filesystem for (magic) faster boot times). Pipedream? idk... haven't found a good guide on doing this.
- maybe there is still something to reduce. systemd-analyze blame gives a list of the services and orders by slowest to fastest, so you can find the worst and perhaps optimize them. e.g. Keyboard service seems to be taking ~4seconds.
- maybe I could init the MIDI USB Gadget before systemd initializes services? Maybe using the init.d/rc.d system? IDK. information here is murky. I tried to run my service there but it killed the device and that was the last thing i tried. I could spend more time here. I haven't fully explored yet.
- I dont have a clear understanding what happens before my service runs - nor whether I can move my service earlier. Can you help me think of ways to diagnose / troubleshoot this?


measurements from 2 separate boots, returned by systemd-analyze blame (this list is ordered by slowest to fastest systemd service):

Code: Select all

          9.011s dev-mmcblk0p2.device
          3.858s keyboard-setup.service
          3.204s systemd-udev-trigger.service
          2.995s busybox-syslogd.service
          2.436s [[[[---this is my controller---]]].service     <-------
          2.368s systemd-logind.service
          2.273s dhcpcd.service
          2.219s systemd-journald.service
          2.027s avahi-daemon.service
          1.916s networking.service
          1.856s ssh.service
          1.835s rpi-eeprom-update.service
          1.798s systemd-modules-load.service
          1.734s triggerhappy.service
          1.496s systemd-remount-fs.service
          1.434s rng-tools.service
          1.164s wpa_supplicant.service
          1.156s systemd-user-sessions.service
          1.113s systemd-tmpfiles-setup.service
          1.052s ntp.service
           947ms rc-local.service
           917ms kmod-static-nodes.service
           900ms raspi-config.service
           865ms fake-hwclock.service
           851ms run-rpc_pipefs.mount
           849ms sys-kernel-debug.mount
           823ms dev-mqueue.mount
           813ms systemd-sysctl.service
           802ms systemd-tmpfiles-setup-dev.service
           718ms [email protected]
           689ms systemd-udevd.service
           678ms systemd-random-seed.service
           671ms systemd-fsck-root.service
           597ms alsa-restore.service
           491ms systemd-update-utmp.service
           415ms var-tmp.mount
           414ms tmp.mount
           368ms systemd-journal-flush.service
           357ms sys-kernel-config.mount
           330ms var-lib-dhcpcd5.mount
           298ms [email protected]\x2dpartuuid-6c586e13\x2d01.service
           280ms console-setup.service
           276ms nfs-config.service

Code: Select all

          13.987s dhcpcd.service
          9.364s dev-mmcblk0p2.device
          4.289s networking.service
          3.678s keyboard-setup.service
          3.597s systemd-logind.service
          3.294s systemd-udev-trigger.service
          2.827s [[[[---this is my controller---]]].service     <-------
          2.607s wpa_supplicant.service
          2.385s systemd-journald.service
          2.089s rng-tools.service
          1.958s systemd-modules-load.service
          1.827s avahi-daemon.service
          1.644s busybox-syslogd.service
          1.471s systemd-remount-fs.service
          1.391s rpi-eeprom-update.service
          1.064s systemd-tmpfiles-setup.service
          1.056s fake-hwclock.service
           950ms kmod-static-nodes.service
           932ms triggerhappy.service
           930ms run-rpc_pipefs.mount
           842ms dev-mqueue.mount
           838ms alsa-restore.service
           820ms raspi-config.service
           775ms ssh.service
           722ms systemd-fsck-root.service
Any ideas to get this to boot faster - specifically the "time till USB Gadget" of my MIDI device init?
I was also thinking to try OTG mode on Raspberry PI 4 - it should boot a lot faster... maybe.

Otherwise, i might move over to Teensy 4.0, arduinos boot very fast. I'd like to stay with raspberry pi if possible...

Can you think of ways to troubleshoot or diagnose this?
Last edited by subatomicglue on Sun Jan 19, 2020 9:08 pm, edited 2 times in total.

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Fri Jan 17, 2020 2:42 am

An initramfs will do what you think, however it's not a trivial task to get going.

I suggest you try looking into Buildroot and build your own Linux, you can get some great speeds out of it.

You have to way out what you need when doing either method. You could just use an initramfs to load the OTG drivers and then the rest of the system would come up more slowly.

If you have a short list of what software you need for your project please post it I'll be able to suggest something better from that and point you to some information.

Goodluck with your project

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Fri Jan 17, 2020 7:23 am

Hi,

Once my USB MIDI gadget is registered I would load a c++ custom app I wrote based on RtMidi. I would also have a LCD hat on, the 16x2 Adafruit one with i2C And buttons. Pretty simple. Low dependencies. Headless. No internet except for development purposes

Loading the rest of system later sounds safe. I just need to figure out how to accomplish that
Would "loading OTG drivers" early, simply be to run modprobe dwc2 and libcomposite? Or is there more... not sure if those 2 depend on other systems to be up

Thank you for the ideas, and any config help/pointers you can

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Fri Jan 17, 2020 10:12 pm

subatomicglue wrote: Loading the rest of system later sounds safe. I just need to figure out how to accomplish that
Would "loading OTG drivers" early, simply be to run modprobe dwc2 and libcomposite? Or is there more... not sure if those 2 depend on other systems to be up
So using an initramfs to accomplish this should work. First you need to know what modules you need the easiest way to do this is to boot up without OTG enable and look at what is loaded then to boot with everything you need enabled and list the modules and note each difference.

Then you add them to the end of /etc/initramfs-tools/modules

Generate initramfs

Code: Select all

update-initramfs -c -k `uname -r`
Then all you need to do is add the initramfs line to your /boot/config.txt

Code: Select all

 initramfs  initrd.img-4.19.58+
you will need to make sure that you use the correct filename this is just an example I'm running from Stretch on a Pi Zero W

Try that out and see if you get the speed your after. This method has advantages and drawbacks. Doing any kernel updates tends to break initramfs especially when dealing with modules. The kernel numbers change and the update will try to make a new initramfs without deleting the old versions and doesn't update the config.txt



For clarity I gather these steps from here
https://www.raspberrypi.org/forums/view ... p?t=104108 and modified the steps for your needs, basically just loading the modules. This also gives you an idea of what to look for.

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sat Jan 18, 2020 1:32 am

Thank you, I will try this this soon.
boot up without OTG enable and look at what is loaded then to boot with everything you need enabled and list the modules and note each difference.
Am I listing just modules here? I know to list services.., I’ll look around for how to list modules

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sat Jan 18, 2020 3:39 am

subatomicglue wrote:
Sat Jan 18, 2020 1:32 am
Thank you, I will try this this soon.
boot up without OTG enable and look at what is loaded then to boot with everything you need enabled and list the modules and note each difference.
Am I listing just modules here? I know to list services.., I’ll look around for how to list modules
Yes the goal is to find out which modules are loaded for your needs and have them loaded in the initramfs. The command

Code: Select all

lsmod
Should provide insight here.

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sat Jan 18, 2020 11:31 pm

Raspberry PI 4 gives me 13 seconds "time till midi" using a 64gb, Class10, v30 A2 UHS-1/U3 microsd card...

(working on initrd next)
Last edited by subatomicglue on Sun Jan 19, 2020 5:30 pm, edited 1 time in total.

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sun Jan 19, 2020 1:00 am

lsmod from a fresh install of Buster on Raspberry Pi Zero (ssh enabled so i could get in via ethernet USB dongle, I have no HDMI mini display connector)

Code: Select all

cat ./modules-clean-zero.txt

Module                  Size  Used by
sha256_generic         20480  0
cfg80211              610304  0
rfkill                 28672  2 cfg80211
8021q                  32768  0
garp                   16384  1 8021q
stp                    16384  1 garp
llc                    16384  2 garp,stp
ax88179_178a           24576  0
snd_bcm2835            24576  1
raspberrypi_hwmon      16384  0
hwmon                  16384  1 raspberrypi_hwmon
snd_pcm                98304  1 snd_bcm2835
bcm2835_codec          36864  0
bcm2835_v4l2           45056  0
v4l2_mem2mem           24576  1 bcm2835_codec
snd_timer              32768  1 snd_pcm
bcm2835_mmal_vchiq     32768  2 bcm2835_codec,bcm2835_v4l2
v4l2_common            16384  1 bcm2835_v4l2
videobuf2_vmalloc      16384  1 bcm2835_v4l2
videobuf2_dma_contig    20480  1 bcm2835_codec
snd                    73728  5 snd_timer,snd_bcm2835,snd_pcm
videobuf2_memops       16384  2 videobuf2_dma_contig,videobuf2_vmalloc
videobuf2_v4l2         24576  3 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
videobuf2_common       45056  4 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
videodev              192512  6 bcm2835_codec,v4l2_common,videobuf2_common,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
vc_sm_cma              36864  1 bcm2835_mmal_vchiq
media                  36864  3 bcm2835_codec,videodev,v4l2_mem2mem
fixed                  16384  0
uio_pdrv_genirq        16384  0
uio                    20480  1 uio_pdrv_genirq
ip_tables              24576  0
x_tables               32768  1 ip_tables
ipv6                  446464  20
lsmod from a OTG USB MIDI+Ether Gadget on Buster, on Raspberry Pi Zero

Code: Select all

$ cat modules-midi-zero.txt
Module                  Size  Used by
sha256_generic         20480  0
usb_f_midi             20480  2
snd_rawmidi            32768  1 usb_f_midi
snd_seq_device         16384  1 snd_rawmidi
cfg80211              610304  0
rfkill                 28672  2 cfg80211
usb_f_ecm              16384  2
8021q                  32768  0
u_ether                20480  1 usb_f_ecm
garp                   16384  1 8021q
stp                    16384  1 garp
llc                    16384  2 garp,stp
libcomposite           61440  10 usb_f_ecm,usb_f_midi
ax88179_178a           24576  0
snd_bcm2835            24576  1
snd_pcm                98304  1 snd_bcm2835
raspberrypi_hwmon      16384  0
snd_timer              32768  1 snd_pcm
hwmon                  16384  1 raspberrypi_hwmon
snd                    73728  8 snd_timer,snd_rawmidi,snd_seq_device,snd_bcm2835,usb_f_midi,snd_pcm
bcm2835_codec          36864  0
bcm2835_v4l2           45056  0
v4l2_mem2mem           24576  1 bcm2835_codec
bcm2835_mmal_vchiq     32768  2 bcm2835_codec,bcm2835_v4l2
v4l2_common            16384  1 bcm2835_v4l2
videobuf2_vmalloc      16384  1 bcm2835_v4l2
videobuf2_dma_contig    20480  1 bcm2835_codec
videobuf2_memops       16384  2 videobuf2_dma_contig,videobuf2_vmalloc
videobuf2_v4l2         24576  3 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
videobuf2_common       45056  4 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
videodev              192512  6 bcm2835_codec,v4l2_common,videobuf2_common,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
media                  36864  3 bcm2835_codec,videodev,v4l2_mem2mem
vc_sm_cma              36864  1 bcm2835_mmal_vchiq
uio_pdrv_genirq        16384  0
uio                    20480  1 uio_pdrv_genirq
fixed                  16384  0
dwc2                  167936  0
udc_core               49152  5 usb_f_ecm,dwc2,u_ether,libcomposite,usb_f_midi
ip_tables              24576  0
x_tables               32768  1 ip_tables
ipv6                  446464  26
The differences here are:

Code: Select all

usb_f_midi, snd_rawmidi, snd_seq_device, usb_f_ecm, u_ether, libcomposite, dwc2, udc_core

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sun Jan 19, 2020 2:05 am

Alright, "time to midi" on the rPI Zero is now 34seconds (got slower, was 28).
This is what I did:

1. lsmod running under a clean install (see previous post)
2. Install my OTG MIDI+Ether config
3. lsmod on a full install (e.g. with OTG MIDI+Ether and readonly FS) (see previous post)

4. Add the difference to /etc/initramfs-tools/modules:

Code: Select all

$ sudo vi /etc/initramfs-tools/modules

# add these:
dwc2
usb_f_midi
usb_f_ecm
libcomposite
snd_rawmidi
snd_seq_device
u_ether
udc_core
5. Enable initrd:

Code: Select all

$ sudo apt-get install initramfs-tools
$ sudo update-initramfs -c -k `uname -r`
     update-initramfs: Generating /boot/initrd.img-4.19.75+

# Add to end of /boot/config.txt:
$ initramfs initrd.img-4.19.75+
6. Reboot, and use stopwatch to get the new "time to midi" is 34 seconds (up from 28)

Ideas why it got slower? How to diagnose/troubleshoot this... ? See anything I did wrong?

(update: 17 seconds "time to midi" running on an rPI 4. (was 14seconds). 10 seconds of that is blank screen before any boot text happens!)

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sun Jan 19, 2020 5:41 pm

subatomicglue wrote:
Sun Jan 19, 2020 2:05 am
Alright, "time to midi" on the rPI Zero is now 34seconds (got slower, was 28).
This is what I did:

1. lsmod running under a clean install (see previous post)
2. Install my OTG MIDI+Ether config
3. lsmod on a full install (e.g. with OTG MIDI+Ether and readonly FS) (see previous post)

4. Add the difference to /etc/initramfs-tools/modules:

Code: Select all

$ sudo vi /etc/initramfs-tools/modules

# add these:
dwc2
usb_f_midi
usb_f_ecm
libcomposite
snd_rawmidi
snd_seq_device
u_ether
udc_core
5. Enable initrd:

Code: Select all

$ sudo apt-get install initramfs-tools
$ sudo update-initramfs -c -k `uname -r`
     update-initramfs: Generating /boot/initrd.img-4.19.75+

# Add to end of /boot/config.txt:
$ initramfs initrd.img-4.19.75+
6. Reboot, and use stopwatch to get the new "time to midi" is 34 seconds (up from 28)

Ideas why it got slower? How to diagnose/troubleshoot this... ? See anything I did wrong?
I don't see anything wrong. You can try looking at the kernel boot logs. I suspect the extra time is from loading the initramfs. This suggests something else is required to get OTG to start not just the modules.

I don't see much mention about how long OTG takes to come up. I don't know enough about OTG to tell you for sure if you build a customized kernel and filesystem it would be any faster.

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sun Jan 19, 2020 7:55 pm

Right. Feels like I’m maybe loading ramFS plus all the normal boot process as well.

Do I need to somehow disable the normal boot process that initrd replaces?

dmesg wasn’t clear to me. Is there another way to view what’s happening? I’ll post the dmesg soon...

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sun Jan 19, 2020 8:43 pm

here is my dmesg with the initrd & OTG MIDI+Ether configuration (I disabled the readonly FS, it's RW now)...

midi-controller.service is mentioned here, that's my service that registers the OTG gadgets

Code: Select all

$ dmesg
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.19.75+ ([email protected]) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1270 Tue Sep 24 18:38:54 BST 2019
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi Zero Rev 1.3
[    0.000000] Memory policy: Data cache writeback
[    0.000000] cma: Reserved 8 MiB at 0x1ac00000
[    0.000000] On node 0 totalpages: 114688
[    0.000000]   Normal zone: 1008 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 114688 pages, LIFO batch:31
[    0.000000] random: get_random_bytes called from start_kernel+0x8c/0x49c with crng_init=0
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 113680
[    0.000000] Kernel command line: coherent_pool=1M bcm2708_fb.fbwidth=800 bcm2708_fb.fbheight=480 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:67:36:7E vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait noswap ro fastboot sdhci.debug_quirks2=4
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 425648K/458752K available (6973K kernel code, 635K rwdata, 2080K rodata, 464K init, 797K bss, 24912K reserved, 8192K cma-reserved)
[    0.000000] Virtual kernel memory layout:
                   vector  : 0xffff0000 - 0xffff1000   (   4 kB)
                   fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
                   vmalloc : 0xdc800000 - 0xff800000   ( 560 MB)
                   lowmem  : 0xc0000000 - 0xdc000000   ( 448 MB)
                   modules : 0xbf000000 - 0xc0000000   (  16 MB)
                     .text : 0x(ptrval) - 0x(ptrval)   (6975 kB)
                     .init : 0x(ptrval) - 0x(ptrval)   ( 464 kB)
                     .data : 0x(ptrval) - 0x(ptrval)   ( 636 kB)
                      .bss : 0x(ptrval) - 0x(ptrval)   ( 798 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] ftrace: allocating 25197 entries in 74 pages
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000032] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
[    0.000092] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
[    0.000219] bcm2835: system timer (irq = 27)
[    0.000637] Console: colour dummy device 80x30
[    0.001285] console [tty1] enabled
[    0.001365] Calibrating delay loop... 697.95 BogoMIPS (lpj=3489792)
[    0.060397] pid_max: default: 32768 minimum: 301
[    0.060968] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.061028] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.062472] CPU: Testing write buffer coherency: ok
[    0.063873] Setting up static identity map for 0x8200 - 0x8238
[    0.065374] devtmpfs: initialized
[    0.076115] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[    0.076597] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.076676] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.078054] pinctrl core: initialized pinctrl subsystem
[    0.079662] NET: Registered protocol family 16
[    0.083092] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[    0.090289] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[    0.090368] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.090688] Serial: AMBA PL011 UART driver
[    0.093918] bcm2835-mbox 2000b880.mailbox: mailbox enabled
[    0.137278] bcm2835-dma 20007000.dma: DMA legacy API manager at (ptrval), dmachans=0x1
[    0.139882] SCSI subsystem initialized
[    0.140201] usbcore: registered new interface driver usbfs
[    0.140344] usbcore: registered new interface driver hub
[    0.140603] usbcore: registered new device driver usb
[    0.160983] raspberrypi-firmware soc:firmware: Attached to firmware from 2019-09-24 17:37, variant start
[    0.171017] raspberrypi-firmware soc:firmware: Firmware hash is 6820edeee4ef3891b95fc01cf02a7abd7ca52f17
[    0.183503] clocksource: Switched to clocksource timer
[    0.287990] VFS: Disk quotas dquot_6.6.0
[    0.288176] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.288545] FS-Cache: Loaded
[    0.288945] CacheFiles: Loaded
[    0.308467] NET: Registered protocol family 2
[    0.309844] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
[    0.309969] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.310083] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.310206] TCP: Hash tables configured (established 4096 bind 4096)
[    0.310399] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.310469] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.310927] NET: Registered protocol family 1
[    0.312079] RPC: Registered named UNIX socket transport module.
[    0.312143] RPC: Registered udp transport module.
[    0.312174] RPC: Registered tcp transport module.
[    0.312203] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.312651] Trying to unpack rootfs image as initramfs...
[    1.451233] Freeing initrd memory: 8776K
[    1.478613] hw perfevents: no irqs for PMU, sampling events not supported
[    1.478743] hw perfevents: enabled with armv6_1176 PMU driver, 3 counters available
[    1.482916] Initialise system trusted keyrings
[    1.483408] workingset: timestamp_bits=14 max_order=17 bucket_order=3
[    1.498762] FS-Cache: Netfs 'nfs' registered for caching
[    1.500152] NFS: Registering the id_resolver key type
[    1.500251] Key type id_resolver registered
[    1.500286] Key type id_legacy registered
[    1.500338] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    1.506176] Key type asymmetric registered
[    1.506247] Asymmetric key parser 'x509' registered
[    1.506389] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    1.506914] io scheduler noop registered
[    1.506972] io scheduler deadline registered (default)
[    1.507604] io scheduler cfq registered
[    1.507657] io scheduler mq-deadline registered (default)
[    1.507693] io scheduler kyber registered
[    1.510442] bcm2708_fb soc:fb: FB found 1 display(s)
[    1.522187] Console: switching to colour frame buffer device 100x30
[    1.532145] bcm2708_fb soc:fb: Registered framebuffer for display 0, size 800x480
[    1.539416] bcm2835-rng 20104000.rng: hwrng registered
[    1.543335] vc-mem: phys_addr:0x00000000 mem_base=0x1ec00000 mem_size:0x20000000(512 MiB)
[    1.548159] vc-sm: Videocore shared memory driver
[    1.552392] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[    1.577031] brd: module loaded
[    1.594366] loop: module loaded
[    1.598748] Loading iSCSI transport class v2.0-870.
[    1.603212] usbcore: registered new interface driver smsc95xx
[    1.606825] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    1.610544] dwc_otg: FIQ enabled
[    1.610555] dwc_otg: NAK holdoff enabled
[    1.610560] dwc_otg: FIQ split-transaction FSM enabled
[    1.610581] Module dwc_common_port init
[    1.611032] usbcore: registered new interface driver usb-storage
[    1.615159] mousedev: PS/2 mouse device common for all mice
[    1.620169] bcm2835-wdt bcm2835-wdt: Broadcom BCM2835 watchdog timer
[    1.624360] bcm2835-cpufreq: min=700000 max=1000000
[    1.628644] sdhci: Secure Digital Host Controller Interface driver
[    1.632219] sdhci: Copyright(c) Pierre Ossman
[    1.636459] sdhost-bcm2835 20202000.mmc: could not get clk, deferring probe
[    1.640291] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.644580] ledtrig-cpu: registered to indicate activity on CPUs
[    1.648339] hidraw: raw HID events driver (C) Jiri Kosina
[    1.652234] usbcore: registered new interface driver usbhid
[    1.655982] usbhid: USB HID core driver
[    1.660746] vchiq: vchiq_init_state: slot_zero = (ptrval), is_master = 0
[    1.666852] [vc_sm_connected_init]: start
[    1.678309] [vc_sm_connected_init]: end - returning 0
[    1.684048] Initializing XFRM netlink socket
[    1.687747] NET: Registered protocol family 17
[    1.691358] Key type dns_resolver registered
[    1.696825] registered taskstats version 1
[    1.700189] Loading compiled-in X.509 certificates
[    1.713676] uart-pl011 20201000.serial: cts_event_workaround enabled
[    1.717269] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    2.217708] random: fast init done
[    2.478761] console [ttyAMA0] enabled
[    2.489489] sdhost: log_buf @ (ptrval) (5ad10000)
[    2.545266] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    2.556075] of_cfs_init
[    2.562128] of_cfs_init: OK
[    2.593671] Freeing unused kernel memory: 464K
[    2.601513] This architecture does not have kernel memory protection.
[    2.611341] Run /init as init process
[    2.682357] mmc0: host does not support reading read-only switch, assuming write-enable
[    2.703832] mmc0: new high speed SDXC card at address aaaa
[    2.734302] mmcblk0: mmc0:aaaa SN64G 59.5 GiB
[    2.755599]  mmcblk0: p1 p2
[    4.485557] dwc2 20980000.usb: 20980000.usb supply vusb_d not found, using dummy regulator
[    4.581419] dwc2 20980000.usb: Linked as a consumer to regulator.0
[    4.673222] dwc2 20980000.usb: 20980000.usb supply vusb_a not found, using dummy regulator
[    5.013778] dwc2 20980000.usb: dwc2_check_params: Invalid parameter lpm=1
[    5.024246] dwc2 20980000.usb: dwc2_check_params: Invalid parameter lpm_clock_gating=1
[    5.035706] dwc2 20980000.usb: dwc2_check_params: Invalid parameter besl=1
[    5.046059] dwc2 20980000.usb: dwc2_check_params: Invalid parameter hird_threshold_en=1
[    5.213688] dwc2 20980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM
[    5.270011] dwc2 20980000.usb: DWC OTG Controller
[    5.306271] dwc2 20980000.usb: new USB bus registered, assigned bus number 1
[    5.358348] dwc2 20980000.usb: irq 33, io mem 0x20980000
[    5.391050] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19
[    5.402893] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    5.413540] usb usb1: Product: DWC OTG Controller
[    5.421542] usb usb1: Manufacturer: Linux 4.19.75+ dwc2_hsotg
[    5.430723] usb usb1: SerialNumber: 20980000.usb
[    5.442780] hub 1-0:1.0: USB hub found
[    5.450163] hub 1-0:1.0: 1 port detected
[    6.326469] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    7.380231] systemd[1]: System time before build time, advancing clock.
[    7.543840] NET: Registered protocol family 10
[    7.553977] Segment Routing with IPv6
[    7.619256] systemd[1]: systemd 241 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
[    7.653028] systemd[1]: Detected architecture arm.
[    7.684931] systemd[1]: Set hostname to <raspberrypi>.
[    7.704813] systemd[1]: Failed to bump fs.file-max, ignoring: Invalid argument
[    9.165561] uart-pl011 20201000.serial: no DMA platform data
[    9.576420] systemd[1]: File /lib/systemd/system/systemd-journald.service:12 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.
[    9.601643] systemd[1]: Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)
[   10.479065] random: systemd: uninitialized urandom read (16 bytes read)
[   10.505500] systemd[1]: sysinit.target: Found ordering cycle on cryptsetup.target/start
[   10.518148] systemd[1]: sysinit.target: Found dependency on midi-controller.service/start
[   10.531005] systemd[1]: sysinit.target: Found dependency on basic.target/start
[   10.542572] systemd[1]: sysinit.target: Found dependency on sockets.target/start
[   10.571772] random: systemd: uninitialized urandom read (16 bytes read)
[   10.597719] random: systemd: uninitialized urandom read (16 bytes read)
[   12.654999] systemd[1]: Mounting Kernel Configuration File System...
[   12.758990] systemd[1]: Condition check resulted in FUSE Control File System being skipped.
[   13.029673] systemd[1]: Started Journal Service.
[   13.915873] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   15.965253] systemd-journald[149]: Received request to flush runtime journal from PID 1
[   17.429964] vc_sm_cma: module is from the staging directory, the quality is unknown, you have been warned.
[   17.432952] bcm2835_vc_sm_cma_probe: Videocore shared memory driver
[   17.432976] [vc_sm_connected_init]: start
[   17.463089] [vc_sm_connected_init]: installed successfully
[   17.517376] media: Linux media interface: v0.10
[   17.683394] videodev: Linux video capture interface: v2.00
[   17.946122] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
[   17.984569] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
[   18.039139] bcm2835_v4l2: module is from the staging directory, the quality is unknown, you have been warned.
[   18.114229] bcm2835_codec: module is from the staging directory, the quality is unknown, you have been warned.
[   18.160297] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[   18.207987] bcm2835-codec bcm2835-codec: Device registered as /dev/video10
[   18.208053] bcm2835-codec bcm2835-codec: Loaded V4L2 decode
[   18.233286] bcm2835-codec bcm2835-codec: Device registered as /dev/video11
[   18.233347] bcm2835-codec bcm2835-codec: Loaded V4L2 encode
[   18.247865] bcm2835-codec bcm2835-codec: Device registered as /dev/video12
[   18.247931] bcm2835-codec bcm2835-codec: Loaded V4L2 isp
[   18.264861] bcm2835_audio soc:audio: card created with 8 channels
[   24.076301] random: crng init done
[   24.076327] random: 7 urandom warning(s) missed due to ratelimiting
[   25.720289] using random self ethernet address
[   25.720312] using random host ethernet address
[   25.770825] 8021q: 802.1Q VLAN Support v1.8
[   26.326620] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   26.389296] usb0: HOST MAC 48:6f:73:74:50:43
[   26.398481] usb0: MAC 42:61:64:55:53:42
[   26.415743] dwc2 20980000.usb: bound driver configfs-gadget
[   26.592610] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready
[   26.672472] dwc2 20980000.usb: new device is high-speed
[   26.727698] dwc2 20980000.usb: new device is high-speed
[   26.783409] dwc2 20980000.usb: new device is high-speed
[   26.839440] dwc2 20980000.usb: new device is high-speed
[   26.894753] dwc2 20980000.usb: new device is high-speed
[   26.950260] dwc2 20980000.usb: new device is high-speed
[   27.005781] dwc2 20980000.usb: new device is high-speed
[   27.025724] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[   27.061373] dwc2 20980000.usb: new device is high-speed
[   27.117249] dwc2 20980000.usb: new device is high-speed
[   27.209545] dwc2 20980000.usb: new address 29
[   27.940481] configfs-gadget gadget: high-speed config #1: c
[   29.051831] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready
Last edited by subatomicglue on Mon Jan 20, 2020 12:47 am, edited 1 time in total.

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Sun Jan 19, 2020 9:55 pm

The log tells you that the initrd is unpacked at 0.312651 seconds, then at 4.485557 usb devices are coming online, then at 26.389296 the OTG Ethernet is initializing. Finally at 27.940481 the OTG configuration is complete and at 29.051831 the OTG Ethernet is up.

The initramfs seems to only run for approximately 1 second as it's freed from memory at 1.451233

Can you post the service that registers the OTG maybe it can be tweaked

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Mon Jan 20, 2020 12:50 am

Code: Select all

sudo systemctl enable midi-controller
sudo systemctl start midi-controller
/etc/systemd/system/midi-controller.service

Code: Select all

# View services tree:
# sudo systemctl list-dependencies

[Unit]
Description=MIDI Controller
Before=raspi-config.service

[Service]
Type=oneshot
ExecStart=/usr/bin/midi-controller
RemainAfterExit=yes
StandardOutput=journal+console

[Install]
WantedBy=default.target
WantedBy=busybox-klogd.service
WantedBy=display-manager.service
WantedBy=multi-user.target
RequiredBy=cryptsetup.target
/usr/bin/midi-controller (called by the service above)

Code: Select all

#!/bin/bash

##########################################
# INIT LIBCOMPOSITE
echo "creating composite ethernet & midi OTG Gadget..."
modprobe dwc2
modprobe libcomposite

##########################################
# INIT USB GADGET
echo "INIT USB GADGET"
cd /sys/kernel/config/usb_gadget/
rm -rf midi_over_usb # clear out old if there...
mkdir -p midi_over_usb
cd midi_over_usb

echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2

mkdir -p strings/0x409
echo "asdfghlMIDIController34579381" > strings/0x409/serialnumber
echo "manufacturer" > strings/0x409/manufacturer
echo "MIDI Controller" > strings/0x409/product

N="usb0"
C=1

##########################################
# SETUP DEVICES
echo "SETUP DEVICES"

# ETHERNET USB
echo " - ETHERNET USB"
mkdir -p functions/ecm.$N
# first byte of address must be even
HOST="48:6f:73:74:50:43" # "HostPC"
SELF="42:61:64:55:53:42" # "BadUSB"
echo $HOST > functions/ecm.$N/host_addr
echo $SELF > functions/ecm.$N/dev_addr
mkdir -p configs/c.$C
ln -s functions/ecm.$N configs/c.$C/

# MIDI DEVICE USB 
# See new device:  amidi -l
# Get device port: aplaymidi --list
# Sample File:     curl https://www.midiworld.com/download/3861 > techno.midi
# Play MIDI Out:   aplaymidi --port 20:0 techno.midi
echo " - MIDI DEVICE USB"
mkdir -p functions/midi.$N
# id     - ID string for the USB MIDI adapter
echo "pi-zero-midi" > functions/midi.$N/id
mkdir -p configs/c.$C
ln -s functions/midi.$N configs/c.$C/

#########################################
# END SETUP
echo "END SETUP"

# this lists available UDC drivers  (refresh the system)
ls /sys/class/udc > UDC
#########################################

# ETHERNET POST SETUP
echo "ETHERNET POST SETUP"
ifconfig $N 10.0.0.1 netmask 255.255.255.252 up
route add -net default gw 10.0.0.2 &> /dev/null

echo "done"

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Mon Jan 20, 2020 1:00 am

[ 0.312651] Trying to unpack rootfs image as initramfs...
[ 1.451233] Freeing initrd memory: 8776K
This is really interesting...

If it's freed, I take that to mean we are not benefitting from it...

Questions this evokes:
- Wouldn't we want this to remain in memory?
- Do I need to init my service in this timeslice here for the initrd stuff to stick around? (I can't imagine there is dependency checking that would keep it in mem just because of that)...
- Do I need to init my service in this timeslice here in order to have my "time to MIDI" be ~2seconds?? (that'd be awesome)
- I'm not sure how I would init my service earlier...
- All this stuff between 1.451233 and 27 seems to not be benefitting from the initrd - either it isn't in it, or, the freeing of the initrd means it still has to load again...

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Mon Jan 20, 2020 1:57 am

subatomicglue wrote:
Mon Jan 20, 2020 1:00 am
[ 0.312651] Trying to unpack rootfs image as initramfs...
[ 1.451233] Freeing initrd memory: 8776K
This is really interesting...

If it's freed, I take that to mean we are not benefitting from it...

Questions this evokes:
- Wouldn't we want this to remain in memory?
- Do I need to init my service in this timeslice here for the initrd stuff to stick around? (I can't imagine there is dependency checking that would keep it in mem just because of that)...
- Do I need to init my service in this timeslice here in order to have my "time to MIDI" be ~2seconds?? (that'd be awesome)
- I'm not sure how I would init my service earlier...
- All this stuff between 1.451233 and 27 seems to not be benefitting from the initrd - either it isn't in it, or, the freeing of the initrd means it still has to load again...
All the initrd is doing is loading the modules the kernel needs and then once it's done it hands off to the main os. I don't think your getting the performance increase because you need to do more than just load the modules. Looking at your code it looks as though the midi part could be run seperate from the ethernet part. If this is so you can try have the midi service with

Code: Select all

[Install]
WantedBy=basic.target
this might get your 2 seconds

tqhien
Posts: 73
Joined: Thu Feb 02, 2012 10:07 am

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Mon Jan 20, 2020 11:31 am

Hello,

My best advice would be to reconsider using Buildroot to custom your kernel and OS :

- In your log, systemd is used as it is the default init system for Raspbian. But it loads a lot of things (see the next log line :

Code: Select all

[    7.619256] systemd[1]: systemd 241 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
With buildroot, build a basic system : it should boot in less that 5 seconds on a PiZero !

One trick is to add lpj in /boot/cmdline.txt with the value you find in log : lpj=3489792

Code: Select all

[    0.001365] Calibrating delay loop... 697.95 BogoMIPS (lpj=3489792)
so the system does'nt need to compute that value but uses it directly.

Then optimise kernel.

Finally, with busybox as init system, you can reorder startup script (/etc/init.d/Sxx files) so you load your midi files before you set lan/network.

Your system should be able to boot into Midi in about 10-12 seconds on a Rpi0,

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Mon Jan 20, 2020 7:28 pm

tqhien wrote:
Mon Jan 20, 2020 11:31 am
Hello,

My best advice would be to reconsider using Buildroot to custom your kernel and OS :

- In your log, systemd is used as it is the default init system for Raspbian. But it loads a lot of things (see the next log line :

Code: Select all

[    7.619256] systemd[1]: systemd 241 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
With buildroot, build a basic system : it should boot in less that 5 seconds on a PiZero !

One trick is to add lpj in /boot/cmdline.txt with the value you find in log : lpj=3489792

Code: Select all

[    0.001365] Calibrating delay loop... 697.95 BogoMIPS (lpj=3489792)
so the system does'nt need to compute that value but uses it directly.

Then optimise kernel.

Finally, with busybox as init system, you can reorder startup script (/etc/init.d/Sxx files) so you load your midi files before you set lan/network.

Your system should be able to boot into Midi in about 10-12 seconds on a Rpi0,
That's true I have built root on my pi 0W and with boot optimizations I can fully boot in 6 seconds. That's on a 1GB slow SD card.

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Tue Jan 21, 2020 3:22 am

All the initrd is doing is loading the modules the kernel needs and then once it's done it hands off to the main os. I don't think your getting the performance increase because you need to do more than just load the modules. Looking at your code it looks as though the midi part could be run seperate from the ethernet part. If this is so you can try have the midi service with
Code: Select all

[Install]
WantedBy=basic.target

this might get your 2 seconds
Sounds like the easy option if I can get it to work. Rather than rebuilding things with build root and busybox.

Question: with the message that initrd is freeing, should that be concerning us, will I be able to init USB gadgets in light of that? “Freeing” sounds like the work initrd did is now gone

I’ll try your suggestion first, see if this can be easy.

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Tue Jan 21, 2020 4:17 am

subatomicglue wrote:
Tue Jan 21, 2020 3:22 am
All the initrd is doing is loading the modules the kernel needs and then once it's done it hands off to the main os. I don't think your getting the performance increase because you need to do more than just load the modules. Looking at your code it looks as though the midi part could be run seperate from the ethernet part. If this is so you can try have the midi service with
Code: Select all

[Install]
WantedBy=basic.target

this might get your 2 seconds
Sounds like the easy option if I can get it to work. Rather than rebuilding things with build root and busybox.

Question: with the message that initrd is freeing, should that be concerning us, will I be able to init USB gadgets in light of that? “Freeing” sounds like the work initrd did is now gone

I’ll try your suggestion first, see if this can be easy.
The initrd is basically a mini OS all on it's own, it's all packaged and compressed. During the boot process it unpacks into memory does it thing and then passes execution to the main OS. Since it's not needed anymore that memory is freed for other things.

A very simple example of an initramfs. The kernel loads the initramfs to memory and runs the init script. The init simple will mount the root partition and switch root to it. Then the initramfs is no longer needed and it can be freed from memory. The same is true if it had to load a module before the kernel could understand how to mount the root partition. Once the module is loaded into the kernel it stays loaded even after the initramfs is freed from memory.

I hope that answers your question, the work isn't gone it's just finished.

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Tue Jan 21, 2020 5:18 am


Once the module is loaded into the kernel it stays loaded even after the initramfs is freed from memory.

I hope that answers your question, the work isn't gone it's just finished.
That’s reassuring. Sounds like I need to execute my midi service inside the initrd section (between start and free), then the modules invoked by my midi service would stay in the kernel...

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Tue Jan 21, 2020 12:43 pm

subatomicglue wrote:
Tue Jan 21, 2020 5:18 am

Once the module is loaded into the kernel it stays loaded even after the initramfs is freed from memory.

I hope that answers your question, the work isn't gone it's just finished.
That’s reassuring. Sounds like I need to execute my midi service inside the initrd section (between start and free), then the modules invoked by my midi service would stay in the kernel...
In that case you're script would need to go in one of the sub folders of /etc/initramfs-tools/scripts/ you should be sure you have busybox installed. Your going to have to write your script with

Code: Select all

#!/bin/sh
bash will not be available

This man page is a good place to start https://manpages.ubuntu.com/manpages/xe ... ols.8.html for help writing the script and what it needs.

tqhien
Posts: 73
Joined: Thu Feb 02, 2012 10:07 am

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Wed Jan 22, 2020 3:54 pm

So, I built a custom Buildroot system for a RpiZero for you, to demonstrate how fast it is.
Here is the console log of boot sequence. As you can see, I could type the date command (to view system date) and it showed only 4 seconds from startup (date without RTC starts from 1970-01-01 00:00:00). I asked a lsmod command also, which showed me that midi is well loaded. And I asked again a date time (not right after previous command), just 12 seconds after turning on...

Code: Select all

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.95 ([email protected]) (gcc version 7.4.0 (Buildroot 2019.02.8)) #2 PREEMPT Wed Jan 22 15:31:03 CET 2020
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi Zero W Rev 1.1
[    0.000000] Memory policy: Data cache writeback
[    0.000000] cma: Reserved 8 MiB at 0x19000000
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 104648
[    0.000000] Kernel command line: 8250.nr_uarts=1 bcm2708_fb.fbwidth=720 bcm2708_fb.fbheight=480 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:1C:C8:32 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200 lpj=3489792
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 402992K/421888K available (4599K kernel code, 223K rwdata, 1412K rodata, 172K init, 287K bss, 10704K reserved, 8192K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xda000000 - 0xff800000   ( 600 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xd9c00000   ( 412 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0486138   (4601 kB)
[    0.000000]       .init : 0xc0609000 - 0xc0634000   ( 172 kB)
[    0.000000]       .data : 0xc0634000 - 0xc066bd78   ( 224 kB)
[    0.000000]        .bss : 0xc066bd78 - 0xc06b3ca4   ( 288 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000] 	Tasks RCU enabled.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000029] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
[    0.000070] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
[    0.000153] bcm2835: system timer (irq = 27)
[    0.000706] Console: colour dummy device 80x30
[    0.001417] console [tty1] enabled
[    0.001470] Calibrating delay loop (skipped) preset value.. 697.95 BogoMIPS (lpj=3489792)
[    0.001527] pid_max: default: 32768 minimum: 301
[    0.001728] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001781] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.002778] CPU: Testing write buffer coherency: ok
[    0.003891] Setting up static identity map for 0x8200 - 0x8238
[    0.004152] Hierarchical SRCU implementation.
[    0.005433] devtmpfs: initialized
[    0.013772] random: get_random_u32 called from bucket_table_alloc+0x80/0x1a4 with crng_init=0
[    0.014535] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[    0.014920] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.014994] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.016102] pinctrl core: initialized pinctrl subsystem
[    0.017156] NET: Registered protocol family 16
[    0.019950] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[    0.025448] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[    0.025523] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.025673] Serial: AMBA PL011 UART driver
[    0.028230] bcm2835-mbox 2000b880.mailbox: mailbox enabled
[    0.028954] uart-pl011 20201000.serial: could not find pctldev for node /soc/[email protected]/uart0_pins, deferring probe
[    0.063406] bcm2835-dma 20007000.dma: DMA legacy API manager at da00d000, dmachans=0x1
[    0.065416] SCSI subsystem initialized
[    0.065623] usbcore: registered new interface driver usbfs
[    0.065747] usbcore: registered new interface driver hub
[    0.065935] usbcore: registered new device driver usb
[    0.070896] raspberrypi-firmware soc:firmware: Attached to firmware from 2019-01-22 16:50
[    0.072670] clocksource: Switched to clocksource timer
[    0.072922] VFS: Disk quotas dquot_6.6.0
[    0.073051] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.073358] FS-Cache: Loaded
[    0.073690] CacheFiles: Loaded
[    0.089292] NET: Registered protocol family 2
[    0.090429] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.090563] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.090685] TCP: Hash tables configured (established 4096 bind 4096)
[    0.090850] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.090911] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.091239] NET: Registered protocol family 1
[    0.092310] hw perfevents: no irqs for PMU, sampling events not supported
[    0.092423] hw perfevents: enabled with armv6_1176 PMU driver, 3 counters available
[    0.094311] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.106804] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    0.106884] io scheduler noop registered (default)
[    0.108910] BCM2708FB: allocated DMA memory 59100000
[    0.109017] BCM2708FB: allocated DMA channel 0 @ da00d000
[    0.117979] Console: switching to colour frame buffer device 90x30
[    0.127940] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[    0.134083] bcm2835-rng 20104000.rng: hwrng registered
[    0.137532] vc-mem: phys_addr:0x00000000 mem_base=0x1ec00000 mem_size:0x20000000(512 MiB)
[    0.144953] vc-sm: Videocore shared memory driver
[    0.148787] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[    0.166831] brd: module loaded
[    0.177006] loop: module loaded
[    0.180379] Loading iSCSI transport class v2.0-870.
[    0.184647] usbcore: registered new interface driver smsc95xx
[    0.188010] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    0.191874] usbcore: registered new interface driver usb-storage
[    0.195660] mousedev: PS/2 mouse device common for all mice
[    0.199009] IR NEC protocol handler initialized
[    0.202218] IR RC5(x/sz) protocol handler initialized
[    0.205523] IR RC6 protocol handler initialized
[    0.208680] IR JVC protocol handler initialized
[    0.211651] IR Sony protocol handler initialized
[    0.214706] IR SANYO protocol handler initialized
[    0.217608] IR Sharp protocol handler initialized
[    0.220345] IR MCE Keyboard/mouse protocol handler initialized
[    0.223222] IR XMP protocol handler initialized
[    0.227178] bcm2835-wdt 20100000.watchdog: Broadcom BCM2835 watchdog timer
[    0.230590] sdhci: Secure Digital Host Controller Interface driver
[    0.233616] sdhci: Copyright(c) Pierre Ossman
[    0.237042] mmc-bcm2835 20300000.mmc: could not get clk, deferring probe
[    0.240571] sdhost-bcm2835 20202000.mmc: could not get clk, deferring probe
[    0.243786] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.247146] ledtrig-cpu: registered to indicate activity on CPUs
[    0.250155] hidraw: raw HID events driver (C) Jiri Kosina
[    0.253233] usbcore: registered new interface driver usbhid
[    0.256008] usbhid: USB HID core driver
[    0.259676] vchiq: vchiq_init_state: slot_zero = d9180000, is_master = 0
[    0.264753] [vc_sm_connected_init]: start
[    0.275309] [vc_sm_connected_init]: end - returning 0
[    0.279021] Initializing XFRM netlink socket
[    0.281868] NET: Registered protocol family 17
[    0.284769] Key type dns_resolver registered
[    0.288770] registered taskstats version 1
[    0.294372] uart-pl011 20201000.serial: cts_event_workaround enabled
[    0.297320] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    1.011961] console [ttyAMA0] enabled
[    1.020841] 20215040.serial: ttyS0 at MMIO 0x0 (irq = 160, base_baud = 50000000) is a 16550
[    1.037034] mmc-bcm2835 20300000.mmc: mmc_debug:0 mmc_debug2:0
[    1.046317] mmc-bcm2835 20300000.mmc: DMA channel allocated
[    1.115117] sdhost: log_buf @ d9110000 (59110000)
[    1.138819] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
[    1.161594] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    1.171889] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    1.183239] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
[    1.212756] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    1.221155] of_cfs_init
[    1.226544] of_cfs_init: OK
[    1.252090] random: fast init done
[    1.259129] uart-pl011 20201000.serial: no DMA platform data
[    1.268186] Waiting for root device /dev/mmcblk0p2...
[    1.348209] mmc1: new high speed SDIO card at address 0001
[    1.382444] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.398794] mmc0: new high speed SD card at address e624
[    1.407594] mmcblk0: mmc0:e624 SU02G 1.84 GiB
[    1.426101]  mmcblk0: p1 p2
[    1.473444] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.487392] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    1.502269] devtmpfs: mounted
[    1.508770] Freeing unused kernel memory: 172K
[    1.516016] This architecture does not have kernel memory protection.
[    1.835590] dwc2 20980000.usb: 20980000.usb supply vusb_d not found, using dummy regulator
[    1.849553] dwc2 20980000.usb: 20980000.usb supply vusb_a not found, using dummy regulator
[    2.322833] dwc2 20980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM
[    2.334276] dwc2 20980000.usb: DWC OTG Controller
[    2.342329] dwc2 20980000.usb: new USB bus registered, assigned bus number 1
[    2.352883] dwc2 20980000.usb: irq 33, io mem 0x20980000
[    2.361853] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    2.372109] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.382826] usb usb1: Product: DWC OTG Controller
[    2.390989] usb usb1: Manufacturer: Linux 4.14.95 dwc2_hsotg
[    2.400116] usb usb1: SerialNumber: 20980000.usb
[    2.409265] hub 1-0:1.0: USB hub found
[    2.416750] hub 1-0:1.0: 1 port detected
Starting syslogd: OK
Starting klogd: OK
read-only file system detected...done
$ date
Thu Jan  1 00:00:04 UTC 1970
$ lsmod
Module                  Size  Used by    Not tainted
usb_f_midi             10989  0 
snd_rawmidi            20856  1 usb_f_midi
snd_seq_device          4257  1 snd_rawmidi
libcomposite           43073  1 usb_f_midi
snd                    54982  3 usb_f_midi,snd_rawmidi,snd_seq_device
dwc2                  104497  0 
udc_core               17968  3 usb_f_midi,libcomposite,dwc2
$ date
Thu Jan  1 00:00:12 UTC 1970
$ 
I added dropbear (for SSH), fixed Wlan0 ip, turned it to an Access Point (with hostapd for wifi and dnsmasq for attributing IP addresses), but deactivated them to keep the log cleared. As I said in another post, those Lan settings can be set after launching your main program. To reactivate them, rename mxx files to Sxx in /etc/init.d, adapt config files in /etc and uncomment the line with brcm in inittab to reenable wlan.

I also prebuilt python3 into the system.

Zipped file image is 47Mo and only 512Mo minimum SD Card is required : boot partition is 34Mo, rootfs is 255Mo (with plenty of space in it...) and it is available here : https://drive.google.com/open?id=1LFPRR ... FM0xSXSiio

root password is rpi and there's an autologin for user rpi / password rpi

Have fun !

[Edit] : system is read-only by default. To turn to read-write :

Code: Select all

sudo rw
and to get back to read-only :

Code: Select all

sudo ro
and use [sudo] nano to edit files.

[Edit #2] Previous link was the basic system, without midi loading. My bad. Now it is the correct link, for a 2Go SD Card

DarkElvenAngel
Posts: 390
Joined: Tue Mar 20, 2018 9:53 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Wed Jan 22, 2020 7:39 pm

tqhien wrote:
Wed Jan 22, 2020 3:54 pm
So, I built a custom Buildroot system for a RpiZero for you, to demonstrate how fast it is.
Here is the console log of boot sequence. As you can see, I could type the date command (to view system date) and it showed only 4 seconds from startup (date without RTC starts from 1970-01-01 00:00:00). I asked a lsmod command also, which showed me that midi is well loaded. And I asked again a date time (not right after previous command), just 12 seconds after turning on...

Code: Select all

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.95 ([email protected]) (gcc version 7.4.0 (Buildroot 2019.02.8)) #2 PREEMPT Wed Jan 22 15:31:03 CET 2020
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi Zero W Rev 1.1
[    0.000000] Memory policy: Data cache writeback
[    0.000000] cma: Reserved 8 MiB at 0x19000000
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 104648
[    0.000000] Kernel command line: 8250.nr_uarts=1 bcm2708_fb.fbwidth=720 bcm2708_fb.fbheight=480 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:1C:C8:32 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200 lpj=3489792
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 402992K/421888K available (4599K kernel code, 223K rwdata, 1412K rodata, 172K init, 287K bss, 10704K reserved, 8192K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xda000000 - 0xff800000   ( 600 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xd9c00000   ( 412 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0486138   (4601 kB)
[    0.000000]       .init : 0xc0609000 - 0xc0634000   ( 172 kB)
[    0.000000]       .data : 0xc0634000 - 0xc066bd78   ( 224 kB)
[    0.000000]        .bss : 0xc066bd78 - 0xc06b3ca4   ( 288 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000] 	Tasks RCU enabled.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000029] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
[    0.000070] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
[    0.000153] bcm2835: system timer (irq = 27)
[    0.000706] Console: colour dummy device 80x30
[    0.001417] console [tty1] enabled
[    0.001470] Calibrating delay loop (skipped) preset value.. 697.95 BogoMIPS (lpj=3489792)
[    0.001527] pid_max: default: 32768 minimum: 301
[    0.001728] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001781] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.002778] CPU: Testing write buffer coherency: ok
[    0.003891] Setting up static identity map for 0x8200 - 0x8238
[    0.004152] Hierarchical SRCU implementation.
[    0.005433] devtmpfs: initialized
[    0.013772] random: get_random_u32 called from bucket_table_alloc+0x80/0x1a4 with crng_init=0
[    0.014535] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[    0.014920] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.014994] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.016102] pinctrl core: initialized pinctrl subsystem
[    0.017156] NET: Registered protocol family 16
[    0.019950] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[    0.025448] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[    0.025523] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.025673] Serial: AMBA PL011 UART driver
[    0.028230] bcm2835-mbox 2000b880.mailbox: mailbox enabled
[    0.028954] uart-pl011 20201000.serial: could not find pctldev for node /soc/[email protected]/uart0_pins, deferring probe
[    0.063406] bcm2835-dma 20007000.dma: DMA legacy API manager at da00d000, dmachans=0x1
[    0.065416] SCSI subsystem initialized
[    0.065623] usbcore: registered new interface driver usbfs
[    0.065747] usbcore: registered new interface driver hub
[    0.065935] usbcore: registered new device driver usb
[    0.070896] raspberrypi-firmware soc:firmware: Attached to firmware from 2019-01-22 16:50
[    0.072670] clocksource: Switched to clocksource timer
[    0.072922] VFS: Disk quotas dquot_6.6.0
[    0.073051] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.073358] FS-Cache: Loaded
[    0.073690] CacheFiles: Loaded
[    0.089292] NET: Registered protocol family 2
[    0.090429] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.090563] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.090685] TCP: Hash tables configured (established 4096 bind 4096)
[    0.090850] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.090911] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.091239] NET: Registered protocol family 1
[    0.092310] hw perfevents: no irqs for PMU, sampling events not supported
[    0.092423] hw perfevents: enabled with armv6_1176 PMU driver, 3 counters available
[    0.094311] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.106804] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    0.106884] io scheduler noop registered (default)
[    0.108910] BCM2708FB: allocated DMA memory 59100000
[    0.109017] BCM2708FB: allocated DMA channel 0 @ da00d000
[    0.117979] Console: switching to colour frame buffer device 90x30
[    0.127940] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[    0.134083] bcm2835-rng 20104000.rng: hwrng registered
[    0.137532] vc-mem: phys_addr:0x00000000 mem_base=0x1ec00000 mem_size:0x20000000(512 MiB)
[    0.144953] vc-sm: Videocore shared memory driver
[    0.148787] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[    0.166831] brd: module loaded
[    0.177006] loop: module loaded
[    0.180379] Loading iSCSI transport class v2.0-870.
[    0.184647] usbcore: registered new interface driver smsc95xx
[    0.188010] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    0.191874] usbcore: registered new interface driver usb-storage
[    0.195660] mousedev: PS/2 mouse device common for all mice
[    0.199009] IR NEC protocol handler initialized
[    0.202218] IR RC5(x/sz) protocol handler initialized
[    0.205523] IR RC6 protocol handler initialized
[    0.208680] IR JVC protocol handler initialized
[    0.211651] IR Sony protocol handler initialized
[    0.214706] IR SANYO protocol handler initialized
[    0.217608] IR Sharp protocol handler initialized
[    0.220345] IR MCE Keyboard/mouse protocol handler initialized
[    0.223222] IR XMP protocol handler initialized
[    0.227178] bcm2835-wdt 20100000.watchdog: Broadcom BCM2835 watchdog timer
[    0.230590] sdhci: Secure Digital Host Controller Interface driver
[    0.233616] sdhci: Copyright(c) Pierre Ossman
[    0.237042] mmc-bcm2835 20300000.mmc: could not get clk, deferring probe
[    0.240571] sdhost-bcm2835 20202000.mmc: could not get clk, deferring probe
[    0.243786] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.247146] ledtrig-cpu: registered to indicate activity on CPUs
[    0.250155] hidraw: raw HID events driver (C) Jiri Kosina
[    0.253233] usbcore: registered new interface driver usbhid
[    0.256008] usbhid: USB HID core driver
[    0.259676] vchiq: vchiq_init_state: slot_zero = d9180000, is_master = 0
[    0.264753] [vc_sm_connected_init]: start
[    0.275309] [vc_sm_connected_init]: end - returning 0
[    0.279021] Initializing XFRM netlink socket
[    0.281868] NET: Registered protocol family 17
[    0.284769] Key type dns_resolver registered
[    0.288770] registered taskstats version 1
[    0.294372] uart-pl011 20201000.serial: cts_event_workaround enabled
[    0.297320] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    1.011961] console [ttyAMA0] enabled
[    1.020841] 20215040.serial: ttyS0 at MMIO 0x0 (irq = 160, base_baud = 50000000) is a 16550
[    1.037034] mmc-bcm2835 20300000.mmc: mmc_debug:0 mmc_debug2:0
[    1.046317] mmc-bcm2835 20300000.mmc: DMA channel allocated
[    1.115117] sdhost: log_buf @ d9110000 (59110000)
[    1.138819] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
[    1.161594] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    1.171889] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    1.183239] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
[    1.212756] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    1.221155] of_cfs_init
[    1.226544] of_cfs_init: OK
[    1.252090] random: fast init done
[    1.259129] uart-pl011 20201000.serial: no DMA platform data
[    1.268186] Waiting for root device /dev/mmcblk0p2...
[    1.348209] mmc1: new high speed SDIO card at address 0001
[    1.382444] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.398794] mmc0: new high speed SD card at address e624
[    1.407594] mmcblk0: mmc0:e624 SU02G 1.84 GiB
[    1.426101]  mmcblk0: p1 p2
[    1.473444] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.487392] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    1.502269] devtmpfs: mounted
[    1.508770] Freeing unused kernel memory: 172K
[    1.516016] This architecture does not have kernel memory protection.
[    1.835590] dwc2 20980000.usb: 20980000.usb supply vusb_d not found, using dummy regulator
[    1.849553] dwc2 20980000.usb: 20980000.usb supply vusb_a not found, using dummy regulator
[    2.322833] dwc2 20980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM
[    2.334276] dwc2 20980000.usb: DWC OTG Controller
[    2.342329] dwc2 20980000.usb: new USB bus registered, assigned bus number 1
[    2.352883] dwc2 20980000.usb: irq 33, io mem 0x20980000
[    2.361853] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    2.372109] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.382826] usb usb1: Product: DWC OTG Controller
[    2.390989] usb usb1: Manufacturer: Linux 4.14.95 dwc2_hsotg
[    2.400116] usb usb1: SerialNumber: 20980000.usb
[    2.409265] hub 1-0:1.0: USB hub found
[    2.416750] hub 1-0:1.0: 1 port detected
Starting syslogd: OK
Starting klogd: OK
read-only file system detected...done
$ date
Thu Jan  1 00:00:04 UTC 1970
$ lsmod
Module                  Size  Used by    Not tainted
usb_f_midi             10989  0 
snd_rawmidi            20856  1 usb_f_midi
snd_seq_device          4257  1 snd_rawmidi
libcomposite           43073  1 usb_f_midi
snd                    54982  3 usb_f_midi,snd_rawmidi,snd_seq_device
dwc2                  104497  0 
udc_core               17968  3 usb_f_midi,libcomposite,dwc2
$ date
Thu Jan  1 00:00:12 UTC 1970
$ 
I added dropbear (for SSH), fixed Wlan0 ip, turned it to an Access Point (with hostapd for wifi and dnsmasq for attributing IP addresses), but deactivated them to keep the log cleared. As I said in another post, those Lan settings can be set after launching your main program. To reactivate them, rename mxx files to Sxx in /etc/init.d, adapt config files in /etc and uncomment the line with brcm in inittab to reenable wlan.

I also prebuilt python3 into the system.

Zipped file image is 47Mo and only 512Mo minimum SD Card is required : boot partition is 34Mo, rootfs is 255Mo (with plenty of space in it...) and it is available here : https://drive.google.com/open?id=1LFPRR ... FM0xSXSiio

root password is rpi and there's an autologin for user rpi / password rpi

Have fun !

[Edit] : system is read-only by default. To turn to read-write :

Code: Select all

sudo rw
and to get back to read-only :

Code: Select all

sudo ro
and use [sudo] nano to edit files.

[Edit #2] Previous link was the basic system, without midi loading. My bad. Now it is the correct link, for a 2Go SD Card
Why would you use dropbear for ssh? You get no SFTP I found that to be essential for development. Also did you enable gadget ethernet the OP is using that also.

subatomicglue
Posts: 54
Joined: Sun Oct 13, 2019 5:58 pm

Re: Help me Fast Boot my pi-Zero MIDI "USB Gadget"

Wed Jan 22, 2020 7:56 pm

tqhien wrote:
Wed Jan 22, 2020 3:54 pm
So, I built a custom Buildroot system for a RpiZero for you, to demonstrate how fast it is.
Wow, thanks! I'll take a look.

If I'm reading that correctly, it's an image to burn (Not seeing scripts or instructions to build that).
I'd love to learn how to generate it.
Is that quick to learn?
Got any pointers to an example or guide? Or loose instructions (install XXX, follow quick thing here, pick these 7 things).
With buildroot, build a basic system : it should boot in less that 5 seconds on a PiZero !
Looking to unpack this statement, "build a basic system" :)
So far I am reading this: https://bootlin.com/doc/training/buildr ... slides.pdf
Last edited by subatomicglue on Thu Jan 23, 2020 2:32 pm, edited 2 times in total.

Return to “Advanced users”