wiki:laguna/gw2388-4

Gateworks Laguna GW2388-4 and Other Laguna NOR Based Boards

Useful Information

Gateworks has created a list of information that we have deemed useful to anybody looking to become familiar with the GW2388-4 or looking for development information on the GW2388-4. A list of this information has been provided below.

Booting from microSD (uSD)

NOTE: Problems have been reported with certain SD cards. If you are experiencing issues, please try a different brand/card/etc. Additional note, there was an issue with Uboot not detecting the uSD which has been fixed in the latest Uboot release. The binary for the updated Uboot can be found in the pre-built images directory.

There are many options and configurations for booting from microSD.

  1. The bootloader must have support for any device/filesystem you use within the bootloader.
  2. The kernel must have support for whatever root filesystem device/type you wish to use as the rootfs.
  3. You must choose a partitioning scheme and image your microSD properly. You can even mix things up a bit more by booting partially from FLASH and partially from microSD.

The GW2388 bootloader configuration supports FAT fiilesystems on MMC devices. While the linux kernel supports a variety of block device filesystems, to keep the static kernel size down for our FLASH configuration, our default kernel configuration supports only the following 'FLASH' based filesystems: overlayfs, jffs2, squashfs.

To boot from microSD you will need to build your own firmware with the following options/configuration changes:

  1. either use a FAT filesystem on uSD or rebuild u-boot with ext2 support
  2. rebuild the kernel with other commonly used block filesystem support (ie ext2/ext3/ext4) and use the proper rootfs= parameter to tell the kernel where your rootfs is

Example 1. Kernel and Root Filesystem On Card

As an example here is how you would boot from uSD with your kernel on a small FAT partition and your rootfs on an ext3 fs on the remainder of the device:

Step 1 - Add ext2/ext4 support to the kernel

  • Add ext2 support to kernel: run 'make kernel_menuconfig' and add support for EXT2 via 'File systems' -> 'Ext3 journalling file system support' (CONFIG_EXT3_FS)
  • NOTE: If problems occur, one may try turning off squashfs in the config.

Step 2 - Modify OpenWrt to output tarball

  • Configure OpenWRT to create a root filesystem tarball: 'make menuconfig' select 'Target Images' -> 'tar.gz' (CONFIG_TARGET_ROOTFS_TARGZ=y)
  • To see what SD card is attached to a Linux Desktop use the command df -h

Step 3 - Create MicroSD Card On Linux Desktop Machine

  • Create a microSD with a small FAT partition as partition1 where you place the kernel uImage as 'uImage' and the rest an ext4 fs where you untar the root filesystem created above. For example, on a linux system where /dev/sdb is the device where your uSD is (understand this carefully as you do NOT want to re-partition and format your host drive):
    # partition /dev/sde with a 9MB FAT partition and the rest a Linux partition
    sfdisk -uS /dev/sde << EOF
    ,$((9*2048)),c,*,
    $((9*2048)),,L,,
    EOF
    

Example Output:


ryan@Ryan:~/Downloads/binaries/images$ sudo sfdisk -uS /dev/sde << EOF
,$((9*2048)),c,*,
$((9*2048)),,L,,
EOF
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 60480 cylinders, 4 heads, 32 sectors/track
Old situation:
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sdb1   *     0+     8      9-      9215+   c  W95 FAT32 (LBA)
/dev/sdb2         9   3779   3771    3861504   83  Linux
/dev/sdb3         0      -      0          0    0  Empty
/dev/sdb4         0      -      0          0    0  Empty
New situation:
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sdb1   *     0+     8      9-      9215+   c  W95 FAT32 (LBA)
/dev/sdb2         9   3779   3771    3861504   83  Linux
/dev/sdb3         0      -      0          0    0  Empty
/dev/sdb4         0      -      0          0    0  Empty
Successfully wrote the new partition table

Re-reading the partition table ...

Continuing on with the steps....

