SDRAM Hardware & Firmware Tutorial (STM32) - Phil's Lab #80

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ก.ย. 2024

ความคิดเห็น • 78

  • @DjordjeNedic
    @DjordjeNedic ปีที่แล้ว +23

    Instead of reading and writing data using pointers or memcpy, what you can do is modify the linkerscript to create a memory segment at the memory region mapped to SDRAM address range and then use the section attribute on your variables: __attribute___((section("sectionname"))).

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +5

      Great point!

    • @oguzhanbalc1689
      @oguzhanbalc1689 ปีที่แล้ว

      No one can do this on youtube.

  • @nicestmanintheworld
    @nicestmanintheworld ปีที่แล้ว +25

    Love your channel, can't find a better source for STM32 dev than you!

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +5

      Thanks a lot!

  • @m1geo
    @m1geo ปีที่แล้ว +4

    Your memory test is doing "byte by byte" and uint8_t. But your memory interface is 16bit wide.
    You could very easily achieve double the speed by using 16b words!

  • @PCBWay
    @PCBWay ปีที่แล้ว +9

    As always, informative! 👍

  • @yellowcrescent
    @yellowcrescent ปีที่แล้ว +1

    Awesome video, glad you showed the actual implementation details. Implementing support for DRAM has always been mysterious to me. Glad to see ST's implementation with the FMC is mostly straightforward. I think the H7 also supports interfacing via OctoSPI/Hyperbus for Flash devices, so would be cool to explore that as well.

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +1

      Thanks, Jacob! Yes, I actually have a QSPI Flash memory part attached to the H7 on this board and want to make a video on that on the future as well.

  • @RandomValueToBe
    @RandomValueToBe ปีที่แล้ว +1

    Thank you, I'm willing to learn more about embedded systems, and you are one of those channels where I say thank you for sharing your knowledge. At the moment, when I have the money and time, I will be doing your course about Mixed-Signal Hardware Design.

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Thank you very much for your support, Edgar!

  • @xpressivemusic4578
    @xpressivemusic4578 ปีที่แล้ว +4

    saving up for your course Phil thank you for the amazing videos

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +1

      Thank you very much for your support! :)

    • @aliismail2962
      @aliismail2962 ปีที่แล้ว

      Where can I find details about the course ? Is it about FPGA hardware design ?

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Right now, I just have two KiCad courses available. One is free (Udemy/YT) and the other via Fedevel Education and covers mixed-signal HW design. I'm working on an FPGA/SoC course to be released Q1 2023.

    • @xpressivemusic4578
      @xpressivemusic4578 ปีที่แล้ว

      @@PhilsLab fantastic I'm getting the mixed signal course next month will definitely get the fpga soc course too when it's up. I need to get my Hardware skills up

  • @jordanpales3503
    @jordanpales3503 ปีที่แล้ว

    Thank you for your videos! When I need to measure the exact execution time of a command, I submit a logical unit for output pin at the start of the command and convert it to a logical zero at the end. Of course the output pin must be configured to the maximum speed I measure the time itself with an oscilloscope or a logic analyzer. It turns out very high accuracy. Sorry for my English, it's not my native language

  • @unperrier5998
    @unperrier5998 ปีที่แล้ว +1

    There are checks you can implement like checkers, climbing bit, alternating bits, etc IIRC JEDEC has document that describes them. That's what is typically used in BIST tests (I mean ATE silicon testing)
    Also one thing that needs checking is whether the refresh rate is properly programmed by waiting much longer than the refresh rate and reading again. Sometimes it's just outside the value and once in a blue moon a bit will flip. Hard to find except by running those pattern tests with enough time between write and reads.

  • @piranha1337
    @piranha1337 ปีที่แล้ว +7

    I think its kind of sad that Altium now "invades" every hw design YT channel. Not that altium is bad, I think it's a very desireable piece of software but it's pricing is definitely not made for hobbists and makers which is the major audience of these kind of channels. I liked the videos where you used KiCad.
    Anyway... Thank you so much for your videos. I'll get my order next week and a good portion of the boards arriving will be based on the knowledge I got from your videos!

    • @m1geo
      @m1geo ปีที่แล้ว +2

      Agreed. Altium and PCBWay. Lol

    • @xxbatman69xx98
      @xxbatman69xx98 9 หลายเดือนก่อน

      It’s literally all the same concept though. I am just getting into circuit design and I’ve been using kicad. From my understanding between altium and other software there isn’t anything (circuit wise) that you can do in altium that you can’t in something like kicad.

  • @Sovvyy
    @Sovvyy ปีที่แล้ว

    Another well-explaned tutorial - thanks for sharing your knowledge!

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +1

      Thanks for watching!

  • @arcoshpl
    @arcoshpl 8 หลายเดือนก่อน

    Super video. Next please a video how to debug the FMC if it did not work... :D

  • @codewithdaniel-1
    @codewithdaniel-1 ปีที่แล้ว +1

    Nice work

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Thanks, Danny!

  • @bsodmike
    @bsodmike 6 หลายเดือนก่อน

    Hi Phil, have you shared the full schematic by any chance? Thanks!

  • @marek_ryn
    @marek_ryn ปีที่แล้ว

    As always excellent video :) To bad it was not available few months ago :) It took me so much time to collect all necessary information for my STM32 gaming console where I also use SDRAM :) Anyway, the idea to put SDRAM chip underneath microcontroler is excellent and I will definitely use it for next iteration of my project. Thank you Phil for your work!

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +1

      Thanks, Marek! It did take me quite some time as well to piece together various bits of information to get it running. Should hopefully be somewhat of a template for future projects!

  • @Xerox482
    @Xerox482 ปีที่แล้ว

    great your channel is amazing keep sharing knowledge . may god give you long life

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Thank you!

  • @swatty2009
    @swatty2009 ปีที่แล้ว +1

    I know this was just a basic test but wouldn't it be faster (factor two) to access the data in 2-byte blocks? Basically using uint16_t instead of uint8_t to utilize the full memory width?

  • @raultanasie2111
    @raultanasie2111 ปีที่แล้ว +1

    Great demystifying of the SDRAM ! Question > Can the sdram memory be integrated in the linker script so that it replaces the internal memory ? That would allow straight up initializing variables in it at compile time and using memory allocation commands (malloc), instead of just using pointers to it, which are prone to code design errors.

    • @m1geo
      @m1geo ปีที่แล้ว

      Yes. You can create memory segments and get the linkerscript to use them.

  • @gtcollection6933
    @gtcollection6933 ปีที่แล้ว

    You should have a look at the Expressif S3 with built-in RAM

  • @alexevivi
    @alexevivi ปีที่แล้ว +2

    Great video! When the new course will be available?

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +3

      Thanks, Alex! I just received the FPGA boards for the course - will hopefully have it ready by start of 2023.

  • @wissamtedros1339
    @wissamtedros1339 11 หลายเดือนก่อน

    At 6:22 you mentioned that pin swapping for the FMC data line is possible to make the routing easier, could you please state how? Because the datasheet does not provide alternate function for those pins
    On another note, thank you so much for your valuable videos, they've taught me much and they're always insightful.
    Cheers!

  • @mortezaghorbani7927
    @mortezaghorbani7927 ปีที่แล้ว

    excellent video, How to do bit swapping in code in an efficient way(using SDRAM as an LCD framebuffer)?

  • @gaurangvadher493
    @gaurangvadher493 ปีที่แล้ว

    Thank you so much this helped a lot!!!! You saved my life

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Glad to hear that - thanks for watching!

  • @isaacclark9825
    @isaacclark9825 ปีที่แล้ว +1

    Phil, can you tell me what limits the speed for accessing memory? Is the limit based on the processor?

    • @TheBackyardChemist
      @TheBackyardChemist 11 หลายเดือนก่อน

      If you clock the bus too fast you get garbage data. The same also happens if you do not wait the appropriate amount of time between certain operations because the DRAM chip has internal circuitry that has to settle into a definitive state.

  • @asmi06
    @asmi06 ปีที่แล้ว

    I would suggest repeating these tests, but writing 32 bit values instead of bytes. It should be faster, but I'm curious to see by how much.

  • @mh-le5ov
    @mh-le5ov ปีที่แล้ว +1

    Does the databus width of the SDRAM chip determine what size data you can store at a time?
    Or will the FMC handle 8, 16 or 32 bit loads/stores for you by making multiple requests?

    • @Sumida2
      @Sumida2 ปีที่แล้ว

      FMC handles it.

  • @romyaz1713
    @romyaz1713 หลายเดือนก่อน

    noob question: does your read or write command have constant delay?
    or is it variable delay due to SDRAM refresh?

  • @szymon4602
    @szymon4602 ปีที่แล้ว +1

    Nice content. Thanks.

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Thanks for watching!

    • @szymon4602
      @szymon4602 ปีที่แล้ว

      @@PhilsLab Are you planning to elaborate on this topic regarding the correct routing of paths for the parallel interface? It would be nice to see something below the BGA and on the 4 layer PCB. Some simple project is best in KiCad with such an interface ...

  • @RebelCoderX
    @RebelCoderX 8 หลายเดือนก่อน

    Hi Phil, I'm developing a DSP device as well and I wanted to add some external RAM. I found another SDRAM chip, the Winbond W9825G6KH-6 which is slightly cheaper, has double the capacity, and is already in stock at JLC as well as Mouser. So I wondered why you chose this ISSI part over the Winbond one. I have literally 0 experience in working with these SDRAM parts so maybe there is something I'm not aware of. The winbond chip is 166MHz for instance while your ISSI part is 143MHz. Could it be 166MHz is too fast so that it needs a refresh time which the STM32 can't handle? The 16MB of the ISSI one should really be large enough for me and they have it in stock at mouser so I could experiment with it before going in production, but I wondered if the Winbond SDRAM might also work. (Provided I don't kill it while handsoldering 😅)

  • @LiveEnjoyment
    @LiveEnjoyment ปีที่แล้ว

    Awesome vid btw

  • @RixtronixLAB
    @RixtronixLAB ปีที่แล้ว

    Creative video, thanks for sharing :)

  • @LiveEnjoyment
    @LiveEnjoyment ปีที่แล้ว

    Knowing that certain adress pins of a sdram chip might be used for specific funtions and other are just for the adress. Would u recommend pin swapping of the adress pins during routing?

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Pin swapping of the address pins is generally not recommended (unless you know what you're doing, or can/will adjust the controller to suit). Address pins aren't just for addressing for some are also even control (even ones labelled as 'just address' pins).

  • @arcoshpl
    @arcoshpl 8 หลายเดือนก่อน

    I am confused about the size of the SDRAM how does the 128Mb correspond to the hex size SDRAM_SIZE 0x1000000

  • @utthamsingh
    @utthamsingh 6 หลายเดือนก่อน

    How can we use multiple buffers??

  • @markburton3306
    @markburton3306 ปีที่แล้ว

    Good stuff

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Thanks, Mark!

  • @juanchoavid123
    @juanchoavid123 ปีที่แล้ว +1

    Hi Phil! I would like to make this question. Maybe I did not understand that part. When do you tell the microcontroller to use external memory and not the internal RAM? Or is the internal RAM attached to one bank and you changed the bank to bank one corresponding to the external memory? And after that when you are creating a variable, for example, it saves the value in the external memory?
    Thanks a lot for the content I love it so much!

    • @marek_ryn
      @marek_ryn ปีที่แล้ว +1

      External SDRAM is assigned to separate pool of address. Starting 0xC0000000 or 0xD0000000 as I remember correctly. You can just write/read directly to those addresses, although this memory is much slower than internal RAM.

    • @Sumida2
      @Sumida2 ปีที่แล้ว +2

      The internal memory and external memory are mapped to different addresses. Any read or write will go to the right place depending on the address you choose. Creating a global variable or one on the stack will use the internal memory unless you change the compiler/linker settings to use different memory ranges for those things. That is only because this is set up before hand. You could also add your own memory allocator to keep track of external memory usage. It's more of a software development issue and not something you "tell" the microcontroller about.

  • @smoua4588
    @smoua4588 ปีที่แล้ว

    Thank you!

  • @MSP_TechLab
    @MSP_TechLab ปีที่แล้ว

    0.4 sec for read, isn't it too slow for 90MHz? Perhaps DMA can imrove result.

  • @energycsdx
    @energycsdx ปีที่แล้ว

    Did you tested SDRAM read performance? a friend of mine accidentally discovered that it`s know issue that FMC inserts dummy read cycles when reading from SDRAM

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +1

      Haven't gone into too much detail testing the SDRAM performance - will be interesting to see if I run into the same issue.

    • @energycsdx
      @energycsdx ปีที่แล้ว

      @@PhilsLab www.st.com/resource/en/errata_sheet/es0491-stm32h72xx73xx-device-errata-stmicroelectronics.pdf 2.6.1

  • @raxneff
    @raxneff ปีที่แล้ว +1

    maybe not the best place to ask this, but: what actually is Firmware? (per definition)? Whats the difference between "normal code", an operating system (kernel), and firmware?
    is "firmware" just low level stuff or is there more to it?

    • @helmutlord4335
      @helmutlord4335 ปีที่แล้ว +1

      Firmware is code that runs on any device that isn’t easily updated. Another definition is anything that you don’t think of being “a computer” runs firmware. Your car runs firmware. Your microwave runs firmware. Hell your fridge probably runs firmware! It’s not a strict definition (and all firmware is also software) but I hope that helps.

    • @Mr.Leeroy
      @Mr.Leeroy ปีที่แล้ว +1

      originated as meaning hardware microcode, now is probably a short for firmware image/code as a whole software part, which is a deployment ready package of everything programmer generated that is required to run particular hardware.

  • @ricardo_9726
    @ricardo_9726 ปีที่แล้ว

    Where did you get your hands on a stm32h7

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +1

      LCSC has quite a few of them still in stock.

  • @charlesspringer4709
    @charlesspringer4709 ปีที่แล้ว

    Great as usual. One item that is irritating to old-timers. '0x' or zero x, is a C pre-processor flag or directive and not part of the number or part of C. I know it has become common to include it while speaking or in text, but it ain't right. Just say 'hex', and it is zero x, not 'oh x', which is entirely different.
    If these languages had radix modes like Forth and a few others, we could all save a lot of eye strain and typos by typing HEX and then just using hex numbers in tables and arrays. At the end type DECIMAL. Personally I would like BINARY modes when setting up registers or using masks and the like. Cheers.

  • @johnadriani7467
    @johnadriani7467 ปีที่แล้ว

    I'm really happy to watch your presentation for free, but you should start at a technical school as a lecturer

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Thanks a lot, John - who knows maybe someday! :)

  • @tamaseduard5145
    @tamaseduard5145 ปีที่แล้ว

    👍🙏

  • @johnadriani7467
    @johnadriani7467 ปีที่แล้ว

    you talk like a commander from a space shuttle.. crazy

  • @chenzora2417
    @chenzora2417 ปีที่แล้ว

    Hi Phil’s Lab, I have been following you. You do a great work. I work for NextPCB. We would like to sponsor your projects. You can send a DM for more details.
    /Dolphin