lpc1788 transplant u-boot-2010.03 spi flash transplant

Publisher:VS821001Latest update time:2021-10-19 Source: eefocusKeywords:lpc1788 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Development environment:
MCU: NXP LPC1788
u-boot: u-boot-2010.03
SPI Flash: AT45DB321D

Since ATMEL's SPI flash has been implemented in u-boot, we don't need to write the driver for AT45DB321D. Now consider the SPI bus (the SPI driver in u-boot is in the driver/spi directory). In the driver/spi directory, you can see the SPI bus implementation of various chips, but lpc1788 does not have it. Don't move. You will see a soft_spi.c. Now you don't need to write the driver for the SPI bus. Just use soft SPI.

Add the following content to the lpc1788 configuration file:

#define CONFIG_CMD_SF //Add cmd_sf.c file compilation to implement the spi flash operation command sf in u-boot

#define CONFIG_SOFT_SPI //Add driver/spi/soft_spi.c file to compile and implement software spi bus

#define CONFIG_SPI_FLASH //Add driver/mtd/spi/spi_flash.c file to compile

#define CONFIG_SPI_FLASH_ATMEL //Add driver/mtd/spi/atmel.c file to compile and implement AT45 driver


#define CONFIG_SF_DEFAULT_MODE SPI_MODE_1

#define SPI_SCL spi_scl

#define SPI_SDA spi_sda

#define SPI_READ spi_read()

void spi_scl(int);

void spi_sda(int);

unsigned char spi_read(void);

#define SPI_DELAY udelay(2)


Add the following to the board/nxp/lpc1788/board.c file: 


void spi_scl(int bit)

{

struct lpc178x_gpio_dsc dsc;

dsc.port = 2;

dsc.pin = 22;

lpc178x_gpout_set(&dsc, bit);

}


void spi_sda(int bit)

{

struct lpc178x_gpio_dsc dsc;

dsc.port = 2;

dsc.pin = 27;

lpc178x_gpout_set(&dsc, bit);

}


unsigned char spi_read(void)

{

struct lpc178x_gpio_dsc dsc;

dsc.port = 2;

dsc.pin = 26;

return (unsigned char)lpc178x_gpin_get(&dsc);

}

int spi_cs_is_valid(unsigned int bus, unsigned int cs)

{

return bus == 0 && cs == 0;

SPI flash operation commands in u-boot:
1. Select SPI flash
    SF probe 0
2. Erase command
   SF erase 0 0x210 //Note that the erase length must be an integer multiple of 0x210
3. Read command
    SF read addr offset len
​​4. Write command
    SF write addr offset len

Keywords:lpc1788 Reference address:lpc1788 transplant u-boot-2010.03 spi flash transplant

Previous article:MicroPython LPC1788 porting
Next article:S3C2440 startup code analysis start.s

Recommended ReadingLatest update time:2024-11-24 10:20

Introduction to PIC32 SPI (Master/Slave Mode)
SPI serial synchronous interface (with clock pulse) The Serial Peripheral Interface (SPI) module is a synchronous serial interface used to communicate with external peripherals and other microcontroller devices. These peripherals can be serial EEPROMs, shift registers, display drivers, and analog-to-digital converter
[Microcontroller]
Introduction to PIC32 SPI (Master/Slave Mode)
Serial port control based on SPI device of single chip microcomputer
0 Introduction Serial Peripheral Interface (SPI) is a high-speed synchronous serial input/output port. In recent years, it has been widely used in the expansion of external devices such as shift registers, D/A converters, A/D converters, serial E2PROMs, LED display drivers, etc. The SPI interface can be sha
[Microcontroller]
Use of logic analyzer (UART, SPI)
First, a wiring diagram The top shows the UART wiring method, and the bottom shows the SPI wiring method. In fact, you can receive the signal in this way. If it is SPI, you need to set yourself as the host. UART does not have this problem.    The following is an explanation of the interface settings of the logic ana
[Test Measurement]
Use of logic analyzer (UART, SPI)
STM32 learning 013_SPI serial peripheral interface communication
SPI (Serial Periphreal Iterface) bus system is a synchronous serial peripheral interface that enables MCU to communicate and exchange information with various peripheral interfaces in a serial manner. SPI has three registers, control register SPCR, status register SPSR, data register SPDR, peripheral devices include F
[Microcontroller]
STM32 learning 013_SPI serial peripheral interface communication
STM8S hardware SPI driver 74HC595
Introduction: I have always been interested in the hardware SPI of STM8S, but I have never really used it. In the past, I used IO port simulation. This time, there happened to be a board with two 595-driven 8-bit LED digital tubes, so I tried it on it and recorded the process. Hardware wiring diagram: 595 is a dat
[Microcontroller]
STM8S hardware SPI driver 74HC595
Design of SPI interface based on PIC microcontroller and serial flash memory
Introduction PIC microcontrollers are widely used in industrial control, instrumentation, home appliances, communications and other fields due to their stable performance and wide variety. Although many models have integrated memory, in many cases it is difficult to meet the system's requirements for large-cap
[Microcontroller]
Design of SPI interface based on PIC microcontroller and serial flash memory

Recommended posts

Polar Fox received an investment of 100 billion!
Thisamountofmoney,Ireallywipedmyeyesthreetimes!!! IsaidIdon’tknowhowtoexpressitfornow,let’sjustwatchthenewstogether Recently,ZhangJianyong,chairmanofBAICGroup,saidatthedeliveryceremonyofthefirstbatch
okhxyyo Automotive Electronics
"Large Language Model: Principles and Engineering Practice" - Evaluation + Application + Engineering Practice
#1.EvaluationoflargelanguagemodelsMainevaluationdimensions:1.Languagemodelcapability2.Comprehensiveknowledgecapability1.Commonsensereasoning,suchasPIAQ,SIQA,ARC,etc.2.Readingcomprehension,suchasNaturalQuestions,Triv
rtyu789 Embedded System
What are the requirements for lightning protection filter circuit boards for frequency converters?
SmallpowerinvertersusuallyhaveavaristororvaristorconnectedtothegroundPEontheinputside.Thefunctionofthiscircuitistoshort-circuittheinvertertothegroundtodischargeenergywhenhighvoltagelightningisconnected. Inhi
乱世煮酒论天下 Motor Drive Control(Motor Control)
The application principle and connection method of AND gate circuit
IntroductiontoANDGateCircuits   Fromsmallelectronicwatchestocomplexelectroniccomputers,manyoftheircomponentsaremadeintointegratedcircuits,thatis,dozens,hundreds,oreventensofthousandsofelectroniccomponentsaremadeon
fish001 Analogue and Mixed Signal
【micropython】Bluetooth BLE routine
TheofficialBLEexampleisout https://github.com/micropython/micropython/tree/master/examples/bluetooth TemperatureSensor #Thisexampledemonstratesasimpletemperaturesensorperipheral. # #Thesensor'slocalvalueupdateseverysec
dcexpert MicroPython Open Source section
Please help explain the antenna's directivity diagram. Thank you
1.Pleaseexplainthispictureindetail. 2.Whatdoesthehorizontallinefrom18.3ontheleftto18.3ontherightmean? 3.Whydoesthedecibelvaluechangefrom18.3to0.3andthento-5.7fromtheoutsidetotheinside?Shouldn'tthedeci
一沙一世 MCU
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号