Technicavolous Posted February 19, 2018 Share Posted February 19, 2018 Background Most of the instructions I found on installing anything on the Clearfog Pro or Base with eMMC were either not applicable to me, incomplete or missing some file or there was some other barrier. After a couple weeks of tinkering and notation I feel I have a good handle on getting Armbian on this board by several different methods. Here I will describe my path to using TFTP to install Armbian on my Clearfog Pro. First off, I have no clue why so many tutorials include a line that reads something like "but that would require you to set up a TFTP server so we're going to go through a lot of other rigamarole instead.' Really? This guide got my TFTP server up and running in a few minutes, all I had to figure out was that since I had used sudo to install the server, it owned the tftpboot directory so copying files there took root or sudo to do it, which is fine since you probably want a little security over a TFTP directory anyway. I have an M.2 SSD drive installed on my Clearfog, but these instructions should work if you use a USB stick large enough to carry the images. If the Clearfog had a little more RAM, we could do it all on the hardware but Armbian images are too large to fit in RAM with Buildroot or U-Boot so we need an intermediate medium. In another post I'll describe doing the entire install from a prepared M.2 SSD. I chose the TFTP path for my first load because the U-Boot that ships with the board is configured to attempt to find files via TFTP if it fails to find what it is looking for locally. At the time I had no clue what I was about to learn about the U-Boot process or all the configuration it goes through. I just knew it was looking for boot.scr via tftp so I decided to give it what it was looking for. Further investigation revealed that the U-boot that ships with the board is 'broken' in that it doesn't allow the obvious function of booting from USB and can't interact with the USB storage. The buildroot image that can load to ram via TFTP can interact with 'SCSI' and USB storage, so again I felt TFTP was the way to go. The instructions on this page have necessary files and info to get their version of Debian on it but it is missing a CRITICAL instruction in section 8 to boot the board. It took me days to figure that out, after mostly realizing how similar the various boot methods are. If you are interested in following those instructions see this post I made on the Solid Run forum and add that line to the end of section 8. This forum post has very good information on the U-boot part of the process. This information helped me immensely. If you use the 'next' kernel (as of 4.14.14) you will have to remove network manager and configure networking manually. 'Default' (4.4.112 currently) networking is fine. I am using Armbian_5.38_Clearfogpro_Debian_stretch_next_4.4.112.img in this guide. The step by step This guide is verbose - it assumes little. I hope to have made this so even someone fairly new to SBCs should be able to get this board up and running a basic Armbian configuration. Get the necessary files Download u-boot.mmc from Solidruns download page for Clearfog Download clearfog-emmc.tar.gz and extract zImage armada-388-clearfog.dtb boot.scr from the link in the emmc section on Solidruns installation page Download an Armbian image of your choice from Armbian's Clearfog download page, I used the 'default' image for now because I don't want to go through configuring networking manually Armbian_5.38_Clearfogpro_Debian_stretch_next_4.4.112.img Prepare your TFTP server install your favorite TFTP server or follow the instructions on the link above and move the following files to your tftp boot directory (I had to use su to move the files) - u-boot.mmc zImage armada-388-clearfog.dtb boot.scr Armbian_5.38_Clearfogpro_Debian_stretch_next_4.4.112.img Connect to the Clearfog terminal You will need a USB terminal program on your host PC. I use an Odroid XU4 with Armbian. 'screen' is the terminal I like, use any you want. For me, opening any terminal and typing screen /dev/ttyUSB0 115200 gets me a display ready for the Clearfog. (connect a USB to micro USB cable to the Clearfog and your PC ...) Make sure the dip switches are configured for eMMC boot. Power up the Clearfog and you should see U-boot load and attempt to find bootfiles. It was a scary screen of failures the first time I saw it, don't worry we're going to get that looking the way we want. Configure the stock U-Boot to see the TFTP server Since you probably let it go past the stop boot prompt, power down the Clearfog and power it up again ;] stop the boot process by pressing a key when instructed. You will get a Marvell>> prompt. We need to set some IP parameters so U-boot can find the TFTP server - setenv serverip [IP of your TFTP server] setenv ipaddr [IP that you want the Clearfog to have] Write the newer U-Boot to eMMC Now we can attempt to write the eMMC u-boot image to eMMC by TFTP. We have to bring it down from the TFTP server to ram, then write the file from ram to the eMMC - tftpboot 0x02000000 u-boot.mmc mmc write 0x02000000 0 ${filesize} Now we want the new u-boot to load, so we have to reboot the board from the currently running u-boot reset You should notice a difference with the boot behavior with the new U-boot. Again, we stop the boot process when prompted. Of course you will be tempted to let it run through its failures, the messages are very educational. To continue, stop the boot process. Boot to Buildroot Now we need a little more functionality than U-Boot can give us. We can do some of these in U-Boot but it is much easier and IMO better in a basic linux environment. Buildroot is good for this and Solidrun has provided a buildroot image that provides access to the USB and M.2 storage. From the Marvell>> prompt - tftp 0x2000000 zImage tftp 0x1000000 armada-388-clearfog.dtb You will see the data load, the zImage is larger and takes just a second, the dtb file is almost instant. Once these are loaded into memory storage we need to start the image we loaded into the first address and pass it the device tree data we loaded into the second address - bootz 0x2000000 - 0x1000000 You should now have a Buildroot prompt. Login with root, it will not ask for a password. Kewl! You now have basic linux hardware control at this point. Configure IP We need to set our IP address so we can bring down the Armbian image via TFTP. ifconfig eth0 [IP address of your Clearfog] netmask [your networks mask] up Prepare your SSD drive I created the filesystem on the Clearfog so there was no incompatibility superstition on my part ... obviously only do this once. You could do it on a host PC, but again I didn't want to have to mess with any kind of permission issue or controller incompatibility, etc. Confirm your SSD device - fdisk -l I'm assuming your device is at /dev/sda. If there is a partition on the SSD delete it - fdisk /dev/sda d (once for each partition if multiple exist) w Now we know we have a 'clean' drive but need to go ahead and partition it - fdisk /dev/sda o (create the partition table) n (new partition) p (primary) 1 (first partition) 257 (just start it at 257 ... I failed to note where I found this and why) (enter to accept default, last sector) w (write to the drive) There is a lot of instructions online for the linux fdisk command. While this guide assumes little, it is beyond my scope to teach fdisk and mkfs. Take a look here and here. If you type exactly as above (excluding parenthesis data) it should create a partition and leave enough in the front for u-boot and the file allocation table. Now we need to create a filesystem. I want to use ext4 64 bit so the mkfs command ends up being - mkfs.ext4 -O ^64bit /dev/sda1 We can now mount the drive mkdir /ssd mount /dev/sda1 /ssd cd /ssd and bring down the image via TFTP tftp -g -r Armbian_5.38_Clearfogpro_Debian_stretch_next_4.4.112.img [TFTP server IP] Just for the thoroughness of it I brought all the files in the TFTP directory to my SSD ... Write the image to eMMC Now we can actually put the image in the Clearfog eMMC - dd if=Armbian_5.38_Clearfogpro_Debian_stretch_next_4.14.14.img bs=1M of=/dev/mmcblk0 The eMMC will always be mmcblk0 and will have mmcblk0p1 after the image is written. We can't mount this partition yet, so lets reboot and get one step closer. reboot Prepare the Armbian U-Boot The new image has overwritten all the U-Boot parameters, so we'll have to tell U-Boot the network information again.Stop the boot process again and at the Marvell>> prompt setenv serverip [your TFTP server IP] setenv ipaddr {your Clearfog IP] saveenv reset Load boot.scr via TFTP and start Armbian Now when it boots it will fail to load the boot.scr from the mmc because we still have to put it there, so we will let the boot.scr load via tftp. U-Boot tries numerous ways to boot before it gets to trying boot.scr via TFTP. We will have to ctrl-c several times to stop the failing attempts until it finally finds the script on the tftp server, then it will start to boot Armbian. Alternatively we could just sit and wait a very long time for each operation to time out but I've not once had the patience to do that! Once U-Boot finds boot.scr on the TFTP server it should load Armbian from eMMC. Armbian will force you to do the first login process where you will replace your root password and create a user. Finalize Armbian so it loads boot.scr from eMMC Now we can copy the boot script to the root of the mmc. Log in as root with your new password then - mkdir /ssd mount /dev/sda1 /ssd mkdir /emmc mount /dev/mmcblk0p1 /emmc cp /ssd/boot/boot.scr /emmc/boot.scr reboot This time don't interrupt the boot process, the unit should boot from mmc. OMG you're freakin' done! Play with Armbian. ***PLEASE respond with corrections, clarifications and additions and I will update this post. Link to comment Share on other sites More sharing options...
zador.blood.stained Posted February 24, 2018 Share Posted February 24, 2018 I don't have the eMMC equipped board but I helped adding and testing USB boot on Clearfogs, so that's how I think flashing to eMMC should be done: Download and unpack an Armbian image (to get the .img file) Go to apt.armbian.com, download an unpack u-boot.mmc and u-boot-uart.mmc from u-boot .deb package for your board. It is important to choose the right device here (Base or Pro) Flash the Armbian image to a USB flash drive, i.e. with Etcher Mount the USB flash locally and copy the Armbian .img file and u-boot.mmc on it. This assumes that you have access to a Linux based host, but it will be required for kwboot anyway and I have no intentions for testing if kwboot can be used in WSL. Insert any SD card in the Clearfog. This is important since the SD card slot has a card detection switch but on boards with eMMC it is still wired to the SD slot and kernel will still use this switch to check if SD/eMMC is "inserted". Set DIP switches to UART boot Insert the USB flash in the Clearfog USB3 port Boot the u-boot-uart.mmc using kwboot or mrvl_uart.sh Connect to the UART port using screen on another terminal program, default baud rate is 115200 You should be at the u-boot command prompt (if eMMC is empty or has non-Armbian image on it), enter "run usbboot" command to boot the system from USB Armbian should boot, it will force you to change the root password and create a new user (just hit <Ctrl-C> at this step) Once you logged in as root, flash the previously copied .img file to /dev/mmcblk0, run "echo 0 > /sys/block/mmcblk0boot0/force_ro" and flash u-boot.mmc to /dev/mmcblk0boot0, alternatively for the second step run nand-sata-install and choose "Update the bootloader on a special eMMC partition" currently not fully implemented for Clearfog Shut down the board, remove the USB flash, set DIP switches to MMC and boot the system again Once you logged in (after changing the root password and optionally creating the user) edit (as root/with sudo) /boot/armbianEnv.txt and set "emmc_fix=on" Shut down the board and remove the SD card NOTE: this assumes that you don't have a spare M.2 SSD but have a spare USB flash instead (which is usually easier to find). You can boot an image from M.2 SSD directly if you reflash u-boot on it and set DIP switches to M.2 SATA so you could skip a part of this guide. Link to comment Share on other sites More sharing options...
zador.blood.stained Posted February 24, 2018 Share Posted February 24, 2018 And some notes regarding your instructions On 19.02.2018 at 11:35 AM, Technicavolous said: If the Clearfog had a little more RAM, we could do it all on the hardware but Armbian images are too large to fit in RAM with Buildroot or U-Boot so we need an intermediate medium. You could probably load a compressed (gzip or xz) image to RAM (tmpfs) and uncompress it directly to eMMC ("gunzip -c image.gz | dd of=/dev/mmcblk0"). Or you could use netcat and bypass downloading the whole image to RAM. On 19.02.2018 at 11:35 AM, Technicavolous said: Further investigation revealed that the U-boot that ships with the board is 'broken' in that it doesn't allow the obvious function of booting from USB and can't interact with the USB storage. I wouldn't call it "broken", it's just our u-boot was "enhanced" to allow booting Armbian images from USB. On 19.02.2018 at 11:35 AM, Technicavolous said: I want to use ext4 64 bit so the mkfs command ends up being - mkfs.ext4 -O ^64bit /dev/sda1 This tells mkfs to unset the 64bit flag, in this case it doesn't matter but for a bootable storage it may be necessary since u-boot would not be able to read an ext4 partition with 64bit flag enabled. On 19.02.2018 at 11:35 AM, Technicavolous said: The eMMC will always be mmcblk0 and will have mmcblk0p1 after the image is written. We can't mount this partition yet, so lets reboot and get one step closer. You can use "partprobe /dev/mmcblk0" to update the partition table and mount /dev/mcblk0p1 after that without rebooting, but partprobe may be not available in a buildroot image in your case. On 19.02.2018 at 11:35 AM, Technicavolous said: Finalize Armbian so it loads boot.scr from eMMC I don't understand why is this needed, an Armbian image should have the correct boot script already. Link to comment Share on other sites More sharing options...
Recommended Posts