Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

S5PV210-uboot porting-starting from Samsung's official uboot

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

11. 1. Preparation work before uboot transplantation

1. Samsung's transplanted uboot source code preparation

(1) Samsung's official development board for S5PV210 is SMDKV210, and the transplanted uboot is android_uboot_smdkv210.tar.bz2 in the resource download.

(2) this source code can not be downloaded online, it can not be downloaded at first, Samsung officials will not put these things on the official website to download. These things initially flowed out along with the official development board.

2. Preparation of SI

(1) when porting, the most important task is to look at the code, change the code, compile and run the test.

(2) the compiled code must be compiled in Linux (because to create symbolic links, it is not possible to configure uboot in the Windows shared folder), look at the code and change the code can be in Linux (vim) or in windows (SI).

(3) the correct method should be to extract a copy of the uboot source code in windows and a copy of the source code in Linux, which are exactly the same at the beginning, and then when we transplant, we look at the code in this part of windows, change the code, and then compile and burn it in this one in Linux. This practice requires a synchronization between the code in windows and the code in Linux, that is, after you have changed it in windows, copy the modified source code to the one in Linux to overwrite the same directory access file in Linux.

(4) the question is, how to synchronize the code in windows and Linux? Replicate in Linux through shared folders, or through some special tools sshsecureshell

11. 2. Convenient file transfer tool sshsecureshell

1. Install sshsecureshell client in windows

In the Ubuntu10.04 version, the command to restart the Nic is / etc/init.d/networking/ restart

In the Ubuntu14.04 version, the command to restart the network card is to find that it works in NAT mode when ifdown eth0 ifup eth0 campus network

11, 3, Ubuntu14.04 surfing the Internet and installing openssh

1, virtual machine Internet should pay attention to, you use the bridge to access the Internet, or NAT mode to access the Internet. The second thing to note is that the / etc/network/interfaces file in the network configuration file in Ubuntu configures the network card information, static IP or dhcp static IP. Third, if it is a bridging mode, you should pay attention to which network card is bridged to. Generally, the notebook has two network cards, a limited network card and a wireless network card. It doesn't matter if it's NAT mode.

The command to restart the network card in Ubuntu14.04 has changed, ifdown eth0 ifup eth0.

If you use the campus network, you can only access the Internet through NAT mode, because our computer to connect to the campus network dhcp server, will automatically assign our computer and ubunut an ip address, so / etc/network/interfaces the contents of this file should be set to dhcp automatic access to IP address, while the network center in the virtual machine access mode should also be set to automatically obtain ip address.

If you use wife, NAT mode is also good, and bridging mode is also good.

If you want the virtual machine Ping to connect to windows, first of all, the virtual machine should choose the bridging mode to connect to the wired network card. At the same time, because the windows has bug, the network port of widows must be connected to a place with Internet access ability by network cable. Later, change the / etc/network/interfaces file in Ubuntu to static static mode, so that the ip address will not change each time you boot. Set the ip address to be on the same network segment as our host windows. Then restart the network card ifdown eth0 ifup eth0, under the Ubuntu terminal, the ping host, if the ping is connected, it will be OK, and then your SSH communication will be fine. Tools like openssh can be used.

2. Set up the openssh environment

(1) ubuntu online

(2) install openssh-server. If the error message depends on the error, you can refer to: http://www.cnblogs.com/mliudong/p/4094519.html

(3) securecrt login

(4) sshsecretshell login is available for both.

If the ssh login is not available, modify / etc/ssh/sshd_config, refer to: http://blog.sina.com.cn/s/blog_5f435c130102v6pv.html. If / etc/init.d/ssh restart does not work after modification, you can use: ps-e | grep ssh, look at the process number of sshd, and then the process number of kill-9 kills the ssh process to achieve the purpose of restart, or restart the ubuntu system directly.

11, 4. Samsung's uboot transplant

0. First, directly use the uboot transplanted by Samsung, depending on what happens.

1. Copy the uboot to the source directory of Linux and decompress it.

2. Check the cross-compilation tool chain in makefile

3. Configuration, when we configure it, because Samsung's is smdkv210xxxx, let's try it first and configure it with smdkv210single_config first. With this, our configuration header file is in include/config/smdkv210single.h.

