# README-AT91SAMA5D35-CM.txt # Creating a working system with Build machine for Yocto project, # Linux kernel, root fs and so on. # # Ronetix GmbH # www.ronetix.at # February, 2014 # Table of contents: 1. Choosing Build machine 2. Installation of OS on the Build machine ------------------------------------------------------------------------- |From now on You should have installed machine, in which You may login.| ------------------------------------------------------------------------- 3. Add some extra software in the Build machine needed by Yocto project 4. Get Yocto 4.1. Create local yocto directory 4.2. Get Yocto meta data 4.3. Get tested state of the Yocto project 4.4. Get meta openembedded 4.5. Get meta-atmel layer --------------------------------------------------------------------------------------- |From now on You should have all needed to build the minimal system on AT91SAMA5D35_CM| --------------------------------------------------------------------------------------- 5. Setup local configuration after Yocto meta data is get locally, for the first time only 5.1. Create configuration files 5.2. Adjust local configuration 5.3. Choose the board you want Yocto to generate files for 5.4. First time build 5.5. Build boot loaders 5.6. Minimal images for the target --------------------------------------------------------------------------- |From now on You should have minimal system for AT91SAMA5D35_CM to work on| --------------------------------------------------------------------------- 6. Base images for the target 7. Atmel demo images for the target 7.1. additional local.conf changes are needed for our QT demo image 7.2. build Atmel demo 8. Toolchain 8.1. Create SDK 8.2. Install SDK 8.3. Simple usage of SDK ------------------------------------------------------- |From now on You should have and a Toolchain installed| ------------------------------------------------------- 9. Some notes how to configure and build the kernel 9.1. Fix a command line for Fedora 20 9.2. Unpack and default config the kernel 9.3. Config the kernel and check that configuration is ok 9.4. Finally force compile and deploy it 9.5. To rebuild the kernel again on clean(if it is needed) --------------------------------------- |Additional setup of the Build machine| --------------------------------------- 10. Add user(s) on the Build machine 11. Prepare tftpd server 11.1. Prepare SELinux, and set sticky group for /home/tftpboot 11.2. Make tftp server accessible over the internal network 12. Manage Build machine software 13. Accessing the build machine 13.1. A command line with SSH 13.2. FreeNX and OpenXN for GUI 13.2.1. Install OpenNX on the MS Windows machine 13.2.2. Install FreeNX on build machine 13.2.3. Install XFce on build machine ------------ |Daily work| ------------ 14. Init Yocto build environment 15. Programming images [TODO] 16. Uploading customer application to the target References: Notes: 1. Choosing Build machine Disk Space: 500GB is enough. You may consider two equal disk in a mirror! - OS full installation requires 10GiB of disk space. - SWAP partition equal to the available RAM - Work space for builds plus some free space - 300GiB is Ok. RAM: the bigger the better :) More RAM for sure will save You valuable time! 8 GiB DDR2 or DDR3 looks good. CPU: faster the stronger :) Consider using at least one CPU with _Multi_ Cores/Threads! Internet access: most of the code is on a public GIT servers, so Internet is required. The build process saves locally all grabbed files, so they will be reused when needed. At first the build process will make a lot of traffic. 2. Installation of OS on the Build machine Fedora 20 is the latest of its brand and can be installed with a few click for around 30 min. You may get and burn a DVD with 32-bit(i386) or 64-bit(x86_64) Fedora 20 from: http://download.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/i386/iso/Fedora-20-i386-DVD.iso http://download.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/iso/Fedora-20-x86_64-DVD.iso Choose full installation with XServer and Gnome for Desktop. There is option to make the partitions by default, so if You are new to GNU/Linux it is better to let install to do partitioning. Please, DO NOT use "root" account for your daily work! First: NO root privileges are needed, Second: YOU could destroy ALL YOUR WORK IN A BLINK OF AN EYE!!! A extensive description You may find here: http://docs.fedoraproject.org/en-US/Fedora/20/pdf/Installation_Guide/Fedora-20-Installation_Guide-en-US.pdf For your daily work use the account you have created during Fedora 20 installation and use root account only for some special tasks. ------------------------------------------------------------------------- |From now on You should have installed machine, in which You may login.| ------------------------------------------------------------------------- 3. Add some extra software in the Build machine needed by Yocto project To add needed packages to as show: [3] Needed packages for Fedora by Yocto $ su - # yum install mc # yum install gawk make wget tar bzip2 gzip python unzip perl patch # yum install diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath # yum install ccache perl-Data-Dumper perl-Text-ParseWords SDL-devel xterm # yum install geany geany-themes # yum install setools-console # exit $ 4. Get Yocto [1] Use Yocto layer: meta-atmel from https://github.com/linux4sam/meta-atmel 4.1. Create local yocto directory Prepare a place to work with Yocto $ pwd /home/sechko $ mkdir -p src/at91sama5d35_cm/yocto 4.2. Get Yocto meta data Go to the workplace for Yocto and get it $ cd /home/sechko/src/at91sama5d35_cm/yocto $ pwd /home/sechko/src/at91sama5d35_cm/yocto $ git clone git://git.yoctoproject.org/poky < need some time to download the project > 4.3. Get tested state of the Yocto project When Yocto meta data is get, then do this: $ cd poky $ git checkout dora-10.0.1 -b my_dora-10.0.1 $ git branch master * my_dora-10.0.1 $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky Note: at 20.02.2014 the stable label for at91sam is dora-10.0.1 [2] 4.4. Get meta openembedded $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky $ git clone git://git.openembedded.org/meta-openembedded $ cd meta-openembedded $ git checkout 6572316557e742c2dc93848e4d560242bf0c3995 -b meta_oe_test_branch $ git branch master * meta_oe_test_branch $ cd .. (meta-open embedded tested with commit ID: 6572316557e742c2dc93848e4d560242bf0c3995) 4.5. Get meta-atmel layer $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky $ git clone http://github.com/linux4sam/meta-atmel --------------------------------------------------------------------------------------- |From now on You should have all needed to build the minimal system on AT91SAMA5D35_CM| --------------------------------------------------------------------------------------- 5. Setup local configuration after Yocto meta data is get locally, for the first time only 5.1. Create configuration files For the first use some configuration files have to be created and set up. This command will create them in the proper place. $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky $ source oe-init-build-env build-atmel $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel 5.2. Adjust local configuration From with in /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel directory, edit conf/bblayers.conf file and make it looks like this. This is the whole file: --- conf/bblayers.conf --- # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf # changes incompatibly LCONF_VERSION = "6" BBPATH = "${TOPDIR}" BBFILES ?= "" BBLAYERS ?= " \ /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-atmel \ /home/sechko/src/at91sama5d35_cm/yocto/poky/meta \ /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-yocto \ /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-yocto-bsp \ /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-openembedded/meta-oe \ /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-openembedded/meta-networking \ " BBLAYERS_NON_REMOVABLE ?= " \ /home/sechko/src/at91sama5d35_cm/yocto/poky/meta \ /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-yocto \ " --- conf/bblayers.conf --- 5.3. Choose the board you want Yocto to generate files for From with in /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel directory, edit conf/local.conf file and make it looks like this. --- conf/local.conf --- [...] #BB_NUMBER_THREADS ?= "4" BB_NUMBER_THREADS ?= "8" [...] #PARALLEL_MAKE ?= "-j 4" PARALLEL_MAKE ?= "-j 8" [...] # MACHINE ??= "qemux86" [...] MACHINE ??= "sama5d3xek" [...] DISTRO ?= "poky" [...] PACKAGE_CLASSES ?= "package_ipk" --- conf/local.conf --- A brief which are the changed options: BB_NUMBER_THREADS - should be less or equal the number of Cores/Threads of the CPU PARALLEL_MAKE - should be less or equal the number of Cores/Threads of the CPU MACHINE - the name of the target board, in Your case this is "sama5d3xek" 5.4. First time build This first time build is to test if all till now steps are successfully done. And will prepare the system to be used in the day-to-day activities. It will get the needed packages from the i-net, build toolchain, kernel and more. As this will take some hour/hours - on a build machine with 8 core CPU with 8GiB DDR2 RAM it took 50 mins. ## NOTE: run this lines in the console when "source oe-init-build-env build-atmel" ## command was executed. $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel $ bitbake core-image-minimal < this takes time ~50mins to finish, hopefully successful > 5.5. Build boot loaders ## NOTE: run this lines in the console when "source oe-init-build-env build-atmel" ## command was executed. $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel $ bitbake at91bootstrap $ bitbake u-boot 5.6. Minimal images for the target Images ready for burn/program in the target are located at /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel/tmp/deploy/images/sama5d3xek Note that the "strange" numbers in the file can change, but the "key names" remains. At91Bootstrap: at91sama5d3xek-nandflashboot-uboot-3.5.4.bin 14KiB U-Boot: u-boot-sama5d3xek-v2012.10-at91-r1.bin 301KiB DTB: zImage--3.10+c43e663f3f933921467e5a03ca9887390156746a-r2-sama5d35ek-20140220213428.dtb 21KiB Kernel: zImage--3.10+c43e663f3f933921467e5a03ca9887390156746a-r2-sama5d3xek-20140220213428.bin 3.3MiB RootFS: core-image-minimal-sama5d3xek-20140220213428.rootfs.ubi 4.9MiB core-image-minimal-sama5d3xek-20140220213428.rootfs.ubifs 4.5MiB --------------------------------------------------------------------------- |From now on You should have minimal system for AT91SAMA5D35_CM to work on| --------------------------------------------------------------------------- 6. Base images for the target ## NOTE: run this lines in the console when "source oe-init-build-env build-atmel" ## command was executed. $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel $ bitbake core-image-base < this takes time ~20mins to finish, hopefully successful > Images ready for burn/program in the target are located at /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel/tmp/deploy/images/sama5d3xek RootFS: core-image-base-sama5d3xek-20140223181441.rootfs.ubi 27MiB core-image-base-sama5d3xek-20140223181441.rootfs.ubifs 26MiB 7. Atmel demo images for the target 7.1. additional local.conf changes are needed for our QT demo image Some lines are needed in order to build the demo. --- conf/local.conf --- [...] LICENSE_FLAGS_WHITELIST += "commercial" SYSVINIT_ENABLED_GETTYS = "" --- conf/local.conf --- 7.2. build Atmel demo ## NOTE: run this lines in the console when "source oe-init-build-env build-atmel" ## command was executed. $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel $ bitbake atmel-qt4e-demo-image < this takes time ~80mins to finish, hopefully successful > Images ready for burn/program in the target are located at /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel/tmp/deploy/images/sama5d3xek RootFS: atmel-qt4e-demo-image-sama5d3xek-20140223190406.rootfs.ubi 195MiB atmel-qt4e-demo-image-sama5d3xek-20140223190406.rootfs.ubifs 189MiB 8. Toolchain 8.1. Create SDK The name SDK(software development kit) is a synonym of a Toolchain. ## NOTE: run this lines in the console when "source oe-init-build-env build-atmel" ## command was executed. $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel $ bitbake meta-toolchain Cross toolchain is in /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel/tmp/deploy/sdk/ With self installed file poky-eglibc-i686-meta-toolchain-cortexa5hf-vfp-toolchain-1.5.1.sh 8.2. Install SDK Toolchains may be installed locally for each user, or may be globally for each users. Only root may install toolchain(s) globally. Each user may install it for him/her self if needed. Run installer as root and follow instructions while keeping default values. # ./poky-eglibc-i686-meta-toolchain-cortexa5hf-vfp-toolchain-1.5.1.sh 8.3. Simple usage of SDK Before usage the toolchain environment have to be prepared. This is done with calling /opt/poky/1.5.1/environment-setup-cortexa5hf-vfp-poky-linux-gnueabi. The settings are done for the console where this was executed. $ source /opt/poky/1.5.1/environment-setup-cortexa5hf-vfp-poky-linux-gnueabi $ echo '#include int main(int argc, char** argv) { printf("Hello World!\n"); return 0; } ' > hello.c $ arm-poky-linux-gnueabi-gcc hello.c -o hello $ file hello hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/ Linux 2.6.16, BuildID[sha1]=421c316c6ed38783805a418346044fd06a243d0b, not stripped ------------------------------------------------------- |From now on You should have and a Toolchain installed| ------------------------------------------------------- 9. Some notes how to configure and build the kernel To build kernel as it is setup by meta-atmel layer, do this: $ bitbake linux-yocto-custom And the reset steps below should be skipped because "bitbake linux-yocto-custom" command will do it except to fix the command line for Fedora 20. 9.1. Fix a command line for Fedora 20 Change meta/lib/oe/terminal.py as shown(remove --disable-factory) to satisfy gnome-terminal. This have to be done once. File is /home/sechko/src/at91sama5d35_cm/yocto/poky/meta/lib/oe/terminal.py --- terminal.py --- class Gnome(XTerminal): """command = 'gnome-terminal --disable-factory -t "{title}" -x {comm command = 'gnome-terminal -t "{title}" -x {command}' priority = 2 --- terminal.py --- Now comes a sequence of steps. 9.2. Unpack and default config the kernel Taking this step ensures you have the sources prepared and the default configuration completed. $ bitbake linux-yocto-custom -c kernel_configme Here it will be build: /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel/tmp/work/ sama5d3xek-poky-linux-gnueabi/linux-yocto-custom/ 3.10+c43e663f3f933921467e5a03ca9887390156746a-r2/linux-sama5d3xek-standard-build 9.3. Config the kernel and check that configuration is ok $ bitbake linux-yocto-custom -c menuconfig $ bitbake linux-yocto-custom -c kernel_configcheck -f If you are ready and want to save configuration and use it next time after a clean, then do this: Save the original /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-atmel/recipes-kernel/linux/files/sama5d3xek/defconfig to /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-atmel/recipes-kernel/linux/files/sama5d3xek/defconfig_orig Then copy file /home/sechko/src/at91sama5d35_cm/yocto/poky/build-atmel/tmp/ work/sama5d3xek-poky-linux-gnueabi/linux-yocto-custom/ 3.10+c43e663f3f933921467e5a03ca9887390156746a-r2/linux-sama5d3xek-standard-build/.config to /home/sechko/src/at91sama5d35_cm/yocto/poky/meta-atmel/recipes-kernel/linux/files/sama5d3xek/defconfig 9.4. Finally force compile and deploy it Deployment cooks the kernel is a format ready to be written in the target memory. This also make the DTB files(run time kernel configuration data). $ bitbake linux-yocto-custom -c compile -f $ bitbake linux-yocto-custom -c deploy In case that modules have been selected/unselected then and the root file system have to be recreated in order to include/exclude these modules. 9.5. To rebuild the kernel again on clean(if it is needed) This step is done rare and is here for clarity. $ bitbake linux-yocto-custom -c cleansstate --------------------------------------- |Additional setup of the Build machine| --------------------------------------- 10. Add user(s) on the Build machine This step may be skipped now and can be done when there is new user to be added. Add a new user, make the user to be able to write/read in the tftpboot directory. And on the user first login it will be prompted to enter a password. # adduser -G nobody user_name_here # usermod -p “” user_name_here # chage -d 0 user_name_here To delete a user and the USER HOME DIR: Removing users files in the home directory are not recoverable! # userdel -r user_name_here 11. Prepare tftpd server PEEDI may use a tftpd server to easy write images to the target. Here it is how to set it, this is done only one time at the /home/tftpboot directory will be the base of tftp server. 11.1. Prepare SELinux, and set sticky group for /home/tftpboot This folder may be used by users to share files. $ su - # yum install tftp-server # yum install tftp # cd /home # mkdir tftpboot # chgrp nobody tftpboot/ # chmod 0775 tftpboot/ # chown nobody tftpboot/ # chmod g+s tftpboot/ # ls -ld /home/tftpboot/ drwxrwsr-x. 2 nobody nobody 4096 Feb 23 22:24 /home/tftpboot/ --- edit /etc/xinit.d/tftp to look like this --- user = root server = /usr/sbin/in.tftpd server_args = -c -s /home/tftpboot disable = no --- /etc/xinit.d/tftp --- # systemctl start xinetd.service # systemctl enable xinetd.service # chcon -Rv -t tftpdir_rw_t tftpboot # semanage fcontext -a -t tftpdir_rw_t "/home/tftpboot(/.*)?" # setsebool -P tftp_home_dir 1 # exit $ 11.2. Make tftp server accessible over the internal network From within X Window System: open console and run firewall-config as root, like this: $ su # firewall-config Next in the "Zone" tab, left click on "internal" zone and enable "tftp"and "tftp-client". Then menu Options -> Change Zones of Connections... -> select the ethernet device and click "Edit" button. And in the "General" tab, choose "internal" Firewall Zone and fit the "Save" button. Finally quit firewall-config and exit the root console. 12. Manage Build machine software Install some programs which deals with applications with GUI. $ su - # yum install dconf-editor # yum install gnome-packagekit-installer gnome-packagekit-updater # exit $ Now the GUI application manager can be started by either from the menus or from command line. In Command line run "gnome-software" as not root user and a root password will be ask if some operation have to be done. $ gnome-software 13. Accessing the build machine 13.1. A command line with SSH From a Windows machine You may use PuTTy or other SSH client. PuTTY may be get from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html 13.2. FreeNX and OpenXN for GUI OpenNX should be installed on Windows machine. FreeNX and XFce4 have to be installed on build machine. 13.2.1. Install OpenNX on the MS Windows machine Get install files from: http://sourceforge.net/projects/opennx/files/opennx/CI-win32/OpenNX-0.16.0.725-Setup.exe/download Note: OpenNX-0.16.0.729-Setup.exe is not usable, it do not works. (Some files are not included in the installer - a closed source issue) So use the older OpenNX-0.16.0.725-Setup.exe. After installation open the "OpenNX Connection Wizard" and setup connection. Session: A_Session_name_for_you Host: put_build_machine_ip Connection: LAN Press"next" button Select "Unix" and "Custom" Press "Settings..." button then select "Run the following command" and enter "xfce4-session" in the field. Next select "New virtual desktop" and press OK. Press"next" button And a desktop icon with the name "A_Session_name_for_you" will be crated. Respond with yes when a fingerprint approval is needed. 13.2.2. Install FreeNX on build machine $ su - # yum install freenx-server # yum install libXcomp libXcompext nxagent nxauth # /usr/libexec/nx/nxsetup --install --setup-nomachine-key # systemctl enable freenx-server.service # systemctl start freenx-server.service 13.2.3. Install XFce on build machine # yum install @xfce After some time an error will be shown... # yum install abrt-java-connector # yum install @xfce Now conflict is solved and Xfce is installed. 14. Init Yocto build environment Prior starting with any bitbake command, some shell variables must be set. This is achieved with the next command and bitbake should be called from within that console. $ pwd /home/sechko/src/at91sama5d35_cm/yocto/poky $ source oe-init-build-env build-atmel ---------------------------------------------------------------------------------------------------------------------------------------- 15. Programming images Reference: [12] ---------------------------------------------------------------------------------------------------------------------------------------- Please refer the following image while attempting the steps. http://www.at91.com/linux4sam/pub/Linux4SAM/GettingStarted/a5d3x_board_presentation.png Reference: [13] ______________________________________________________ 15.1) Preparing Connections and Retrieving Information ________________________________________________________ 15.1.1 As seen in the link above please open the "JP9:Boot Mode Select" pin. Plug the 5V DC supply to power on the circuit. Connect a RS232 Serial Cable to the board's RS232 port and to the HOST-PC. Alternatively Use the J14 USB micro-B port and a USB to the HOST-PC. 15.1.2 To obtain information about the serial connection on your HOST-PC (which port it is using). Case 1: If you connected a RS232 to your board and to the PC - In Terminal use " dmesg | grep ttyS". This will show you the HOST-PC's serial connections. "ttyS0" is the usual connection. Case 2: If you are using a USB to micro USB use "dmesg" and observe the last line. See the connection at "ttyACM0" (for exp.) _________________________________________________________________ 15.2) Configuring Serial Connection and Obtaining RomBOOT mode. _________________________________________________________________ 15.2.1 In a new Terminal run a "terminal emulation software" for this example, "minicom" is used. - "sudo apt-get install minicom" (to download and use the software). 15.2.2 Run minicom with root permissions: "sudo minicom -s". 15.2.3 In minicom prompt, go to and press "Enter" on "Serial port setup". 15.2.4 In Serial port setup, pressing "a" will prompt you to the "A - Serial Device : /dev/ttyS4". Here you will change the "/ttyS4" example value based on the one in step "15.1.2 - Case 1 or 2". For RS232 usually it is ttyS0. (NOTE: If "dmesg | grep ttyS" shows "n" number of ttyS devices try with ttyS0. If you weren't able to reach step "15.2.8", change the value to the other possible ones until you do.) For USB it usually is ttyACM0. 15.2.5 Assure that the "E" case looks like this: "E - Bps/Par/Bits : 115200 8N1". 15.2.6 Assure that cases "F" and "G" are set to "No". 15.2.7 Make sure you press "Enter" when you are done configuring the "Serial port setup". 15.2.7 Go to and press "Enter" on "Exit" option. This will initialize the terminal and connect to the board allowing you to observe responses from it. 15.2.8 Here is an example connection: ________________________________________ Welcome to minicom 2.5 OPTIONS: I18n Compiled on May 2 2011, 00:39:27. Port /dev/ttyS4 Press CTRL-A Z for help on special keys ________________________________________ => Now upon restart of the board (PB1 NRST) or alternatively "Power Cycle", in the same terminal you should receive a "RomBOOT" prompt. (NOTE: If you encounter difficulties close the current session and repeat the steps in a new terminal). (NOTE: If you do not receive a RomBOOT prompt this means there is some code existing in the memory Please see step 15.4.3 and then return here and continue). __________________________ 15.3) Downloading SAM-BA __________________________ 15.3.1 Go to the following link: http://www.atmel.com/tools/atmelsam-bain-systemprogrammer.aspx 15.3.2 Follow the steps by Atmel (writhe a request and receive a download link). 15.3.3 Install the zip in an appropriate directory (In this case for Linux it's "/opt/sam-ba...". 15.3.4 Additionally get the patch available trough the above link. 15.4.5 If you wish to patch the version follow the simple instructions trough the link: http://www.atmel.com/Images/SAM-BA%202.12%20Patch%205%20Release%20Note.txt How to patch/unpatch SAM-BA 2.12 for Windows (XP, Vista, Seven editions) - Execute sam-ba_2.12_patch5.exe to apply 'patch5'. - Execute Unpatch_patch5.exe to remove this patch. How to patch/unpatch SAM-BA 2.12 for Linux - Unzip patch5.diff.gz - Copy patch5.diff to the directory where sam-ba 2.12 is located.([SAMBA INSTDIR]/sam-ba_cdc_cdc_linux) - Change to this directory. - To apply this patch to entire directories, use command: patch -p1 --binary (In Terminal type "su" and enter the root password or use sudo in front of the following command). - Type "./sam-ba /dev/ttyACM0 at91sama5d3x-ek" where each element stands as follow: "path to executable; path to connection to PC; board model;". 15.4.5 Both cases will prompt the SAM-BA Graphical User Interface where the given images will be programmed. (Note: If you encounter any problems while using the GUI, for example program dose not communicate with the board's memory, try using "Case 2" with root permissions: "su" then "./sam-ba /dev/ttyACM0 at91sama5d3x-ek" or "sudo ./sam-ba /dev/ttyACM0 at91sama5d3x-ek"). _____________________________________ 15.5) Flashing Images to the Board _____________________________________ 15.5.1 In the middle of the interface select the "NANDFlash" panel. 15.5.2 In the "Scripts" section select/see "Enable NandFlash" and press "Execute". 15.5.3 From the drop-down menu select "Enable OS PMECC parameters" and press "Execute. You receive "ECC configuration" panel. Leave default and press "OK". 15.5.4 In the scripts menu select "Erase All" and press "Execute". This will erase all information on the NAND flash memory. 15.5.5 Now select "Send Boot File" and press "Execute". This prompts you a browser window. Navigate to the "at91sama5d3xek-nandflashboot-uboot-3.5.4.bin" file and "Open" it. The bootstrap is now programmed. 15.5.6 Now in the middle section of the software use the "browse" icon at "Send File Name:" and browse for the "u-boot.bin" image. Now at "Address" where by default its "0x0" type the following "0x00040000". (NOTE: Please make sure you erase any value before you paste the given one. Best practice type by hand.) Now press "Send File". The U-boot is now programmed. 15.5.7 Now repeat the above process (browse for file) and find the "zImage-sama5d33ek.dtb". (Hint: Select "Files of type: All Files(*.*))". Now at "Address" type "0x00180000" and press "Send File". 15.5.8 Now repeat the process and find "uImage.bin". Now at "Address" type "0x00200000" and press "Send File". 15.5.9 Now repeat the process and find "core-image-base-sama5d3xek.rootfs.ubi". (Hint: Select "Files of type: All Files(*.*))". Now at "Address" type "0x00800000" and press "Send File". (NOTE: When you press "Send File" with correct configurations it actually programs the images, so it takes some time to upload and program the larger ones like the root file system.) ____________________________ 15.6) Launching the Board. ____________________________ 15.6.1 Close SAM-BA software. 15.6.2 Disconnect the USB cable from J20. 15.6.3 Power Cycle or Restart the board. 15.6.4 Observe the console (the minicom one) until you receive a login prompt. (NOTE: At a certain point you will see a elapsing timer and a "Press key ..." option remember this point, as it is required in the next step, but leave it to elapse at this restart). 15.6.5 In login prompt, use "root" for login with no password and you receive a "root@sama5d3xek:~#" command prompt. Restart the board. When you reach the "Hit any key to stop autoboot: 3 .. 2 .. 1 ... 0" press a key to enter U-Boot mode. You will receive a "U-Boot>" prompt. (NOTE: Please enlarge the console, so you can observe the whole message from the next step) 15.6.6 Type "editenv bootargs" and press "Enter" You will see a long list similar, or the same as the one below: edit: console=ttyS0,115200 earlyprintk mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro,256K(env),256k (evn_redundent),256k (spare),512k(dtb),6M(kernel)ro,-(rootfs) rootfstype=ubifs ubi.mtd=7 root=ubi0:rootf (NOTE: If you don't see the full message just press "Enter" while viewing the variables. Then enlarge the console then redo this step). Add "rw" to the "rootfstype=ubifs" like so: edit: console=ttyS0,115200 earlyprintk mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro,256K(env), 256k(evn_redundent),256k (spare),512k(dtb),6M(kernel)ro,-(rootfs) rootfstype=ubifs rw ubi.mtd=7 root=ubi0:rootf When you apply the change, press "Enter". (NOTE: If you happen to delete the variables just restart the board from the button.) (NOTE: Before attempting the next step ensure that the variables are in place with the add-on "rw" To do so type "editenv bootargs"). 15.6.7 Type "saveenv" and press enter, then type "reset" and press enter or reboot the board from button. 15.6.8 Now if all boots correct you can skip the next section, otherwise do 15.7 ________________________________________________________ 15.7) Second boot failed - Kernel Panic of "some type" ________________________________________________________ Info: Upon second boot it is possible to get a message similar to the one below: __________________________________________________________________________________ VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0): error -74 Please append a correct "root=" boot option; here are the available partitions: 1f00 256 mtdblock0 (driver?) 1f01 512 mtdblock1 (driver?) 1f02 256 mtdblock2 (driver?) 1f03 256 mtdblock3 (driver?) 1f04 256 mtdblock4 (driver?) 1f05 512 mtdblock5 (driver?) 1f06 6144 mtdblock6 (driver?) 1f07 253952 mtdblock7 (driver?) 1f08 4096 mtdblock8 (driver?) 1f09 240560 mtdblock9 (driver?) Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) __________________________________________________________________________________ There are a few additional steps to do to get the board running upon each boot. 15.7.1 Reach RomBOOT(see: 15.4.3). Connect the USB to J20 of the board and launch SAM-BA (see: section 15.4). 15.7.2 Navigate to the NAND Flash panel and "Execute" the "Enable NAND Flash" script (see: 15.5.1 , 15.5.2). 15.7.3 Now at "Send File Name:","browse" for "core-image-base-sama5d3xek.rootfs.ubifs". 15.7.4 At "Address" set "0x00800000" and press "Send File". 15.7.5 Now close SAM-BA GUI, disconnect the J20 UBS and restart the board. 15.7.6 Now it will boot and it will reach a similar "Kernel Panic" to the one shown above. 15.7.7 Now repeat step "15.7.1" and step "15.7.2" (Re-launch SAM-BA). (NOTE: It is important to Enable NandFlash) 15.7.8 Now at "Send File Name:","browse" for "core-image-base-sama5d3xek.rootfs.ubi". 15.7.4 At "Address" set "0x00800000" and press "Send File". 15.7.5 Now close SAM-BA GUI, disconnect the J20 UBS and restart the board. 15.7.6 Hopefully you will reach the logint prompt (see: 15.6.6). Login and do a restart of the board. 15.7.7 Now the board should boot any time you restart it or power it on. Additional Notes: It is advisable to do a second boot after returning the .ubi image (the secound load) to test if all is working correct and before you start any development. It is advisable to reboot your system using "reboot" from the console. _________________________________________ 15.8) Initial Steps to Test the System _________________________________________ 15.8.1 Connect a Ethernet cable to the board's "GETH" ethernet port. 15.8.2 In the Console type "udhcpc" to obtain an IP address and then you can load an example application to test. 15.8.3 Please see section "16" for detailed explanation. -------------------------------------------------------------------------------------------------------------------------------- 16. Uploading customer application to the target A. Using USB stick The simplest way is to use a USB stick - just copy the file example to a USB stick inserted into your PC. Unmount the stick and put it into the target board. After few seconds the USB stick will be discovered(most probably). You should have support of the file system on the USB stick, most probably it will be VFAT(FAT32). Take a look at the kernel messages to see the device node of your USB stick. Depending auto-mounter is enabled and installed on the rootfs, the USB stick could be automatically mounted. To see if it is automatically mounted: On target machine: # mount /dev/sda1 on /media/sda1 In case it is not mounted automatically: On target machine: # mkdir /mnt/sda1 # mount /dev/sda1 /mnt/sda1 -t vfat # cp /mnt/sda1/main . # chmod +x main # ./main Hello world B. Tftp over network A tftp server should work on a host(or any development) computer. On host: $ cp hello tftp_boot_dir/ On target machine: # udhcpc # tftp -g -r tftp_boot_dir/hello -l hello 192.168.3.1 # chmod u+x hello # ./hello Hello world Alternatively to the "udhcpc" you can use "dhclient eth0". References: [1] http://www.at91.com/linux4sam/bin/view/Linux4SAM/PokyBuild [2] https://github.com/linux4sam/meta-atmel/blob/master/README [3] http://www.yoctoproject.org/docs/current/yocto-project-qs/yocto-project-qs.html [4] http://download.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/i386/iso/Fedora-20-i386-DVD.iso [5] http://download.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/iso/Fedora-20-x86_64-DVD.iso [6] http://docs.fedoraproject.org/en-US/Fedora/20/pdf/Installation_Guide/Fedora-20-Installation_Guide-en-US.pdf [7] http://download.ronetix.info/boards/README/ [8] http://wiki.centos.org/HowTos/SELinux [9] http://www.yoctoproject.org/docs/current/kernel-dev/kernel-dev.html [10] http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html [11] http://sourceforge.net/projects/opennx/files/opennx/CI-win32/OpenNX-0.16.0.725-Setup.exe/download [12] http://www.at91.com/linux4sam/bin/view/Linux4SAM/GettingStarted_a5d3x [13] http://www.at91.com/linux4sam/pub/Linux4SAM/GettingStarted/a5d3x_board_presentation.png Notes: Symbol '$' denotes a regular user command prompt Symbol '#' denotes a "root" user command prompt For text editing in X Window System may use Geany.