MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.89k stars 497 forks source link

PINE64 | Add support and optimizations in DietPi #261

Closed rhkean closed 8 years ago

rhkean commented 8 years ago

Add PINE64 support and optimizations to DietPi

(you can assign this to me)

Fourdee commented 8 years ago

@rhkean Done :+1:

Mines arriving in May, i think lol.

Which Debian Jessie image base will you be using for it?

Some notes/suggestions:

rhkean commented 8 years ago

@Fourdee , Don't hold your breath on a May delivery. I was supposed to have mine in February... still don't have it. :disappointed:

I'm not certain which base I'll use yet... a lot depends on which (if any) are available, tested, and supported by PINE when I start. At the moment, in the forums, it doesn't look like they're planning on supporting debian... just Ubuntu. But, the comments are suggesting a look at hardkernel images. So, I will probably start with the C2 images....

k-plan commented 8 years ago

@rhkean

it doesn't look like they're planning on supporting debian... just Ubuntu

Debian Linux with Mate GUI 20160422

rhkean commented 8 years ago

cool! now, if I can just get my board.. :cry:

rhkean commented 8 years ago

got my board tonight... woot!

xenfomation commented 8 years ago

${somuch}envy On the positive @rhkean, I am testing 3+ "additional packages" to the dietpi-sotware utility instead of throwing 60 in! enjoy the board!!

rhkean commented 8 years ago

don't be too envious... it's 2 1/2 months late and missing the screws to mount the board in on the case. 😭

rhkean commented 8 years ago

wow.... 1.1GB zip file, unzips to 8GB, writes a 2.3GB partition. 😃

Fourdee commented 8 years ago

@rhkean

got my board tonight... woot!

woop woop :+1:. When you've had time to test it, you will have to let us know what you think of it.

wow.... 1.1GB zip file, unzips to 8GB, writes a 2.3GB partition.

lol. I feel the pain from your SD card :)

rhkean commented 8 years ago

well, this is going to take a while.

I might just build it from scratch... not sure, but it definitely won't be up to DietPi standards for a couple versions. sorry

Fourdee commented 8 years ago

@rhkean

well, this is going to take a while.

We can always release it under alpha/beta if its "semi-working", this will be your call. I did that for the Odroid C2 whilst we wait for X11 GPU drivers and gives me a chance to iron out some of those "arm64 issues".

I might just build it from scratch... not sure, but it definitely won't be up to DietPi standards for a couple versions.

Probably best to start from scratch and compile the kernel. I'd focus on getting the device working stable as a headless system first. GPU/VPU support (eg: Kodi, desktop) and wifi could be something to be added at a later date.

When mine turns up (hopefully this year lol), i'll jump in aswell.

rhkean commented 8 years ago

I got an email from backerkit.com with my tracking number...

2 days AFTER my package arrived

Fourdee commented 8 years ago

lmao. Epic 1st release for Pine :+1:

rhkean commented 8 years ago

I just got this to boot into a simple kernel/busybox environment

And connected via UART from my Raspberry Pi

http://forum.pine64.org/showthread.php?tid=99&pid=7625#pid7625

rhkean commented 8 years ago

blarg!!!! when did "minimal" come to mean 1.1GB??? http://forum.pine64.org/showthread.php?tid=87

Fourdee commented 8 years ago

@rhkean

when did "minimal" come to mean 1.1GB???

lol. Clearly the definition of minimal, varies depending on the person claiming it :)

rhkean commented 8 years ago

@Fourdee , don't know if it's gonna boot yet, but I was too excited not to share...

http://dietpi.com/phpbb/viewtopic.php?p=1698#p1698

rhkean commented 8 years ago

@Fourdee how big is your C2 image?

k-plan commented 8 years ago

how big is your C2 image?

DietPi_v115_Odroid-C2-(Jessie_arm64).img = 644,9 MB

Burned-to-SD-Card: boot = 42,3 MB + rootfs = 454,8 MB

rhkean commented 8 years ago

I've got a bootable rootfs at 465MB on the Pine.

I did a dpkg --get-selections | grep -v deinstall

on the RPi and the Pine 64 after running the debian install, then deleted the extra packages

