beaglebone uenv parameters

This commit is contained in:
Bob Mottram 2017-05-30 10:20:12 +01:00
parent 911f90b25f
commit 68777f0059
1 changed files with 143 additions and 1 deletions

View File

@ -31,7 +31,14 @@ PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-image-hardware-setup
export TEXTDOMAINDIR="/usr/share/locale"
setup_flash_kernel() {
function enable_serial_console {
# By default, spawn a console on the serial port
device="$1"
echo $"Adding a getty on the serial port"
echo "T0:12345:respawn:/sbin/getty -L $device 115200 vt100" >> /etc/inittab
}
function setup_flash_kernel {
if [ ! -d /etc/flash-kernel ] ; then
mkdir /etc/flash-kernel
fi
@ -49,29 +56,164 @@ setup_flash_kernel() {
apt-get -yq install flash-kernel
}
function a20_env {
dtb="$1"
# Setup boot.cmd
if grep -q btrfs /etc/fstab ; then
fstype=btrfs
else
fstype=ext4
if [ -n "$command_line" ] ; then
echo flash-kernel flash-kernel/linux_cmdline string "$command_line" | debconf-set-selections
fi
kernelVersion=$(ls /usr/lib/*/$dtb | head -1 | cut -d/ -f4)
version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
initRd=initrd.img-$version
vmlinuz=vmlinuz-$version
# Create boot.cmd
cat >> /boot/boot.cmd <<EOF
setenv mmcdev 0
setenv mmcpart 1
setenv mmcroot /dev/mmcblk0p2 ro
setenv mmcrootfstype $fstype rootwait fixrtc
setenv mmcrootflags subvol=@
setenv console ttyS0,115200n8
setenv kernel_file $vmlinuz
setenv initrd_file $initRd
setenv fdtfile $dtb
setenv loadaddr 0x46000000
setenv initrd_addr 0x48000000
setenv fdtaddr 0x47000000
setenv initrd_high 0xffffffff
setenv fdt_high 0xffffffff
setenv loadkernel load mmc \${mmcdev}:\${mmcpart} \${loadaddr} \${kernel_file}
setenv loadinitrd load mmc \${mmcdev}:\${mmcpart} \${initrd_addr} \${initrd_file}\\; setenv initrd_size \\\${filesize}
setenv loadfdt load mmc \${mmcdev}:\${mmcpart} \${fdtaddr} /dtbs/\${fdtfile}
setenv loadfiles run loadkernel\\; run loadinitrd\\; run loadfdt
setenv mmcargs setenv bootargs console=\${console} root=\${mmcroot} rootfstype=\${mmcrootfstype} rootflags=\${mmcrootflags}
run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
EOF
# boot.scr for Allwinner A20 based device
mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
# Copy all DTBs
mkdir -p /boot/dtbs
cp /usr/lib/$kernelVersion/* /boot/dtbs
# extra boot modules
echo "rtc_sunxi" >> /etc/initramfs-tools/modules
}
function beaglebone_env {
bbb_version=$1
# Setup uEnv.txt
if grep -q btrfs /etc/fstab ; then
fstype=btrfs
else
fstype=ext4
fi
if [ ! $bbb_version ]; then
kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
else
kernelVersion=$(ls /usr/lib/*/am335x-boneblack-${1}.dtb | head -1 | cut -d/ -f4)
fi
version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
initRd=initrd.img-$version
vmlinuz=vmlinuz-$version
#bbb_loadaddr='0x80200000'
#bbb_initrd_addr='0x81000000'
#bbb_fdtaddr='0x80F80000'
#if [[ "$bbb_version" == "wireless" ]]; then
bbb_loadaddr='0x82000000'
bbb_initrd_addr='0x88080000'
bbb_fdtaddr='0x88000000'
#fi
# uEnv.txt for Beaglebone
# based on https://github.com/beagleboard/image-builder/blob/master/target/boot/beagleboard.org.txt
cat >> /boot/uEnv.txt <<EOF
mmcroot=/dev/mmcblk0p2 ro
mmcrootfstype=$fstype rootwait fixrtc
mmcrootflags=subvol=@
console=ttyO0,115200n8
kernel_file=$vmlinuz
initrd_file=$initRd
loadaddr=$bbb_loadaddr
initrd_addr=$bbb_initrd_addr
fdtaddr=$bbb_fdtaddr
initrd_high=0xffffffff
fdt_high=0xffffffff
loadkernel=load mmc \${mmcdev}:\${mmcpart} \${loadaddr} \${kernel_file}
loadinitrd=load mmc \${mmcdev}:\${mmcpart} \${initrd_addr} \${initrd_file}; setenv intrd_size \${filesize}
loadfdt=load mmc \${mmcdev}:\${mmcpart} \${fdtaddr} /dtbs/\${fdtfile}
loadfiles=run loadkernel; run loadinitrd; run loadfdt
mmcargs=setenv bootargs console=tty0 console=\${console} root=\${mmcroot} rootfstype=\${mmcrootfstype} rootflags=\${mmcrootflags}
uenvcmd=run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
EOF
mkdir -p /boot/dtbs
cp /usr/lib/linux-image-*-armmp/* /boot/dtbs
}
case "$MACHINE" in
beaglebone)
beaglebone_env
enable_serial_console ttyO0
setup_flash_kernel 'TI AM335x BeagleBone Black' 'ttyO0'
;;
beaglebonewifi)
beaglebone_env
enable_serial_console ttyO0
setup_flash_kernel 'TI AM335x BeagleBone Black Wireless' 'ttyO0'
;;
cubietruck)
a20_env sun7i-a20-cubietruck.dtb
enable_serial_console ttyO0
setup_flash_kernel 'Cubietech Cubietruck'
;;
a20-olinuxino-lime)
a20_env sun7i-a20-olinuxino-lime.dtb
enable_serial_console ttyO0
setup_flash_kernel 'Olimex A20-OLinuXino-LIME'
;;
a20-olinuxino-lime2)
a20_env sun7i-a20-olinuxino-lime2.dtb
enable_serial_console ttyO0
setup_flash_kernel 'Olimex A20-OLinuXino-LIME2'
;;
a20-olinuxino-micro)
a20_env sun7i-a20-olinuxino-micro.dtb
enable_serial_console ttyO0
setup_flash_kernel 'Olimex A20-Olinuxino Micro'
;;
cubieboard2)
a20_env sun7i-a20-cubieboard2.dtb
enable_serial_console ttyO0
setup_flash_kernel 'Cubietech Cubieboard2'
;;
pcduino3)
a20_env sun7i-a20-pcduino3.dtb
enable_serial_console ttyO0
setup_flash_kernel 'LinkSprite pcDuino3'
;;
esac