4. After the configuration is completed, compile the make directly, and then burn it to the SD card directly and try it under startup.

5. In uboot/sd_fusing/sd_fusing.sh, this script is used to burn. But sometimes the script needs to change something to see where the BL1 in the script is located and in which sector of the SD the size of the entire uboot is placed. How many sectors. It should be 1 and 49. You can find that formula in the source code of uboot and deduce it yourself. In the burning process to see the burning run of the printed information, analysis to see if the burn is successful, pay attention to whether the attribute digits of mkdbl1 and sd_fisk files are the same as our current Ubuntu digits.

6. After the burning is successful, insert it into the development board and try it.

11, 5, 1, code analysis, problem finding

1. After plugging into the development board to start, you will find a printed SD check error (this information is done in IROM). But the power self-lock is working.

Recall that when printing information through the uboot serial port, the earliest print was OK, which was printed at the time of initialization in lowlevel_init in start.S. The serial port does not output O, which means that the code is dead before it is executed to O. However, the power supply latch of the development board is successful, and the power supply latch is also in the lowlevel_init in start.S, so there is no problem in the first part of the code of power supply latch. Therefore, it can be preliminarily judged that there is a problem with this code after the power supply latch and before the serial port is printed out.

2. Then we need to analyze the code and establish the SI project under windows. It is found that it may be the problem of calling PMIC in lowlevel_init.S, because our development board does not have this power management chip, so when we call this function, I2C can not get an answer from the PMIC power management chip when we send information to PMIC, so the program dies here.

After blocking the function calling PMIC above, it is found that uboot is ready to start. But a lot of configuration information is problematic, a lot of functions should not be used, all have to be checked.

3, after changing the uboot version number that starts printing, the value of the macro corresponding to the version_string in the display_banner function called in the start_armboot function, that is, the value of the macro config _ IDENT_STRING is for "xxx". This macro is in the smdkv210single.h, which is the header file of the key configuration. After the modification, synchronize to the Linux source directory, and then in make distclean, make smdkv210single_config, make

4. Clock configuration

The clock code does not need to be modified. In lowlevel_init.S, because we Samsung use the same chip, we also use this chip, so most of us should focus on the development board-level migration. From the serial port printing information, we can also see that the clock configuration is indeed correct, if you want to change the clock configuration. You just need to open or close a macro in the smdkv210single.h header file. If you want to change the configuration of the clock, you don't have to change the code in the clock function, you just need to change the configuration of the macro in the configuration header file smdkv210single.h.

5. Change of DDR configuration information

(1) because the DDR size printed by Samsung's uboot runtime is 1G, but our DDR is 512m, so there is a problem, there is a problem with the relevant information of DDR. You can use the bdinfo command to see more information such as DDR while uboot is running. From the information printed by the bdinfo command, it can be seen that the starting address of DDR is configured by Samsung to 0X20000000 and the size of 0X40000000ddr is configured to 0X20000000 (512m large).

(2) We use the md command and the mw command to read the contents of DDR's memory and write to memory, respectively, and find that DDR is available, so it shows that the initialization of DDR is successful, but the configuration is incorrect. When we visit the 0X30000000 address, we find that the situation of access is the same as that of 0X20000000, which shows that our DDR itself is not 512m in size, only 256m in size. So why is it that accessing 0X30000000 is the same as accessing 0X20000000 memory address? it may be some feature of memory itself, or it may be implemented in code.

6. DDR address is configured separately.

(1) Target, configure the starting address of DDR port 0 as 0X30000000, and the address that starts with 30000000 can be connected with the 40000000 address of the second DDR of bank1 on our board. Because the size on our board is 256MB.

(2) DDR initialization code in lowlevel_init.S, initialization code does not need us to change, we only need to change the macro configuration in include/configs/xxx.h.

(3) the setting of DDR-related parameters should be combined with the data manual of our development board.

Change # define DMC0_MEMCONFIG_0 0x20E01323 in the configuration header file to # define DMC0_MEMCONFIG_0 0x30E01323