Just gotta put dietpi on the image now, but need sleep.

Fourdee commented 8 years ago

@rhkean

Steps to convert a standard Debian Jessie image into DietPi. Make sure the following files exist. Grab these from the testing branch:

Also, backup your current image (eg dd > file), before you start this process, just incase. These are notes I work from, just go through each line/command and let me know if you have any issues. Also, most of these are copy/paste commands, but keep an eye out for manual entries (eg: nano file).

#-------------------------------------------------------------------------
//DietPi on a fresh install
#-------------------------------------------------------------------------

#Jessie , unified apt sources.
rm /etc/apt/sources.list.d/deb-multimedia.list

cat << _EOF_ > /etc/apt/sources.list
deb http://ftp.debian.org/debian jessie main contrib non-free
deb http://ftp.debian.org/debian jessie-updates main contrib non-free
deb http://security.debian.org jessie/updates main contrib non-free
deb http://ftp.debian.org/debian jessie-backports main contrib non-free
_EOF_

#Remove following Jessie
apt-get purge dialog dhcpcd5 libsqlite* libxapian22 lua5.1 netcat-* make makedev ncdu plymouth openresolv shared-mime-in* tcpd strace tasksel* wireless-* xdg-user-dirs triggerhappy python* v4l-utils traceroute xz-utils ucf xauth zlib1g-dev xml-core aptitude* avahi-daemon rsyslog logrotate man-db manpages vim vim-common vim-runtime vim-tiny mc mc-data
apt-get autoremove --purge -y

#install
echo -e "CONF_SWAPSIZE=0" > /etc/dphys-swapfile
apt-get install -y ifmetric fbset wpasupplicant resolvconf bc dbus bzip2 psmisc bash-completion cron whiptail sudo ntp ntfs-3g dosfstools parted hdparm pciutils usbutils zip htop wput wget fake-hwclock dphys-swapfile curl unzip ca-certificates console-setup console-data console-common keyboard-configuration wireless-tools wireless-regdb crda --no-install-recommends

#firmware
apt-get install firmware-realtek firmware-ralink firmware-brcm80211 firmware-atheros -y --no-install-recommends

#DIETPI STUFF
#Create folders
mkdir /DietPi
mkdir -p /mnt/usb_1
mkdir -p /mnt/samba
mkdir -p /mnt/ftp_client
echo -e "Samba client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config 8" > /mnt/samba/readme.txt
echo -e "FTP client mount can be installed and setup by DietPi-Config.\nSimply run: dietpi-config 8" > /mnt/ftp_client/readme.txt

/boot/dietpi/dietpi-logclear 2

#FSTAB
cp /boot/dietpi/conf/fstab /etc/fstab

#setup dietpi service
echo 1 > /boot/dietpi/.install_stage
cp /boot/dietpi/conf/dietpi-service /etc/init.d/dietpi-service
chmod +x /etc/init.d/dietpi-service
update-rc.d dietpi-service defaults 00 80
service dietpi-service start

#Cron jobs
cp /DietPi/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi
chmod +x /etc/cron.daily/dietpi
cp /DietPi/dietpi/conf/cron.hourly_dietpi /etc/cron.hourly/dietpi
chmod +x /etc/cron.hourly/dietpi

#Crontab
cat << _EOF_ > /etc/crontab
#Please use dietpi-cron to change cron start times
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 1    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 1    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 1    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
_EOF_

#ntp
rm /etc/cron.daily/ntp &> /dev/null
rm /etc/init.d/ntp &> /dev/null

#/etc/sysctl.conf
echo -e "vm.swappiness=1" >> /etc/sysctl.conf

#rc.local
cat << _EOF_ > /etc/rc.local
#!/bin/sh -e
/DietPi/dietpi/dietpi-services start
/DietPi/dietpi/dietpi-banner 0
echo " Default Login:\n Username = root\n Password = dietpi\n"
exit 0
_EOF_

#login
echo -e "\n/DietPi/dietpi/login" >> /root/.bashrc

