Hi, Excellent video on creating External Loaders for STM32!
@bluewat Жыл бұрын
Thank you!
@fvgm22 күн бұрын
Thank you! Well explained !!
@bluewat16 күн бұрын
I'm glad to see that you like it
@Bulent2k Жыл бұрын
An educational and beautiful video.
@bluewat Жыл бұрын
Thanks, Bluent2k.
@SEEMERIDECOM Жыл бұрын
This is awesome!! I'm designing a board that uses an STM32H723 and (2X) W25Q128JV NOR Flash in a Dual Quad config using the OCTO-SPI. SO, my config will be a bit more complex, but I think I will be able to use these examples to get started on the large task. Thank you so much for sharing.
@bluewat Жыл бұрын
Hi @seemeridecom, interesting project. It would be interesting to know the performance of this architecture. Could it be interesting, in some cases (heavy data handling), to store program over OSPI keeping data on the internal flash?
@SEEMERIDECOM Жыл бұрын
@@bluewatThe project I'm building will be a larger HMI and I'm not 100% sure of the size of all the assets or code. The processor has 1MB of internal flash and I know I'll overrun that for sure. My plan is to put as much code in that internal flash and most all the assets (graphics/fonts) in the 32MB. I think with having them set up at Octo SPI, they should be pretty fast. Also, if I overrun the 32MB, I can always go larger. This will be a product that I want to release new firmware to my customers via download and they can install using a USB drive. I may also leverage an internal SD FLASH for custom user backgrounds and such.
@kevinperillo Жыл бұрын
Nice Video and great implementation!
@bluewat Жыл бұрын
Thank you!
@hashirama9997 Жыл бұрын
Great example! Thank you
@bluewat Жыл бұрын
👋
@electronic-ebox64039 ай бұрын
hi, thanks for video. i followed steps you shows. i am using w25q64 chip. in program Flash_init sims to be working well but at Flash_chiperase goes into infinite loop it stuck in busy flag. what is the problem?
@bluewat9 ай бұрын
That's strange. Writing cycle starts as soon as /CS is driven high and autonomously resets busy bit at the end.
@electronic-ebox64039 ай бұрын
@@bluewat you are right but in the function Flash_WaitForWritingComplete(); ---> infinite loop at while (buffer[0]& SR1_BIT_BUSY ); . This buffer never receive S1 register value and causes a loop infinity
@electronic-ebox64038 ай бұрын
@@bluewat is library support w25q64?
@electronic-ebox64038 ай бұрын
is library support w25q64?
@electronic-ebox64038 ай бұрын
@@bluewat now working... my chip was faulty i replaced with new one and program is working
@blcouz Жыл бұрын
Why did you have to redefine the hal functions (Hal_GetTic IncTick ...) in the Loader.c file? What's the reason for this?
@bluewat Жыл бұрын
uC calls the external loader having disabled all interrupts. So, systick also is disabled and functions like HAL_InitTick(), called in initialization, would hang. That's why they are redefined. That's explained somewhere in the ST documentation indicated in the video desctiption. Library (in some cases: for instance resetting and initializing flash chip) needs some delays: I left the library calling HAL_Delay() so, when it is normally used in a project, it will use the system timer. While I redefined it here, making it working with no systick.
@blcouz Жыл бұрын
@@bluewat thanks
@bluewat Жыл бұрын
👋@@blcouz
@DianiAmine10 ай бұрын
Nice demonstration! One question, it's working on IAR workbench also?
@bluewat10 ай бұрын
Unfortunately I don't know that IDE. In CubeIDE, handling is done by CubeProgrammer, having a sort of plug-in for it. I don't know about IAR
@DianiAmine10 ай бұрын
@@bluewat thank you, I'll try this using cubeIDE
@eyalgoltzman1845 Жыл бұрын
Hello Mauro, Very comprehensive and detailed video, thank you! I'm struggling with building an external loader for an SPI flash for the STM32WLE5, I have the CubeIDE project up and running based on the video but when I connect to the device with CubeProgrammer and try to use the stldr I built I get a message "Error: Data read failed". I tried to take the SPI out of the stldr and only test the init part with blinking a led on my target but I get the same error. When I run the same project in debug configuration from main.c the led is blinking. What could go wrong? Any way to debug it? Thanks
@bluewat5 ай бұрын
A possible cause and solution is on video about 12kB external loaders
@rocky098210 күн бұрын
Hi, I have a custom board with stm32 u585 having micron nand flash with ospi. I checked everywhere I couldn't find any one example for Nand flash external loader. Nand flash external loader is possible right?
@bluewat9 күн бұрын
Everything is possible. 😳 - if you have a driver handling the Micron nand flash, you should be able to setup an EL. If not you have to develop it: you must have to develop the basic functions: init, read, write, clear, ... the driver functions called by Loader_Src.c - strictly about EL: the second field in the Dev_Inf.c struct has to be set with values listed in Dev_Inf.h. Over there you see also a "NAND*" parameter. I have to say that I tried to use different values in my tests on SPI and QSPI with a NOR flash and I remember I saw the EL always working (or always not-working 😒). I haven't found specific documentation about their meaning, but... maybe... you have to test them. - I haven't tried to develop ELs for U5 or any M33 core. I don't know exactly if something specific has to be set in Dev_Inf.c or in the linker script...
@bluewat9 күн бұрын
Anyway, I'm close to publishing a video about QSPI. It includes a session about QSPI ELs
@rocky09829 күн бұрын
Thank you for replying. I am able to generate the external loader file for my flash. But it was failing in the init function when loaded in cube programmer. I am doing autopolling method since nand flash does not support memory mapped mode. Yep a session on qspi will surely help.
@2wheels9 ай бұрын
Hi...I have tried implementing this for issi 4MByte memory on stm32h750. It works fine until I tried to program a bin file > 100kByte. Cube programmer shows download failure at segment (0). Any idea what is wrong?
@bluewat8 ай бұрын
Are you getting error in reading or writing? or both?
@2wheels5 ай бұрын
I have resolved this issue. Need to change variable quota in z_flash_W25QXXX.c from uint16_t to uint32_t. Many thanks for making this tutorial. 😊
@hareeshs862 ай бұрын
Hello. I am creating an external loader following your tutorial for the STM32U599(I have tried U5F7 too) and W25Q32 flash IC. I am able to read and erase the external flash using cube programmer, but whenever I try to write to flash (Fill Memory), I get the following error 15:51:42 : Error: Failed to download data! If it's a Flash memory, it may be not erased or protected 15:51:42 : Error: Failed to fill memory with the given pattern Similarly, when I try to program a bin file to flash I get the following error 15:55:36 : Error: failed to download Segment[0] 15:55:36 : Error: failed to download the File 15:55:36 : RUNNING Program ... 15:55:36 : Address: : 0x90000000 15:55:36 : Warning: The core is locked up 15:55:36 : Start operation achieved successfully I have tried following different tutorials as well as writing my own functions from scratch but I get the same error. Any idea what could be the issue?
@bluewat2 ай бұрын
Is it possible that your flash is write-protected? There are many write-protected modes in W25Qs, setting up registers SR1, SR2 and SR3. I never tested the write protection features and the possible returned messages by CubeProgrammer and CubeIde
@hareeshs862 ай бұрын
@@bluewat I did not consider that. I will check that out as soon as I can in that case. Thanks for the reply!
@bluewat2 ай бұрын
Can you provide the full chip name? Some W25Qs leave WinBond farm in QSPI data format mode as default. Here also I never tested what happens trying to SPI-write them without changing setup.
@hareeshs862 ай бұрын
@@bluewat Hello W25Q32JVSSIQ would this suffice?
@bluewat2 ай бұрын
IQ chips have QE bit in SR2 preset for SPI (refer to flash datasheet), that means that /HOLD pin function is available. You should take care of handling it also (keep it high for normal operation).
@vishesh6837 Жыл бұрын
Hello sir, great video ! I am building a project on stm32 bluepill(f103CT8) and i require to store char arrays and for that i am using winbound flash chip , can give some steps to take care while writing the arrays in the memory and how to read them as i will require to read them mutiple times .
@bluewat Жыл бұрын
You should find, more or less, all information here in the video (how flash works and how it should be handled), in the related GitHub page (how to setup a project), and in the library function descriptions (how to use the single library functions). If the array is a "const" (written one time only, programming the system and read-only on project runtime) you could get to a very easy flash handling by mapping flash on the uC address space. Not described here until now. I'm working on a new video on this topic.
@gutserto2 ай бұрын
Hi, I have a F411 like you but when I get offered to pick a flash I only get flashes associated to different boards, is there something I'm not understanding?
@bluewat2 ай бұрын
I don't understand: what do you mean by "pick a flash"? Selecting an external loader? where? in CubeProgrammer or CubeIde? If so, I suppose you moved the external loader in a wrong directory.
@gutserto2 ай бұрын
@@bluewat nevermind I didn't listen with sufficient attention and misunderstood that part, it's fixed now. I implemented everything in the video and it works. Now I am working on saving integer and float objects in the flash and especially reading them proprely (so not doing the number to ASCII conversion) if someone has already done it I would love to read about it . Btw thank you for your video, it's excellent and very helpful
@bluewat2 ай бұрын
That should be possible with pointer typecasting. This way: float fldata = 0; HAL_SPI_Transmit(&FLASH_SPI_PORT , (uint8_t*)&fldata, 4, HAL_MAX_DELAY); or even better: HAL_SPI_Transmit(&FLASH_SPI_PORT , (uint8_t*)&fldata, sizeof(fldata), HAL_MAX_DELAY); reading data in the same way you'll get back the float variable;
@gutserto2 ай бұрын
@@bluewat thank you very much for your answer, I implemented your adjustment in a new function and also created new functions to write float data all the way up to Flash_write_float. It indeed writes the correct amount of 4 bytes objects in the winbond but unfortunately data integrity is not achieved and the hexs in stm32 prg are not consistent with the data saved in the first place when I convert them back to floats
@bluewat2 ай бұрын
Just two final comments/hints: - you don't need to create specific "flash_write_float", "flash_write_double", "flash_write_int" and so on: you can just typecast the pointer in the "flash_write" call. (what shown above, was just a hint) - there should be something wrong, somewhere in your tests, in your calls (maybe an inaccurate flash address?). Type cast should not introduce any error. But that's good 👍: keep on working.
@ricardo-rector5 ай бұрын
Hello!! Mauro, I have issues with CubeIDE, External Loader. In CubeProgrammer works great, but when i try use it on CubeIDE i cant write, so i dont know whats going on. Could you help me with.
@bluewat5 ай бұрын
CubeIDE and CubeProgrammer use THE SAME modules so you should easily detect the error: your EL is good (!), that's just a CubeIDE project problem. My 2 cents is: (first hypotesis) did you unselect "verify" in CubeIDE EL properties? If yes I see only (second one) a linker script problem. But it is not easy from here helping you much more than this.
@ricardo-rector5 ай бұрын
@@bluewat Thanks for your help!!! Yes the verify is unselected. i'm using ST-Link-V3Set.
@ricardo-rector5 ай бұрын
@@bluewatOk after checking all, I could fix it. And now is working.
@bluewat5 ай бұрын
Well done!
@chaos_technology Жыл бұрын
Hello, great tutorial, but can You try this for STM32G0B0CET6 ? I got only blank name/board/mem size and device type: "UNKNOWN" in stm32CubeProgrammer.
@bluewat Жыл бұрын
I can only tell you to doublecheck the various steps
@pallavikadaam8 ай бұрын
hello i 'm also facing same issue.
@chaos_technology7 ай бұрын
@@pallavikadaam If I remember correctly, there is a problem with memory organization. In my case, an additional section was created in RAM before the loader functions. Solution: check the RAM structure with a memory analyzer. Delete the extra section. It worked for me.
@blcouz Жыл бұрын
I don't understand why any writing or reading operation only works once (external loader functions). When I want to make a second transaction, I need to connect to stlink again. What could be the reason for this?
@bluewat Жыл бұрын
that's strange. What uC are you using? The flash? And what is the clock speed you set in the external loader CubeMX?
@blcouz Жыл бұрын
@@bluewat I use an eeprom, all functions work. I'm using f446re and 24lc256. Clock speed 180mhz
@bluewat Жыл бұрын
integrating an I2C eeprom, that's interesting: something I have in mind to test but I haven't yet done. F446re: ok, no problem with ram size. How you use I2C? In some my first tests (SPI) I had some problems with DMA. (Even considering disabled interrupts) Then I used only polling mode. But it was in my first tests: maybe now it could work. Even if I keep working only in polling mode on external loaders. Something else could be in the uC status left, after writing: changes something enabling/disabling "verify" after writing?
@blcouz Жыл бұрын
@@bluewat I did not use dma or interrupt. I did any delay part as you did. The functions already work stably on their own. The problem is that after performing any operation, I have to reconnect to stlink to perform a second operation. I experienced the same problem about six months ago when I tried to make an external loader with w25q32.
@FlyHIGHSIM10 ай бұрын
Is it possible to have my external flash memory via SPI having part of my program from the STM32CUBEIDE loaded like if it were the internal flash to carry a few variables?
@bluewat10 ай бұрын
In principle, yes. But: (1) what you mean referring to "a few variables"? They should be "a few constants". If so: external loader would program flash and, setting up an appropriate driver, "variable/constants" could be read regadless where they are stored: inside or outside uC. (2) Take in consideration the SPI flash speed: what said at point (1) is valid "in principle". External flash is a widely used to store data and software. But not and SPI one. I'm working on a "smaller footprint" version of the external loader. Much smaller. I'll try to set an example of this kind of handling also.
@FlyHIGHSIM10 ай бұрын
@@bluewatOh, great!! BTW my interest is basically do stuff with LCD Displays and for other projetcs, working with lookup tables. In this format, if i have a Lookup Table saved in the external memore like this: uint16_t Lookuptable[1000*60] __attribute__((section("ExtFlashSection"))); Can i address in the code calling like this: uint16_t data = Lookuptable[60]; To try to get the data from the Lookuptable[60] (in the pos 60) ? os do i need to get the pointer of the variable + the 60 positions and fetch from the Flash with the library functions?
@bluewat10 ай бұрын
No, you can't do that with an SPI flash. You have to setup a function handling flash/memory reading and than, using that function, you can forget if the data is stored intertnally or not in the rest of the program.
@FlyHIGHSIM10 ай бұрын
I was trying to make the external loader for the STM32G0B1CBT6 that has a RAM of 144K. It generates ok, but the issue is that when i try to open in the cube programmer, it shows as unknown and with address 0x0000000 and no name. Any idea of what could be the issue? (I've oppened an issue in the github as well with screenshots)@@bluewat
@saleemshaikh64298 ай бұрын
Hi, Thank you for the Video. I created the .stldr file. But Cube programmer doesn't show Memory Size, page size or Memory type. What could be the reason. I checked and rechecked every step mentioned in your video. Thanks in Advance My device is: STM32G0B0CET6
@bluewat8 ай бұрын
Hi, the easiest part of the answer is that you can be sure that there is something wrong. Not easy is to say what is wrong. That could be also just the structure in Dev_Inf.c. Maybe just a too long string as device name?
@chaos_technology7 ай бұрын
In my case, an additional section was created in RAM before the loader functions. STM32G0B0CET6
@iacacch8 ай бұрын
what about if instead of a Flash memory I have an FPGA with SPI in passive mode? Would that work?
@bluewat8 ай бұрын
I'm not sure, but it shouldn't be difficult to adapt the library to another type of communication. As you can see, Loader_Src.c makes calls to a library handling SPI communication through simple functions: Flash_Read(), Write(), Clear(),...
@iacacch8 ай бұрын
I agree on that, I don’t see why it should not work. I will try!
@bluewat8 ай бұрын
Keep in mind that you must avoid interrupts (so, DMA also) as they are disabled exiting the external loader functions
@kursadgulereem Жыл бұрын
hi, i connected W25Q16 and F411 when i debugging "Flash_TestAvailability" function return 0 always, i cant find where is the problem, pls help me
@bluewat Жыл бұрын
As you probably have already seen, TestAvailability just reads SFDP record from the flash. That record reports JEDEC information about device connected. Despite the memory size, the record starts with the string "SFDP". That is the only test done by TestAvailability function to see if a chip si connected and communicating. Now, I see only three possibilities: - (the absolutely most likely one) there is something wrong in the communication (SPI port setup and/or wiring). I noted that winbond SPI communication is quite weak (compared to other SPI devices). So, while prototyping over a breadboard, I keep a quite slow speed: below 2mbps. I rise it to higher speed (50mpbs and above) when I move the project over a PCB. Doublecheck wiring and CubeMX configuration - (it is possible, but only if you really belive communication is good) the flash could be damaged? can you test another chip? can you use current chip in another circuit? - (is it possible?) Winbond says that its devices follow Jedec standard since 2011 but not saying how was SFDP record before 2011. Is it possible you have a chip made before 2011?
@kursadgulereem Жыл бұрын
you are so right, i slowed down mcu speed and it works...😀@@bluewat
@bluewat Жыл бұрын
👍👍👍You should be able to keep a fast MCU, slowing down only SPI port (working on the "prescaler" parameter of SPI).
@gabrielfienco2531 Жыл бұрын
@@kursadgulereem you are right this worked for me too, not I can program w25q64 using h723, now I want to figure out how to boot from that code.. I think I need to copy it to RAM.. then jump to RAM, right @bluewat?
@apaczenko1993 Жыл бұрын
Hello, great libray but I have some problems with creating external loader. I another project, libray works excellent (while testing communication with flash chip). But when I want create a external loader while debuging project the Flash_TestAvailability always return 0. I tried to set lower speed but without success (in another (test) project i was able to set max SPI speed and everythink works well. Regarding to debugging the loader project i found that HAL_SPI_Transmit(&FLASH_SPI_PORT , data, dataSize, HAL_MAX_DELAY) always return HAL status BUSY. Maybe someone knows why :)
@bluewat Жыл бұрын
I'll take a look
@apaczenko1993 Жыл бұрын
@@bluewat my mistake, i forgot add last zero to adress, I was writing 0x9000000 instead 0x90000000, now everythink works excellent also touchgfx :)
@DianiAmine10 ай бұрын
nice@@apaczenko1993Its working on IAR?
@electronic-ebox64038 ай бұрын
Hi my external loader is downloading only upto 128Kb file. in flash (w28q64). but can read full chip of size 0x800000 =8mb. could you please help?
@technosavy3978 ай бұрын
Hi. I am also facing the same issue. External loader cant write more than 128kb data. Have you solved problem? Or anyone have solution?
@bluewat8 ай бұрын
I had a project having about 1MB loaded onto a flash without problems, I don't remember if sometimes I had something needing more than 1M. I checked that project right now: an F103@64MHz (a bluepill) with a w25q64 on spi1@2Mbps. If you like a help, you should provide at least some information: what's your system? How you say you can't write data over 128k? You mean you get an error? what's the error? ...
@bluewat8 ай бұрын
I guess you have an error READING/VERIFYING flash (via CubeProgrammer). If so your EL is ok, flash is (hopefully, if you haven't a mistake somewhere) correctly programmed, it is a limit of CubeProgrammer. Try to disable verify option (even on CubeIde), and see what happens. I'm close to publish a new video explaining (among other topics) even this case
@hareeshs863 ай бұрын
Hello. I have issues using this loader with W25Q32JV flash and STM32U599 MCU. I am able to generate the .stldr with no issues (except for that warning which is expected) but in cubeprogrammer, I cannot select the external flash address from the dropdown in the "memory & file editing" tab. I have modified the z_flash_W25QXXX.h file as such #define EXT_FLASH_PAGE_SIZE 0x0100 // 256 bytes page size (bytes) #define EXT_FLASH_SECTOR_SIZE 0x1000 // 4KB sector size (bytes) #define EXT_FLASH_BLOCK_SIZE 0x00010000 // 64KB block size (bytes) #define EXT_FLASH_SIZE 0x00400000 // 4MB-32Mb total size (bytes) #define EXT_FLASH_PAGE_NUM 0x4000 // 16384 pages #define EXT_FLASH_SECTOR_NUM 0x0400 // 1024 sectors #define EXT_FLASH_BLOCK_NUM 0x0040 // 64 blocks and in the EL_linker.ld file I have modified as such LENGTH = 2512K Followed all the other instructions. SPI Baud rate at 18Mbps (I have tested this module at 18Mbps and could successfully read JEDEC and other IDs) Any clue what could be wong? Any help is appreciated
@bluewat3 ай бұрын
Can you provide more details about accessing the mapped flash via CubeProgrammer?
@hareeshs863 ай бұрын
@@bluewat Hello, I get the error " Error: Data read failed" When I set the address to 0x90000000 and try to read the external flash module Is there any other information you would like in detail? EDIT: Apologies, not sure what changed but it seems to be working as intended now. Thank you for the informative tutorials regardless!