Slackware - ARMThis forum is for the discussion of Slackware ARM.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I was wondering whether I could tftp a u-boot script and call it but didn't find out how to do that yet.
I've been playing around with this tonight. I have an TFTP server set up as per INSTALL_BANANAPI.TXT with a u-boot script, boot.scr, in /tftpboot. I'm using a freshly compiled u-boot from u-boot-2016.09 source. U-boot working fine on bananapro with current installed
It seems that there would be only a few commands required to tftp a u-boot script
I can get u-boot to begin to load the script but no matter what load address I give it there is an error after transferring 979 bytes. The same error mesage and same number of bytes each time. I'm not really up to speed on the memory addressing and I'm not quite sure if this is indeed the problem.
Code:
=> tftp 0x52000000 boot.scr
Speed: 1000, full duplex
Using ethernet@01c50000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.8
Filename 'boot.scr'.
Load address: 0x52000000
Loading: #
190.4 KiB/s
done
Bytes transferred = 979 (3d3 hex)
CACHE: Misaligned operation at range [52000000, 520003d3]
=>
One thing I note is that I get a different number of Kbs loaded with different addresses.
OK I have it now. A trip to the land of nod always helps. I'm now able to bring up a Slackwarearm install using a boot.scr located on the tftp server. The script is in /tftpexport. This still requires cli entries once at a u-boot prompt to get started but if commands are saved then u-boot will boot into a tftp install every time.
Code:
=> env default -a ; reset
# Use the above line first time only
=> setenv ipaddr 192.168.1.8
=> setenv serverip 192.168.1.2
=> setenv gatewayip 192.168.1.1
=> setenv scriptname boot.scr
=> setenv scriptaddr 0x43100000
=> setenv tftpcmd tftp
=> setenv bootcmd '${tftpcmd} ${scriptaddr} ${scriptname}; source ${scriptaddr}'
=> saveenv ; reset
My boot.scr commands were taken from INSTALL_BANANAPI.TXT
Hmm ok. I am thinking about how this could be used within the installer and in the OS, and try to automate the u-boot config as much as possible.
There are some obvious things to do to find out what the file system is and stuff like that, but I'm not sure how the hard stuff could work since you don't know that /dev/sda could be on SATA or USB within u-boot -- how could you write a u-boot script file that referenced the kernel and initrd using the appropriate device names and u-boot object loading commands.
Otherwise I'd probably think about writing it.
Yes, I have been thinking about this in terms of Slackwarearm installation. This is the end of the week and I enter into a very intensive work cycle. Still thinking .... but will reply later than anon. I have thought about springing for another board with different cpu to have a bit of a play to see how generic this can become but still it comes down to u-boot is compiled to a specific board/device so I'm thinking it would be X number of u-boots (maybe), each for a specific board/mach all of which point to a /tftpboot set up with appropriate contents by the person doing the install. It would at least be a little bit easier to howto. U-boot scripts can do if else if type stuff, I've managed that, haven't checked out case statements though.
Board suggestions are welcome, Another board won't go astray. On a different tack book markers will post soon.
Last edited by justwantin; 10-12-2016 at 01:24 AM.
Reason: tyop
@SCerovec,Thank you for the heads up I had a squiz.
@drmozes, I've had a bit of a thought and a bit of a play. Perhaps this might be worth thinking about. By default, a boot.scr located in the boot directory of the root file system on an sd card, sata drive, or usb drive where Slackwarearm is installed will be run when u-boot with default settings is run on my PiPro and the system will boot. The order is mmc, scsi, usb. I had changed the default u-boot environment for a TFTp install with:
and could then boot into an install using a boot.src in the tftpboot directory.
Once I have installed Slackwarearm on either an sd card, sata disk, or usb drive I need to change u-boot back to default settings before I can reboot into the new install using an appropriate boot.src pre-positioned in the /boot directory of the given storage device.
If a boot.src was installed in /boot during installation then it would be a matter of setting u-boot back to defaults.
Code:
=> env default -f -a
=> saveenv ; reset
Now if the install is on the sd card the system boots. If there is only an sd card with u-boot on board and the install is on a sata drive, that will boot. Finally if there is no sata drive connected, or there is but there is no boot.scr or /boot/boot.scr to be found, the system on the usb drive will boot.
I thought about using if else in boot.scr for testing but then default u-boot does the work already. I don't think there would be the possibility of a dual boot setup with two different media.
This would require a pre-built boot.cmd boot.scr for each type of install and they would be configured to a given layout, e.g. swap sda1, root sda2. If something else was desired the person doing the install could drop into a command line after installation and use ROOT=/mnt joe to edit a boot.cmd then run ROOT=/mnt mkimage to create the new boot.scr.
Alternatively, my three boot.cmds used to mkimage are (almost) exactly the same except for addressing the storage device, i.e. mmc, scsi, usb. If the relevant lines for all three mediums were all included in the installed boot.cmd but commented out then the appropriate three lines could be uncommented either manually or with some clever stream editing. Mkimage would have to run after editing.
Might be that boot.cmd will need some fine tuning but some variation of this might fly. Note that I've tested and get the boot results discussed above. Slackware current pre 14.2 on the sd card, Slackware current on SSD, and Slackware current kernel /dtb and initrd-armv7.img on usb stick (allright ... I'm lazy and didn't do the usb install). U-boot was compiled natively on Slackwarearm current using u-boot-2016-09 source. This might be fairly generic for mach sunxi devices and easily adapted to some or another non-sunxi sbc's down the track somewhere.
Last edited by justwantin; 10-14-2016 at 07:06 PM.
Reason: tyop
then "each to his own" we generate the actual boot.scr from the appropriate script?
The catch it all script was made for me- to more easy fiddle with many parameters, but towards the end i found my self more looking for than actually coding - the monolithic script isn't really providing good oversight to what's going on?
Also, the u-boot shell supports sourcing: we could define one central script for all that's edited, and separate scripts that call it on execution?
A can of worms, eh?
:-J
P.S.
I just also figured we could make the mmc/usb/sata be checked in one single script by an user provided variable?
I must go try code it
BRB
Last edited by SCerovec; 10-15-2016 at 02:59 AM.
Reason: more added :-]
I was just talking out loud, an idea tested, so to speak, its really up to Stuart where if anywhere he goes with it. I thought it might be a simple way to go but without looking any further dunno. I don't like getting too complicated, like sailing rigs and automatic weapons, the less moving parts (read simplicity) the less that can go wrong ;*}
###
#
# v0.2-alpha (C) GPL cest73@ya.ru 2016 for Slackware ARM and U-BOOT
#
# Generic (hopefully) Uboot script with templates for many scenarios
# typical on-disk layout:
# /boot/ for kernel and initrd
# /boot/dtb/ for device tree files
# /boot.scr /boot.scr.uimg our filename and format:
# generated by
# ./mkimage -C none -A arm -T script -d boot.cmd boot.scr
#
# filename: boot.cmd
###
###
#
# defining the way we boot...
#
###
# uncomment only one of the two
#setenv mode 'setup'
setenv mode 'regular'
# set the appropriate boot target(CASE sensitive!):
# 'ftfp' for booting over LAN
# 'usb' for booting from a USB storage (stick or disk)
# 'sata' to harness the speedy SATA interface for boot
# 'fel' if You deliver this file and the boot items by means of an OTG micro USB cable
# 'mmc' for the most usual setup - the files residing on a SD or MMC card
setenv media 'mmc'
#'serial' for the UART0
#'hdmi' for the HDMI port
#TODO 'composite'
#TODO 'ssh'
setenv interface 'serial'
#'auto' dhcp
#'172.32.16.0' our local address, then also set host below
#'none' no net during boot
setenv net 'none'
#setenv net '192.168.168.128'
# the IP of the tftp serving host
#setenv host '192.168.168.102'
# below this line WHERE THERE BE DRAGONS! (dont go!)
echo 'for SlackwareARM U-boot v0.2...'
###
#
# defining the host specific parameters
#
###
# for Banana PI:
setenv fdtfile '/boot/dtb/sun7i-a20-bananapi.dtb'
setenv kernelfile '/boot/zImage-armv7'
if test $mode = 'setup'; then
# for setup
setenv setupfs '/boot/initrd-armv7.img'
else
# for everyday
setenv initrdfile '/boot/initrd-armv7'
fi
setenv tftpfdtfile 'slackwarearm-current/dtb/sun7i-a20-bananapi.dtb'
setenv tftpkernelfile 'slackwarearm-current/zImage-armv7'
if test $mode = 'setup'; then
# for setup
setenv tftpsetupfs 'slackwarearm-current/initrd-armv7.img'
else
# for everyday
setenv tftpinitrdfile 'slackwarearm-current/initrd-armv7'
fi
###
#
# defining the load addresses
#
###
if test $media = 'fel' ; then
# derived from UBOOT-FEL load address
setenv fdt_addr_r 0x43000000
setenv kernel_addr_r 0x42000000
setenv ramdisk_addr_r 0x43300000
else
# use this for tftfp setup
setenv fdt_addr_r 0x43000000
setenv kernel_addr_r 0x46000000
setenv ramdisk_addr_r 0x47000000
fi
###
#
# crafting the file source commands
#
###
if test $media = 'tftp'; then
# by ftfpboot .......... setup in the install on Banana PI HOWTO
# adjust to own TFTP server/host
if test $net != 'auto'; then
setenv serverip ${host}
setenv ipaddr ${net}
else
# this is actually a parachute option ;)
dhcpcd
fi
tftp ${fdt_addr} ${tftpfdtfile}
tftp ${kernel_addr_r} $tftpkernelfile
if test $mode = 'setup'; then
# for setup
tftp ${ramdisk_addr_r} $tftpsetupfs
else
# for everyday
tftp ${ramdisk_addr_r} $tftpinitrdfile
fi
else
if test $media = 'fel'; then
#for FEL we load via the cable O.o
echo 'no files needed for download in FEL mode'
else
if test $media = 'sata'; then
scsi reset
scsi scan
elif test $media = 'usb'; then
usb reset
usb scan
fi
# except for fel, we load for mmc, usb and scsi/sata
echo "Loading files from ${media}"
load ${media} 0:1 ${fdt_addr_r} ${fdtfile}
load ${media} 0:1 ${kernel_addr_r} ${kernelfile}
if test $mode = 'setup'; then
# for setup
load ${media} 0:1 ${ramdisk_addr_r} ${setupfs}
else
# for every day
load ${media} 0:1 ${ramdisk_addr_r} ${initrdfile}
fi
fi
fdt addr ${fdt_addr_r} 0x40000
fi
###
#
# crafting the boot arguments
#
###
### common boot arguments
if test $interface = 'serial'; then
setenv bootcmd_generic ' debug earlyprintk sunxi_g2d_mem_reserve=0 sunxi_ve_mem_reserve=0'
else
setenv bootcmd_generic ' debug earlyprintk sunxi_g2d_mem_reserve=0 sunxi_ve_mem_reserve=0 disp.screen0_output_mode=EDID:1280x720p50 hdmi.audio=EDID:0'
fi
### initial output
if test $interface = 'serial'; then
# for serial console
setenv slkconsole ' console=ttyS0,115200'
else
# or for HDMI
setenv slkconsole ' console=tty1'
fi
### OS related parameters
if test $mode = 'setup'; then
if test $net = 'auto'; then
# setup with automatic network parameters
setenv osargs " TERM=screen-256color nic=auto:eth0:dhcp root=/dev/ram rw"
else
# setup with manual or special network setup
setenv osargs " TERM=screen-256color nodhcp root=/dev/ram rw"
fi
else
if test $media = 'mmc' ; then
# everyday parameters for MMC/SD card
setenv osargs " resumedev=/dev/mmcblk0p2 root=/dev/mmcblk0p1 rootfstype=ext4 ro"
else
# everyday parameters for SCSI or USB
setenv osargs " resumedev=/dev/sda2 root=/dev/sda1 waitforroot=2 rootfstype=ext4 ro"
fi
fi
### gluing it all together
# kernel command line
setenv bootargs ${slkconsole} ${bootcmd_generic} ${osargs}
###
#
# initial output
#
###
# passing control to kernel
bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
# here from You should be with Slackware setup or system
highly untested BEWARE
I just pulled out a boot via OTG/fel to boot the MMC (worked!)
I'm about to put it for good on my MMC now.
use as found appropriate (maybe derive something out of it?)
further testing on my 0.2-alpha:
I went and modified the option to boot to HDMI (console=tty1 etc)
and it worked (off MMC media)
maybe I need some sort of wrapper (as visudo) for editing the file?
file: /usr/bootedit.sh
Quote:
#!/bin/sh
#wrapper for editing /boot.src
# GPL v3 apply - support on Linuxquestions.org for Slackware ARM
# author: cest73@ya.ru
# version V1.0-release
# file /usr/sbin/bootedit
#put Your favorite editor instead mcedit
Editor='/usr/bin/mcedit'
Converter='/usr/bin/mkimage'
tgt='/boot.scr'
src='/boot.cmd'
if [[ -x ${Editor} ]] ; then
if [[ -x ${Converter} ]] ; then
$Editor ${src} && $Converter -C none -A arm -T script -d ${src} ${tgt}
else
echo "converter [${Converter}] not found! aborting."
exit 2
fi
else
echo "editor [${Editor}] not found! aborting."
exit 2
fi
echo "done."
I was just talking out loud, an idea tested, so to speak, its really up to Stuart where if anywhere he goes with it. I thought it might be a simple way to go but without looking any further dunno. I don't like getting too complicated, like sailing rigs and automatic weapons, the less moving parts (read simplicity) the less that can go wrong ;*}
Yes this is my concern. You'd still need to manually configure some stuff up front in u-boot, so I'm not really sure what the point is of having a script to update the settings. Whilst it'd be a nice to have, it'd add complexity and would probably be buggy.
Perhaps one of the easiest ways to use this would be to create installer boot scripts that you can tftp. However, the script would have to assume that the setup (paths and so on) on the tftp server are exactly as laid out in the HOWTO.
I'd certainly use it although I don't know if it'd be useful enough for anyone else.
I have been using Slackware since 7.1 and had installed Slackwarearm using community images when the first Raspberrypi's came out in 2012 and installed later using FatDogs' boot image. The first time I read INSTALL_BANANAPI.TXT my eyes glazed over. Eventually I got an install going on a Bananapro. I'd guess that the majority of folks who install and run Slackwarearm have enough expertise to manage just fine but I'd like to see something just a tad simpler for the Slackwarearm newbie for the first time around install.
My first idea is not always my final idea but .... if tftp and /tftpexport is setup, simple http server and source in /export is setup and u-boot is on an sd card than all is needed is the u-boot commands necessary for a tftp install. There are three boot.scr's available (mmc, scsi and usb). Exit to cli and with ROOT=/mnt copy the appropriate one to /boot. Reboot to u-boot hit enter before auto boot and setenv back to defaults saveenv and reset. Dunno maybe that would look just as complicated in a howto document. If not it might just attract a few more owners of supported SBC's out there to give Slackwarearm a go.
Personally, I prefer to have my install source on a usb stick. I install u-boot on an sdcard which is formatted with one ext4 partition. I create a boot directory in that partition and copy in a boot.src based on the commands provided in INSTALL_BANANAPI.TXT, the kernel, /dtb and the initrd.img. I can then boot into an install, mount the usb stick and install. I have the exact same boot.src except it points to an initrd, not initrd.img. It is on the mounted usb stick. Post install I exit, drop to cli and copy that boot.src to /mnt/boot. If I have installed to the sdcard, I will have removed /boot on the sd card when I formatted the card before running setup. If I have installed on an sdd, I will have to delete boot.src or remove the /boot directory on the sd card. That can be done by mounting the sd card before hitting reboot.
I only have one monitor so I use UART and SSH to interface with my two bananapro's. However, with this second method the install can be accomplished connected to a keyboard and monitor and no network required. Installing from another medium is not an alien idea (no pun intended!) That's how most people install linux on x86 machines.
After an arm newbie has installed once they know it can be done. They can then commence to make problems for themselves.
I just had in mind a helper:
Did anyone fiddle with boot settings on a running system?
I did: EDID params, Monitor resolution, kernel parameters...
I'm a great fan of grub (especially if i forget to run #lilo after an /etc/lilo.conf edit), so I'm used to tweak the way my system boots:
I determine the run level in command line and not in /etc/inittab every since.
So You can imagine I found my self typing every once in a while the editor command, the cd command and the convert command.
That's a lot of cursor up and wading through the command history...
And if i work in more sessions, and exit them out of order;the history gets bloated quite a lot...
So i figured, why sudo can have a command, and I can't for boot.scr?
And I tried it, and it really accelerated the process while providing some basic sanity checks?
I've been playing with u-boot and tftp again. I thought I might clarify that there are only 8 actual command lines required in a /tftpboot/boot.scr needed to bring up a Slackwarearm installation. Here is the ftp-boot.cmd I am using to create that boot.scr
Code:
# tftp-boot.cmd
# Create a boot.src from this script and copy to the
# /tftpboot directory. Change dtb line if installing
# on a BananaPi.
# Use the following command to reset u-boot to defaults:
# env -f -a ; reset
#
setenv fdt_addr 0x43000000
setenv kernel_addr_r 0x47000000
setenv ramdisk_addr_r 0x48000000
#
setenv bootargs console=ttyS0,115200n8
#
tftp ${fdt_addr} slackwarearm-current/dtb/sun7i-a20-bananapro.dtb
tftp ${kernel_addr_r} slackwarearm-current/zImage-armv7
tftp ${ramdisk_addr_r} slackwarearm-current/initrd-armv7.img
#
bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr}
#
# Use the following command to ceate a boot.scr:
# mkimage -C none -A arm -T script -d tftp-boot.cmd boot.scr
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.