How to build Linux 3.10.17 for iMX6?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to build Linux 3.10.17 for iMX6?

40,605 Views
Contributor II

Hi,

There should be three things I need to build: rootfs, kernel, and uboot.

I downloaded kernel from here: linux-2.6-imx.git - Freescale i.MX Linux Tree, and uboot from here: uboot-imx.git - Freescale i.MX u-boot Tree. But I couldn't find where to download rootfs. Could somebody help?

With the cross-compiler installed previously, I built kernel by doing this under the root folder:

  1. exportPATH=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/:$PATH
  2. export ARCH=arm
  3. export CROSS_COMPILE=arm-none-linux-gnueabi-
  4. make imx_v7_defconfig
  5. sudo apt-get install lzop (need to install zlop)
  6. make uImage LOADADDR=0x70008000 (need to specify load address to avoid build error)

The output file uImage was put under ./arch/arm/boot.

I then tried to build uboot. The first three steps are the same as above. But at step 4, I couldn't find a config file in the whole uboot tree. Can somebody tell me how to build?

I used this as reference: Linux booting on IMX6 SABRESDB. I tried to follow Ed's notes, but when building uboot, I also couldn't find the config file.

Thanks a lot.

Jason

Labels (2)
0 Kudos
16 Replies

66 Views
NXP Employee
NXP Employee

- For U-boot

make mrproper

make mx6qsabresd_config

make

Then flash it into the SD card: dd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2; sync

- For kernel

make imx_v7_defconfig

make -j4 uImage LOADADDR=0x10008000

make imx6q-sabresd.dtb

(Your LOADADDR was incorrect).

- For rootfs

You can use your favourite rootfs (Yocto, LTIB, buldroot, etc). Yocto does all the above steps for you and generate you a sdcard image ready to boot.

Regards,

Fabio Estevam

0 Kudos

66 Views
Contributor II

Fabio,

Thanks to your reply, I was able to build u-boot.

I chose buildroot to build rootfs. I got the latest one from http://www.buildroot.org/download.html. I tried to build it in the following way:

$ make menuconfig...

#  Target ARM (Little-Endian)

#  Target Cortex A-9

#  Under toolchain:

#      External

#      Sourcery Codebench ARM 2013.05

#      Downloaded and installed

#  Under System Configuration, chose ttymxc0 as the Port to run a getty (login prompt) on,

#  Under Target Packages->Filesystem and Flash utilities: enable dosfstools and e2fsprogs

#  Under Filesystem Images, selected Output cpio - gzipped; tar the root filesystem

$ make busybox-menuconfig...

#  Do nothing, just exit (this step probably isn't necessary).

$ make V=1 2>&1 | tee make.out

But at the end, I got link error: "/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/../../../../arm-fsl-linux-gnueabi/bin/ld: cannot find crti.o: No such file or directory". I googled around for the whole day and just couldn't figure out the solution. Could you help please?

Thank you so much!

Jason

0 Kudos

66 Views
Contributor II

Hi Fabio,

To this point, I was able to build u-boot and kernel successfully. But after I flashed them to SD card, it won't boot (cannot even see u-boot prompt). I replaced u-boot on the SD card with the one I always used (3.0.35), then I could see u-boot prompt. But when it tried to load kernel from SD card, it failed on CRC check as below.

MX6Q SABRESD U-Boot > boot

mmc2 is current device

MMC read: dev # 2, block # 2048, count 8192 ... 8192 blocks read: OK

## Booting kernel from Legacy Image at 10800000 ...

   Image Name:   Linux-3.10.17

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    5201152 Bytes =  5 MB

   Load Address: 10008000

   Entry Point:  10008000

   Verifying Checksum ... Bad Data CRC

ERROR: can't get kernel image!

BTW, I used the following commands to program u-boot and kernel onto SD card:

      sudo dd if=u-boot-mx6q-sabresd.bin of=/dev/sde bs=512 seek=2 skip=2 conv=fsync

      sudo dd if=uImage of=/dev/sde bs=512 seek=2048 conv=fsync


Do you have any idea what's going on?

Thank you very much.

Jason

0 Kudos

66 Views
NXP Employee
NXP Employee

Recent U-boot versions are flashed like this:

dd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2; sync

Regards,

Fabio Estevam

0 Kudos

66 Views
Contributor II

Great. I used your command to flash U-boot and it can boot to the prompt now. Sorry I missed your first note about this command.

I then flashed the kernel to the card using the command "dd if=uImage of=/dev/sde bs=512 seek=2048; sync". I tweaked the boot env a little (attached at the end), but still got the same error.

U-Boot > boot

mmc1 is current device

MMC read: dev # 1, block # 2048, count 8192 ... 8192 blocks read: OK

