WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Delay loading extensions for absolute minimum boot times.  (Read 3833 times)

Offline mb300sd

  • Newbie
  • *
  • Posts: 5
Delay loading extensions for absolute minimum boot times.
« on: January 22, 2017, 05:08:21 PM »
Here's a trick I found that cut the time from power on to my application starting from 10+ sec to 4 secs. Maybe it'll be useful to some others. I'm using the pi as a bridge/translator between my engine control unit and transmission controller, so startup time is critical.

I removed everything from onboot.lst except the modules for the CAN controller.
Code: [Select]
can-4.4.39-piCore_v7+_local.tcz
Then I still want openssh and several other things to load, so I delay load them in bootlocal.sh
Code: [Select]
#!/bin/sh

# Configure can bus
echo 500000 > /sys/class/net/can0/can_bittiming/bitrate
ifconfig can0 up
#ip link set can0 up type can bitrate 500000
echo 500000 > /sys/class/net/can1/can_bittiming/bitrate
ifconfig can1 up
#ip link set can1 up type can bitrate 500000

# Start CAN bridge
/opt/car_can/car_can&

# Load RTC
su tc -c "/usr/bin/ondemand -e rtc-4.4.39-piCore_v7+.tcz"

# Load modules
/sbin/modprobe i2c-dev
/sbin/modprobe vcan

# Openssh is slow to load, do it later.
su tc -c "/usr/bin/ondemand -e openssh.tcz"

# Start openssh daemon
/usr/local/etc/init.d/openssh start

# Set CPU frequency governor to ondemand (default is performance)
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Load other tczs
su tc -c "/usr/bin/ondemand -e iproute2.tcz"
su tc -c "/usr/bin/ondemand -e nano.tcz"

# Mount boot partition
/bin/mount /dev/mmcblk0p1 /mnt/mmcblk0p1

Might I suggest a postboot.lst function to do this in a cleaner way?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Delay loading extensions for absolute minimum boot times.
« Reply #1 on: January 22, 2017, 09:15:18 PM »
Hi!
I'm kind of amazed that you're using the  ondemand  command in bootlocal.sh, not that I would tell you not to,
though. But I wonder what would be the cleaner way.
Download a copy and keep it handy: Core book ;)

Offline mb300sd

  • Newbie
  • *
  • Posts: 5
Re: Delay loading extensions for absolute minimum boot times.
« Reply #2 on: January 22, 2017, 10:50:10 PM »
Well, clean is probably out the window for me now.

I figured out how to remaster the image, and gained a second by inserting the CAN modules and my exe into it. I think I might be able to run my code from /etc/init.d/rcS before tinycore even loads.

If that works, everything else can go back to normal, loading after my stuff is already running.

Offline andriusr

  • Newbie
  • *
  • Posts: 34
Re: Delay loading extensions for absolute minimum boot times.
« Reply #3 on: January 23, 2017, 06:06:55 AM »
mb300sd,
it would be great if you can share your way of remastering image... This is something that I also want to do, however, there are no any guide how to do this. Your help would be greatly appreciated!

Offline mb300sd

  • Newbie
  • *
  • Posts: 5
Re: Delay loading extensions for absolute minimum boot times.
« Reply #4 on: January 23, 2017, 08:38:11 AM »
I pretty much followed this. http://wiki.tinycorelinux.net/wiki:remastering Skip down to this part.

Code: [Select]
mkdir /tmp/extract
cd /tmp/extract
zcat /tmp/core.gz | sudo cpio -i -H newc -d

core.gz is 8.1.5v7.gz file from mmcblk0p1.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 661
Re: Delay loading extensions for absolute minimum boot times.
« Reply #5 on: January 23, 2017, 09:28:19 AM »
Here some tips on making it faster to boot for embedded systems.
http://free-electrons.com/doc/training/boot-time/boot-time-slides.pdf

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 661
Re: Delay loading extensions for absolute minimum boot times.
« Reply #6 on: January 26, 2017, 08:21:21 AM »
I think you could also compile your own busybox with bootchartd support.

To make some fine graphics chart of the boot process.

To easily verify what taking time.

I don't have Bela busybox config file to do it.
But i think, if you ask gently he give it to you.