[Linux bottom layer] U-boot compilation and transplantation

Publisher:柳絮轻风Latest update time:2022-07-14 Source: csdnKeywords:Linux Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

System version: Ubuntu18.04-64


Compiler version: gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1)


uboot version: 2018.07-linux4sam_6.0


Board model: at91sama5d3x-xplained


MCU model: sama5d36


1. The uboot directory is as follows:

picture

2. There is an official default configuration under the configs/ folder


   # To put environment variables in nandflash (default):

   sama5d3_xplained_nandflash_defconfig

   # To put environment variables in SD/MMC card:

   sama5d3_xplained_mmc_defconfig

Compile for SAMA5D3-Xplained board:


Select nandflash boot

make sama5d3_xplained_nandflash_defconfig

make


3. The uboot downloaded from the official website can basically run, and the printed information can be seen through the serial port. There may be no problem with the DDR2 and NAND Flash drivers and they can be used normally. The network driver and LED driver designed by the manufacturer are adapted and cut according to the model;


Burn the compiled file u-boot.bin into it, and you can see the information printed by the serial port


U-Boot 2018.07-linux4sam_6.0 (Oct 11 2019 - 23:57:20 -0700)


CPU: SAMA5D36

Crystal frequency:       12 MHz

CPU clock        :      528 MHz

Master clock     :      132 MHz

DRAM:  256 MiB

NAND:  256 MiB

MMC:   Atmel mci: 0, Atmel mci: 1

Loading Environment from NAND... OK

In:    serial@ffffee00

Out:   serial@ffffee00

Err:   serial@ffffee00

Netjack:   macb_eth_probe phy-mode=mii,devname=ethernet@f0028000

eth0: ethernet@f0028000 [PRIME]macb_eth_probe phy-mode=rmii,devname=ethernet@f802c000

, eth1: ethernet@f802c000

Hit any key to stop autoboot:  0 

=> at

arch=arm

baudrate=115200

board=sama5d3_xplained

board_name=sama5d3_xplained

bootargs=console=ttyS0,115200 earlyprintk mtdparts=atmel_nand:256k(bootstrap)ro,768k(uboot)ro,256K(env_redundant),256k(env),512k(dtb),6M(kernel)ro,-(rootfs) rootfstype=ubifs ubi.mtd=6 root=ubi0:rootfs

bootcmd=tftp 0x21000000 at91-sama5d3_xplained.dtb;tftp 0x22000000 zImage;bootz 0x22000000 - 0x21000000

bootdelay=3

cpu=armv7

eth1addr=AA:AB:C1:D2:E6:C6

ethact=ethernet@f0028000

ethaddr=EE:AB:C1:D2:E6:C6

ethprime=ethernet@f0028000

fdtcontroladdr=2fb16b08

gatewayip=192.168.1.1

ipaddr=192.168.1.100

ipaddr1=192.168.2.100

netmask=255.255.255.0

serverip=192.168.1.108

soc=at91

stderr=serial@ffffee00

stdin=serial@ffffee00

stdout=serial@ffffee00

vendor=atmel


Environment size: 778/131067 bytes

=> 


4. Key Document Description


scripts/config_whitelist.txt List of all macro definitions


SAMA5D3_XPLAINED BOARD


M: Bo Shen


S: Maintained


F: board/atmel/sama5d3_xplained/sama5d3_xplained.c


F: include/configs/sama5d3_xplained.h


F: configs/sama5d3_xplained_mmc_defconfig


F: configs/sama5d3_xplained_nandflash_defconfig


arch/arm/mach-at91/spl_at91.c


arch/arm/mach-at91/include/mach/at91_common.h //public function declaration header file


sama5d3.h //CPU base address


sama5_boot.h //Boot mode


include/configs at91-sama5_common.h //CPU series common configuration


5. Cropped file list


//============================================


Determine the file of uboot compilation configuration, and the compilation option macro definition is found in these files


include/configs/at91-sama5_common.h


include/configs/sama5d3_xplained.h


configs/sama5d3_xplained_nandflash_defconfig


//


CONFIG_DM_ETH //Support device tree, network configuration is read from the device tree


This version of uboot supports the device tree function, making uboot lighter and no longer bloated and clumsy.


6. Modify the device tree and change the MAC interface mode of the network


arch/arm/dts


Makefile


dtb-$(CONFIG_TARGET_SAMA5D3_XPLAINED) +=


at91-sama5d3_xplained.dtb


macb0: ethernet@f0028000 {


phy-mode = "mii"; //Change the PHY interface mode


#address-cells = <1>;


#size-cells = <0>;


status = "okay";




ethernet-phy@7 {


reg = <0x7>;


};


};


