Content
- Prepare a host machine
- Edit uBoot
- Edit Linux Kernel
- Edit YOCTO meta layer
- Compile YOCTO, Create SD card and Test it
- Edit Filesystem
See also
Prepare a host machine
Before you start doing any changes, you may want to go through: How to start with Software >Edit uBoot
Get the source code
You have two options to get the source code. You can download it directly from github or you can edit the uBoot files in your YOCTO OpenRex project.Option 1: Get the uBoot source code from github
git clone -b jethro https://github.com/FEDEVEL/openrex-uboot-v2015.10.git cd openrex-uboot-v2015.10Option 2: Find uBoot source code located inside your YOCTO project
Usualy the uBoot source code is located inside your build directory. The path may look like this:
cd ~/fsl-community-bsp/build-openrex/tmp/work/imx6q_openrex-poky-linux-gnueabi/u-boot-openrex/v2015.10+gitAUTOINC+d542ed07a4-r0/git
Install & select cross compiler
If you do not have any compiler installed (or you are not sure)apt-get install gcc-arm-linux-gnueabihf export CROSS_COMPILE=arm-linux-gnueabihf- export ARCH=armIf you have a compiler installed
export CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-none-linux-gnueabi- export ARCH=arm
Edit files
Here are the files what we normally edit:gedit configs/mx6qopenrex_defconfig gedit include/configs/mx6openrex.h gedit include/configs/mx6openrex_common.h gedit board/fedevel/mx6openrex/mx6openrex.c gedit board/fedevel/mx6openrex/mx6q_4x_mt41j256.cfg
Compile uBoot
make distclean make mx6qopenrex_config make cp u-boot.imx /tftp/imx6/u-boot-imx6q-openrex.imx*Note: If you get error like "lib/asm-offsets.c:1:0: error: bad value (armv5) for -march= switch", then run the "Select cross compiler" again (these are the commands "export CROSS_COMPILE=..." and "export ARCH=arm")
Reflash uBoot
Switch on your OpenRex board, go to uBoot and run following command:run update_spi_ubootIn case you would like to update it manually, here are the commands:
mw.b 0x10800000 0xFF 0x80000;tftp 0x10800000 imx6/u-boot-imx6q-openrex.imx;sf probe;sf erase 0x0 0x80000;sf write 0x10800000 0x400 0x80000*Note: If you have updated environmental variables inside uBoot source code, after you reboot uBoot, you may want to run:
env default -a run set_ethernet setenv serverip 192.168.0.37 //use your Linux host IP saveenv
Upload the new uBoot to Github
When you are happy with the new uBoot, run following commands to update uBoot github:git remote -v //check the origin, should point to your github //git remote add origin https://github.com/FEDEVEL/openrex-uboot-v2015.10.git //run this if you get error about no origin //git remote set-url origin https://github.com/FEDEVEL/openrex-uboot-v2015.10.git //run this if you get error, that "git://" is read only git checkout jethro //set the current active branch to jethro git branch //check if you are on jethro branch git status //have a look what files were changed //based on the status command, add the files you would like to upload to github //you could also use "git add .", but that occasionally cause problems //sometimes "add ." wants to upload also files which you have not changed, that's why I use "git add filename" git add filename1 git add filename2 git diff origin/jethro //check if it shows correct differences //in case differences are not what you expected or you find a mistake, you can use "git reset". Then repeat the procedure again //if you are happy with the differences, upload the changes to github git commit -m 'Fixed SD card: CD and RW pin definition' //use a comment describing the changes git push origin jethro
Edit Linux Kernel
Get the source code
You have two options to get the source code. You can download it directly from github or you can edit the Kernel files in your YOCTO OpenRex project.Option 1: Get the Kernel source code from github
git clone -b jethro https://github.com/FEDEVEL/openrex-linux-3.14.git cd openrex-linux-3.14Option 2: Find Kernel source code located inside your YOCTO project
Usualy the Kernel source code is located inside your build directory. The path may look like this:
cd ~/fsl-community-bsp/build-openrex/tmp/work/imx6q_openrex-poky-linux-gnueabi/linux-openrex/3.14-r0/git
Install & select cross compiler
If you do not have any compiler installed (or you are not sure)apt-get install gcc-arm-linux-gnueabihf export CROSS_COMPILE=arm-linux-gnueabihf- export ARCH=armIf you have a compiler installed
export CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-none-linux-gnueabi- export ARCH=arm
Edit files
Here are the files what we normally edit:gedit arch/arm/boot/dts/imx6q-openrex.dts gedit arch/arm/boot/dts/imx6qdl-openrex.dtsi gedit arch/arm/configs/imx_v7_defconfig
Compile Kernel
make clean make imx_v7_defconfig make -j4 zImage imx6q-openrex.dtb cp arch/arm/boot/zImage /tftp/imx6/zImage-imx6q-openrex cp arch/arm/boot/dts/imx6q-openrex.dtb /tftp/imx6/imx6q-openrex.dtb
Test the Kernel
In case you run OpenRex from SD card, switch on your OpenRex board, go to uBoot and run following commands:run update_kernel;run update_fdt;resetIn case you boot from SATA, you can use these commands:
run set_ethernet;run update_set_filename;sata init;tftp ${tftp_dir}/${upd_kernel};fatwrite sata ${satadev}:${satapart} ${loadaddr} ${image} ${filesize}; run set_ethernet;run update_set_filename;sata init;tftp ${tftp_dir}/${upd_fdt};fatwrite sata ${satadev}:${satapart} ${loadaddr} ${fdt_file} ${filesize}; resetImportant: fatwrite error
There is a bug in some versions of uBoot where fatwrite may not work properly. To go around the fatwrite problem, re-format the FAT partion on your SD card. Here is how you can do it: insert SD card into your host machine and run following commands:
umount /dev/sdb? sudo mkfs.vfat -F16 -s 2 /dev/sdb1 sudo mount /dev/sdb1 /media/fedevel/ sudo cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.bin /media/fedevel/zImage sudo cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.dtb /media/fedevel/imx6q-openrex.dtb sudo umount /media/fedevelIf you would like to test the kernel without saving it to SD card, go to uBoot and use following commands:
tftp 0x12000000 imx6/zImage-imx6q-openrex; tftp 0x18000000 imx6/imx6q-openrex.dtb;bootz 0x12000000 - 0x18000000
Upload the new Kernel to Github
When you are happy with the new Kernel, run following commands to update Kernel github:git remote add origin https://github.com/FEDEVEL/openrex-linux-3.14.git //git remote set-url origin https://github.com/FEDEVEL/openrex-linux-3.14.git //run this if you get error, that "git://" is read only git checkout jethro //set the current active branch to jethro git branch //check if you are on jethro branch git status //have a look what files were changed //based on the status, add the files you would like to upload to github //you could also use "git add .", but that occasionally cause problems //sometimes "add ." wants to upload also files which you have not changed, that's why I use "git add filename" git add filename1 git add filename2 git diff origin/jethro //check if it shows correct differences //in case differences are not what you expected or you find a mistake, you can use "git reset". Then repeat the procedure again //if you are happy with the differences, upload the changes to github git commit -m 'Fixed SD card: CD and RW pin definition' //use a comment describing the changes git push origin jethro
Edit YOCTO meta layer
In case you have updated uBoot or Kernel github, you will need to update also your meta layer.If you have updated uBoot
In case you have updated uBoot and uploaded changes to github, you have to update also meta-openrex. Run:gedit ~/fsl-community-bsp/sources/meta-openrex/recipes-bsp/u-boot/u-boot-openrex_2015.10.bband edit commit number. It may look like this:
Before
... SRC_URI = "git://github.com/FEDEVEL/openrex-uboot-v2015.10.git;branch=${SRCBRANCH}" #SRCREV is the commit number, must be always changed for a new version SRCREV = "b17a70691ea4ec77561c4532ec777338f3b0758a" S = "${WORKDIR}/git" ...After
... SRC_URI = "git://github.com/FEDEVEL/openrex-uboot-v2015.10.git;branch=${SRCBRANCH}" #SRCREV is the commit number, must be always changed for a new version SRCREV = "d542ed07a4398d53e12bf89e14abd169343cef64" S = "${WORKDIR}/git" ...
If you have updated Kernel
In case you have updated Kernel and uploaded changes to github, you have to update also meta-openrex. Run:gedit ~/fsl-community-bsp/sources/meta-openrex/recipes-kernel/linux/linux-openrex_3.14.bband edit commit number. It may look like this:
Before
... #Always update SRCREV based on your last commit SRCREV = "58f44dd3178b7a9878298bd948082e01f4fe28fb" KERNEL_SRC ?= "git://github.com/FEDEVEL/openrex-linux-3.14.git;protocol=git" ...After
... LOCALVERSION = "-yocto" #Always update SRCREV based on your last commit SRCREV = "cc643ef3144090d5b78906361561c6170243e5c8" KERNEL_SRC ?= "git://github.com/FEDEVEL/openrex-linux-3.14.git;protocol=git" ...Important: Now, test the new meta layer. See: Compile YOCTO, Create SD card and Test it
Upload the new Meta Layer to Github
If everything works oki, upload the new meta layer to github:git remote add origin https://github.com/FEDEVEL/meta-openrex.git //run this if you get error, that "git://" is read only //git remote set-url origin https://github.com/FEDEVEL/meta-openrex.git //run this if you get error, that "git://" is read only git checkout jethro //set the current active branch to jethro git branch //check if you are on jethro branch git status //have a look what files were changed //based on the status, add the files you would like to upload to github //you could also use "git add .", but that occasionally cause problems //sometimes "add ." wants to upload also files which you have not changed, that's why I use "git add filename" git add filename1 git add filename2 git diff origin/jethro //check if it shows correct differences //in case differences are not what you expected or you find a mistake, you can use "git reset". Then repeat the procedure again //if you are happy with the differences, upload the changes to github git commit -m 'Fixed SD card: CD and RW pin definition' //use a comment describing the changes git push origin jethro
Compile YOCTO, Create SD card and Test it
Compile
cd ~/fsl-community-bsp/ MACHINE=imx6q-openrex source setup-environment build-openrex MACHINE=imx6q-openrex bitbake core-image-base*Note: If you would like to completely recompile all the files, delete build-openrex directory.
Create SD Card
Check the time & date of the files, just to be sure you have just generated them and they are the recent files:ls -la ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/Insert an SD card into your host machine. Check under what /dev/? it was recognized:
dmesg | tailNote: The SD card in my system is recognized as "/dev/sdb". This is what I will be using in the examples below.
Make the SD card
umount /dev/sdb? gunzip -c ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard.gz > ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard sudo dd if=~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/core-image-base-imx6q-openrex.sdcard of=/dev/sdb umount /dev/sdb?Work around of the fatwrite issue. Re-format the fat partition and upload the zImage + dtb again. Run following commands:
sudo mkfs.vfat -F16 -s 2 /dev/sdb1 sudo mount /dev/sdb1 /media/fedevel/ sudo cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.bin /media/fedevel/zImage sudo cp ~/fsl-community-bsp/build-openrex/tmp/deploy/images/imx6q-openrex/zImage-imx6q-openrex.dtb /media/fedevel/imx6q-openrex.dtb sudo umount /media/fedevelExtend root disk size to SD card size (default size of the root is very small):
fedevel@ubuntu:~/fsl-community-bsp/build-openrex$ sudo fdisk /dev/sdb Command (m for help): p Disk /dev/sdb: 7948 MB, 7948206080 bytes 4 heads, 32 sectors/track, 121280 cylinders, total 15523840 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xe9358ca2 Device Boot Start End Blocks Id System /dev/sdb1 8192 24575 8192 c W95 FAT32 (LBA) /dev/sdb2 24576 204799 90112 83 Linux Command (m for help): d Partition number (1-4): 2 Command (m for help): p Disk /dev/sdb: 7948 MB, 7948206080 bytes 4 heads, 32 sectors/track, 121280 cylinders, total 15523840 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xe9358ca2 Device Boot Start End Blocks Id System /dev/sdb1 8192 24575 8192 c W95 FAT32 (LBA) Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (1-4, default 2): 2 First sector (2048-15523839, default 2048): 24576 Last sector, +sectors or +size{K,M,G} (24576-15523839, default 15523839): Using default value 15523839 Command (m for help): p Disk /dev/sdb: 7948 MB, 7948206080 bytes 4 heads, 32 sectors/track, 121280 cylinders, total 15523840 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xe9358ca2 Device Boot Start End Blocks Id System /dev/sdb1 8192 24575 8192 c W95 FAT32 (LBA) /dev/sdb2 24576 15523839 7749632 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. fedevel@ubuntu:~/fsl-community-bsp/build-openrex$*Note: As the First sector number use the same number where partition 2 originally started. In the example above, it's 24576.
Then run:
sudo e2fsck -f /dev/sdb2 sudo resize2fs /dev/sdb2 umount /dev/sdb?
Test the new SD card
Remove the card and plug it into OpenRex. Press "RESET" button and wait until it boots up.*Note: If you resized the partition, you may want to double check if it worked oki:
root@imx6q-openrex:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 7.2G 59.3M 6.7G 1% / devtmpfs 849.3M 0 849.3M 0% /dev tmpfs 1009.5M 188.0K 1009.3M 0% /run tmpfs 1009.5M 76.0K 1009.4M 0% /var/volatile root@imx6q-openrex:~#
THE PART BELOW HAS NOT BEEN FINISHED YET
Edit Filesystem
The initial Fileystem is generated when YOCTO is compiled. You can do some changes there. Here are some examples.TODO: This part is under testing, here are just some of my notes
//changing to debian, adding support for apt-get //edit ~/fsl-community-bsp/build-openrex/conf/local.conf MACHINE ??= 'imx6q-openrex' DISTRO ?= 'poky' PACKAGE_CLASSES ?= "package_deb" IMAGE_FEATURES += "package-management" IMAGE_INSTALL_append += "dpkg" CORE_IMAGE_EXTRA_INSTALL += "apt" EXTRA_IMAGE_FEATURES = "debug-tweaks" USER_CLASSES ?= "buildstats image-mklibs" PATCHRESOLVE = "noop" BB_DISKMON_DIRS = "\ STOPTASKS,${TMPDIR},1G,100K \ STOPTASKS,${DL_DIR},1G,100K \ STOPTASKS,${SSTATE_DIR},1G,100K \ STOPTASKS,/tmp,100M,100K \ ABORT,${TMPDIR},100M,1K \ ABORT,${DL_DIR},100M,1K \ ABORT,${SSTATE_DIR},100M,1K \ ABORT,/tmp,10M,1K" PACKAGECONFIG_append_pn-qemu-native = " sdl" PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl" ASSUME_PROVIDED += "libsdl-native" CONF_VERSION = "1" DL_DIR ?= "${BSPDIR}/downloads/" ACCEPT_FSL_EULA = "1"!!!! TODO !!!! //TODO uBoot problem - fatwrite doesn't work for the image generated by YOCOTO I guess, it has something with: WARNING: Not enough clusters for .... (FAT32/16). Uboot detects it as FAT12 and getting error: writing zImage Error: Invalid FAT entry: 0x00000fff error: overflow occurs Error: writing contents ** Unable to write "zImage" from mmc 0:1 ** OpenRex U-Boot> You can go around it by formating Partition 1 with this command: sudo mkfs.vfat -F16 -s 2 /dev/sdb1 SD card formated this way will work. vi /etc/apt/sources.list Press i: deb http://ftp.us.debian.org/debian wheezy main deb-src http://ftp.us.debian.org/debian wheezy main deb http://security.debian.org/ wheezy/updates main contrib non-free deb-src http://security.debian.org/ wheezy/updates main contrib non-free //this will download and istall everything, problem is, it doesnt work deb http://ftp.de.debian.org/debian jessie main deb http://ftp.de.debian.org/debian wheezy main root@imx6q-openrex:~# alsamixer -sh: /usr/bin/alsamixer: No such file or directory root@imx6q-openrex:~# Press ESC:wq apt-get update Test if your apt-get works oki, we can for example install nano: apt-get install nano //armhf vs armel ... default we use armel (?) DPKG_ARCH = "armhf" ... didnt work dpkg --print-architecture dpkg --add-architecture armhf apt-get update apt-get -f install apt-get update apt-get upgrade https://community.freescale.com/docs/DOC-95044 apt-get install binfmt-support qemu-user-static debootstrap