In this way, the value written to that DMC0CONTRL register in the future will change, the value in the register will change, and the corresponding hardware will change, and the address will really be mapped to the address at the beginning of 3, but the hardware has changed, but the configuration of the software has not changed, so we have to change the base address of the macro # define MEMORY_BASE_ADDRESS 0x20000000 memory in the configuration file to 0X30000000, which is made up of the software frame. We tell uboot where the starting address of the memory starts.

(4) modify the virtual address mapping table accordingly.

MMU is enabled in uboot to do segment mapping of memory, and there is a memory mapping table.

(5) how to find this virtual address mapping table?

Now look for _ mmu_table_base in start.S:

.word mmu_table

Find the symbol related to mmu_table, find mmu_table at the place where you go to index mmu_table in SI, and finally find it in lowlevel_init.s.

What do you think?

.set _ _ base,0

/ / Access for iRAM

.rept 0x100

FL_SECTION_ENTRY _ _ base,3,0,0,0

.set _ _ base,__base+1

.endr

It means that from the beginning of address 0 to the place of 0X10000000 address, the space of 256m is the same.

.rept 0x200-0x100

.word 0x00000000

.endr

It means 0x20000000-0x10000000. This address is mapped to a zero address and should not be accessible.

.set _ _ base,0x200

/ / should be accessed

.rept 0x600-0x200

FL_SECTION_ENTRY _ _ base,3,0,1,1

.set _ _ base,__base+1

.endr

It means that the address range at the beginning of 0x200 is mapped to 0x600 to 0x200, and the starting address is mapped as is.

.rept 0x800-0x600

.word 0x00000000

.endr

It means that 0x8000-0x600 addresses are also inaccessible.

Set _ _ base,0x200

/ / 256MB for SDRAM with cacheable

.rept 0xD00-0xC00

FL_SECTION_ENTRY _ _ base,3,0,1,1

.set _ _ base,__base+1

.endr

It means that the address at the beginning of 0x200 is mapped to the range from 0XC00 to 0XD00, with a total of 256m

(6) therefore, in our virtual address mapping table, we should map the C0000000-D0000000 address space to the 256MB address of 30000000-40000000.

The way is to modify this

Set _ _ base,0x300

/ / 256MB for SDRAM with cacheable

.rept 0xD00-0xC00

FL_SECTION_ENTRY _ _ base,3,0,1,1

.set _ _ base,__base+1

.endr

(7) after the modification, carefully check whether the configuration of the memory macro in the configuration header file is correct, mainly to see if the address is changed by me.

(8) run, found that only printed out the OK, after analysis, found that the problem is DMC0_MEMCONFIG_0, change the value of this macro to 0X30F01323, and then in the compilation burn, run, found a good part of the. But the section printed by the SD card will not run.

(9) after analysis, it is a problem in the mapping function from virtual address to physical address. Change-0x20000000 to-0x30000000, in uboot/board/samsung/smdkc110/smdkc110.c.

(10) solution to the problem of iNand driver

@ 1: first locate the problem from the phenomenon. Will print out the error message, find the keyword search in the SI, find the place of the problem, look at the context of the current location, to understand what is the cause, and finally found that the version number read from the extension register of the mmc device is greater than the version number given in our code. Our first solution is to change from greater than 5 to greater than 8, giving a larger version number.

@ 2: there is another thing, that is, in Samsung's uboot, the initialization print is mmc channel 0, that is, inand. If we change this device number to 1, we may send the external SD card to read the SD card version number. The inand version is higher than the SD card version, although the two are very similar, so changing this channel may also solve the problem. These are the parameters passed when initializing the mmc device.

(11) modify the serial number output to the console from Samsung's default serial port 2 to serial port 0

@ 1: you just need to change the macro on the serial port in smdkv210single.h. The code for initializing the serial port is in lowlevel_init.S, and the binding to the standard input and output is in seriver.c. The total macro definition determines which serial port to initialize is in smdkv110.h

(12) to modify the configuration information of the network, you can also modify it in the macro about the network configuration in smdkv210single.h.

(13) when our uboot starts to run, if your mmc device is 0 and you use the inand on the board, your environment variable starts with the value of the environment variable included in uboot, but after you change it, if your mmc device is 0 in saveenv, it will be saved to the device corresponding to channel 0 of your mmc device, and our board corresponds to inand. So it is saved to inand, not to the SD card channel 2 corresponding to your mmc device channel 1, our SD card.

