<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hant-TW">
	<id>https://tommy0804.ddns.net/index.php?action=history&amp;feed=atom&amp;title=Application_-_MX35LFxGE4AB%2C_SPI_NAND_Flash</id>
	<title>Application - MX35LFxGE4AB, SPI NAND Flash - 修訂紀錄</title>
	<link rel="self" type="application/atom+xml" href="https://tommy0804.ddns.net/index.php?action=history&amp;feed=atom&amp;title=Application_-_MX35LFxGE4AB%2C_SPI_NAND_Flash"/>
	<link rel="alternate" type="text/html" href="https://tommy0804.ddns.net/index.php?title=Application_-_MX35LFxGE4AB,_SPI_NAND_Flash&amp;action=history"/>
	<updated>2026-08-21T17:32:13Z</updated>
	<subtitle>本wiki上此頁面的修訂紀錄</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://tommy0804.ddns.net/index.php?title=Application_-_MX35LFxGE4AB,_SPI_NAND_Flash&amp;diff=515&amp;oldid=prev</id>
		<title>Tommy：​Refactor: add Category:Projects</title>
		<link rel="alternate" type="text/html" href="https://tommy0804.ddns.net/index.php?title=Application_-_MX35LFxGE4AB,_SPI_NAND_Flash&amp;diff=515&amp;oldid=prev"/>
		<updated>2026-08-21T05:17:41Z</updated>

		<summary type="html">&lt;p&gt;Refactor: add [[Category:Projects]]&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hant-TW&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上個修訂&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年8月21日 (五) 13:17的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l107&quot;&gt;第107行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第107行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Projects]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Tommy</name></author>
	</entry>
	<entry>
		<id>https://tommy0804.ddns.net/index.php?title=Application_-_MX35LFxGE4AB,_SPI_NAND_Flash&amp;diff=63&amp;oldid=prev</id>
		<title>Tommy：​已建立頁面，內容為 &quot;RPi2 with SPI NAND Flash(MX35LFxGE4AB)  == HW connection == &lt;pre&gt; PRi2         --  MX35LFxGE4AB VCC          --  VC…&quot;</title>
		<link rel="alternate" type="text/html" href="https://tommy0804.ddns.net/index.php?title=Application_-_MX35LFxGE4AB,_SPI_NAND_Flash&amp;diff=63&amp;oldid=prev"/>
		<updated>2018-08-23T02:20:51Z</updated>

		<summary type="html">&lt;p&gt;已建立頁面，內容為 &amp;quot;&lt;a href=&quot;/index.php/%E6%AA%94%E6%A1%88:Rpi2_with_spi_nand_flash.jpg&quot; title=&quot;檔案:Rpi2 with spi nand flash.jpg&quot;&gt;thumb|200px|RPi2 with SPI NAND Flash(MX35LFxGE4AB)&lt;/a&gt;  == HW connection == &amp;lt;pre&amp;gt; PRi2         --  MX35LFxGE4AB VCC          --  VC…&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新頁面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[File:rpi2_with_spi_nand_flash.jpg|thumb|200px|RPi2 with SPI NAND Flash(MX35LFxGE4AB)]]&lt;br /&gt;
