Delaying Wifi Setup for RPI3.

Sorry if i have to delay on how to make the wifi works for this build. I have been busy and i am going to transfer this blog on github. sorry for any inconvenience adn will soon delete this account. This will be the new Site . Also i am trying to simulate if i can build this on Windows 10 Bash… So far the only hurdle that i am on now is the qemu-user-static not installing properly. So meaning i can not chroot on our custom rootfs.

Advertisements
Posted in Raspberry pi 3

Using Ubuntu base arm64 rootfs for RPI3

Following my previous post here, we now can now boot our kernel thru u-boot. Now we’re going to create a filesystem base from arm64 ubuntu base rootfs.

Create a folder were we will extract the Ubuntu base rootfs, and tar to extract.

mkdir rootfs
cd rootfs/
sudo tar –xzvf ubuntu-base-16.04.2-base-arm64.tar.gz

Install the kernel module into the rootfs folder.

sudo ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH={directory}/rootfs/

Check that it was installed correctly.

ls rootfs/lib/modules/4.11~

build           modules.builtin        modules.devname         modules.symbols.bin
kernel        modules.builtin.bin      modules.order        source
modules.alias         modules.dep     modules.softdep
modules.alias.bin   modules.dep.bin    modules.symbols

We’ll use chroot to further setup our filesystem.

sudo cp –av /usr/bin/qemu-aarch64-static {directory}/rootfs/usr/bin

Note*:
• /usr/bin/qemu-arm-static is for 32-bit armhf architecture
• /usr/bin/qemu-aarch64-static is for 64-bit arm64 architecture

Enter chroot environment:

sudo chroot {directory}rootfs/

Now that you’re in the chroot environment, we can now add an admin user with sudo permission.

useradd -G sudo -m -s /bin/bash rpi3
echo rpi3:raspberry | chpasswd

Note*: The format input line of chpasswd is: user_name:password.

Setup a hostname for your target device.

echo U-Base_min > /etc/hostname
echo 127.0.0.1 localhost

Fetch the latest package lists from server then upgrade.

apt-get update
apt-get upgrade

Install minimal packages:

apt-get install sudo ifupdown net-tools ethtool udev wireless-tools iputils-ping perl resolvconf wget apt-utils dialog wpasupplicant initramfs-tools</>

Create a Ramdisk(optional).

mkinitramfs -o /boot/initrd.img /lib/modules/4.11~

When everything you want to setup has been done, exit chroot:

exit

Then copy the rootfs/ content to the 2nd partition of your µSD car. Now boot it up and you should now be able to login.

Net post will be about setting up the wifi.

Reference:

http://docs.khadas.com/social/BuildUbuntuRootfsViaUbuntuBase/

https://gnu-linux.org/building-ubuntu-rootfs-for-arm.html

 

 

Tagged with:
Posted in Raspberry pi 3

Rpi3 64bit kernel and U-boot booting up

Cross-build prerequisite:

gcc-arch64-linux-gnu          g++-5               ncurses-dev
make       git           bc          u-boot-tools          device-tree-compiler

Assuming there is already a Cross-build environment: Built on Ubuntu Server 16.04.02

Prerequisites:

Ubuntu Base Rootfs (install additional package using apt-get)
Raspberry pi kernel (Have not tried using Upstream kernel)
Raspberry pi firmware (bootcode.bin, start.elf, fixup.dat and the rest of start_ and fixup_)
U-boot


µSD card:(assuming you already know how)

Your µSD card(boot partition) should contain the following:

bootcode.bin
start.elf (and the rest of the start_ file)
fixup.dat (and the rest of the fixup_ file)
config.txt
cmdline.txt

For the config.txt and cmdline.txt, we have to create them and include this lines.

config.txt:

arm_control=0x200
force_turboo=1
enable_uart=1
device_tree_address=0x100
device_tree_end=0x8000
#kernel=u-boot.bin
dtparam=i2c_arm=on
dtparam=spi=on

cmdline.txt:

net.ifnames=0 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait


U-Boot:

Get the source code by cloning the U-Boot git repository or download the tar file.

git clone –depth 1 –branch v2017.03 –single-branch git://git.denx.de/u-boot.git
ftp://ftp.denx.de/pub/u-boot/u-boot-2017.03.tar.bz2

Then configure and build u-boot. For 64-bit use rpi_3_defconfig

cd u-boot/
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rpi_3_defconfig

Then compile it.

sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

To change output directory use O=directory path/

sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=directory path/

After it has been built. Locate u-boot.bin as this is the file we need. Copy it to your µSD card and rename it to kernel8.img or keep its name as it is and uncomment the line kernel=u-boot.bin in config.txt. Boot it up to confirm that it’s working.


Kernel:

Get the kernel source code at the official Raspberry pi git repository.

git clone –depth 1 –branch v2017.03 –single-branch https://github.com/raspberrypi/linux.git

Use bcmrpi3_defconfig for kernel config. You can further configure it according to your needs. But for now, its fine to leave it be.

cd linux
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcmrpi3_defconfig
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j 3
after the above compiled run for device-tree-blob:
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j 3 dtbs

Locate Image (no need to convert for U-Boot use it as it is for 64bit) file at arch/arm64/boot/ and the bcm2710-rpi-3-b.dtb at arch/arm/boot/dts/. I’m having trouble using bcm2837-rpi-3-b.dtb. So for now use bcm2710-rpi-3-b.dtb instead. Copy the Image and bcm2710-rpi-3-b.dtb files to your µSD card boot partition. At this point, you can test it if it will boot the kernel but we need to have a boot script that U-Boot needs. We’re using the boot.script from this file: 20160517-raspi3-arm64-firmware-kernel.tar.xz. Modify and create the boot.scr from it.

boot.script should look like this:

fdt addr 0x100
fdt get value bootargs /chosen bootargs
setenv kernel_addr_r 0x01000000
setenv ramdisk_addr_r 0x02100000
fatload mmc 0:1 ${kernel_addr_r} Image
fatload mmc 0:1 ${ramdisk_addr_r} initrd.img
setenv initrdsize $filesize
fatload mmc 0:1 ${fdt_addr_r} bcm2710-rpi-3-b.dtb
booti ${kernel_addr_r} ${ramdisk_addr_r}:${initrdsize} ${fdt_addr_r}

Since we don’t have a Ramdisk yet, comment that line and replace ${ramdisk_addr_r}:${initrdsize} with ‘-‘. removing the apostrope
Or copy the initrd.img to use it temporarily. You can now then verify at this point that our kernel boot as well and will stop at some point since we still do not have a filesystem.

next post will be about on how to make a filesystem base on Ubuntu Base.

rpi3-64

Reference:

https://wiki.ubuntu.com/ARM/RaspberryPi/RaspberryPi3

https://wiki.ubuntu.com/Base

https://www.raspberrypi.org/documentation/linux/kernel/building.md

https://kernelnomicon.org/?p=682

Donate

Tagged with:
Posted in Raspberry pi 3