#Network
# - enable allow-hotplug eth0 after copying.
cp /boot/dietpi/conf/network_interfaces /etc/network/interfaces
/DietPi/dietpi/func/obtain_network_details
sed -i "/allow-hotplug eth/c\allow-hotplug eth$(sed -n 1p /DietPi/dietpi/.network)" /etc/network/interfaces

#Add ipv6 flags DietPi uses to disable IPV6 if set.
# - nano /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0

#htop cfg
cp /boot/dietpi/conf/htoprc /root/.config/htop/htoprc

#Hosts
cat << _EOF_ > /etc/hosts
127.0.0.1       localhost
127.0.1.1       DietPi
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
_EOF_

cat << _EOF_ > /etc/hostname
DietPi
_EOF_

#hdparm
cat << _EOF_ >> /etc/hdparm.conf

#DietPi external USB drive. Power management settings.
/dev/sda {
        #10 mins
        spindown_time = 120

        #
        apm = 254
}
_EOF_

#MANUALLY ADD /etc/bash.bashrc -----------------------------------------
export $(cat /etc/default/locale | grep LANG=)
#DietPi Additions
alias dietpi-process_tool='/DietPi/dietpi/dietpi-process_tool'
alias dietpi-letsencrypt='/DietPi/dietpi/dietpi-letsencrypt'
alias dietpi-autostart='/DietPi/dietpi/dietpi-autostart'
alias dietpi-cron='/DietPi/dietpi/dietpi-cron'
alias dietpi-launcher='/DietPi/dietpi/dietpi-launcher'
alias dietpi-cleaner='/DietPi/dietpi/dietpi-cleaner'
alias dietpi-morsecode='/DietPi/dietpi/dietpi-morsecode'
alias dietpi-sync='/DietPi/dietpi/dietpi-sync'
alias dietpi-backup='/DietPi/dietpi/dietpi-backup'
alias dietpi-bugreport='/DietPi/dietpi/dietpi-bugreport'
alias dietpi-uninstall='/DietPi/dietpi/dietpi-uninstall'
alias dietpi-services='/DietPi/dietpi/dietpi-services'
alias dietpi-config='/DietPi/dietpi/dietpi-config'
alias dietpi-software='/DietPi/dietpi/dietpi-software'
alias dietpi-update='/DietPi/dietpi/dietpi-update'
alias emulationstation='/opt/retropie/supplementary/emulationstation/emulationstation'
alias opentyrian='/usr/local/games/opentyrian/run'

alias cpu='/DietPi/dietpi/dietpi-cpuinfo'
alias dietpi-logclear='/DietPi/dietpi/dietpi-logclear'
treesize()
{
     du -k --max-depth=1 | sort -nr | awk '
     BEGIN {
        split("KB,MB,GB,TB", Units, ",");
     }
     {
        u = 1;
        while ($1 >= 1024)
        {
           $1 = $1 / 1024;
           u += 1;
        }
        $1 = sprintf("%.1f %s", $1, Units[u]);
        print $0;
     }
    '
}
#MANUAL ADD END---------------------------------------------------

#fakehwclock - allow times in the past
sed -i "/FORCE=/c\FORCE=force" /etc/default/fake-hwclock

#wifi dongles
echo -e "options 8192cu rtw_power_mgnt=0" > /etc/modprobe.d/8192cu.conf
echo -e "options 8188eu rtw_power_mgnt=0" > /etc/modprobe.d/8188eu.conf

#Set swapfile size
echo -e "CONF_SWAPSIZE=0" > /etc/dphys-swapfile

#--------SYSTEMD---------
#nano /etc/systemd/logind.conf
#NAutoVTs=1

#nano /etc/default/console-setup
#Reduce gettys ACTIVE_CONSOLES="/dev/tty[1-2]"

systemctl disable getty@tty[2-6].service
systemctl disable serial-getty@ttyS0.service

#NTPd - remove systemd's version
systemctl disable systemd-timesync

#Remove rc.local from /etc/init.d
update-rc.d -f rc.local remove
rm /etc/init.d/rc.local
cat << _EOF_ > /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
After=dietpi-service.service

[Service]
Type=idle
ExecStart=/etc/rc.local
StandardOutput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
_EOF_
systemctl enable rc-local.service
systemctl daemon-reload