(14) so if we want to destroy the value of the environment variable in inand, and want to use the value of the environment variable included in the uboot source code, we need to destroy the environment variable in inand that was saved from the environment variable partition in DDR to the environment variable partition in inand. The destruction method is to use mmc writer 0 30000000 1 sector 32 because my environment variable is saved in the 17th sector with a partition size of 32 sectors. It means that the initial environment variable in the 0x30000000 in memory is partitioned to the size of the entire environment variable partition, all written as 0, and then saved to the device corresponding to mmc device channel 0. So at this time, the value of the corresponding environment variable partition in the mmc device is incorrect. When checking in the future, you will find that there are no environment variables available in this device, so you will use the value of the environment variable included in the uboot source code when using it.

(15) Transplant 1 driven by network card

@ 1:srom is sram/rom, which is a general term. The srom controller controller inside SOC is a kind of bus interface provided by SOC to connect sram/rom. If our SOC wants to connect a sram or this rom memory chip externally, or some chips disguised as srom interface (such as network card chip, DM9000), we need to use this srom controller of SOC to connect and expand externally. The advantage of bus access is that it can be accessed directly by address, and there is no need to issue commands or timing to access. When the network card chip is connected to the soc through the srom interface, when our host soc accesses the registers inside the network card chip, we can directly ask the network card chip by addressing through the bus. On our board, the network card chip is connected to a bank in the srom of soc.

@ 2: there are many registers inside the network card chip. Since the network card chip and our soc are linked through the srom interface, we can access the network card chip by bus addressing. Because the registers inside the network card chip are addressed from zero relative to the network card, our soc wants to access the registers inside the network card chip through the address. It is necessary to use a relative address to access the network card chip, which is the starting address + the address of the register of the network card chip itself.

The starting address refers to the address of the bank where the network card chip is connected to the bank of the srom of soc. That is, when using soc to access the internal registers of the network card chip, it is necessary to use the base address of the network card chip connected to the srom bank plus an internal address of the network card chip. It is equivalent to using the base address plus offset to access, which is easy to understand.

@ 3: if the host soc wants to access the Internet, it has to operate the internal register of the network card chip and the buffer (can be understood as memory) inside the network card chip to access the Internet, so the host soc uses the network card chip to access the Internet indirectly.

@ 4: therefore, after connecting to the network, if the host wants to receive data through the network, the hardware of the network card chip will automatically put the data from the network into its own internal buffer. Our host soc only needs to read the data in the buffer inside the network card chip, if our host soc wants to send data over the network. Just throw the data we want to send into the buffer inside the network card chip, and the network card chip hardware will automatically send the data from its own buffer through the network.

@ 5: by looking at the schematic diagram of our development board, we can see that our network card chip has 16 data lines connected to our soc, so it shows the 16bit interface mode used by our soc srom controller.

@ 6: there are eight wires in the network cable, but only four wires are useful, and the other four wires are related to anti-jamming. Of these four useful wires, two hair and two receive. Because the differential signal transmitted over the network cable. The transmission distance of differential signal is relatively long, and the anti-jamming ability is also strong.

@ 7: the Nic chip has a CS pin: chip selcte, chip selection signal, which means that the host sends a valid signal to the CS, then our slave chip works, and the host sends an invalid signal to the CS, then the slave chip does not work. This pin will receive the chip selection signal in the srom bank in our soc. Each of our srom bank has a chip selection signal terminal CSn. It can be seen from the schematic that the chip selection signal of our DM9000 is terminated on the srom bank1 in the soc. Because it is cs1, the bus base address of our DM9000 relative to our host soc is the base address (0x88000000) of the sromc bank1 in our host soc.

@ 8:DM9000 's CMD pin is connected to soc's addr2 pin, which is also important. DM9000 in order to reduce the number of pins on the chip, the data line and address line are reused. DATA0-DATA15 these 16 lines are sometimes used as data lines to transmit data and sometimes address lines to transmit addresses. When the CMD pin of the DM9000 receives a high level, it means that the data line is reused at this time, and the address is transmitted when the CMD is low. It is called index in DM9000, which means the index address relative to the address of the host. I knew this when I checked DM9000's data manual.

