Porting U-Boot and Linux To T4240
Porting U-Boot and Linux To T4240
Contents
1 Introduction 1 Introduction................................................................1
This application note describes how to port U-Boot and Linux 2 Porting U-Boot...........................................................1
sources from Freescale's Software Development Kit (SDK) to 3 Porting Linux............................................................6
a new T4240 platform.
4 Revision history......................................................10
This document covers the main areas within the U-Boot and
Linux sources that a developer should be aware of to port
these packages to a new T4240 platform. It also assumes the
reader has at least a basic knowledge on U-Boot, Linux and
git. Note that the code sources referenced in this document are
based on SDK 1.4 which uses U-Boot 2013.01 and Linux
kernel 3.8.13. For different U-Boot or kernel releases there
may be slight changes to some of these references.
The SDK includes support for the T4240QDS, therefore
T4240 device support is already included within the package.
As such, the items discussed here focus on board level
changes. For the purposes of this document, the example
platform is the T4240-SDP, a custom T4240 reference design
from Freescale.
2 Porting U-Boot
This section covers the process of obtaining the U-Boot
source, modifying the source to support the new platform and
building binary images that will execute on the platform.
2.1 Overview
U-Boot is a multi-functional open-source bootloader which allows a developer to load an operating system.
In addition to the bootstrapping functionality, U-Boot also supports other features such as device drivers, networking and file
systems support.
U-Boot is free software released under the terms of the GNU General Public License (GPL). For the purposes of this
document U-Boot will be responsible for initial board bring-up including DDR, PCIe and networking interfaces, and for
booting the Linux operating system.
The method detailed below uses the U-Boot package available within the SDK as a starting point for the port. Information on
how to extract/modify the U-Boot sources from the SDK is available on the infocenter website:
http://www.freescale.com/infocenter/index.jsp?topic=%2FQORIQSDK%2F2880375.html.
The main steps are as follows:
1. Install the latest SDK release
2. In the main install directory create a build directory for the T4240QDS, i.e.
• source ./fsl-setup-poky -m t4240qds
3. From the <yocto_install_path>/build_t4240qds_release directory, extract the U-Boot source using the following
command:
• bitbake -c patch u-boot
4. To find the location of the extracted U-Boot source run the following command and look for the source ‘S=’ result
• bitbake -e u-boot | grep ^S
The output will look something like:
• S="/home/Projects/sdk-1.4/QorIQ-SDK-V1.4-20130625-yocto/build_t4240qds_release/tmp/
work/t4240qds-fsl_networking-linux/u-boot/git-r33/git"
The source code in the directory above can now be modified for the new platform. The steps in this application note assume
U-Boot and the kernel are built manually, i.e. not using bitbake. If users prefer to use bitbake they should refer to the
infocenter QorIQ instructions/FAQs for U-Boot and Linux.
• New board configuration files required to add overall support for the platform
• Modification of existing drivers to support new features/components used on the board
The steps below outline the process of completing both these tasks.
The fields above define the Target, ARCH, CPU, Board name, Vendor, SoC and Options for the board. The Target is the
name used during the build process to create binaries for a specific platform. A new entry is therefore required in this file for
the new platform, for example:
Part of this initialization handles enabling interleaving based on the requirements passed in from the U-Boot environment
variable hwconfig. For example: If the user has the hwconfig setting shown below, the populate_memctl_options() function
in arch/powerpc/cpu/mpc8xxx/ddr/options.c will take these inputs and ensure the DDR initialization completes with the
relevant interleaving options in place. The example below enables both controller and bank based interleaving. If interleaving
should be disabled these entries within hwconfig should be removed.
hwconfig=fsl_ddr:ctlr_intlv=3way_4KB,bank_intlv=auto;
• eth.c Board specific Ethernet initialization functions including setting up the MDIO bus for each of the FMan
interfaces.
The PHY addresses used in the board_eth_init() function are defined in the board configuration file discussed in Step 2:
Create a board configuration file , for example:.
pci_of_setup() is called in ft_board_setup() within t4sdp.c if CONFIG_PCI is defined in the board configuration file covered
in Step 2: Create a board configuration file.
• law.c Defines local access windows for interfaces such as flash memory based on the memory map of the system.
If users copy the T4240QDS file as a starting point it is easy to add/remove/modify entries in law_table[]. For example, to
change the size of the flash LAW from 256MB to 128MB users should change the entry below from:
to
All valid size options can be found in arch/powerpc/include/asm/fsl_law.h. The LAW target options can also be found in this
header file. If the base address of a LAW needs to be changed, for example CONFIG_SYS_FLASH_BASE_PHYS, the
relevant parameter in the board configuration files covered in Step 2: Create a board configuration file should be changed to
the correct value for the new platform.
• tlb.c Defines translation lookaside buffers to handle memory management in regions such as DDR, CCSR space, flash
and PCIe.
As with all files in this section the best approach is to start with the T4240QDS file and modify as required for the new
platform.
• Makefile Makefile is used to compile files listed above.
#define CONFIG_SYS_FSL_CORENET_SERDES4_ADDR \
(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_CORENET_SERDES4_OFFSET)
Once defined the identifier can be used within board initialization code to read/write registers within this block.
Once running on the platform U-Boot supports an ‘errata’ command which will list all the errata workarounds implemented
in the particular build. To ensure any new errata workarounds are included when the command is executed users should
update cmd_errata.c to include a new entry in the format shown below.
#ifdef CONFIG_SYS_FSL_ERRATUM_A005977
if (IS_SVR_REV(svr, 1, 0))
puts("Work-around for Erratum A005977 enabled\n");
#endif
• arch/powerpc/include/asm/config_mpc85xx.h
The config_mpc85xx.h file includes SoC specific defines for Freescale MPC85xx and QorIQ processors. This includes
values such as the maximum number of CPUs (CONFIG_MAX_CPUS) and the number of DDR controllers
(CONFIG_NUM_DDR_CONTROLLERS). Also defined for each processor are the errata workarounds that should be
implemented, e.g.
#define CONFIG_SYS_FSL_ERRATUM_A005977
Therefore if new workarounds are being added a #define should be added for each to ensure all workaround code is
controlled at this level.
• In drivers/net/phy/broadcom.c ensure the new PHY is registered by adding a phy_register() call, for example:
phy_register(&BCM54616S_driver);
For other PHY vendors users should refer to the drivers/net/phy options where other files are available such as vitesse.c.
3 Porting Linux
This section covers the process of obtaining the Linux sources, modifying the source to support the new platform and
building binary images that will execute on the platform.
3.1 Overview
Linux as an operating system in the embedded space is increasing in popularity and provides a stable, scalable solution that is
updated frequently to include the latest device drivers, etc for embedded system components.
In a system the Linux operating system must be capable of bringing up the correct network interfaces and other system
peripherals such as SATA and PCIe.
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Users can clone the tree from this location to port their new platform using the command below.
The method detailed below uses the Freescale SDK package and will use the Linux kernel sources available within the SDK
as a starting point for the port.
Information on how to extract/modify the kernel sources from the SDK is available on the infocenter website: http://
www.freescale.com/infocenter/index.jsp?topic=%2FQORIQSDK%2F2880375.html.
The main steps are as follows:
1. Install the latest SDK release
2. In the main install directory create a build directory for the T4240QDS, i.e.
• source ./fsl-setup-poky -m t4240qds
3. From the <yocto_install_path>/build_t4240qds_release directory extract the kernel source using the following
command:
• bitbake -c patch virtual/kernel
4. To find the location of the extracted kernel source run the following command and look for the source S= result
• bitbake -e virtual/kernel | grep ^S
The output will look something like:
• S="/home/Projects/sdk-1.4/QorIQ-SDK-V1.4-20130625-yocto/build_t4240qds_release/tmp/
work/t4240qds-fsl_networking-linux/linux-qoriq-sdk/3.8-r14.3/git"
5. cd to the source directory given by S=
6. Set <ARCH> and <CROSS_COMPILE> to the correct values:
• export ARCH=powerpc
• Using export CROSS_COMPILE= set the path to the relevant cross compile tools within the /opt directory on
your system
7. Check the build process by building the T4240QDS binary, i.e.
• Run make 85xx/e6500rev1_defconfig
• Run make uImage
• Check the uImage file is created within the arch/powerpc/boot directory of Linux
The source code in the directory above can now be modified for the new platform. The steps in this application note assume
the kernel is built manually, i.e. not using bitbake. If users prefer to use bitbake they should refer to the infocenter QorIQ
instructions/FAQs for Linux.
define_machine(t4240_sdp) {
.name = "T4240 SDP",
.probe = t4240_sdp_probe,
.setup_arch = corenet_ds_setup_arch,
.init_IRQ = corenet_ds_pic_init,
#ifdef CONFIG_PCI
.pcibios_fixup_bus = fsl_pcibios_fixup_bus,
#endif
/* coreint doesn't play nice with lazy EE, use legacy mpic for now */
#ifdef CONFIG_PPC64
.get_irq = mpic_get_irq,
#else
.get_irq = mpic_get_coreint_irq,
#endif
.restart = fsl_rstcr_restart,
.calibrate_decr = generic_calibrate_decr,
.progress = udbg_progress,
#ifdef CONFIG_PPC64
.power_save = book3e_idle,
#else
.power_save = e500_idle,
#endif
.init_early = corenet_ds_init_early,
};
config T4240_SDP
bool "Freescale T4240 SDP"
select DEFAULT_UIMAGE
select E500
select PPC_E500MC
select PHYS_64BIT
select SWIOTLB
NOTE
The first file name specified for the board should match the board initialization file
created in Step 1: Create a new board initialization file
ifc: localbus@ffe124000 {
reg = <0xf 0xfe124000 0 0x2000>;
ranges = <0 0 0xf 0xe8000000 0x08000000>;
nor@0,0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "cfi-flash";
reg = <0x0 0x0 0x8000000>;
bank-width = <2>;
device-width = <1>;
};
};
Developers should ensure that the U-Boot addressing for LAWs and TLBs is inline with the addressing defined in the device
tree.
.phy_id = PHY_ID_BCM54616,
.phy_id_mask = 0xfffffff0,
.name = "Broadcom BCM54616",
.features = PHY_GBIT_FEATURES |
SUPPORTED_Pause | SUPPORTED_Asym_Pause,
.flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
.config_init = bcm54xx_config_init,
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
.ack_interrupt = bcm54xx_ack_interrupt,
.config_intr = bcm54xx_config_intr,
.driver = { .owner = THIS_MODULE },
The final step in broadcom.c is to add an entry for the PHY to the broadcom_tbl structure, like this:
{ PHY_ID_BCM54616, 0xfffffff0 }
• In include/linux/brcmphy.h add a #define for the new PHY to specify what the PHY identifier register values are (this
value should be provided in the PHY datasheet).
NOTE
Users should ensure the device drivers section in the kernel config file (Step 3:
Create Kernel configuration file) includes the correct PHY option for the board,
e.g. CONFIG_BROADCOM_PHY=y.
make 85xx/t4240sdp_defconfig
This step reads the kernel configuration options from the specified file and these are stored in the .config file at the top
level directory. If the user wishes add/remove options the make menuconfig command can be used at this stage to
bring up a user interface showing all available options.
• make uImage
• make t4240sdp.dtb
The kernel binary (uImage) file and the device tree binary (e.g. t4240sdp.dtb) will be created within the arch/powerpc/boot
directory. These can then be flashed to the new platform and tested using the U-Boot build created in Porting U-Boot.
4 Revision history
This table summarizes revisions to this document.
Table 1. Revision history
Revision Date Description
0 10/2013 Initial public release.