Putting Linux on mini2440

I hope to make this

  • Pain free
  • As close to first principles as possible so when new versions come out you can still follow this guide

Building the kernel and root file system

I grabbed the latest version of buildroot off http://buildroot.uclibc.org/downloads/.

The version I got was 2015.02. I managed to get Linux 3.18.6 working on the mini2440, but you might want the newest version at the point you’re doing this.

Untar the tarball and go to the extracted directory.

Type make menuconfig.

I tried using the mini2440 defconfig (as in default config), but I kinda tried so many different things that I don’t know which of those are still valid. If you’d like to try the mini2440 defconfig, or at least use that as a starting point, go to < Load > and load configs/mini2440_defconfig.

If not, here’s my final configuration.

  • Target Architecture: ARM (little endian)
  • Target Binary Format: ELF
  • Target Architecture Variant: arm920t
  • Target ABI: EABI
  • Floating point strategy: Soft float
  • ARM instruction set: ARM

I changed the System hostname and System banner in System configuration, but those are cosmetic.

For Linux kernel configuration, I used a defconfig, and the name of the defconfig is mini2440.

I am using uImage for the Kernel binary format

As for filesystem, I selected initial RAM filesystem linked into linux kernel

I also selected jffs2 root filesystem and for Flash Type, I selected NAND flash with 2kB Page and 128 kB erasesize

This version of buildroot doesn’t build U-Boot properly due to a missing defconfig, so I did not select any bootloader.

Then…

make

Putting U-boot on mini2440

I got a compiled version of U-boot from http://www.mech.tohoku-gakuin.ac.jp/rde/contents/tech/mini2440/archive/u-boot_20100701.zip, but just in case that file disappears, u-boot_20100701.zip.

This zip file contains two tools that you might need to transfer files over USB to the mini2440. After you extract the files in the archive, they will be in the tools/ directory. I don’t think there is a difference between s3c2410_boot_usb and usbpush.

Hardware connections

  • Connect the mini2440 to power
  • Connect the mini2440 to a USB port on your Linux PC using a Type A (male) to Type B (male) USB cable
  • Connect the mini2440 to a serial port on your Linux PC using a serial cable

Start minicom

sudo minicom -s

Here are my settings

    +-----------------------------------------------------------------------+
    | A -    Serial Device      : /dev/ttyS0                                |
    | B - Lockfile Location     : /var/lock                                 |
    | C -   Callin Program      :                                           |
    | D -  Callout Program      :                                           |
    | E -    Bps/Par/Bits       : 115200 8N1                                |
    | F - Hardware Flow Control : No                                        |
    | G - Software Flow Control : No                                        |
    |                                                                       |
    |    Change which setting?                                              |
    +-----------------------------------------------------------------------+
            | Screen and keyboard      |
            | Save setup as dfl        |
            | Save setup as..          |
            | Exit                     |
            | Exit from Minicom        |
            +--------------------------+

If you set the NAND/NOR switch on the mini2440 to NOR and power up the mini2440, you should see something like this:

##### FriendlyARM BIOS 2.0 for 2440 #####
[x] format NAND FLASH for Linux
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[a] Absolute User Application
[n] Download Nboot for WinCE
[l] Download WinCE boot-logo
[w] Download WinCE NK.bin
[d] Download & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the nand flash
[b] Boot the system
[s] Set the boot parameters
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
Enter your selection:

Conceptually,

You want to put U-Boot, a bootloader, into NAND flash, which will then load your linux kernel, which would in turn load your root filesystem.

Here’s the final layout you want to achieve

MINI2440 # mtdparts

device nand0 <mini2440-nand>, # parts = 4
 #: name                        size            offset          mask_flags
 0: u-boot              0x00040000      0x00000000      0
 1: u-boot_env          0x00020000      0x00040000      0
 2: kernel              0x00500000      0x00060000      0
 3: rootfs              0x0faa0000      0x00560000      0

active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000

defaults:
mtdids  : nand0=mini2440-nand
mtdparts: <NULL>

Putting U-Boot into NAND flash

In this section, you’re going to first put U-Boot onto mini2440’s ram, and then run U-Boot from ram to make it do some cleanup, and then get U-Boot to copy itself into NAND flash.

Ask mini2440 to receive U-Boot:

In minicom:

##### FriendlyARM BIOS 2.0 for 2440 #####
[x] format NAND FLASH for Linux
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[a] Absolute User Application
[n] Download Nboot for WinCE
[l] Download WinCE boot-logo
[w] Download WinCE NK.bin
[d] Download & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the nand flash
[b] Boot the system
[s] Set the boot parameters
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
Enter your selection:

Press q

Supervivi> load ram <destination-address-in-ram> <size-to-transfer> u

What I used:

Supervivi> load ram 0x32000000 242360 u

Send U-Boot over USB to mini2440. I used u-boot-256M.bin, because my mini2440 had a flash size of 256M. Many sites say that there should be no difference between using u-boot-256M.bin and u-boot-128M.bin, but I used u-boot-256M.bin anyway. On Linux PC:

