Boot on a custom Linux

Discussion in 'UDOO NEO' started by cyrilf, May 5, 2016.

  1. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    Hi,

    I recently bought a UDOO NEO and I need to boot on my custom Linux I've been using with the UDOO Quad for a while. I've built my custom Linux using Buildroot, U-Boot and Linux Kernel sources. I want my OS to output the display on my LVDS touchscreen and I need to be able to run commands via the USB shield with picocom or minocom. I'll use the analog input so I disabled the M4 as it should be possible to read analog inputs from Linux according to the UDOO NEO docs.

    I'm not sure about my config so here are my scripts:

    Here is my build script:
    Code:
    #!/bin/bash
    
    # Exit if a compilation error occurs
    set -e
    
    SH_ROOT=`pwd`
    MAKE_JOBS=$(cat /proc/cpuinfo | grep processor | wc -l)
    
    # Buildroot branch
    BUILDROOT_BRANCH=2016.02
    
    # Toolchain
    TOOLCHAIN=$SH_ROOT/buildroot/output/host/usr/bin/arm-freescale-linux-uclibcgnueabi-
    
    # Creating the distribution directory
    mkdir -p $SH_ROOT/dist
    
    # Building the rootfs using buildroot
    echo -en "\033[41m"
    echo -n "####################### Building rootfs... ########################"
    echo -e "\033[0m"
    cd $SH_ROOT/buildroot
    cp $SH_ROOT/../config/buildroot.config $SH_ROOT/buildroot/.config
    git checkout $BUILDROOT_BRANCH
    make
    cp $SH_ROOT/buildroot/output/images/rootfs.tar.gz $SH_ROOT/dist
    
    # Building the bootloader
    echo -en "\033[41m"
    echo -n "####################### Building U-Boot... ########################"
    echo -e "\033[0m"
    cd $SH_ROOT/u-boot
    make ARCH=arm CROSS_COMPILE=$TOOLCHAIN udoo_neo_config
    make ARCH=arm CROSS_COMPILE=$TOOLCHAIN
    cp $SH_ROOT/u-boot/SPL $SH_ROOT/dist
    cp $SH_ROOT/u-boot/u-boot.img $SH_ROOT/dist
    
    # Building the Linux kernel
    echo -en "\033[41m"
    echo -n "#################### Building Linux kernel... #####################"
    echo -e "\033[0m"
    cd $SH_ROOT/kernel
    make ARCH=arm CROSS_COMPILE=$TOOLCHAIN udoo_neo_defconfig
    make -j$MAKE_JOBS ARCH=arm CROSS_COMPILE=$TOOLCHAIN uImage LOADADDR=0x10008000 modules
    make -j$MAKE_JOBS ARCH=arm CROSS_COMPILE=$TOOLCHAIN dtbs
    mkdir -p $SH_ROOT/dist/dtb
    cp $SH_ROOT/kernel/arch/arm/boot/dts/*.dtb $SH_ROOT/dist/dtb
    cp $SH_ROOT/kernel/arch/arm/boot/uImage $SH_ROOT/dist
    
    echo -en "\033[41m"
    echo -n "############################ Done ! ################################"
    echo -e "\033[0m"
    cd $SH_ROOT
    
    and here is the script I use to make the SD card:
    Code:
    #!/bin/bash
    
    SH_ROOT=`pwd`
    
    # Toolchain
    TOOLCHAIN=$SH_ROOT/buildroot/output/host/usr/bin/arm-freescale-linux-uclibcgnueabi-
    
    # 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
    
    # Make sure arguments were passed
    if [ "$#" -ne 1 ] && [ "$#" -ne 2 ]; then
        echo "Usage : sudo ./mksdcard /dev/<xxx> [wpa_supplicant.conf]"
        exit 1
    fi
    
    CARD=$1
    unset LANG
    
    # Unmount the automagically mounted SD card
    umount ${CARD}* >& /dev/null
    
    # Formatting SD card
    if [ -b "$CARD" ]; then
        echo -en "\033[41m"
        echo -n "##################### Formatting SD card... #######################"
        echo -e "\033[0m"
        dd if=/dev/zero of=$CARD bs=1024 count=1024
        SIZE=`fdisk -l $CARD | grep Disk | awk '{print $5}'`
        echo "Disk size: $SIZE bytes"
        sfdisk $CARD < $SH_ROOT/../config/partitions.sfdisk
        mkfs.vfat -F 32 -n "boot" ${CARD}1
        mke2fs -j -L "filesystem" ${CARD}2
    fi
    
    # Mounting partitions
    echo -en "\033[41m"
    echo -n "#################### Mounting partitions... #######################"
    echo -e "\033[0m"
    mkdir $SH_ROOT/tmp_boot
    mkdir $SH_ROOT/tmp_fs
    mount ${CARD}1 $SH_ROOT/tmp_boot
    mount ${CARD}2 $SH_ROOT/tmp_fs
    
    # Copying bootloader
    echo -en "\033[41m"
    echo -n "################### Installing Bootloader... ######################"
    echo -e "\033[0m"
    dd if=$SH_ROOT/dist/SPL of=${CARD} bs=1K seek=1
    dd if=$SH_ROOT/dist/u-boot.img of=${CARD} bs=1K seek=69
    cp $SH_ROOT/../config/uEnv.txt $SH_ROOT/tmp_boot
    
    echo -en "\033[41m"
    echo -n "#################### Installing OS... #######################"
    echo -e "\033[0m"
    
    # Copying the kernel
    mkdir -p $SH_ROOT/tmp_boot/dts
    cp $SH_ROOT/dist/uImage $SH_ROOT/tmp_boot
    cp $SH_ROOT/dist/*.dtb $SH_ROOT/tmp_boot/dts
    cd $SH_ROOT/kernel
    make ARCH=arm CROSS_COMPILE=$TOOLCHAIN firmware_install modules_install INSTALL_MOD_PATH=$SH_ROOT/tmp_fs
    cd $SH_ROOT
    
    # Extracting rootfs
    tar -xvf $SH_ROOT/dist/rootfs.tar.gz -C $SH_ROOT/tmp_fs
    mkdir -p $SH_ROOT/tmp_fs/root
    
    echo -en "\033[41m"
    echo -n "################ Synchronizing I/O operations... ##################"
    echo -e "\033[0m"
    sync
    
    echo -en "\033[41m"
    echo -n "#################### Unmounting partitions... #####################"
    echo -e "\033[0m"
    umount $SH_ROOT/tmp_boot
    umount $SH_ROOT/tmp_fs
    rm -rf $SH_ROOT/tmp_boot $SH_ROOT/tmp_fs
    
    echo -en "\033[41m"
    echo -n "############### SD card successufully created ! ###################"
    echo -e "\033[0m"
    My uEnv.txt file looks like:
    Code:
    video_output=lvds7
    m4_enabled=false
    use_custom_dtb=false
    Unfortunately the OS doesn't boot, there is nothing in the serial command line and the touchscreen stays black. One LED stays green (the power LED I suppose) and an other stays red.
     
    Last edited: Jul 21, 2016
  2. ektor5

    ektor5 Administrator Staff Member

    Joined:
    Jul 1, 2013
    Messages:
    97
    Likes Received:
    48
    Hi there,
    What U-Boot branch are you using?
    This is the right one: https://github.com/UDOOboard/uboot-imx/tree/2015.04.imx-neo

    Other thing, maybe it's better to not use uImage, our U-Boot use zImage by default.

    Also, the USB Shield you mentioned spawns two serials (on Linux spawns ttyUSB{0,1}) : use the second one to talk to the A9 processor.

    Ek5
     
  3. ektor5

    ektor5 Administrator Staff Member

    Joined:
    Jul 1, 2013
    Messages:
    97
    Likes Received:
    48
    Hi again,
    You cannot include modules with build-in dependences and vice-versa. Make sure that mac80211 is a module or a built-in like the WLAN module you are trying to compile.

    Ek5
     
    Andrea Rovai likes this.
  4. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    Hi ek5

    As you can see, everything is selected as a module (I have no choice actually).
    Now I've been able to compile all the modules but it seems that they're not loaded or maybe they're the wrong modules for the WLAN interface?

    When I do a "find", I can find all the .ko files:
    If I look at UDOObuntu udev rules, there is a line about WL18xx driver:
    This is the name of the Wi-Fi module so that means I try to install the wrong modules.

    Edit:
    I found the WL18xx driver in the kernel menuconfig. I added the modules to the /etc/modules file and I wrote a script in /etc/init.d/ to load the modules at boot:
    Code:
    #!/bin/sh -e
    
    # List of modules to load
    modules=/etc/modules
    
    # Silently exit if the kernel does not support modules.
    [ -f /proc/modules ] || exit 0
    [ -x /sbin/modprobe  ] || exit 0
    
    case "$1" in
      start)
      echo "Loading modules..."
      grep -h '^[^#]' $modules |
      while read module args; do
        [ "$module" ] || continue
        modprobe $module $args || true
        echo "Module $module loaded"
      done
      ;;
    
      stop|restart|reload|force-reload)
      echo "Action '$1' is meaningless for this init script"
      exit 0
      ;;
    
      *)
      echo "Usage: $0 start"
      exit 1
    esac
    Code:
    # /etc/modules: kernel modules to load at boot time.
    #
    # This file contains the names of kernel modules that should be loaded
    # at boot time, one per line. Lines beginning with "#" are ignored.
    
    cfg80211
    mac80211
    wlcore
    wl18xx
    I still have
    I tried to boot with UDOObutun Minimal and it loads the same modules at boot but it doesn't even try to start the wlan neither the eth interface. Is there any network support for the UDOO NEO?

    Regards
     
    Last edited: Jun 8, 2016
  5. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    Is there any Wi-Fi support for the NEO or is it still under development?
     
  6. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
  7. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    I see...

    But the official kernel doesn't have the WL1831 drivers enabled.

    I enabled it manually:
    [​IMG]

    But it still doesn't load the drivers module (see my last post).

    I also tried with UDOObuntu minimal and it also doesn't load Wi-Fi drivers.
     
  8. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    The driver you uploaded is wrong. The right one you need to use is inside the menu called "linux backports".
    If you follow the docs to compile the kernel you got everything working.
     
  9. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    OK this is a good point :)

    I must correct my last post: it DOES load modules but no wlan0 interface is created. If they are still the wrong modules as you said that makes sense.

    The doc I follow, where there is nothing about WLAN drivers, is here : http://www.udoo.org/docs-neo/Advanced_Topics/Compile_Linux_Kernel.html
    Unfortunately I cannot find a "linux backports" or simply "backports" entry in the menuconfig of the official Kernel.

    Code:
    make ARCH=arm menuconfig
    [​IMG]
     
    Last edited: Jul 21, 2016
  10. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    Have you loaded the default UDOO NEO config? This one I mean:
    Code:
    ARCH=arm make udoo_neo_defconfig
     
  11. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    Yes, you can see my build script in my first post.
    Code:
    # Building the Linux kernel
    echo -en "\033[41m"
    echo -n "#################### Building Linux kernel... #####################"
    echo -e "\033[0m"
    cd kernel
    make ARCH=arm CROSS_COMPILE=$TOOLCHAIN udoo_neo_defconfig
    make -j$MAKE_JOBS ARCH=arm CROSS_COMPILE=$TOOLCHAIN zImage
    make -j$MAKE_JOBS ARCH=arm CROSS_COMPILE=$TOOLCHAIN modules
    make -j$MAKE_JOBS ARCH=arm CROSS_COMPILE=$TOOLCHAIN dtbs
    mkdir -p $SH_ROOT/dist/dtb
    cp kernel/arch/arm/boot/dts/*.dtb $SH_ROOT/dist/dtb
    cp kernel/arch/arm/boot/zImage $SH_ROOT/dist
     
    Last edited: Jul 27, 2016
  12. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    Any news on the WLAN drivers for UDOO Neo ?
     
  13. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    Hi there cyrilf,
    no news, sorry.
     
  14. cyrilf

    cyrilf Active Member

    Joined:
    Feb 19, 2015
    Messages:
    168
    Likes Received:
    47
    Personnaly I have some news. After a pull I got the "linux backport" menu:

    [​IMG]

    In a support ticket, I've learned that I need to add the firmware which contains the specific software for the UDOO NEO. I got a .deb file containing the firmware. I extracted it and moved it into the lib directory of the kernel sources so the command
    Code:
    make install_firmware
    can install the firmware directory at the right place in the rootfs of the SD card.

    Unfortunately, that didn't work as expected :(
    I still have the same output: http://paste.ofcode.org/DCcsJXEGnU2KTfKYNP8VaH
    The script to init the network in /etc/init.d looks like: http://paste.ofcode.org/3vrEGAiKs7VThpryamMGfe

    The directory in the .deb file is firmware/3.14.56-udooneo-02023-g8d371df. I suspect that I must rename it with the right kernel version.

    Edit:
    Actually the firmware is already available on the repository: https://github.com/UDOOboard/linux_kernel/tree/3.14-1.0.x-udoo/firmware

    I changed this line in the mksdcard script:
    Code:
    make ARCH=arm CROSS_COMPILE=$TOOLCHAIN firmware_install modules_install INSTALL_MOD_PATH=$SH_ROOT/tmp_fs
    for:
    Code:
    make ARCH=arm CROSS_COMPILE=$TOOLCHAIN modules_install INSTALL_MOD_PATH=$SH_ROOT/tmp_fs
    make ARCH=arm CROSS_COMPILE=$TOOLCHAIN firmware_install INSTALL_FW_PATH=$SH_ROOT/tmp_fs/lib/firmware
    Now I have all the firmware in /lib/firmware but it still doesn't load WLAN drivers.
    According to the documentation of mdev at FIRMWARE section, it should load load the firmware from /lib/firmware.
    ---------------------------------------------------

    I've recently pulled the last commit from the kernel repository and I can't build it anymore. After a while I get this error:
    Code:
      CC  drivers/media/v4l2-core/videobuf2-core.o
      CC  drivers/media/v4l2-core/videobuf2-memops.o
      CC  drivers/media/v4l2-core/videobuf2-dma-contig.o
      LD  drivers/video/fb.o
      LD  drivers/media/v4l2-core/videodev.o
      LD  drivers/video/mxc/built-in.o
      LD  drivers/video/built-in.o
      LD  drivers/media/v4l2-core/built-in.o
      LD  drivers/media/built-in.o
      LD  drivers/built-in.o
      LINK  vmlinux
      LD  vmlinux.o
      MODPOST vmlinux.o
      GEN  .version
      CHK  include/generated/compile.h
      UPD  include/generated/compile.h
      CC  init/version.o
      LD  init/built-in.o
    drivers/built-in.o: In function `fec_probe':
    vf610_adc.c:(.text+0xff45c): undefined reference to `fec_phy_reset'
    Makefile:835: recipe for target 'vmlinux' failed
    make: *** [vmlinux] Error 1
     
    Last edited: Sep 9, 2016
  15. ektor5

    ektor5 Administrator Staff Member

    Joined:
    Jul 1, 2013
    Messages:
    97
    Likes Received:
    48
    Fixed that ;)
     

Share This Page