#Shutdown SSH/Dropbear before reboot
cat << _EOF_ > /etc/systemd/system/kill-ssh-user-sessions-before-network.service
[Unit]
Description=Shutdown all ssh sessions before network
DefaultDependencies=no
Before=network.target shutdown.target

[Service]
Type=oneshot
ExecStart=/usr/bin/killall sshd && /usr/bin/killall dropbear

[Install]
WantedBy=poweroff.target halt.target reboot.target
_EOF_
systemctl enable kill-ssh-user-sessions-before-network
systemctl daemon-reload

#set en_GB.UTF8
dpkg-reconfigure tzdata
dpkg-reconfigure keyboard-configuration #Keyboard must be plugged in for this to work!
dpkg-reconfigure locales
rhkean commented 8 years ago

screenshot 2016-05-01 at 11 13 52 am

Fourdee commented 8 years ago

@rhkean Whoooooohoo, excellent work, nice one! :+1:

k-plan commented 8 years ago

─────────────────────────────────────── DietPi | 16:13 | Sun 01/05/16 ─────────────────────────────────────── V117 | PINE64 ─────────────────────────────────────── IP Address | ─────────────────────────────────────── Created by: Daniel Knight

:flushed: No:

─────────────────────────────────────── DietPi | 16:13 | Sun 01/05/16 ─────────────────────────────────────── V117 | PINE64 ─────────────────────────────────────── IP Address | ─────────────────────────────────────── Created by: rhkean (Rob) and Daniel Knight

👬

:wink:

Fourdee commented 8 years ago

@k-plan

If Rob continues to contribute, it won't be long before I add his name in the banner :)

Fourdee commented 8 years ago

@rhkean

You will also need to install and configure netplug on the image, as per: https://github.com/Fourdee/DietPi/issues/273#issuecomment-216048131

Run these commands:

#netplug. Resolves issues with unplugging eth and breaking all connections, when WiFi is also active: https://github.com/Fourdee/DietPi/issues/273#issuecomment-215996025
apt-get install netplug -y
cat << _EOF_ > /etc/netplug/netplugd.conf
eth*
wlan*
_EOF_
rhkean commented 8 years ago

but,

rhkean commented 8 years ago

HA!!!! it's not autorunning because of the

echo 1 > /boot/dietpi/.install_stage

I probably shouldn't have stayed up until 6:00am this morning.... 😆

rhkean commented 8 years ago

so, I'm pretty sure that the reason the banner doesn't show up on the hdmi output is related to the way the TTY's are laid out with @longsleep 's kernel.

Unfortunately, that seems to have gotten really bad after I ran /DietPi/dietpi/finalise on my image. When I booted the finalized image, I didn't see anything on the output but the dmesg's.

I'll hook the Pi + minicom back up and see if there's any more info that comes over the UART.

EDIT: yup, it's sending the output to UART.

screenshot 2016-05-01 at 10 23 34 pm

rhkean commented 8 years ago

Now, I have to figure out how to redirect the output to /dev/console screenshot 2016-05-01 at 10 27 52 pm

rhkean commented 8 years ago

SUCCESS!!!!!!!!!!!! boot-2-hdmi-tty1 now, to patch DietPi

rhkean commented 8 years ago

@Fourdee this is exhausting.... how did you do this for so many other boards

Fourdee commented 8 years ago

@rhkean Persistence lol

Fourdee commented 8 years ago

Sorry Rob, probably wasnt much help.

So the main things when adding another device to DietPi:

Theres alot to do for a new device, so if need any assistance, just let me know. Although, I'am still waiting for my Pine so I wont be able to test it lol :(.

rhkean commented 8 years ago

@Fourdee no worries there.... that was funny.

really, that was just my way of saying, "I'm still here. I didn't abandon the task."

The biggest challenge is that there isn't an official (or supported, for that matter) build to fall back on... Everything is in flux.

This will definitely go up as alpha when I'm done with it... Which I'm hoping to complete this weekend.

Fourdee commented 8 years ago

@rhkean

This will definitely go up as alpha when I'm done with it... Which I'm hoping to complete this weekend.