7. Since uboot is a naked running program, it must have a main function. Start with the main function to see how to initialize peripherals, GPIO, network card, etc.


void board_init_r(gd_t *new_gd, ulong dest_addr)

{

    /*

     * Set up the new global data pointer. So far only x86 does this

     * here.

     * TODO(sjg@chromium.org): Consider doing this for all archs, or

     * dropping the new_gd parameter.

     */

#if CONFIG_IS_ENABLED(X86_64)

    arch_setup_gd(new_gd);

#endif



#ifdef CONFIG_NEEDS_MANUAL_RELOC

    int i;

#endif


#if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)

    gd = new_gd;

#endif

    gd->flags &= ~GD_FLG_LOG_READY;


#ifdef CONFIG_NEEDS_MANUAL_RELOC

    for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)

        init_sequence_r[i] += gd->reloc_off;

#endif

//All initialization depends on this array



    if (initcall_run_list(init_sequence_r))

        hang();



    /* NOTREACHED - run_main_loop() does not return */

    hang();

}


//Execute functions sequentially in the structure


//Execute functions sequentially in the structure

//Excerpt part of the code, there are many devices in the array, initialize


static init_fnc_t init_sequence_r[] = {



/* PPC has a udelay(20) here dating from 2002. Why? */

#ifdef CONFIG_CMD_NET

    initr_ethaddr, // Network device information initialization     

#endif



#ifdef CONFIG_CMD_NET

    INIT_FUNC_WATCHDOG_RESET  

    initr_net, //Initialize network devices, uboot prints the read network card information

#endif


PHY initialization process

eth_initialize(); //First level initialization of network equipment

eth_common_init(); //Second level initialization of network equipment

miiphy_init(); //Network device third level initialization

phy_init();//

phy_davicom_init(); //Network device fourth level initialization

phy_micrel_ksz8xxx_init();//

MDIO mii MAC+PHY=network card chip, the first 5 registers are the same for all PHY chips;


8. Set the board-level hardware clock configuration


arch/arm/mach-at91/spl_atmel.c


void board_init_f(head dummy)

{

    int ret;


    switch_to_main_crystal_osc();


#ifdef CONFIG_SAMA5D2

    configure_2nd_sram_as_l2_cache();

#endif


#if !defined(CONFIG_AT91SAM9_WATCHDOG)

    /* disable watchdog */

    at91_disable_wdt();

#endif


    /* PMC configuration */

    at91_pmc_init();


    at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);


    matrix_init();


    redirect_int_from_saic_to_aic();


    timer_init();


    board_early_init_f();


    mem_init();


    ret = spl_init();

    if (ret) {

        debug("spl_init() failed: %dn", ret);

        hang();

    }


    preloader_console_init();


9. CPU related settings


arch/arm/cpu/armv7


10. Board level information


board/atmel/sama5d3_xplained/sama5d3_xplained.c


int board_init(void)

{

    /* adress of boot parameters */

    gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;



#ifdef CONFIG_NAND_ATMEL

    sama5d3_xplained_nand_hw_init(); //Nand Flash initialization

#endif

#ifdef CONFIG_CMD_USB

    sama5d3_xplained_usb_hw_init(); //USB initialization

#endif

#ifdef CONFIG_GENERIC_ATMEL_MCI

    sama5d3_xplained_mci0_hw_init(); //EMMC initialization

#endif


    return 0;

}


11. The RESET pin of PHY 9031 is controlled by the CPU, and the power supply and RESET of PHY 8081 are controlled by the CPU. To ensure the timing, after the system is powered on, the RST pin of the PHY chip is pulled high first;


Control GPIO operation under uboot


board/atmel/sama5d3_xplained/sama5d3_xplained.c


Add code


tatic void sama5d3_xplained_phy_hw_init(void)

{

    //GPIO register configuration, output internal pull-up function;

    at91_set_pio_periph(AT91_PIO_PORTE, 9, 1);      /* GPIO output up*/

    at91_set_pio_periph(AT91_PIO_PORTC, 18, 1);         /* GPIO output up*/

    at91_set_pio_periph(AT91_PIO_PORTC, 31, 1);         /* GPIO output up*/

    at91_set_pio_periph(AT91_PIO_PORTB, 12, 1);         /* LED GPIO output up*/


        //Output corresponding level

    at91_set_pio_output(AT91_PIO_PORTE, 9, 1);      //micrel ksz9031 reset gpio

    at91_set_pio_output(AT91_PIO_PORTC, 18, 0);     //micrel ksz8081 power gpio

    at91_set_pio_output(AT91_PIO_PORTC, 31, 1);     //micrel ksz8081 reset gpio



    at91_set_pio_output(AT91_PIO_PORTB, 12, 0);     //Board led on

}


int board_init(void)

{

    /* adress of boot parameters */

    gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;



#ifdef CONFIG_NAND_ATMEL

    sama5d3_xplained_nand_hw_init();

#endif

#ifdef CONFIG_CMD_USB

    sama5d3_xplained_usb_hw_init();

#endif

#ifdef CONFIG_GENERIC_ATMEL_MCI

    sama5d3_xplained_mci0_hw_init();

#endif



    // add by for Jack phy init gpio

        //Add the GPIO initialization function to the initialization function of the development board and call

    sama5d3_xplained_phy_hw_init();



    return 0;

}


12. The official website uboot download link is:


https://www.linux4sam.org/bin/view/Linux4SAM/U-Boot

Keywords:Linux Reference address:[Linux bottom layer] U-boot compilation and transplantation

Previous article:[Linux bottom layer] U-boot debugging command usage tips
Next article:[Linux bottom layer] bootstrap transplantation, cutting and compilation

Recommended ReadingLatest update time:2024-11-16 15:55

Design of matrix keyboard based on ARM and its linux driver implementation
1. Introduction ARM microprocessors have been widely used in industrial control, consumer electronics, communication systems and other fields. Matrix keyboard is a commonly used keyboard form, which designs the keys into M rows and N columns, so that a total of M+N signal lines are required, but M×N keys can be driven
[Power Management]
Design of matrix keyboard based on ARM and its linux driver implementation
Ubuntu installs arm-linux-gcc compiler
/**********************************************************************************  * Ubuntu installs arm-linux-gcc compiler  * illustrate:  * Directly install the arm-linux-gcc compiler in Ubuntu to save the trouble of configuring those environments.  *  * 2017-3-21 Zeng Jianfeng, Pingshan Village, Nanshan, Shenzhen
[Microcontroller]
OK6410A Development Board (VIII) 102 linux-5.11 OK6410A One of the four uses of mmap provided by glibc
OK6410A Development Board (VIII) 102 linux-5.11 OK6410A One of the four uses of mmap provided by glibc Shared anonymous mapping two ways When using the parameter fd = -1 and flags = MAP_ANONYMOUS | MAP_SHARED, the created mmap mapping is a shared anonymous mapping. Shared anonymous mappings allow related processes
[Microcontroller]
Telemetry data network acquisition based on FPGA and ARM
The Ethernet interface has fast communication speed, reliable transmission, and is easy to use and configure. For code rates below 20 Mb/s, a 100 Mb/s network card can forward packets without packet loss. The use of TCP packet format can also make the device miniaturized and facilitate data forwarding. Therefore, it is
[Microcontroller]
Telemetry data network acquisition based on FPGA and ARM
Detailed explanation of adding LED driver and test program to Linux
We have all learned about 51 MCU in college. 51 is also the first processor we come into contact with in embedded systems. Its structure is not complicated. When we study 51 MCU, we can clearly describe the resources in 51 MCU, accumulator A and B, program status register, program counter, 6 interrupt sources, r0-r7 wo
[Microcontroller]
Detailed explanation of adding LED driver and test program to Linux
LINUX system interrupt processing structure and interrupt function implementation
Interrupt system process analysis: asm_do_IRQ(unsigned int irq, struct pt_regs *regs)      handle_IRQ(irq, regs); generic_handle_irq(irq);/*Garmen: perform general interrupt processing*/       struct irq_desc *desc = irq_to_desc(irq); /*#define irq_to_desc(irq) (&irq_desc ) Garmen: It is a global array item with irq
[Microcontroller]
LINUX system interrupt processing structure and interrupt function implementation
Implementation of LCD backlight adjustment and driver based on embedded Linux
0 Introduction In handheld devices, liquid crystal displays are increasingly being used. Since LCDs cannot emit light by themselves, they require a strong light source to provide backlight for them in order to clearly display information. Such light sources are very power-hungry, and the power consumption of liquid cr
[Microcontroller]
Implementation of LCD backlight adjustment and driver based on embedded Linux
Analysis and Design of BootLoader for ARM-Linux Embedded System
0 Introduction The boot loader of an embedded system is composed of the Boot Loader and the Boot code (optional) solidified in the firmware. Its role and function are like a ROM chip program BIOS (basic input output system) solidified on the motherboard of the computer. However, it is generally not configured wi
[Industrial Control]
Analysis and Design of BootLoader for ARM-Linux Embedded System
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号