## Booting kernel from Legacy Image at 12000000 ...

   Image Name:   Linux-3.10.17

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    5201152 Bytes = 5 MiB

   Load Address: 10008000

   Entry Point:  10008000

   Verifying Checksum ... Bad Data CRC

ERROR: can't get kernel image!

U-Boot >

The boot envs are:

U-Boot > printenv

baudrate=115200

boot_fdt=try

bootargs=console=ttymxc0,115200 root=/dev/mmcblk1p1 rootwait

bootargs_base=setenv bootargs console=ttymxc0,115200

bootargs_mmc=setenv bootargs ${bootargs} root=/dev/mmcblk1p1 rootwait

bootcmd=run bootcmd_mmc

bootcmd_mfg=run mfgtool_args;bootm ${loadaddr} ${initrd_addr} ${fdt_addr};

bootcmd_mmc=run bootargs_base bootargs_mmc; mmc dev 1; mmc read ${loadaddr} 0x800 0x2000; bootm

bootdelay=1

bootfile=imx6q-sabresd.dtb

bootscript=echo Running bootscript from mmc ...; source

console=ttymxc0

ethact=FEC

ethaddr=00:04:9f:02:6e:c4

ethprime=FEC

fdt_addr=0x18000000

fdt_file=imx6q-sabresd.dtb

fdt_high=0xffffffff

get_cmd=dhcp

initrd_addr=0x12C00000

initrd_high=0xffffffff

ip_dyn=yes

loadaddr=0x12000000

loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};

loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}

loaduimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}

mfgtool_args=setenv bootargs console=ttymxc0,115200 rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber="" enable_wait_mode=off

mmcargs=setenv bootargs console=${console},${baudrate} ${smp} root=${mmcroot}

mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootm ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootm; else echo WARN: Cannot load the DT; fi; fi; else bootm; fi;

mmcdev=1

mmcpart=1

mmcroot=/dev/mmcblk0p2 rootwait rw

netargs=setenv bootargs console=${console},${baudrate} ${smp} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp

netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${uimage}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootm ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootm; else echo WARN: Cannot load the DT; fi; fi; else bootm; fi;

script=boot.scr

uimage=uImage

video=mxcfb0:dev=hdmi,1920x1200M@60,if=RGB24

Environment size: 2221/8188 bytes

U-Boot >

Is there anything wrong somewhere?

Thanks,

Jason

0 Kudos

66 Views
NXP Employee
NXP Employee

Hi Jason

     I pasted of a simple guide of booting up dtb and kernel from SD/MMC, you can refer to it and have a try:

supposed uImage is flashed to 2M offset of SD, and dtb is flashed to 1M offset of SD.

Boot kernel:

  1. 1) Set dtbaddr and loadaddr, default setting is incorrect, so run command “set dtbaddr 14000000” and “set loadaddr 10800000”;
  2. 2) Read dtb and uImage from SD to DRAM, command is “mmc dev 0;mmc read 14000000 800 800;mmc read 10800000 1000 8000”;
  3. 3) Boot up kernel with “bootm ${loadaddr} - ${dtbaddr}”;

My kernel command line is “setenv bootargs console=ttymxc0,115200n8 noinitrd no_console_suspend root=/dev/mmcblk0p1 rw rootwait;mmc dev 0;mmc read 14000000 800 800;mmc read 10800000 1000 8000;bootm ${loadaddr} - ${dtbaddr}

0 Kudos

66 Views
Contributor II

Hi Yongcai,

Your answer reminded me that I'm missing the .dtb file. My previous working u-boot/kernel didn't need it (maybe hardcoded everything), but this new u-boot/kernel DO need. After I built the .dtb file, I was able to boot.

Thank you so much.

Jason

0 Kudos

66 Views
NXP Employee
NXP Employee

Hi, Jason

     Great, then can you help close this topic? Thanks!

0 Kudos

66 Views
Contributor II

I would suggest to strictly follow the instructions Ed provided here: Linux booting on IMX6 SABRESDB. It IS really working.

I didn't follow all of it the first time by skipping the dtb part, mainly because I didn't think it was necessary, since the Linux images 3.0.35 from Freescale didn't use .dtb files. Seems they hard-coded everything.

Thanks,

Jason

0 Kudos

66 Views
Senior Contributor IV

Jason

Had your issue got resolved? If yes, we are going to close the discussion in 3 days. If you still need help, please feel free to reply with an update to this discussion.

Thanks,

Yixing

0 Kudos

66 Views
Contributor II

Actually it was not directly solved. But I got an new image from Freescale field engineer, so I stopped trying any more.

Thanks.

Jason

0 Kudos

66 Views
Senior Contributor IV

Jason

We are closing the DI now. If you still need help, please feel free to reply with an update to this discussion.

Thanks,

Yixing

0 Kudos