@ 9: the level changes on these pins are all done by the sromc controller in our soc. When configuring the value of the register, we only need to fully take into account the connection of the hardware circuit and configure the correct value for our corresponding register.

(15) Transplant 2 driven by network card

There are many network card chip drivers in the @ 1:uboot program. Under the uboot/drivers/net folder, there are many drivers for different network card chips, most of which come from the Linux kernel. Our network card chip is DM9000, so we should look at the dm9000.c and dm9000.h under this net folder.

We don't have to look at these two files now, because we will get more and more confused, because we haven't started to learn about drivers, and we are not very familiar with the framework of Linux kernel to network drivers.

@ 2: we don't have to look at the code of the DM9000 driver for this network card, because the driver is well done, the data and code are separated, here is only the driver code, the data is determined by the connection in our development board, and the data is provided by a certain data structure, so the driver is portable, so we don't have to move the code here, what we want to move is the data. The data is in the smdkc210single.h macros about the configuration of the network card.

@ 3: the key to the migration of network cards: initialization. In the second phase of uboot, there is a board_init in the function pointer array in start_armboot. In the function pointed to by this function pointer, there is the initialization of the network card. This initialization is the key to the migration of the network card. As long as this initialization initializes the network card chip, the network card chip can work (meaning that the network card drivers dm9000x.c and dm9000x.h depend on the initialization here.)

The function @ 4:dm9000_pre_init is the key to porting the network card chip. This initialization function is related to the DM9000 hardware connection on our development board, which must be analyzed in combination with the schematic diagram of our development board, and then decide how to program this function, so we have to modify this initialization function according to the hardware connection of our development board to make our network card chip work.

The macro @ 5:DM9000_16BIT_DATA is used to indicate that DM9000 works in 16-bit mode, and the DM9000 on our development board also works in 16-bit mode.

@ 6:SROM_BW_REG, from Samsung's source code and the corresponding data manual, we can see that Samsung connects the network card chip DM9000 to bank5 in sromc in SOC, while our development board DM9000 network card chip is connected to bank1 in srom in SOC, so according to the manual we have to operate this registered bit4-bit7, where the four bit bits represent bank1.

@ 7: we work in 16-bit mode, so the bit4 in this SROM_BW_REG register is 1. Because our data lines are aligned one by one, the bit5 is 1, and the other two bits are configured according to the mode, according to the experience of others. If it is not necessary, you do not have to figure out these two bits.

@ 8: so according to the data manual and the actual situation, we should modify the register with three SROM_BC5_REG SROM_BW_REG MP01CON_REG, and the last one is in GPIO.

@ 8: configuration of base address: after modifying the initialization function above, because the driver is divided into two parts: code and data, the code does not need to be moved, so we also need to modify some data, in the configuration header file, those macros about the network card.

CONFIG_DM9000_BASE is the address of the DM9000 network card mapped to the SOC address space through srom bank, because we are using bank1 in srom, so according to the memory diagram in the data manual, we can know that our base address should be 0X88000000.

# define DM9000_IO (CONFIG_DM9000_BASE) this means visiting the base address of our network card chip IO, looking for the internal registers of the chip, etc.

# define DM9000_DATA (CONFIG_DM9000_BASE+4) and this macro, we want to change it to 4, this macro is to determine that what we are currently sending is data. When we want to send data, we know from the schematic that our CMD pin is connected to ADDR2, that is, the second address line is connected to 100, so the second address line is kept high, so it means to reuse the transmitted data.

@ 9: after changing these, the network card actually cannot work directly. It is necessary to modify the CONFIG_DM9000_BASE to change the 0X88000000 of this address to 0X88000300. Why change it to this? guess it may be because the network card chip has an offset because of the version problem. In the past, you can use this 0X88000000 address, that is, the srom bank address, to directly find the starting address of those registers inside the DM9000 itself. However, probably due to version problems, the address of the register of DM9000 itself now starts at 300H.

@ 10: the kernel cannot start, so change the serial port to serial port 2, because the Linux kernel provided by Samsung uses serial port 2. See if there are these two macros in the configuration header file.

# define CONFIG_SETUP_MEMORY_TAGS

# define CONFIG_CMDLINE_TAG

These two macros make sure that the parameters are passed

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report