USB-HOST driver design based on UClinux2.4.x+S3C4510B development platform

Publisher:北极星小鹏Latest update time:2023-02-03 Source: elecfansKeywords:S3C4510B Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Today, USB devices have entered every aspect of our work and life, and they have brought us a lot of convenience. Therefore, having USB functionality has become a basic requirement for many systems now. The S3C4510B developed by Samsung for arm7 is a chip that is currently used very frequently in the industry. Its powerful functions make it the terminator of many traditional 51 and other series of microcontroller development ideas. By transplanting the uClinux operating system to it, it is like adding wings to a tiger. The stable Linux system and the powerful S3C4510B hardware are closely combined to form a powerful development platform and bring new development concepts. This article uses the EMBEST S3C4510B development board developed by Shenzhen Embest Company. It introduces the expansion of USB-HOST based on the SL811HS (HOST) developed by CYPRESS Company on such a powerful platform; it demonstrates the differences between traditional system development based on this platform. Brand new ideas while further enriching the functionality of the system.


1 Expansion board hardware circuit design

When Embest's development board based on uClinux2.4.x+S3C4510B is implemented, the program is placed in ROM/ARAM/FLASH group 0 whose base address is controlled by ROMCON0; when the system starts, the program placed in this group is copied to SDRAM0 Group. This article assigns the address of SL811HS to ROM/ARAM/Flash group 1, controls its base address by ROMCON1, and uses external interrupt 0 to receive the interrupt signal of SL811HS. Since SL811HS does not separate the data and address buses, D0~D7 will be time-shared and multiplexed. This is controlled by the A0 line of SL811HS; when A0 is low, address information is transmitted on D0~D7; when A0 is high, data information is transmitted on D0~D7. Therefore, ADDR10 of S3C4510B is used to control A0, thereby separating the data of SL811HS from the internal address.


2 Kernel modification

To configure SL811HS to Bank1 controlled by ROMCON1, the main application is to make changes to the following two files.

①…armnommusnds100.h

Will Line216

#define DSR1 (0<<2)

Change to:

#define DSR1 (1<<2)

This will define Bank1 as 8-bit byte mode.

Change Line 249

#define rROMCON1 0x0

Change to:

#define ROM_BASE1_R ((0x00200000>>16)<<10)

#define ROM_NEXT1_R (0x00300000>>16)<<20)

#definerROMCON1_R(ROM_NEXT1_R|ROM_BASE1_R|tACC0|tPA0|PMC0)

#define rROMCON0_B

(ROM_NEXT1_B|ROM_BASE1_tACC0|tPA0|PMC0)

Here ROM_x_R refers to the value after the system is reset and is also the value when the system is started. ROM_x_B means that after the system is started, the program must be copied to SDRAM for running, so the original FLASH-BANK0 can no longer use address 0, but SDRAM0 should use address 0. This ROM_x_B is the new address of the corresponding Flash group when the program is running in SDRAM.

②….s

Will line 162

ldr r1,=0x200000

Change to ldr r1,=0x300000

This tells the system how much space to copy from Flash storage to SDRAM.

Will line 259

.word rROMCON1

Change to .word rROMCON1_R

Will line 272

.word rROMCON1

Change to .word rROMCON1_B

In this way, the configuration values ​​of rROMCON1 in reset and boot modes are saved in different registers. However, when the program is running, it is not determined by this value, but by rROMCON1, so the program must assign one of the values ​​​​in these two modes to rROMCON1 at the appropriate time for system use.


3 Hardware circuit detection

After the above two steps, the SL811HS is configured to ROM/ARAM/Flash group 1 controlled by rROMCON1. ​​Its data port address is 0x1200400 and the address port address is 0x1200000. The interrupt is external interrupt 0. You can use the following small program to test whether the internal registers of SL811HS can be read and written correctly.

/***filename:test811.c****/

int main(void){

unsigned char *addr,*data,I,j,x,val;

int k,m;

addr=0x1200000;

data=0x1200400;

for(i=0x10;i<0x100;i++)

{mywriteb(i,addr);

mywriteb(i,data);}

printf("test now!");

for(i=0x10;i<0x100;i++)

{mywriteb(i,addr);

val=myreadb(data);

if(val!=i)

printf("error in test address %d",i);}

}

char myreadb(int addr)

{ unsigned char *addr1;

unsigned char data;

addr1=addr;

data=*addr1;

return(data);}

void mywritten(unsigned char data,int addr)

{ unsigned char*addr1;

addr1=addr;

*addr=data;}

Compile the program as an application together with the kernel. For specific methods, please refer to the file/documentation/adding-user-apps-howto.txt;

After the kernel is compiled and passed, it is downloaded to the development board, then the system is started, and the host computer uses Hyper Terminal to monitor. After the system boots, run the application. If there are no errors, the hardware is connected correctly.


4 driver transplantation

The USB-HOST (SL811HS) driver does not need to be written separately. There are ready-made codes in the Linux kernel for reference, or you can download them from the CYPRESS website. However, this driver is designed for sal100, so corresponding changes must be made before it can be used on our S3C4510B system.

The changes here are mainly modifications to the file hc_s1811.c. This file is located in…/driver/usb/

First, you need to modify the hardware address, because the data and address port addresses of SL811HS are 0x1200400 and 0x1200000 respectively. Modify lines 106 and 107

static int base_addr=0xd3800000;

static int data_reg_addr=0xd3810000;

is static int base_addr=0x1200000;

static int data_reg_addr=0x1200400;

Modify lines 130 and 131

#define SL811HC_IOPORT0 0xa000000

for #define SL811HC_IOPORT0 0x1200000

#define SL811HC_IODATAPORT0 0x120040

Since the interrupt of SL811HS is assigned as interrupt 0, the line 108 should be modified.

static int irq=34;

is static int irq=0;

Modify line 139

#define Sl811HC_IRQ0 27

for #define SL811HC_IRQ0 0

And the function void init_irq(void) needs to be rewritten

for void init_irq(void)

{

INT_ENABLE(irq);

IntPend=0x1FFFFF;

IntMode=INT_MODE_IRQ;

}


Then start kernel compilation. When configuring the kernel, select the SL811HS item, burn the successfully compiled kernel to the board, and then start it. Using the host computer's HyperTerminal monitoring, you can see that the system has allocated resources such as addresses and interrupts to SL811HS. At this point, the extension of USB-HOST is completed.


Conclusion

The wide application of USB devices makes many systems consider extending it to meet the needs of customers. This article introduces the detailed steps of expanding SL811HS (host) on Embest's EMBEST3SC4510B development board, and gives a self-written test program, which provides a simple and powerful tool for hardware detection and porting USB for further development. Device drivers provide the hardware platform.


Keywords:S3C4510B Reference address:USB-HOST driver design based on UClinux2.4.x+S3C4510B development platform

Previous article:Design of embedded CCD image data acquisition system based on USB bus
Next article:Implementing CAN bus intelligent node in μCOS-II on S3C44B0

Latest Microcontroller Articles
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号