66 Views
Senior Contributor IV

Jason

Thanks you for your reply. As you got new image, we are going to close the discussion in 3 days. If you still need help, please feel free to reply with an update to this discussion.

Thanks,

Yixing

0 Kudos

66 Views
NXP Employee
NXP Employee

If you want to boot up L3.10.17 kernel, dtb is necessary, there is no hard coding device info for kernel.

0 Kudos

66 Views
Contributor II

Hi Yongcai,

Thank you for the reply.

When I built u-boot and kernel, seems the dtb files were not built automatically. In my kernel, I found these dts files. Should I pick one of them (like imx6q-sabresd.dts) and build into .dtb file? If so, could you suggest how? I googled around and found "In a normal flow, the DTS file is edited and compiled into a DTB file using a special compiler which comes with the Linux kernel sources" from here: A Tutorial on the Device Tree (Zynq) -- Part I | xillybus.com. I'm confused what special compiler it is.

./arch/arm/boot/dts/imx6q-sabresd-hdcp.dts

./arch/arm/boot/dts/imx6sl-evk-ldo.dts

./arch/arm/boot/dts/imx6dl-sabreauto.dts

./arch/arm/boot/dts/imx6dl-sabresd.dts

./arch/arm/boot/dts/imx6sl-evk-csi.dts

./arch/arm/boot/dts/imx6dl-sabresd-ldo.dts

./arch/arm/boot/dts/imx6dl-sabresd-hdcp.dts

./arch/arm/boot/dts/imx6q-sabrelite.dts

./arch/arm/boot/dts/imx6q-sabresd.dts

./arch/arm/boot/dts/imx6dl-sabreauto-ecspi.dts

./arch/arm/boot/dts/imx6dl-wandboard.dts

./arch/arm/boot/dts/imx6q-sabresd-ldo.dts

./arch/arm/boot/dts/imx6q-sabreauto.dts

./arch/arm/boot/dts/imx6q-sabreauto-flexcan1.dts

./arch/arm/boot/dts/imx6dl-sabreauto-flexcan1.dts

./arch/arm/boot/dts/imx6q-sbc6x.dts

./arch/arm/boot/dts/imx6q-sabreauto-gpmi-weim.dts

./arch/arm/boot/dts/imx6q-sabreauto-ecspi.dts

./arch/arm/boot/dts/imx6dl-sabreauto-gpmi-weim.dts

./arch/arm/boot/dts/imx6q-arm2.dts

./arch/arm/boot/dts/imx6sl-evk.dts

Another question is: do I really need a .dtb file to boot? I didn't have it when booting with Linux 3.0.35 from Freescale.

In order to exclude other factors (SD card programming, etc.) and only to test kernel, I actually tried one more thing, which is to boot kernel from network. Here is the details:

  1. Set up TFTP server on Ubuntu host, and put the kernel file uImage_3.10.17 into /tftpboot
  2. on u-boot prompt, I ran these commands:
    • "setenv serverip 10.0.0.7"
    • "setenv ipaddr 10.0.0.11"
    • "tftp uImage_3.10.17" to copy kernel from Ubuntu to iMX6 RAM
    • "bootm" to boot from RAM

But the kernel hung at the very beginning:

U-Boot > tftp uImage_3.10.17

Using FEC device

TFTP from server 10.0.0.7; our IP address is 10.0.0.11

Filename 'uImage_3.10.17'.

Load address: 0x12000000

Loading: #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #########################################

         1.1 MiB/s

done

Bytes transferred = 5201216 (4f5d40 hex)

U-Boot > bootm

## Booting kernel from Legacy Image at 12000000 ...

   Image Name:   Linux-3.10.17

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    5201152 Bytes = 5 MiB

   Load Address: 10008000

   Entry Point:  10008000

   Verifying Checksum ... OK

   Loading Kernel Image ... OK

OK

No gpc device node -9, force to ldo-enable.

Starting kernel ...

I also downloaded the latest Yocto kernel source code (ver 3.10.3) from linux-yocto-3.10 - Linux 3.10 Embedded Kernel, built and tried to boot from network, and got the exact same symptom. I'm wondering if there's anything wrong in my build process. This is how I built it (I mentioned previously, and I was able to build u-boot with the same process (with different defconfig of course):

  • export PATH=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/:$PATH
  • export ARCH=arm
  • export CROSS_COMPILE=arm-none-linux-gnueabi-
  • make imx_v7_defconfig
  • make uImage LOADADDR=0x10008000

Could you comment?

Thanks a lot,

Jason

0 Kudos

66 Views
NXP Employee
NXP Employee

Hi Jason,

Sorry, but I have no experience with buildroot.

I would suggest you to send an email to the buildroot mailing list.

Regards,

Fabio Estevam

0 Kudos