No worries and no rush. The Pine is a completely new board manufacture which comes with the downside of starting from scratch and lots of debugging (by the looks of it). You are doing a cracking job, so If you need to release it as Alpha, not an issue, we can always live patch the system in future updates as needed.

rhkean commented 8 years ago

@Fourdee @k-plan

Need clarification are the following lines in /etc/network/interfaces supposed to be commented out or uncommented with the the latest netplug additions?

#allow-hotplug eth0
#allow-hotplug wlan0

thank you

Fourdee commented 8 years ago

@rhkean

Need clarification are the following lines in /etc/network/interfaces supposed to be commented out or uncommented with the the latest netplug additions?

They have the same effect as using auto eth0. So you must enable at least one to allow the adapter to be active during boot.

Fourdee commented 8 years ago

@rhkean

When you finalize (prep system to be run for the 1st time at next reboot) the image with /DietPi/dietpi/finalise , both get disabled. One will get enabled during 1st run setup based on user settings in dietpi.txt

https://github.com/Fourdee/DietPi/blob/master/dietpi/finalise#L97-L99 | https://github.com/Fourdee/DietPi/blob/master/dietpi/conf/network_interfaces

If I havn't explained the finalize script to you, please let me know.

k-plan commented 8 years ago

@rhkean

Need clarification are the following lines in /etc/network/interfaces supposed to be commented out or uncommented with the the latest netplug additions?

it is not direct associated with netplug. (or ifmetric) https://github.com/Fourdee/DietPi/issues/305

But because it is no skin off one's nose, it's stay in. https://github.com/Fourdee/DietPi/issues/273#issuecomment-216053065


To explain it short:

We have now the possibility to have two active network interface. Each of them has a default route with a gateway. If both interfaces are active, which one will be used? So we need a metric and someone who exploit this. ( ifmetric ) Now the routing table will be build to use only one preferred gateway with one active default route.

But if one of the interfaces goes down or will be plugged out, routing table will not be automatically rebuild, because only the kernel knows, what's happened. So we needed netplug to watch the interface connectivity. If something happened with the interfaces netplug will trigger a ifdown and ifup, which rebuild routing table correct with currently valid routes. (in some cases a route turn)

allow-hotplug brings only a preconfigured interface up in a running system, without reboot or service networking restart by user. auto does this only at system boot up.

Sorry, complex topic, can't explain it better in english.

But if you got the PINE64 on work, you can test it. I think you have two build-in interfaces. It's work like a charm. Thanks @Fourdee ! 👍 A " special feature" particular for PINE64 with WIFI 802.11BGN module (powered by rhkean) or RPi 3. 😄 And soon, with 13 WiFi Channels in Europe. :sweat_smile:

rhkean commented 8 years ago

I have the following:

What is not completed

xenfomation commented 8 years ago

Impressive! Looks like I need to get a Pine as well. DietPi -- SBC thirst quencher.

rhkean commented 8 years ago

@Fourdee I need a place to upload the image.

Fourdee commented 8 years ago

@rhkean o0o0o0o0o0o0o00o0 :dancer:

Sent you email with FTP details :+1:

k-plan commented 8 years ago

The DietPi image for Pine A64 has been created and implemented by Rhkean.

dietpi-logo_150 DietPi for Pine A64: Give your Pine A64 some lightweight justice

ALPHA notes:

For all up to date information and downloads for this release, please go to: forum.pine64.org - DietPi for PineA64

Fourdee commented 8 years ago

@rhkean As your Pine image is now released :+1: , you can close this ticket at your leisure.

If you have outstanding jobs/fixes that you plan to add to the Pine, probably best to create a new ticket for each specific job, or whatever works for you.

Fourdee commented 8 years ago

@rhkean On the social media band wagon lol: https://twitter.com/DietPi_/status/732630498183368704

ghost commented 8 years ago

Looks like my pine64 just arrived!

Fourdee commented 8 years ago

Mine turned up today :dancer:. @rhkean excellent work on this image :+1:. I'am thinking we should change this to Beta? I cant see any stability issues so far.

rhkean commented 8 years ago

:fireworks: I don't have any objections to beta.