&lt;br /&gt;
== HW connection ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PRi2         --  MX35LFxGE4AB&lt;br /&gt;
VCC          --  VCC(3.3V)&lt;br /&gt;
VCC          --  HOLD(3.3V)&lt;br /&gt;
GPIO19(MOSI) --  SI&lt;br /&gt;
GPIO21(MISO) --  SO&lt;br /&gt;
GPIO23(CLK)  --  SCLK&lt;br /&gt;
GPIO24(CS0)  --  CS&lt;br /&gt;
Gnd          --  Gnd&lt;br /&gt;
Gnd          --  WP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[File:read_devid_timing.jpg|thumb|200px|MX35LFxGE4AB read device ID timing]]&lt;br /&gt;
== Timing ==&lt;br /&gt;
[[File:MX35LFxGE4AB_cmd.jpg]]&lt;br /&gt;
== Hack libbcm2835 ==&lt;br /&gt;
*Add bcm2835_spi_transfernb_adv() in bcm2835.c&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* Writes an number of bytes to SPI and read an number of bytes from SPI*/&lt;br /&gt;
void bcm2835_spi_transfernb_adv(char* tbuf, char* rbuf, uint32_t tx_len, uint32_t rx_len)&lt;br /&gt;
{&lt;br /&gt;
    volatile uint32_t* paddr = bcm2835_spi0 + BCM2835_SPI0_CS/4;&lt;br /&gt;
    volatile uint32_t* fifo = bcm2835_spi0 + BCM2835_SPI0_FIFO/4;&lt;br /&gt;
    uint32_t TXCnt=0;&lt;br /&gt;
    uint32_t RXCnt=0;&lt;br /&gt;
&lt;br /&gt;
    /* This is Polled transfer as per section 10.6.1&lt;br /&gt;
    // BUG ALERT: what happens if we get interupted in this section, and someone else&lt;br /&gt;
    // accesses a different peripheral?&lt;br /&gt;
    */&lt;br /&gt;
&lt;br /&gt;
    /* Clear TX and RX fifos */&lt;br /&gt;
    bcm2835_peri_set_bits(paddr, BCM2835_SPI0_CS_CLEAR, BCM2835_SPI0_CS_CLEAR);&lt;br /&gt;
&lt;br /&gt;
    /* Set TA = 1 */&lt;br /&gt;
    bcm2835_peri_set_bits(paddr, BCM2835_SPI0_CS_TA, BCM2835_SPI0_CS_TA);&lt;br /&gt;
&lt;br /&gt;
    /* Use the FIFO&amp;#039;s to reduce the interbyte times */&lt;br /&gt;
&lt;br /&gt;
        /* TX fifo not full, so add some more bytes */&lt;br /&gt;
        while(TXCnt &amp;lt; len)&lt;br /&gt;
        while((BCM2835_SPI0_CS_TXD &amp;amp; bcm2835_peri_read(paddr)))&lt;br /&gt;
        {&lt;br /&gt;
           bcm2835_peri_write_nb(fifo, tbuf[TXCnt]);&lt;br /&gt;
           TXCnt++;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        /* read dummy */&lt;br /&gt;
        while(RXCnt &amp;lt; tx_len)&lt;br /&gt;
        while((BCM2835_SPI0_CS_RXD &amp;amp; bcm2835_peri_read(paddr)))&lt;br /&gt;
        {&lt;br /&gt;
           rbuf[RXCnt] = bcm2835_peri_read_nb(fifo);&lt;br /&gt;
           RXCnt++;&lt;br /&gt;
        }&lt;br /&gt;
        RXCnt = 0;&lt;br /&gt;
&lt;br /&gt;
        /* Rx fifo not empty, so get the next received bytes */&lt;br /&gt;
        while((BCM2835_SPI0_CS_RXD &amp;amp; bcm2835_peri_read(paddr)))&lt;br /&gt;
        {&lt;br /&gt;
           rbuf[RXCnt] = bcm2835_peri_read_nb(fifo);&lt;br /&gt;
           RXCnt++;&lt;br /&gt;
        }&lt;br /&gt;
    /* Wait for DONE to be set */&lt;br /&gt;
    while (!(bcm2835_peri_read_nb(paddr) &amp;amp; BCM2835_SPI0_CS_DONE))&lt;br /&gt;
        ;&lt;br /&gt;
&lt;br /&gt;
    /* Set TA = 0, and also set the barrier */&lt;br /&gt;
    bcm2835_peri_set_bits(paddr, 0, BCM2835_SPI0_CS_TA);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example code ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;bcm2835.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    int i, tx_len=2, rx_len=2;&lt;br /&gt;
      if (!bcm2835_init())&lt;br /&gt;
        return 1;&lt;br /&gt;
&lt;br /&gt;
    bcm2835_spi_begin();&lt;br /&gt;
    bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST);      // The default&lt;br /&gt;
    bcm2835_spi_setDataMode(BCM2835_SPI_MODE0);                   // The default&lt;br /&gt;
    bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_512); // The default&lt;br /&gt;
    bcm2835_spi_chipSelect(BCM2835_SPI_CS0);                      // The default&lt;br /&gt;
    bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW);      // the default&lt;br /&gt;
&lt;br /&gt;
    // Send a byte to the slave and simultaneously read a byte back from the slave&lt;br /&gt;
    // If you tie MISO to MOSI, you should read back what was sent&lt;br /&gt;
    usleep(500);&lt;br /&gt;
    uint8_t tx_data[]={0x9f, 0x44};&lt;br /&gt;
    static uint8_t rx_data[10]={0};&lt;br /&gt;
    bcm2835_spi_transfernb_adv(tx_data,rx_data, tx_len, rx_len);&lt;br /&gt;
&lt;br /&gt;
    for(i=0;i&amp;lt;rx_len;i++)&lt;br /&gt;
    printf(&amp;quot;Read from SPI: 0x%.2X \n&amp;quot;, rx_data[i]);&lt;br /&gt;
&lt;br /&gt;
    bcm2835_spi_end();&lt;br /&gt;
    bcm2835_close();&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tommy</name></author>
	</entry>
</feed>