$ sudo ./tools/s3c2410_boot_usb u-boot_20100701/u-boot-256M.bin

(Ignore the error if you get one)

Start U-Boot

In minicom:

Supervivi> go 0x32000000

Clear everything in NAND flash

MINI2440 # nand scrub

Create bad block table (This took quite a while for me, be patient)

MINI2440 # nand createbbt

Create/view partitions

MINI2440 # mtdparts

Write uboot to NAND flash. You have some options here.

Raw write, doesn’t look for bad blocks, data might get written to bad block. This will copy the full size of the nand partition, beginning with the address in ram provided.

MINI2440 # nand write <address-in-ram-in-hex> <partition-in-nand>

Write, taking into account bad blocks

MINI2440 # nand write.e <source-in-hex> <destination-in-hex> <bytes-to-write-in-hex>

I used

MINI2440 # nand write 0x32000000 u-boot

Partition the NAND

MINI2440# dynpart

Create the dynamic environment space for u-boot

MINI2440# dynenv set u-boot_env

Save the environment to NAND.

MINI2440# saveenv

Switch off the mini2440, flip the NAND/NOR switch to NAND, and switch on the mini2440.

You should get to a MINI2440# prompt. If you don’t, try pressing enter a few times in minicom, the prompt might show up then.

Transferring uImage into NAND flash

I transferred using tftp, but you might be able to do it using USB like above.

Find the address of the kernel partition:

MINI2440 # mtdparts

device nand0 <mini2440-nand>, # parts = 4
 #: name                        size            offset          mask_flags
 0: u-boot              0x00040000      0x00000000      0
 1: u-boot_env          0x00020000      0x00040000      0
 2: kernel              0x00500000      0x00060000      0
 3: rootfs              0x0faa0000      0x00560000      0

active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000

defaults:
mtdids  : nand0=mini2440-nand
mtdparts: <NULL>

Erase the kernel partition:

MINI2440# nand erase 60000 500000

Set up your network. I connected the mini2440 to my router, and the Linux PC to the router at 192.168.1.50

MINI2440# setenv ipaddr 192.168.1.60
MINI2440# setenv serverip 192.168.1.50

Download uImage from Linux PC over LAN into RAM, at 0x32000000 again. First place uImage into /tftpboot (Google how to set up tftp).

MINI2440# tftp 32000000 uImage

Copy uImage from ram into NAND

MINI2440# nand write.e 32000000 60000 <size-of-uImage-in-hex>

Set the boot command to load kernel image from NAND flash.

MINI2440# setenv bootcmd 'nboot.e kernel;bootm'
MINI2440# saveenv

Power cycle the mini2440, and it should boot into Linux.

Loading from NAND 256MiB 3,3V 8-bit, offset 0x60000
   Image Name:   Linux-3.18.6
   Created:      2015-04-05   4:34:50 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5350896 Bytes =  5.1 MB
   Load Address: 30008000
   Entry Point:  30008000
## Booting kernel from Legacy Image at 32000000 ...
   Image Name:   Linux-3.18.6
   Created:      2015-04-05   4:34:50 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5350896 Bytes =  5.1 MB
   Load Address: 30008000
   Entry Point:  30008000
   Verifying Checksum ... OK
   Loading Kernel Image ...
...

Here’s my entire U-Boot environment, just in case…

MINI2440 # printenv
bootargs=root=/dev/mtdblock3 rootfstype=jffs2 console=ttySAC0,115200
bootdelay=3
baudrate=115200
ethaddr=08:08:11:18:12:27
netmask=255.255.255.0
usbtty=cdc_acm
mini2440=mini2440=0tb
bootargs_base=console=ttySAC0,115200 noinitrd
bootargs_init=init=/sbin/init
root_nand=root=/dev/mtdblock3 rootfstype=jffs2
root_mmc=root=/dev/mmcblk0p2 rootdelay=2
root_nfs=/mnt/nfs
set_root_nfs=setenv root_nfs root=/dev/nfs rw nfsroot=${serverip}:${root_nfs}
ifconfig_static=run setenv ifconfig ip=${ipaddr}:${serverip}::${netmask}:mini2440:eth0
ifconfig_dhcp=run setenv ifconfig ip=dhcp
ifconfig=ip=dhcp
set_bootargs_mmc=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_mmc}
set_bootargs_nand=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_nand}
set_bootargs_nfs=run set_root_nfs; setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_nfs} ${ifconfig}
mtdids=nand0=mini2440-nand
mtdparts=mtdparts=mini2440-nand:0x00040000(u-boot),0x00020000(u-boot_env),0x00500000(kernel),0x0faa0000(rootfs)
bootcmd=nboot.e kernel;bootm
ipaddr=192.168.1.60
serverip=192.168.1.50
partition=nand0,0
mtddevnum=0
mtddevname=u-boot

Environment size: 1151/131068 bytes

References

comments powered by Disqus