Enable SPI

Discussion in 'Kernels' started by cyrilf, Aug 24, 2015.

  1. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    I see something like this:
    Code:
    UDOO board => run loadfdt
    Failed to mount ext2 filesystem...
    ** Unrecognized filesystem type **
    UDOO board => run loaduimage
    reading uImage
    4367032 bytes read in 239 ms (17.4 MiB/s)
    UDOO board => bootm ${loadaddr} - ${fdt_addr};
    ## Booting kernel from Legacy Image at 10800000 ...
      Image Name:  Linux-4.2.0-gec528f1
      Image Type:  ARM Linux Kernel Image (uncompressed)
      Data Size:  4366968 Bytes = 4.2 MiB
      Load Address: 10008000
      Entry Point:  10008000
      Verifying Checksum ... OK
    ## Flattened Device Tree from Legacy Image at 12000000
      Image Name:  Linux-4.2.0-gec528f1
      Image Type:  ARM Linux Kernel Image (uncompressed)
      Data Size:  4366968 Bytes = 4.2 MiB
      Load Address: 10008000
      Entry Point:  10008000
      Verifying Checksum ... OK
    ERROR: uImage is not a fdt - must RESET the board to recover.
    Could not find a valid device tree
     
  2. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    How did you created SD card? What type of partitions are there and where are the files (kernel, device tree, ...).
     
  3. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    I used this script to build my SD card (this works perfecly with the Kernel_Unico):
    Code:
    #!/bin/bash
    
    # Make sure only root runs this script
    if [[ $EUID -ne 0 ]]; then
      echo "This script must be run as root or with sudo!"
      exit 1
    fi
    
    CARD_DEV=$1
    
    umount ${CARD_DEV}* >& /dev/null
    
    if [ -b "$CARD_DEV" ] ; then
        echo "************ Formatting SD card... ************"
        dd if=/dev/zero of=$CARD_DEV bs=1024 count=1024
        SIZE=`fdisk -l $CARD_DEV | grep Disk | awk '{print $5}'`
        echo DISK SIZE - $SIZE bytes
        CYLINDERS=`echo $SIZE/255/63/512 | bc`
        echo CYLINDERS - $CYLINDERS
        {
            echo 1,9,0x0C,*
            echo 10,,,-
        } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $CARD_DEV
        mkfs.vfat -F 32 -n "boot" ${CARD_DEV}1
        mke2fs -j -L "filesystem" ${CARD_DEV}2
        tune2fs -c0 -i0 ${CARD_DEV}2
    fi
    
    mkdir tmp_boot
    mkdir tmp_fs
    mount ${CARD_DEV}1 tmp_boot
    mount ${CARD_DEV}2 tmp_fs
    
    # Copy bootloader
    dd if=dist/u-boot-q.imx of=${CARD_DEV} bs=512 seek=2
    
    # Copy boot screen
    echo "************ Making Vesta OS image... ************"
    mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Vesta OS v1.0" -d ../tools/boot.txt tmp_boot/boot.scr
    
    # Copy kernel image
    cp dist/uImage tmp_boot
    
    # Copy DTB file
    cp dist/imx6q-udoo.dtb tmp_boot
    
    # Extract root file system
    tar -xf dist/rootfs.tar.gz -C tmp_fs
    
    # Copy firmware
    cp dist/sdma-imx6q.bin tmp_fs/lib/firmware/imx/sdma/
    
    echo "************ Synchronizing I/O operations on SD card... ************"
    sync
    
    umount tmp_boot
    umount tmp_fs
    rm -rf tmp_boot tmp_fs
    
    echo "************ SD card successfully created ! ************"
    I use it like this:
    Code:
    sudo ./mksdcard.sh /dev/sdd
     
  4. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    Then this will work:
    Code:
    fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}
    fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
    bootm ${loadaddr} - ${fdt_addr}
    You have both files on first fat partition that's why you need to use fatload and not ext2load. You need to fix your bootscript (boot.txt).
     
  5. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    My boot.txt looks like that:
    Code:
    setenv mmcargs 'setenv bootargs console=${console},${baudrate} root=${mmcroot} ${hdmi_patch} fbmem=24M video=mxcfb0:dev=ldb,LDB-WVGA,if=RGB666,bpp=32'
    setenv uimage uImage
    setenv loaduimage 'fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}'
    setenv mmcroot '/dev/mmcblk0p2 rootwait rw'
    setenv mmcboot 'run mmcargs; bootm ${loadaddr}'
    setenv bootcmd 'mmc dev ${mmcdev};if mmc rescan; then if run loaduimage; then run mmcboot;else run netboot;fi;else run netboot; fi'
    saveenv
    I didn't change it for the new kernel.

    I tried your lines but it still blocks at starting step.
     
    Last edited: Sep 8, 2015
  6. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    I think your script should like something like this:
    Code:
    setenv mmcargs 'setenv bootargs console=${console},${baudrate} root=${mmcroot} ${hdmi_patch} fbmem=24M video=mxcfb0:dev=ldb,LDB-WVGA,if=RGB666,bpp=32'
    setenv uimage uImage
    setenv loadfdt 'fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}'
    setenv loaduimage 'fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}'
    setenv mmcroot '/dev/mmcblk0p2 rootwait rw'
    setenv mmcboot 'run mmcargs; bootm ${loadaddr} - ${fdt_addr}'
    setenv bootcmd 'mmc dev ${mmcdev};if mmc rescan; then if run loaduimage; then if run loadfdt; then run mmcboot; else run netboot; fi; else run netboot; fi; run netboot; fi'
    saveenv
    This from u-boot prompt should work:
    Code:
    setenv loadfdt 'fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}'
    run loaduimage
    run loadfdt
    run mmcargs
    bootm ${loadaddr} - ${fdt_addr}
     
  7. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    OK this is better, the kernel at least try to boot :)
    Unfortunately, I get a kernel panic after a few second.
    Code:
    ...
    [    1.703488] EXT4-fs (mmcblk0p2): mounting ext3 file system using the ext4 subsystem
    [    1.726245] EXT4-fs (mmcblk0p2): recovery complete
    [    1.731051] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
    [    1.739191] VFS: Mounted root (ext3 filesystem) on device 179:2.
    [    1.748498] devtmpfs: mounted
    [    1.751676] Freeing unused kernel memory: 228K (80725000 - 8075e000)
    /sbin/init: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    [    1.843034] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
    [    1.843034]
    [    1.852182] CPU3: stopping
    [    1.854903] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 4.2.0-gec528f1 #1
    [    1.861523] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
    [    1.868086] [<800158bc>] (unwind_backtrace) from [<80012770>] (show_stack+0x10/0x14)
    [    1.875848] [<80012770>] (show_stack) from [<805236c4>] (dump_stack+0x84/0xc4)
    [    1.883084] [<805236c4>] (dump_stack) from [<80014988>] (handle_IPI+0x178/0x18c)
    [    1.890490] [<80014988>] (handle_IPI) from [<800093fc>] (gic_handle_irq+0x58/0x5c)
    [    1.898068] [<800093fc>] (gic_handle_irq) from [<80013280>] (__irq_svc+0x40/0x74)
    [    1.905556] Exception stack(0xab0a3f58 to 0xab0a3fa0)
    [    1.910614] 3f40:                                                       00000000 ab736940
    [    1.918798] 3f60: 00000001 ab0a2000 ab733540 00000001 6e394e35 00000000 6c337d02 00000000
    [    1.926982] 3f80: 00000004 807605d0 80014eac ab0a3fa0 80528a58 803733f0 20000113 ffffffff
    [    1.935175] [<80013280>] (__irq_svc) from [<803733f0>] (cpuidle_enter_state+0x128/0x268)
    [    1.943281] [<803733f0>] (cpuidle_enter_state) from [<80059958>] (cpu_startup_entry+0x18c/0x270)
    [    1.952076] [<80059958>] (cpu_startup_entry) from [<1000948c>] (0x1000948c)
    [    1.959045] CPU2: stopping
    [    1.961764] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.2.0-gec528f1 #1
    [    1.968383] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
    [    1.974930] [<800158bc>] (unwind_backtrace) from [<80012770>] (show_stack+0x10/0x14)
    [    1.982684] [<80012770>] (show_stack) from [<805236c4>] (dump_stack+0x84/0xc4)
    [    1.989914] [<805236c4>] (dump_stack) from [<80014988>] (handle_IPI+0x178/0x18c)
    [    1.997318] [<80014988>] (handle_IPI) from [<800093fc>] (gic_handle_irq+0x58/0x5c)
    [    2.004895] [<800093fc>] (gic_handle_irq) from [<80013280>] (__irq_svc+0x40/0x74)
    [    2.012382] Exception stack(0xab0a1f58 to 0xab0a1fa0)
    [    2.017441] 1f40:                                                       00000000 ab72c940
    [    2.025626] 1f60: 00000001 ab0a0000 ab729540 00000001 6e394e35 00000000 6c337680 00000000
    [    2.033811] 1f80: 00000004 807605d0 80014eac ab0a1fa0 80528a58 803733f0 20000113 ffffffff
    [    2.041996] [<80013280>] (__irq_svc) from [<803733f0>] (cpuidle_enter_state+0x128/0x268)
    [    2.050098] [<803733f0>] (cpuidle_enter_state) from [<80059958>] (cpu_startup_entry+0x18c/0x270)
    [    2.058891] [<80059958>] (cpu_startup_entry) from [<1000948c>] (0x1000948c)
    [    2.065859] CPU1: stopping
    [    2.068579] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.2.0-gec528f1 #1
    [    2.075198] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
    [    2.081744] [<800158bc>] (unwind_backtrace) from [<80012770>] (show_stack+0x10/0x14)
    [    2.089499] [<80012770>] (show_stack) from [<805236c4>] (dump_stack+0x84/0xc4)
    [    2.096730] [<805236c4>] (dump_stack) from [<80014988>] (handle_IPI+0x178/0x18c)
    [    2.104135] [<80014988>] (handle_IPI) from [<800093fc>] (gic_handle_irq+0x58/0x5c)
    [    2.111711] [<800093fc>] (gic_handle_irq) from [<80013280>] (__irq_svc+0x40/0x74)
    [    2.119198] Exception stack(0xab09ff58 to 0xab09ffa0)
    [    2.124256] ff40:                                                       00000000 ab722940
    [    2.132441] ff60: 00000001 ab09e000 ab71f540 00000001 6e394e35 00000000 6dad3c22 00000000
    [    2.140625] ff80: 00000004 807605d0 80014eac ab09ffa0 80528a58 803733f0 200f0013 ffffffff
    [    2.148811] [<80013280>] (__irq_svc) from [<803733f0>] (cpuidle_enter_state+0x128/0x268)
    [    2.156912] [<803733f0>] (cpuidle_enter_state) from [<80059958>] (cpu_startup_entry+0x18c/0x270)
    [    2.165706] [<80059958>] (cpu_startup_entry) from [<1000948c>] (0x1000948c)
    [    2.172676] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
    [    2.172676] 
    Is ${fdt_file} set somewhere ?
     
    Last edited: Sep 8, 2015
  8. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    This is already a problem with your distribution you want to boot. Which one exactly is that?
    Or maybe you should set init=/init in bootargs.
     
  9. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    I use Buildroot to build my rootfs.
    OK thanks, I'll try tomorrow.
     
  10. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    Where do you set the bootargs in U-Boot (I'm quite new with it) ?
    I tried :
    Code:
    setenv bootargs "init=/init"
    but I still have the same output.
     
    Last edited: Sep 10, 2015
  11. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    Seems you are only missing /lib/libc.so.6 library on your rootfs (missed that detail yesterday).
     
  12. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    I do have /lib/libc.so.6 in my rootfs.
    [​IMG]
     
  13. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    Then I don't know what is wrong. Check if maybe symbolic link is used and it points to non existing file.
     
  14. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    OK. So I guess this is impossible to use the SPI of the UDOO yet in Linux ?
     
    Last edited: Sep 10, 2015
  15. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    Why impossible? Just fix this issue.

    Can you upload your image somewhere and I can look inside?
     
  16. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    Because SPI isn't new at all. I don't think it is available in a newer version of the kernel if the UDOO team didn't write the SPI driver.
    So yes, if I can fix it it would probably works and at least, I'll be able to use an up to date kernel with a new rootfs built with the last version of Buildroot. This is a good point. But how about the original goal ? :/

    I uploaded the image here if you can have a look : https://mega.nz/#!Dh0CBB5J!eW-O-51zqz6nzzrHfku8s744si_wMwJILpMF_2yOkZ8
     
  17. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    I'm sure SPI will just work. Driver is already part of the kernel. But driver for your device you want to connect is a different story.

    Anyway, to actually boot this image you need to create one folder and one symbolic link in root of your image. Then it should boot (not 100% sure because was tested this only with qemu-arm emulator).
    Code:
    sudo mkdir lib/arm-linux-gnueabihf
    sudo ln -s /lib/libc.so.6 lib/arm-linux-gnueabihf
    
    Wonder why created image missing this step...
     
  18. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    Hm. It still doesn't find the libc.so.6.

    I'll try tomorrow to build a new rootfs with the last version of Buildroot. Now I'm using the v2014.08.
     
  19. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    If you got same error then you made folder or symbolic link wrong way. Or just copy libc in that folder.
     
  20. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    167
    Likes Received:
    47
    Hm, I guess I used the wrong header files version number in buildroot. I changed my toolchain but I didn't change this in the config file.

    [​IMG]
     

Share This Page