# hotplug the uSD or manually mount /dev/sde1 and /dev/sde2 so that the partitions are mounted on your Linux host
mkfs.vfat /dev/sde1
mount /dev/sde1 /mnt
cp bin/cns3xxx/openwrt-cns3xxx-uImage /mnt/uImage
umount /dev/sde1
mkfs.ext4 /dev/sde2
mount /dev/sde2 /mnt
cp build_dir/linux-cns3xxx/ext4 /dev/sde2
umount /dev/sde2

Step 4 - Insert SD Card into Gateworks Board

  • boot the standard u-boot which has FAT fs support on GW2388 with your uSD in the card slot and use the following uboot commands to load the kernel from FAT partition and boot the kernel with a rootfs of the ext4 partition:
    mmcinit
    fatload mmc 0:1 0x00800000 uImage
    setenv bootargs 'console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 noinitrd init=/etc/preinit'
    bootm 0x00800000
    

Example 2. Only Root Filesystem On Card

Step 1 - Add ext2/ext4 support to the kernel

  • Add ext4 support to kernel: run 'make kernel_menuconfig' and add support for EXT4 via 'File systems' -> 'The Extended 4 (ext4) filesystem'
  • Rebuild the kernel by typing make -j8 V=99 from the trunk directory
  • Look for the kernel output /gateworks-openwrt/trunk/bin/cns3xxx/openwrt-cns3xxx-uImage

Step 2 - Copy the Kernel to Gateworks Board

Step Create Tarball of OpenWrt Linux Filesystem

  • Configure OpenWRT to create a root filesystem tarball: 'make menuconfig' select 'Target Images' -> 'tar.gz' (CONFIG_TARGET_ROOTFS_TARGZ=y)
  • Rebuild the root filesystem by typing make -j8 V=99 from the trunk directory
  • Look for the kernel output /gateworks-openwrt/trunk/bin/cns3xxx/openwrt-cns3xxx-rootfs.tar.gz

Step Create MicroSD Card & Copy Root Filesystem

Format the SD card on Linux Desktop Computer then place the root filesystem onto the SD Card.

NOTE: Each SD card may be a different device on your system. It may not be /dev/sdc as outlined below:

DISK=/dev/sdc
printf ",,L,,\n" | sudo sfdisk -uS ${DISK}
sudo mkfs.ext4 ${DISK}1
sudo mount ${DISK}1 /mnt/disk
sudo tar xvf gateworks-openwrt/trunk/bin/cns3xxx/openwrt-cns3xxx-rootfs.tar.gz -C /mnt/disk
sudo umount /mnt/disk

Step Insert MicroSD into Laguna Gateworks Board

  • Boot the Gateworks Board and immediately break into the bootloader by hitting a key on the keyboard
    • Hit any key to stop autoboot:  0 
               Laguna >  
      
  • Change the Bootargs to tell the kernel to boat to the rootfs on the sd card (which is /dev/mmcblk0p1 - p1 denotes partition one )

NOTE: You may want to record or save your old bootargs in case you want to return back to stock

setenv bootargs 'console=ttyS0,115200 root=/dev/mmcblk0p1 rootfstype=ext4 rootwait'
  • Save the variable...
    saveenv
    
  • Boot the board
    boot
    
  • You can tell the SD card is being booted to by seeing lines in the bootup that look something similar to below:
    [    2.050000] 0x000000200000-0x000000400000 : "rootfs"
    [    2.050000] split_squashfs: no squashfs found in "spi1.0"
    [    2.070000]  mmcblk0: p1
    [    2.080000] rtc-ds1672 0-0068: setting system clock to 1970-01-01 00:42:28 UTC (2548)
    [    2.490000] EXT4-fs (mmcblk0p1): recovery complete
    [    2.500000] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
    [    2.510000] VFS: Mounted root (ext4 filesystem) on device 179:1.
    

Last modified 12 months ago Last modified on 09/06/16 15:19:42